RS232

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

RS232

Post by jollybv »

Hi i am pretty new to flowCode and it is getting the better of me, i was wondering is there anyone out there that can help I am trying to send an receive characters from one pic to another using RS232. I think i have the sending part rite as i see the numbers i key in appear in the RS232 component. But the receiving part has me totally confused me I know there is a get character instruction but how do you use it...??? is there any examples out there..?? Can someone please help

PS is there any way of simulating the receive character????

Regards
Brian :roll:

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 Brian,

The read Byte RS232 macro returns a byte value. If this value is less then 255 then it is valid data. 255 represents a timeout without any valid data being received.

You can simulate a received character by adding a byte to the receive queue and then when the read byte macro is called the byte will move from the queue to the received window.

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Thanks benj

how do you add a bite to the receive cue Is there a example I can look at as i have no idea how to do this..???

I have attached a small bit of code could you please tell me where I am going wrong

Regards
Brian
Attachments
RS232 Receive.fcf
(6 KiB) Downloaded 413 times

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

Post by medelec35 »

jollybv wrote:how do you add a bite to the receive cue
Add to Queue.jpg
Add to Queue.jpg (41.42 KiB) Viewed 13029 times
It depends on what you want to retrieve from RS232 data to how the flowchart would work.
So here is a flowchart (created with FlowcodeV3) that converts the received 232Char into ASCII, Displays text on LCD display and stores the 16 charectors in a variable.
I have only included lower case a to z, just to give you an idea one way to detect and convert received data into a string. There maybe a direct conversion function from byte received to ASCII, but since not sure what that is?

If this is not what you want, then if you let me know what format you want the received data in e.g bytes 0 to 255 then I will see what I can do.
Attachments
RS232 Receive_Modified.fcf
(5.5 KiB) Downloaded 462 times
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Hi Benj

Thanks a lot this is starting to make a bit of seance. Let me explain what I'm trying to do I have is a keypad connected to me HP488 board that when i key in a number from 0 to 999 sends it via RS232 to a second chip, the second chip must read it as a number from 0 to 999 put it in a veritable then I want to use a decision to compare it and the second chip must output something eg if a 3 then pin A3 must go high and so on.

Regards
Brian

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

Post by medelec35 »

Here you are try this version.
Attachments
RS232 Receive_Modified_V2.fcf
(6 KiB) Downloaded 405 times
Martin

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

Post by medelec35 »

Updated to a better version.
This will work with values from 0 - 999 and will dispaly values on LCD Display
Also if you just enter the number 3, port A0 will go high.
Any other number entered, will cause A0 to go low.
Attachments
RS232 Receive_Modified_V3.fcf
(8 KiB) Downloaded 456 times
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Thanks Ben

Will try it and let you know

Regards
Brian

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Hi Ben

That program works like a treat from 1 to 9 but when I inset a 10 it gives me the same return as a when I insert a 1 (100) and the same for a 2 and 20 (200) what can i do to rectify it. i have tried numerous things without any luck.

I have attached the program and you should be able to see what im trying to do a bit better.

regards
Brian
Attachments
RS232 Receive_Modified_V2.fcf
(11.5 KiB) Downloaded 428 times

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

Post by medelec35 »

Hello jollybv
Sorry about that. I realised that after posted it, so I modified it to work correctly and posted it an hour later. Have a look at the post Wed Oct 27, 2010 2:16 pm
that has a corrected V3 version, which has not been downloaded yet. As stated above, it works from number 0 to 999. and I have set it up to light a LED only if number sent is a 3 only. Give that a try and let me know how you get on please.

Kind regards
Martin.
Not Ben (he is the clever one :P) lol
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Thanks Martin

You guys are great this works like a dream now to build the board an see if all is working

Regards
Brian :P

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Hi Martin

One quick question the RS232 signal from the transmitter should it be a square wave 0 to 5v TTL ?? I have checked mine on the scope and it is giving me a sort of a ramp form and the second board is not reading it i am using TX Pin 25 RC6 of the PIC16f877 and connecting it to the RX pin of the PIC 16F876A PIN 18 RC7. As i have never worked with RS232 should I to put a line driver as I'm only transmitting about 1m.

Regards
Brian

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

Post by medelec35 »

I have not done what you are trying to achieve, but I believe TX O/P should be a TTL compatible square wave. You could try reducing Baud to 4800. if o/p signal is changing to fast, could the capacitive i/p of pic + connecting wire integrate the signal slightly?
How about you disconnect the TX o/p then scoping it.

I will have to leave it for people that know more about this aspect than I do to advise you. But good luck
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: RS232

Post by jollybv »

Hi guys

I am still having problems with RS232 is sending from the main board it is a 5v high pulsing low TTL but my board on the other side dose not read it I put another program in to see if the board was working and the board runs fine, is there something i am doing with the connections or what. I have TX pin 25 of the Pic16F788 connected to RX pin 18 of the PIC16f876 and the TX pin 17 connected to the RX pin 26 of the PIC16F788 i am using the same power supply so the ground is common. When i simulate my programs they both work in flowcode so to me this should all work but alas I'm stumped again someone please "HELP" :cry:

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

Post by medelec35 »

If is was me, I would 1st check that both flowcharts are configured for same baud rate. Then I would check characters are sent correctly by connecting TX to a RS232 to usb converter, and check what is displayed in HyperTerminal, I would then connect RS232 to usb converter to RX is still getting correct characters displayed, that would mean the transmission length and stray capacitance's are not causing a problem. If all is OK then It would be down to receiving end. If you have LCD display connected, what characters appear on the display?

Just a thought if you are sending a number like 15, that has two bytes. So could the receiver be treating it like a single 1, then acting on that, then treating as a separate 5, instead of 15?
If so there needs to be a time out routine in the receiver so after receiving a number, the receiver keeps waiting for a timed period for the next number. If this timed period has elapsed e.g. 100 ms then no more numbers are sent, so do the if number = ... then do something routine.

Also with the transmitting side there must be a good delay between groups of numbers sent. Don't just send for example 15 then 184 one after the other, have a delay in between e.g. 200ms.

Hopefully someone else can help you. If not I have an idea how they can be altered. Can you post the two flowcharts you have got (that's if you have added to the ones posted on here).
Then I will modify them and re-post.
Martin

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

Post by medelec35 »

sent you a pm with modified files.
This is what i have sent
"Try these. Cant guarantee they will work, as not tried this before, or got hardware to test this out, since you need two separate target devices. I have removed the CR on TX, and on RX added a 200 ms time out. After 1st char is received ,a timer starts and waits for the 2nd. 3rd etc. As soon as 200ms has elapsed, then the routine of determining numbers sent starts.
Can you please let me know how you got on.
Thanks"
Martin

Post Reply