RS232 Pass Through?

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
Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

RS232 Pass Through?

Post by Ondra »

I have been trying for some time to get this attached program to work. I have 2 Pics connected via RS232. One PIC is connected to a PC. I want to be able to communicate to the second PIC through the first. I have attached the program I am testing with. The problem is; the data stops flowing when the code processes a carriage return and does not pass through the rest of the data, until I send through another string followed by a <CR>. If I connect the second PIC directly to The PC, the data flows correctly. It seem that the next or subsequent <CR> frees the data flow, but only to the next <CR>. So, using Hyper terminal, I have to send a command twice before I get a response from the PIC. Any help on this would be appreciated. Thanks in advance.

Ondra
Attachments
RS232 pass through.fcf
(12.5 KiB) Downloaded 242 times

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

Good day, Steve, Benj and David. Has anyone had a look at this? Is there something obvious that stands out?
I really need some help on this.

Ondra.

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 Pass Through?

Post by Benj »

Hello Ondra,

In your decision icon you have the following code.

DataFromPC < 255 && DataFromPC <> 0x0A

Could you maybe change this to this instead?

DataFromPC < 255

It looks to me like the PC is sending a carriage return as 0x0A followed by 0x0D eg line feed + carriage return which may be causing the problems you are experiencing.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

First, thanks for your assistance Benj.
I've tried possibly about 20 different way to get this working. I just tried your suggestion, and again the same problem.
Rather than building a string then sending it, I tried passing each byte as it came in. As simple as it seems I could not get
that to function either. Could there be an underlying yet unknown issue with Flowcode that would prevent this code from working?
I've attached the C file so you can check that all well with my Flowcode installation.

Ondra
Attachments
RS232 pass through.c
(39.66 KiB) Downloaded 239 times

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 Pass Through?

Post by Benj »

Hello Ondra,

Are you using Hyperterminal to send out your data. It may be worth disconnecting hyperterminal and then looking through the settings to see what is happening when you output a carriage return. There are a number of different settings related to this you could try.

Properties -> Settings Tab -> ASCII setup

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

Does this meen that my code is good?
I've been using 2 different terminal emulators. I checked the properties in Hyper terminal and it's clean.
Has anyone tried to get something like this working? I tried something like this awhile back and gave up
deciding to bit bang the communications instead. I would like to know if anyone gets a chance to test this
and see if it works. If I know it works then I can maybe look at a different Hardware setup.

Ondra

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

HI Benj.
I'm still trying to get this resolved.
I have another question. What could be the cause of an RS232 RX lockup. And how can I overcome this?
Also outside of the 3 byte buffer assigned to this chip, could you give me an example of software buffering I could
do that may help to overcome what I'm experiencing. The largest block of data I have to capture is 600 bytes.


Ondra

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: RS232 Pass Through?

Post by medelec35 »

Hiya Ondra
This may not be causing the issue, but in stead of DataFromPC < 255 && DataFromPC <> 0x0A can you try
(DataFromPC < 255) AND (DataFromPC <> 0x0A) im not saying && is wrong, it probably has the same effect of &&. The problem may be down to not having brackets around multiple decision statements, as I had a problem when not enclosed with in brackets.
Try adding brackets to all the multiple decision statements. If that don't solve issue, then If I can I will look a bit deeper.
Have you tried using ICD and single stepping through problem area?
I personally find ICD great to debugging. Always seem to find cause of error with that.
Martin

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

Thanks medelec35.
I tried your suggestions and still the data stops flowing. Note the chip is still running the code. I used a timer to flash an LED. I see that the chip is still
processing data it's just that the RS232 receive is not collecting the data. If I restart the chip only the rest of the data from the second chip flows through.
I know the RS232 RX is locking up. I just need may be another approach for collecting the data. If I could read in all the data then process it that may help over come the issue. The largest block of data I have to capture is 600 bytes. Could you give me an example of software buffering I could do that may help to overcome what I'm experiencing.

Ondra

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 Pass Through?

Post by Benj »

Hello Ondra,

What might be happening is that the hardware buffer for the RS232 is only 3 bytes long. If this runs out then you will get an overflow and this will cause some data to be missed.

Are you using the UART RX interrupt? If so then are you doing anything else inside the interrupt other then storing the incoming data into a byte or an array. If you are doing other things in your interrupt then this will probably cause the interrupt to take too long and therefore you very quickly start getting behind.

To store large arrays of data on a PIC you must setup multiple arrays of size 255. Then you need an INT count variable and use this to detect which buffer to store the data into.

eg.

if buff > 255

no:
count = buff
data[count] = incoming

yes:
if buff > 511

no:
count = buff - 256
data2[count] = incoming

yes:
if buff > 767

etc...........

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: RS232 Pass Through?

Post by Ondra »

Benj.
Thank you very much.

Ondra

Post Reply