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.
RS232 Rx Flowcode
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 Rx Flowcode
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
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
- Attachments
-
- RS232 Rx flowcode_V2.fcf
- (35.17 KiB) Downloaded 338 times
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 Rx Flowcode
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
Kind regards,
Jan Lichtenbelt
- Attachments
-
- RS232Rxflowcode_V3.1.fcf
- (35.97 KiB) Downloaded 322 times
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 Rx Flowcode
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
E.g. Sending "Hello world" will be displayed as: Hello world. And "Hello@world" as:
Hello
world
Succes with this extention.
Jan Lichtenbelt
- Attachments
-
- RS232Rxflowcode_V4.1.fcf
- (41.33 KiB) Downloaded 354 times