RS232 Help please
Moderator: Benj
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
RS232 Help please
Hi,
I want to use the RS232 component to send data to a Visi display, the protocol is: 8 Bits, No Parity, 1 Stop Bit. I have searched for a demo but cannot find one, basically I wanted to know how you send your data in the component macro, as in do you use the send character a number of times or do you use the send string?
This would be the structure of the information but how do you send it ?
thanks in advance
Acestu
I want to use the RS232 component to send data to a Visi display, the protocol is: 8 Bits, No Parity, 1 Stop Bit. I have searched for a demo but cannot find one, basically I wanted to know how you send your data in the component macro, as in do you use the send character a number of times or do you use the send string?
This would be the structure of the information but how do you send it ?
thanks in advance
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi,
I have posted a thread on the 4D forum asking why all of the example boxes in the Visi Enviroment Reference manual are just blank, however they could not tell me anything of any use, they said try the user manual but it dosen't mention anything, also he said that most of the info is Arduino related, so if anybody could give me any pointers I would be most grateful.
Thanks in advance
Acestu
I have posted a thread on the 4D forum asking why all of the example boxes in the Visi Enviroment Reference manual are just blank, however they could not tell me anything of any use, they said try the user manual but it dosen't mention anything, also he said that most of the info is Arduino related, so if anybody could give me any pointers I would be most grateful.
Thanks in advance
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi,
I found this bit in one of the PDF files:
I understand the command, object id, object index, but not sure what the MSB and LSB are and how is the checksum calculated ?
P.S. how are the numbers put into the rs232 component ?, I am guessing that you use send or receive string then put in your numbers separated by commas ?
Thanks
Acestu
I found this bit in one of the PDF files:
I understand the command, object id, object index, but not sure what the MSB and LSB are and how is the checksum calculated ?
P.S. how are the numbers put into the rs232 component ?, I am guessing that you use send or receive string then put in your numbers separated by commas ?
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi,
I have found this piece about the checksum, however I don't understand it could somebody please help me with it ?
What does XOR ing mean ?
thanks
Acestu
I have found this piece about the checksum, however I don't understand it could somebody please help me with it ?
What does XOR ing mean ?
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: RS232 Help please
XOR is exclusive OR. The C operator is ^ (Flowcode knows XOR in calculations)
Truth table is:
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
For checksum start with 0, then for every byte (including CMD) you send to the display use
checksum = checksum XOR output_byte
After all other bytes have been send, send checksum. Do NOT use above formula on this byte when sending.
MSB = Most significant byte
LSB = Least significant byte
Any value > 256 needs two bytes to send it. for MSB divide value by 256. (MSB = value / 256) For LSB take remainder of division by 256. (LSB = value % 256)
Truth table is:
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
For checksum start with 0, then for every byte (including CMD) you send to the display use
checksum = checksum XOR output_byte
After all other bytes have been send, send checksum. Do NOT use above formula on this byte when sending.
MSB = Most significant byte
LSB = Least significant byte
Any value > 256 needs two bytes to send it. for MSB divide value by 256. (MSB = value / 256) For LSB take remainder of division by 256. (LSB = value % 256)
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi Kersing,
Thanks for the info, I will experiment somewhat and see if I can calculate it correctly
cheers
Acestu
Thanks for the info, I will experiment somewhat and see if I can calculate it correctly

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi,
I am really struggling with this.
In the diagram above I am trying to workout how they get the 16 checksum from this 0704000015 ?
If anybody could just write how this calculation is done I would be most grateful, I have been searching google all night but my findings are getting more complicated
cheers
Acestu
I am really struggling with this.
In the diagram above I am trying to workout how they get the 16 checksum from this 0704000015 ?
If anybody could just write how this calculation is done I would be most grateful, I have been searching google all night but my findings are getting more complicated
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: RS232 Help please
All values are hexadecimal, so 2 digits (A-F are digits as well) are one byte, to calculate the checksum just start with zero and start XORring the values:
Result: checksum = 16
Code: Select all
checksum = 00
checksum = 00 XOR 07 = 07 (0000 0000 XOR 0000 0111 = 0000 0111)
checksum = 07 XOR 04 = 03 (0000 0000 XOR 0000 0100 = 0000 0011)
checksum = 03 XOR 00 = 03 (0000 0011 XOR 0000 0000 = 0000 0011)
checksum = 03 XOR 00 = 03 (0000 0011 XOR 0000 0000 = 0000 0011)
checksum = 03 XOR 15 = 16 (0000 0011 XOR 0001 0101 = 0001 0110)
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi Kersing,
As you said that Flowcode calculations understand the ^ operator I have put a chart together to calculate 03 XOR 15 which is the last line of your above example but instead of giving the answer 16 it gives me 12, so I have done something wrong somewhere...
EDIT: Is it something to do with Decimal numbers that should be Hex in the calculation ? I think I have got to convert from base -16 to base -2 first
cheers
Acestu
As you said that Flowcode calculations understand the ^ operator I have put a chart together to calculate 03 XOR 15 which is the last line of your above example but instead of giving the answer 16 it gives me 12, so I have done something wrong somewhere...

EDIT: Is it something to do with Decimal numbers that should be Hex in the calculation ? I think I have got to convert from base -16 to base -2 first
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: RS232 Help please
You are right, the numbers are all hexadecimal (hex), not decimal. When you use 0x in front of the numbers (0x03 and 0x15) flowcode will interpret them as hex (and so will the compilers).
There is no need to convert the numbers to base-2, just use '0x' in front of what you find in the documentation. If you want to convert them (for your readability and to understand what happens) use 0b in front of the number to tell flowcode it is binary (base-2)
Attached an updates version of your example.
There is no need to convert the numbers to base-2, just use '0x' in front of what you find in the documentation. If you want to convert them (for your readability and to understand what happens) use 0b in front of the number to tell flowcode it is binary (base-2)
Attached an updates version of your example.
- Attachments
-
- checksum.fcfx
- (6.58 KiB) Downloaded 273 times
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi Kersing,
Things are starting to make a little more sense now, I thought there must of been a way of declaring to Flowcode what base your numbers are in, I have never done any coding you see, which is why I use Flowcode, but it is really interesting to learn what is under the bonnet, thanks for your help and I will continue to dabble with this subject until it is clear...
P.S. I cannot open your posted chart it says:
Thanks
Acestu
Things are starting to make a little more sense now, I thought there must of been a way of declaring to Flowcode what base your numbers are in, I have never done any coding you see, which is why I use Flowcode, but it is really interesting to learn what is under the bonnet, thanks for your help and I will continue to dabble with this subject until it is clear...

P.S. I cannot open your posted chart it says:
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: RS232 Help please
You need to download the update to flowcode 6.0.2. Use the menu: 'Help', 'Check for updates'.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi Kersing Wow I just opened your chart and the first thing I saw was
"Remember the printed answer is decimal" so 22 is right just in the wrong base, that explains a lot...
Thanks again Kersing
Acestu
"Remember the printed answer is decimal" so 22 is right just in the wrong base, that explains a lot...
Thanks again Kersing
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: RS232 Help please
Notice I also added 0x to the 3 and 15 in the calculation.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: RS232 Help please
Hi Kersing,
To be honest, I had done that but I was still getting 22 so I thought it was still wrong, it all made sense when you said that the printed number was Decimal, I am just trying to write a chart now that will let me put all the numbers in via a keypad then workout hopefully the checksum.....
cheers
Acestu
To be honest, I had done that but I was still getting 22 so I thought it was still wrong, it all made sense when you said that the printed number was Decimal, I am just trying to write a chart now that will let me put all the numbers in via a keypad then workout hopefully the checksum.....
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.