RS232

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
proton
Flowcode V4 User
Posts: 50
Joined: Sun Feb 03, 2008 10:14 pm
Has thanked: 1 time
Contact:

RS232

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RS232

Post 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.

proton
Flowcode V4 User
Posts: 50
Joined: Sun Feb 03, 2008 10:14 pm
Has thanked: 1 time
Contact:

Re: RS232

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RS232

Post 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.

proton
Flowcode V4 User
Posts: 50
Joined: Sun Feb 03, 2008 10:14 pm
Has thanked: 1 time
Contact:

Re: RS232

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RS232

Post 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.

proton
Flowcode V4 User
Posts: 50
Joined: Sun Feb 03, 2008 10:14 pm
Has thanked: 1 time
Contact:

Re: RS232

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RS232

Post 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.

Post Reply