Page 1 of 1

RS232 Rx Flowcode

Posted: Fri Jun 29, 2012 4:19 pm
by Jan Lichtenbelt
Please find a flowcode macro to receive a string with any baud rate between 1200 and 19200 Hz.

I had troubles with receiving correct data between 2 microchips using RS232 (see elsewhere). That made me to look more in details of the protocol of RS232. That is simple. And that made me think that I can solve my problem by programming a RS232 Rx Flowcode myself. This is of coarse not the most simple solution, but if you ever meet problems with RS232 receiving strings/characters, you can try this one.

Some details of Version 1.0:

1.) Give input parameters in Init_RS232
(Baud rate , number of characters in the string, oscillator frequency)
2.) Character reading is possible with # characters=1
3.) Rx input is port A2. This can be changed manually in the macro
4.) Bits are tested on correct start bit and stop bit
5.) No parity bit allowed, but can easily be added
6.) The time of the stop bit is equal to time for the start bit
7.) Automatically detection of the start bit (falling edge)
8.) All delay are possible, also no delay. That means start bit may follow directly the stop bit.
9.) Tested with RS232 sending with common RS232 macro (software) with second microchip.

Just try it.

Jan Lichtenbelt

PS. I'm sorry to say, but this flowcode works only for strings all with the same number of characters. Version will take care of that.

Re: RS232 Rx Flowcode

Posted: Sat Jun 30, 2012 11:31 am
by Jan Lichtenbelt
Please find attached the second version. In this one the Timeout has been introduced. This made the reading more flexible. Now strings with variable length are possible.

1.) Input parameters (Init macro) are: Baud rate , maximum number of characters in the string, oscillator frequency and timeout
2.) Character reading is possible with string length=1
3.) Rx input is port A2. This can be changed manually in the macro Get_Char (3 places for input start-bit, 8-bits and stop-bit)
4.) Bits are tested on correct start bit and stop bit
5.) No parity bit allowed
6.) Time stop bit is equal to time for start bit. But the length of the stop bit may be larger (but must be smaller then the timeout)
7.) Automatically detection of each start bit.
8.) Tested with RS232 sending with common RS232 macro (software) with second microchip.

Jan Lichtenbelt

Re: RS232 Rx Flowcode

Posted: Sun Jul 08, 2012 7:47 pm
by Jan Lichtenbelt
The interrupt-on-change can be used on more input pins. But I found that these interrupts-on-change are less accurate compared to the INT interrupt. In this version 3.1 I replaced the interrupt-on-change by the INT interrupt. However only the INT-pin can be used in this case. Thus less flexible, but more accurate results.

Kind regards,


Jan Lichtenbelt

Re: RS232 Rx Flowcode

Posted: Mon Jul 09, 2012 6:22 am
by jgu1
Hi jan!

Again a god project from you, thank“s. :D


Jorgen

Re: RS232 Rx Flowcode

Posted: Wed Jul 11, 2012 10:56 am
by Jan Lichtenbelt
In the meanwhile I extended this program for RS232 with output on two lines of the LCD. The newline-carriagereturn character can be choosen by yourself. In this file attached I used the @ for a new line.
E.g. Sending "Hello world" will be displayed as: Hello world. And "Hello@world" as:
Hello
world

Succes with this extention.

Jan Lichtenbelt