RS232 Project Not Working

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

Moderator: Benj

Post Reply
User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

RS232 Project Not Working

Post by acestu »

Hi,

I am basically trying to learn how RS232 works and so I am trying to send a serial command to my 4D display, the chart is supposed to send values of 60 and 40 to the Meter which has an index of 0. When I program the chip it does not do anything but if I program it using the Visi component then it works fine, I have noticed that when using the Visi Console there is an extra command of 0xff on there but I don't know what this is, could somebody give me a pointer please...

cheers
Acestu
rs232test.fcfx
(5 KiB) Downloaded 402 times
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.

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 Project Not Working

Post by Benj »

Hi Stu,

You will need a second delay after the second RS232 command or you will probably only ever see the first state.

Other then that everything looks ok, check sums etc.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

Is the delay between the commands a standard period or is it trial and error ?


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.

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 Project Not Working

Post by Benj »

Hi Stu,

You should just need long enough delay to be able to see the second state before the first state kicks in again.

One thing I missed is that after every command you send out you need to attempt to receive a byte with a fairly big timeout, if the command was accepted then the return value will be equal to 6. It is this waiting for a response that ensured you don't send out commands too quickly.

Another thing I missed is that you are passing the values inside a string which will not work as the bytes sent out will be '0','x','0','1', etc.

Here is an example that should work.
rs232test.fcfx
(9.61 KiB) Downloaded 351 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 Project Not Working

Post by Benj »

Edit,

I missed the RS232 initialise from the very start of the program. You will need to add this for it to work :roll:

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times

Re: RS232 Project Not Working

Post by SHORTCIRCUIT »

Hi Benj
In your example above you use variables which are do not seem to have been defined, such as .command, .MSB, .in.. I don't understand what is happening here. Would you please explain or point me to somewhere that would help me to understand what is going on here. Thank you.

Larry

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 Project Not Working

Post by Benj »

Hi Larry,

Those local variables are parameters of the macro which are passed in from the calls in the main macro. If you double click on the start icon for the SendCommand macro you can see the parameters being specified. The macros tab of the project explorer is another good place to look as it allows you to display this type of information for all macros.
LocalVars.jpg
LocalVars.jpg (96.06 KiB) Viewed 11349 times

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times

Re: RS232 Project Not Working

Post by SHORTCIRCUIT »

Benj, Thanks for the info, I never knew this.

Larry

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

Does the RS232 Initialise macro have to go right at the start of the chart or start of the loop, I have placed it at the beginning but the chart does not want to work in hardware, I will try a few different things anyway...

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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

I have tried putting the initialize command in a few different places but I can't get it to work. I am enclosing a pic of the console when in simulation.
rs232testv2.png
(4.15 KiB) Downloaded 5844 times
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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

I have written a chart using the Visi component and the meter works fine, so there is nothing wrong with the meter.
visitestv2.fcfx
(5.08 KiB) Downloaded 365 times
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.

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 Project Not Working

Post by Benj »

Hi Stu,

Is it the RS232 initialise your having problems with?

Here is an updated version of the last file with the addition of the init function.
rs232test.fcfx
(9.91 KiB) Downloaded 330 times

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

Thanks for the new chart, I will have a look as soon as I get home later.

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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj,

I have tried to program the chip about 20 times with the new chart but every time I get the Error code 118
error118.png
(8.27 KiB) Downloaded 5795 times
cheers
Acestu

EDIT I have also tried medelec's suggestion of reloading the file but no difference
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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi,

I was just about to try a different compiler when I clicked the wrong thing ie compile to chip, and it worked, however the chart still does not work Benj, so I don't really know whats going on as the visi component works fine, but when I program with this chart it doesn't want to know.

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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi,

I have been trying to compare and workout what is going on in the console window, now with the visi component I can see the Hex values that are being sent and I think in the red brackets is what is sent back ie ff 255.

When I look at the RS232 console I just see a lot of gobbledygook is this right if so what does it mean ?

I am enclosing pics of both so you can see what I mean.
visiConsole.png
(9.19 KiB) Downloaded 5779 times
rs232Console.png
(3.79 KiB) Downloaded 5779 times
cheers
Acestu


EDIT:

With the display connected in simulation I can see that the display returns 6 (Red Brackets)
visiconsole2.png
(10.58 KiB) Downloaded 5779 times
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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi,

I have had a look in the Flowcode 6 help but I can't find anything that might explain the letters/symbols/numbers in the RS232 console window, if anybody can explain or has a link I would be grateful.

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.

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: RS232 Project Not Working

Post by JonnyW »

Hi.

The numbers on the console [01][10]<-[01][10](9 are, in hex, 0x01, 0x10, 0x3C, 0x2D, 0x1, 0x10, 0x28, 0x39. This repeats over and over again.

With the exception of the 0x00 characters in the packeted image above, these are the same values as in this image. There is a console mode where you can see the bytes as well as the text that comes down the console (the EEPROM component uses this). This is an option set via the API, but I might add it in as an option in a menu too so you can see what the values are in 'raw bytes' as opposed to ASCII if you wish.

Cheers,

Jonny

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Jonny,

Thanks for the info,
Sorry for sounding thick but how can I find out what each of these symbols mean ?
symbols.png
(492 Bytes) Downloaded 5755 times
ie What does the < and the - mean? or the ( or the 9 ?

also that sounds like a top addition, I am just trying to work out why Benj's chart will not work, if anybody has any pointers please let me know.

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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Jonny,

I realize now that the symbols are ASCii symbols, but the chart still doesn't work :(


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.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: RS232 Project Not Working

Post by acestu »

Hi Benj

If you can could you check the chart that you did for me please, I cannot get it to work on Flowcode 6 for some reason.. :(

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.

Post Reply