Page 1 of 1

RS232

Posted: Tue Jan 25, 2011 12:59 pm
by proton
Hi

I have just captured the following RS232 data string from a pc to a message board

<NUL><FF><FF><NUL><VT><SOH><FF><SOH>01<STX><EF><BO><EF<A4>TEXT<FF><FF><NUL>

This was sent @ 2400buad, databits 8, stopbits 1and parity none

How would i achieve this using the RS232 component in flowcode 4

Regards

Wayne

Re: RS232

Posted: Tue Jan 25, 2011 1:58 pm
by Benj
Hello Wayne,

I would use a ASCII table to look up the values for each of the ASCII characters you want to send.

EG
Null is 0 in decimal
VT is 11 in decimal

You should be able to find all the values from here http://www.asciitable.com/

FF, B0 and EF are likely to be hex numbers so you should be able to enter them straight into the RS232 send macro.

eg
0xFF
0xB0
0xEF

To get the 0xFF (255 in decimal) value to send you must put the RS232 component's receive type into int mode.

This is taken from the RS232 help file.

Receive Type
Defines the value for the timeout return value.

Byte (Legacy) sets the INVALID_RETURN timeout value as 255 allowing acceptable data values 0-254 (8 bit mode).
Errors such as framing and overflow errors also return 255.

Int (Extended) sets the INVALID_RETURN timout value as 512 allowing acceptable data values 0-255 (8 bit mode) or 0-511 (9 bit mode)
When using the extended mode framing errors return a value of 1024 and overflow errors return a value of 2048.

Let me know if you have any problems.

Re: RS232

Posted: Tue Jan 25, 2011 2:29 pm
by proton
Benj,

Am i right in saying i have to open a RS232 send macro for each of the above,i.e null then 0xff and so on

Rgds

Wayne

Re: RS232

Posted: Tue Jan 25, 2011 3:26 pm
by Benj
Hello Wayne,

Yes thats right thats probably the easiest way to do things.

You could also maybe fill up a string with the byte parameters and use the send string macro but I'm not 100% how the null bytes would get treated. A null in a string normally signifies the end of the string.

Re: RS232

Posted: Tue Jan 25, 2011 3:38 pm
by proton
Just two more question how to set up the stopbit and parity, also when i look at the data on my scope it is inverted to what i got from the pc?

Rgds

Wayne

Re: RS232

Posted: Tue Jan 25, 2011 5:02 pm
by Benj
Hello Wayne,

There is 1 stop bit required by the hardware UART.

The partiy bit is normally disabled. To allow for parity you will have to switch the RS232 component into 9-bit data mode and then manually check if the parity bit is correct. I think someone has released example code of how this is done somewhere on the forums. Otherwise it should be quite easy to find example code via google that will allow you to check if the parity is correct for the data received.

RS232 data is inverted by default.

Re: RS232

Posted: Wed Jan 26, 2011 8:55 am
by proton
Good morning Benj,

What i was trying to say is on the scope from the rs232 on the pc i get the following
Null=logic 1
0xFF=logic 0
From flowcode i get
Null=logic 0
0xFF=logic 1
Which would say RS232 from flowcode is not inverted

Any idea's

Regards

Wayne

Re: RS232

Posted: Wed Jan 26, 2011 9:29 am
by Benj
Hello Wayne,

In the conversion from a 12V system (RS232 - PC) to a 5V system (UART - PIC) the transmission lines get inverted. The MAX232 chip on our EB015 E-block does this automatically for you.

If you need a simple way of converting the signals without using a MAX chip then here is a simple circuit that I know works well.
Image

The parts your interested in are D1, R1 and R2.