Search code examples
stm32protocolsuartsdi-12

SDI-12 oscilloscope output explanation, STM32


I am trying to implement the SDI-12 protocol to my STM32L4 microcontroller using UART5 and a buffer (Check schematic, signal level conversion) from this module in a custom PCB in order to make my UART to SDI-12 one wire converter. However, I am not able to communicate with any SDI-12 compatible sensor and I think that I have problems to the output data. I found a datasheet about SDI-12 protocol which shows a picture (picture_1) that is an oscilloscope output when sending this command "0!". I am not able to decode that to see what is the binary sequence in the picture_1 from the datasheet, and when I am trying to send the same command (picture_2) from my implementation the results are not the same except for "break" and "marking" event. The UART specification that needs this protocol is this:

1) BaudRate = 1200, 2) 1 stop bit, 3) Even parity, 4) 1 start bit

So my questions are:

  1. What is the binary sequence from the oscilloscope output of the datasheet (picture_1). I want to decode that in order to check if the output data are in reverse order.
  2. Some SDI-12 datasheets says that the data needs to be in reverse order and some others doesn't say the same. So what is true about that?
  3. This paper doesn't specify any "marking" event however other says that after "break" event is necessary a "marking" event. What is true about that?

Picture_2 (This is an oscilloscope output from my implementation that sends this command "0!") own_implementation_sdi12_command

This is the Picture_1 from datasheet that sends the same command with me.

datasheet_sdi12_command


Solution

  • I found the solution. The SDI-12 protocol indeed has the above configurations for the UART. baudrate = 1200, parity = even, stop bit = 1, start bit = 1. However, if you check on the SDI12 datasheet you will notice that the protocol uses negative logic. Thus, it needs the data in reversed order, but in order to achieve that you should not reverse the data but you have to change the default idle line of the UART protocol, so that the start bit instead of 0 to become one and then the "reversed like data" which are transmitted in reversed order due to the change on UART TX idle line not via the actual data reversion!