- Joined
- May 2, 2016
- Messages
- 34
- Reaction score
- 0
- Age
- 65
I hope, because the unit is unuseful if every time the battery is discharged don't work anymore. Tragedy.
maybe is a TTL level serial, so you need an adapter USB or similar. Is not only a level matter, but also the signal is inverted.The second thing to note is that the amplitude of the serial port is around 3V, then we need a level adapter to connect it to a computer.
Sub Serial232()
'
' Serial232 Macro
'
'
Dim curSamplePos As Long
Dim SamplingFrequency As Long
SamplingFrequency = 1000000 '1MSps
Dim SerialLineSpeed As Long
SerialLineSpeed = 115200 '115200bps
Dim oneBitDuration As Double
oneBitDuration = 1 / SerialLineSpeed 'time in seconds (8,68us)
oneBitDurationSamples = SamplingFrequency / SerialLineSpeed '8,68 Samples
Dim signalThreshold As Double
signalThreshold = 1.7
Dim totalNumberOfSamples As Long
totalNumberOfSamples = ThisWorkbook.Worksheets(1).UsedRange.Rows.Count ' Rows.Count ' Range("B6").End(xlDown).Row
'color all che cells to white:
Range("B6:B" & totalNumberOfSamples).Interior.ColorIndex = 0
Range("C6:C" & totalNumberOfSamples).Value = ""
totalNumberOfSamples = ThisWorkbook.Worksheets(1).UsedRange.Rows.Count
'start from first sample, search the first transition (start bit)
'from 1 to zero
Dim MachineStatus As String
MachineStatus = "searchBegin" 'status of the processign statusMachine
Dim BitAquired As Long 'it's the counter of the bits, from 1 to 8, inside the byte
Dim currentByte As String 'it's the byte aquired in binary format
Dim CompleteDecodedASCII As String
CompleteDecodedASCII = ""
Dim completeDecodedHex As String
completeDecodedHex = ""
Dim remainder As Double 'remainder from quantization (from oversampling of the bit)
Dim hexByte As String 'temporary variable where the info about last byte is stored
For curSamplePos = 6 To totalNumberOfSamples
Range("B" & curSamplePos).Interior.ColorIndex = 37
Select Case MachineStatus
Case "searchBegin"
If (Val(Range("B" & curSamplePos).Value) < signalThreshold) Then
Range("C" & curSamplePos).Value = "Wait..Status:searchingBegin"
Else
'found the nothing
Range("C" & curSamplePos).Value = "Wait..Status:beginOfEmptyArea"
MachineStatus = "searchStartBit"
End If
Case "searchStartBit"
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
Range("C" & curSamplePos).Value = "Wait..Status:searchingStartBit"
Else
'found the start bit
Range("C" & curSamplePos).Value = "Wait..Status:beginOfStartBit"
'found begin of start bit
'now move to the middle of the start bit
curSamplePos = curSamplePos + Int(oneBitDurationSamples / 2)
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'maybe we found a spike, let's report it, and ignore it
Range("C" & curSamplePos).Value = "Error:Spike Found"
Else
Range("C" & curSamplePos).Value = "Wait..Status:middle Of start Bit"
MachineStatus = "acquireBits" 'go to next status
'reset the variable for the byte that we are going to aquire
BitAquired = 0
currentByte = ""
remainder = 0
End If
End If
Case "acquireBits"
'aquire bits
'move on the next bit to acquire
curSamplePos = curSamplePos + Int(oneBitDurationSamples) - 1
remainder = remainder + oneBitDurationSamples - Int(oneBitDurationSamples)
If (remainder > 1) Then 'if we accumulated big remainder, add one sample
curSamplePos = curSamplePos + 1
remainder = remainder - 1
End If
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'found 1
currentByte = currentByte & "1"
Else
'found 0
currentByte = currentByte & "0"
End If
BitAquired = BitAquired + 1
Range("C" & curSamplePos).Value = "Wait..Status:middle Of Bit number " & BitAquired
If (BitAquired = 8) Then
'byte completed
'print the output
hexByte = Application.WorksheetFunction.Bin2Hex(currentByte)
completeDecodedHex = completeDecodedHex & "-" & hexByte
CompleteDecodedASCII = CompleteDecodedASCII & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
Range("C" & curSamplePos).Value = "This is the last bit of the byte. Current Byte in BIN:" & currentByte & ", in HEX:" & hexByte & ", in ASCII:" & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
'cerchiamo il bit di stop
MachineStatus = "searchStopBit"
End If
Case "searchStopBit"
'spostati al centro del bit di stop, che dovrebbe essere il prossimo
curSamplePos = curSamplePos + oneBitDurationSamples - 1
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'trovato stop bit
Range("C" & curSamplePos).Value = "Wait..Status:middle Of Stop bit"
Else
'found 0 but the stop bit should be 1
'report error
Range("C" & curSamplePos).Value = "Error: Stop bit not found"
End If
'quindi ora possiamo ricominciare tutto daccapo.
curSamplePos = curSamplePos + 1
MachineStatus = "searchBegin"
Case Else
End Select
DoEvents
Next
DoEvents
Range("C" & curSamplePos).Value = "Data ended. currently processing data: Current Byte in BIN:" & currentByte & ", in HEX:" & hexByte & ", in ASCII:" & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
Range("C" & curSamplePos + 1).Value = "HEX Decoded Data: " & completeDecodedHex
Range("C" & curSamplePos + 2).Value = "ASCII Decoded Data: " & cleanString(CompleteDecodedASCII)
MsgBox "Done"
End Sub
Function cleanString(str As String) As String
Dim outstr As String
For i = 1 To Len(str)
If (Mid(str, i, 1) = Chr(0)) Then
outstr = outstr & " "
Else
outstr = outstr & Mid(str, i, 1)
End If
Next
cleanString = outstr
End Function
Sub Serial232()
'
' Serial232 Macro
'
'
Dim curSamplePos As Long
Dim SamplingFrequency As Long
SamplingFrequency = 1000000 '1MSps
Dim SerialLineSpeed As Long
SerialLineSpeed = 115200 '115200bps
Dim oneBitDuration As Double
oneBitDuration = 1 / SerialLineSpeed 'time in seconds (8,68us)
oneBitDurationSamples = SamplingFrequency / SerialLineSpeed '8,68 Samples
Dim signalThreshold As Double
signalThreshold = 1.7
Dim totalNumberOfSamples As Long
totalNumberOfSamples = ThisWorkbook.Worksheets(1).UsedRange.Rows.Count ' Rows.Count ' Range("B6").End(xlDown).Row
'color all che cells to white:
Range("B6:B" & totalNumberOfSamples).Interior.ColorIndex = 0
Range("C6:C" & totalNumberOfSamples).Value = ""
totalNumberOfSamples = ThisWorkbook.Worksheets(1).UsedRange.Rows.Count
'start from first sample, search the first transition (start bit)
'from 1 to zero
Dim MachineStatus As String
MachineStatus = "searchBegin" 'status of the processign statusMachine
Dim BitAquired As Long 'it's the counter of the bits, from 1 to 8, inside the byte
Dim currentByte As String 'it's the byte aquired in binary format
Dim CompleteDecodedASCII As String
CompleteDecodedASCII = ""
Dim completeDecodedHex As String
completeDecodedHex = ""
Dim remainder As Double 'remainder from quantization (from oversampling of the bit)
Dim hexByte As String 'temporary variable where the info about last byte is stored
For curSamplePos = 6 To totalNumberOfSamples
Range("B" & curSamplePos).Interior.ColorIndex = 37
Select Case MachineStatus
Case "searchBegin"
If (Val(Range("B" & curSamplePos).Value) < signalThreshold) Then
Range("C" & curSamplePos).Value = "Wait..Status:searchingBegin"
Else
'found the nothing
Range("C" & curSamplePos).Value = "Wait..Status:beginOfEmptyArea"
MachineStatus = "searchStartBit"
End If
Case "searchStartBit"
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
Range("C" & curSamplePos).Value = "Wait..Status:searchingStartBit"
Else
'found the start bit
Range("C" & curSamplePos).Value = "Wait..Status:beginOfStartBit"
'found begin of start bit
'now move to the middle of the start bit
curSamplePos = curSamplePos + Int(oneBitDurationSamples / 2)
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'maybe we found a spike, let's report it, and ignore it
Range("C" & curSamplePos).Value = "Error:Spike Found"
Else
Range("C" & curSamplePos).Value = "Wait..Status:middle Of start Bit"
MachineStatus = "acquireBits" 'go to next status
'reset the variable for the byte that we are going to aquire
BitAquired = 0
currentByte = ""
remainder = 0
End If
End If
Case "acquireBits"
'aquire bits
'move on the next bit to acquire
curSamplePos = curSamplePos + Int(oneBitDurationSamples) - 1
remainder = remainder + oneBitDurationSamples - Int(oneBitDurationSamples)
If (remainder > 1) Then 'if we accumulated big remainder, add one sample
curSamplePos = curSamplePos + 1
remainder = remainder - 1
End If
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'found 1
currentByte = "1" & currentByte
Else
'found 0
currentByte = "0" & currentByte
End If
BitAquired = BitAquired + 1
Range("C" & curSamplePos).Value = "Wait..Status:middle Of Bit number " & BitAquired
If (BitAquired = 8) Then
'byte completed
'print the output
hexByte = Application.WorksheetFunction.Bin2Hex(currentByte)
completeDecodedHex = completeDecodedHex & "-" & hexByte
CompleteDecodedASCII = CompleteDecodedASCII & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
Range("C" & curSamplePos).Value = "This is the last bit of the byte. Current Byte in BIN:" & currentByte & ", in HEX:" & hexByte & ", in ASCII:" & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
'cerchiamo il bit di stop
MachineStatus = "searchStopBit"
End If
Case "searchStopBit"
'spostati al centro del bit di stop, che dovrebbe essere il prossimo
curSamplePos = curSamplePos + oneBitDurationSamples - 1
If (Val(Range("B" & curSamplePos).Value) > signalThreshold) Then
'trovato stop bit
Range("C" & curSamplePos).Value = "Wait..Status:middle Of Stop bit"
Else
'found 0 but the stop bit should be 1
'report error
Range("C" & curSamplePos).Value = "Error: Stop bit not found"
End If
'quindi ora possiamo ricominciare tutto daccapo.
curSamplePos = curSamplePos + 1
MachineStatus = "searchBegin"
Case Else
End Select
DoEvents
Next
DoEvents
Range("C" & curSamplePos).Value = "Data ended. currently processing data: Current Byte in BIN:" & currentByte & ", in HEX:" & hexByte & ", in ASCII:" & Chr(Application.WorksheetFunction.Bin2Dec(currentByte))
Range("C" & curSamplePos + 1).Value = "HEX Decoded Data: " & completeDecodedHex
Range("C" & curSamplePos + 2).Value = "ASCII Decoded Data: " & cleanString(CompleteDecodedASCII)
MsgBox "Done"
End Sub
Function cleanString(str As String) As String
Dim outstr As String
For i = 1 To Len(str)
If (Mid(str, i, 1) = Chr(0)) Then
outstr = outstr & " "
Else
outstr = outstr & Mid(str, i, 1)
End If
Next
cleanString = outstr
End Function
maybe is a TTL level serial, so you need an adapter USB or similar. Is not only a level matter, but also the signal is inverted.
DM36x initialization passed!
UBL Product Vesion : DJI-GSPv2-SUPER-UBL-1.0-rc1(2014-08-15)
Dji UBL Version: 1.51(Aug 15 2014 - 16:55:54)
Booting Catalog Boot Loader
BootMode = NAND
Starting NAND Copy...
Valid magicnum, 0xA1ACED66, found in block 0x00000019.
Valid magicnum, 0xA1ACED66, found in block 0x0000001D.
No valid boot image found!
NAND Boot failed.
Aborting...
BOOTME BOOTME BOOTME BOOTME BOOTME BOOTME BOOTME
-----------------------------------------------------
TI Serial Flasher Host Program for DM36x
(C) 2009, Texas Instruments, Inc.
Ver. 1.50
-----------------------------------------------------
Usage:
sfh_DM36x < -norerase | -nanderase > [<Options>]
-norerase Do a erase of the NOR flash.
-nanderase Do a erase of the NAND flash.
sfh_DM36x -norflash_noubl [<Options>] <Application binary image>
-norflash_noubl Restore NOR Flash with bootable application (typically U-Boot).
sfh_DM36x -norflash [<Options>] <UBL binary image> <Application binary image>
-norflash Restore the NOR Flash with bootable UBL and application (typically U-Boot).
sfh_DM36x -nandflash [<Options>] <UBL binary image> <Application binary image>
-nandflash Restore the NAND Flash with bootable UBL and application (typically U-Boot).
sfh_DM36x -sdflash [<Options>] <UBL binary image> <Application binary image>
-sdflash Restore the SD/MMC Flash with bootable UBL and application (typically U-Boot).
<Options> can be the following:
-APPStartAddr <Application entry point address> Specify in hex, defaults to 0x81080000.
-APPLoadAddr <Application image load address> Specify in hex, defaults to 0x81080000.
-UBLStartAddr <UBL entry point address> Specify in hex, defaults to 0x0100 .
-h Display this help screen.
-v Display more verbose output returned from the DM36x.
-p "<PortName>" Use <PortName> as the serial port (e.g. COM2, /dev/ttyS1).
We use essential cookies to make this site work, and optional cookies to enhance your experience.