PDA

View Full Version : Serin2 and Serout2 with or without level converter



fbestepe
- 29th May 2004, 11:25
Hi everyone,

The project on which I am studying has two main parts.
1)- Data communication between PC and Pic
and
2)- Data communication between Pic and Electronic Electricity Meter (that has an rs232 com. port).

As a summary, The PC will send something to Pic via UART (Hserin) in order to get data from Electricity Meter, then Pic will send something to Electricity Meter(Serout2) and after that the Pic will receive what the meter send (Serin2) and finally Pic will send whatever it received from Meter to PC (Hserout).

Everything is OK about between PC and Pic. Now I am trying to make a data sending and receiving process between Pic and Meter. My related code is as below:

a var byte[16]

Serout2 PortC.2,27889,[47,63,33,13,10] ' 300 baud, Inverted logic
pause 20

Serin2 PortC.3,27889,2000,hata,[str a\16]
pause 10
Hserout [str a\16]

pause 20

for i=0 to 15
Lcdout a[i]
next i


According to its communication protocol, the meter should sent 16 characters as meter identification with 300 baud, after receiving /?! <CR><LF> (Hserout[47,63,33,13,10]) , but instead it sends NULL characters (that is, 0 of Ascii table) to the pic. I used 22K and 1K for Serin2 and Serout2 for the connection between pic's ports and meter's rs2332 port ( and of course, pic's Rx to meter's Tx and pic's Tx to meter's Rx and also ground) . The mode must be 27889 for 7N1,300 baudrate (as required in the meter's communication protocol) and inverted logic.

What should be the problem or solution? I will be pleased very much to hear all of your comments and suggestions.

Sincerely,
Firat.

atomski
- 31st May 2004, 07:10
Firat,

First of all try to troubleshoot what's happening by connecting your PC directly to the meter, sending the quiery sequence and observing the response. If you get nulls you'll know the meter is not responding to the quiery. If you get the expected response, connect the PIC to the PC and see if it's sending the quiery string correctly... I guess I didn't help much but this way you'll be sure your hardware is working properly and that's a start... :)

--
Sincerest regards,

YZ7REA Vladimir M Skrbic
4N7ATV Repeater Administrator
YU7GHZ Radio Club President