Simple RS232 receiver gives all numbers except 255!

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
christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Simple RS232 receiver gives all numbers except 255!

Post by christoph »

Hi all,
Desparately trying to sort out the simple flowchart included below but I have spent some hours on it and got nowhere with the problem.
All I am trying to do is receive the numbers ZERO to 255 inclusive. The flowchart got so complicated that I have taken it back to my original (I thought finished) one!
I CAN get it to receive 255 and display all the LEDs on the port but then it also displays them all, when the number '0' is being received.
I need zero to be no LEDs lit and 255 to be all lit (I also need all the numbers from '1' to '254' but they all work fine and as required).
I HAVE to have zero/0 as no lights on and 255 as all on because it is requirement for a following proprietry chip's 8-bit input.
I am missing something simple I am sure but I have tried using 254 and 256 to 'trick' it into submission but to no avail.
If someone could indicate or tweak the flowchart to achieve this I would be everso grateful...
Chris
RS232 receiver sees all numbers except 255.fcf
(8 KiB) Downloaded 381 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: Simple RS232 receiver gives all numbers except 255!

Post by Benj »

Hi Chris,

I have made some edits to your program to get it to work how you want.

1) RS232 Ext Properties - Switched receive type from Byte to Int. (In Byte mode 255 is reserved to indicate a timeout)
2) Changed the Variable Data0 from a Byte to an Int using the variable manager.
3) Changed the "have we received anything" decision to detect valid data 0-255.
4) Cleaned up some of the unnecessary code.
Attachments
RS232 receiver sees all numbers except 255.fcf
(8 KiB) Downloaded 342 times

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Simple RS232 receiver gives all numbers except 255!

Post by christoph »

Hi Benj,
Much appreciate your responce but it isn't quite how I wanted it but probably not explained it very well - it needs to be as follows:

1) Bring up the flowchart for first time..........all leds off (thats fine),
2) Start the simulation running but with no number put in/no data at all being received............still, all leds off (this is equating to the real-life situation when Receiver power is applied but transmitter is sending nothing),
3) Put in a '0'..........still all leds off,
4) Put in any number from 1 to 255 and the appropriate leds of the port should be lit in bainary.
5) When the number is put in and displayed, it has to 'lock' so that no subsequent nunber(s) changes it (until reset by stopping and re-starting the simulator) - in real life shutting off the power takes it back to 2).
Info: The output to the green led is simply the signal to another chip to say "the code is set, now action it"

I can see whilst typing this that it was not very clear in my first posting - sorry, but I would value your response in the light of the above.

Regards,
Chris

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: Simple RS232 receiver gives all numbers except 255!

Post by Benj »

Hi Chris,

Ok no problems this should be more like what your after.
RS232 receiver sees all numbers except 255.fcf
(8.5 KiB) Downloaded 409 times
The only value that will make it the LEDs is the first one that is received that is greater then 0. Once the data1 variable is set no other values can be output to the port until the device is reset.

Note: Ascii 0 or '0' is not the same as 0 in decimal. Its actually equal to 48 decimal. See this ASCII table for more information: http://www.asciitable.com/

Are you sending the 0 in decimal or in ASCII?

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Simple RS232 receiver gives all numbers except 255!

Post by christoph »

Hi Benj,

Yes - in decimal cos it is what the follow on chip requires - I can't change that

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Simple RS232 receiver gives all numbers except 255!

Post by christoph »

I must have some settings wrong or something cos when I run the latest flowchart all the leds come on from the instant I start the simulation...

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: Simple RS232 receiver gives all numbers except 255!

Post by Benj »

Seems the v4 simulation doesn't actually simulate the int style return value and so you are getting the 255 value as the timeout which is causing the LEDs to go high when you start the simulation running.

Should work fine as is on real hardware and should also work correctly in the v6 simulation.

christoph
Flowcode V4 User
Posts: 382
Joined: Tue Nov 01, 2011 4:28 pm
Has thanked: 196 times
Been thanked: 26 times
Contact:

Re: Simple RS232 receiver gives all numbers except 255!

Post by christoph »

Hi Benj,
OK will put it together and give it a whirl.
While we are in communication, can you throw any light on why I have to keep re-setting my configurations options whenever I want to programme a chip. I have seen the forum info and the fix if chip doesnt compile and I know WHAT to do but what usually happens is I get it all corrected and it doesn't programme and I go back to the options and they are all wrong again. Default makes it right apart from the square bracket directory problem which I correct then fin all the first part is wrong because the Capital letters become lower case AND/OR the dots on the firdt couple of items have become underscors (i.e. '_') .
Never had any problem until a couple of months ago but I havent made any changes to computer or program etc.
Any ideas I could try gratefully accepted cos sometimes I spending half an hour or more re-doing and checking etc before I can program then it suddenly goes ok but next time the same thing occurs. Basically it doesn't seem to save the changes I make.

Chris

Post Reply