SDI-12 communication with 1758

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDI-12 communication with 1758

432 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Saurabh Dey on Sat May 30 02:37:32 MST 2015
Hi all,

I have a Campbell make sensor which has SDi-12 output.
I am trying to interface the sensor with my 1758 development board.
I also wrote a piece of code, but I am not able to get any output.
I am sending a simple command ?! and the output I am getting is the same Echo ?!
Kindly let me know what firmware and hardware changes are required so as to get the output.

Any suggestions will be appreciated.

[u]*Note: The characters in Bold is the code and the characters in bold & Italic is the output.[/u]

[u]Code: [/u]
void InitSDI12(void)
{
call_back_init(SDI12, SDI12_CALLTIME, "ms");
InitDirOut();
SDI12_TX_DISABLE;
}

unsigned int SDI12(void)

unsigned char RxData,Cmd[5]="?!",i=0; ///Here ?! is the command
unsigned int j=0;

SDI12_TX_ENABLE;
put_char(U2,'\r');
put_char(U2,'\n');

//The reason to send \r\n is beacuse the sensor also has RS232 o/p and in RS232 communication the sensor needs to be wake up after pressing Enter for 9-10 times continuously//

for(j =0 ; j < 10000; j ++);
printf("SDI cmd- ");
for(j =0 ; j < 50000; j ++);
for(i = 0;i < (strlen((const char *)Cmd));i++)
{
put_char(U2,Cmd);
printf("%c", Cmd);
}
for(j =0 ; j < 50000; j ++);
SDI12_TX_DISABLE;
for(j =0 ; j < 50000; j ++);
printf("\r\n");
printf("Waiting for Reply\r\n");

for(j =0 ; j < 50000; j ++);
while(get_char(U2,&RxData))
{
//put_char(U0, '$');
put_char(U0, RxData);
printf("\r\n");
}
printf("Data Received\r\n");
printf("\r\n");

return 0;
}

void InitDirOut(void)
{
//!<Set gpio direction>
gpio_dir(GPIO_DIR_PORT, GPIO_DIR_PIN, 1);//dir:- 0-input 1 output
}


[u]Output: [/u]

SDI cmd- ?!
Waiting for Reply



?
!
Data Received

Labels (1)
0 Kudos
2 Replies

330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Saurabh Dey on Sun May 31 22:11:42 MST 2015
Thanks Lix for your valuable suggestion.
I will work on it and get back to you

0 Kudos

330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lix on Sun May 31 03:40:49 MST 2015
Your approach to SDI-12 is rather simplistic, there is way more to do to implement an SDI-12 master functionality. However, as I understand you want only to see an answer from the sensor. I can give you some hints: to wake-up a sensor, you need to send it a break. Only a couple of cr/lfs won't make it. Therefore check once again the SDI-12 spec and implement a send break function. Verify with a scope that the break has the minimum length specified in the protocol.

The second hint is that the SDI-12 hardware configuration is such that you always receive back what you send. Therefore you must implement a technique that:

a) switches the Tx/Rx line only after the last character is out of the UART;

b) filters the characters you have send that will come back to you from the UART.

A good approach would be to listen to your own characters you just sent, and after receiving the SDI-12 terminator (!) start parsing the sensor answer.

Also don't forget that SDI-12 specifies even parity for the serial communication.

Lix
0 Kudos