Simulation injector (how to use!)

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

Moderator: Benj

Post Reply
Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Simulation injector (how to use!)

Post by Chris_MIRA »

Hi,
Im trying to use the injector in simulation for the first time. What I want to do is to "Inject" an RS232 signal of Data value =3 into a simple FC6 code and display the data value on an LCD. My attempt at the code is attached. Ive tried HELP and find the example for RS232 with human interface either confusing (Im probably being thick) or it isn't working, if someone could alter the attached code to what it should be to work, then I think (hope) I can pick it up from there. So in essence, please show me how to use an injecter function in simulation so as to read a RS232 data signal of 3 and display it!
Thanks in advance for the help!

Regards,
Chris
Attachments
RS 232 reader.fcfx
(7.85 KiB) Downloaded 264 times

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: Simulation injector (how to use!)

Post by Chris_MIRA »

Hi,
Im still stuck on this, would be VERY grateful if someone could show me where / why the attached code doesn't work?
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: Simulation injector (how to use!)

Post by Benj »

Hi Chris,

Sorry for the delay, I must have missed your post.

The Human interface injector allows you to type values into the console directly. With the simulation running open the console window from the view menu and select the "RS232 RX Queue" tab. Here you can type in values and they should then be received and printed to the display.
RS232 reader HI.fcfx
(6.78 KiB) Downloaded 297 times
Alternatively if you don't want to have to keep typing values in every time you run the sim then you can use the file injector to provide the data from a file on the system. In the example the file must be in the same directory as the Flowcode project file.
RS232 reader File.fcfx
(7.14 KiB) Downloaded 284 times
data.txt
(14 Bytes) Downloaded 269 times
Let me know how you get on.

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: Simulation injector (how to use!)

Post by Chris_MIRA »

Hi, thanks for the reply,

I think Im following your instructions OK but when I open the console and go to the RS tab (or any of the others!) there is a line prompt (not blinking) but nothing can be inputted from the key board, I can not get any characters to appear at all in the consol.
Im re attaching the file as Im not sure Im calling the simulation properly? Also, I don't seem t obe able to view both the dash board and the console at the same time (they toggle) is this right?

Regards,
Chris
Attachments
RS 232 reader.fcfx
(7.77 KiB) Downloaded 247 times

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: Simulation injector (how to use!)

Post by Chris_MIRA »

Slightly updated file with lcd Print Ascii (Data) instead of print 0, problem still not changed though :(
Regards, again
Chris
Attachments
RS 232 reader.fcfx
(7.78 KiB) Downloaded 250 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: Simulation injector (how to use!)

Post by Benj »

Hi Chris,

This is based on the "RS232 reader HI.fcfx" file I posted above with no modifications.
Console.jpg
Console.jpg (83.27 KiB) Viewed 7597 times
Run the simulation and then open the console window and try to type data into the RS232 RX Queue tab. A new console window can be added as shown by right clicking the tabs and selecting create new tab group.

If the simulation is left running then the data will immediately be received and shown on the LCD.

If the simulation is paused then the data will remain on the console until you start the sim running again or step through.

Adding data before starting the sim seems to result in the data being removed so I will look into this.

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: Simulation injector (how to use!)

Post by Benj »

Hi Chris,

I made a quick vid which hopefully should help.

[/youtube]

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: Simulation injector (how to use!)

Post by Chris_MIRA »

Hi,
Sorry for how long it has taken for me to reply back to you, I've just had a look at the YouTube you made and it is very helpful. My system is still not working (Im now following your steps exactly as in the you tube) the issue seems to be with my FC set up, I can not bring up the dashboard panel and the console separately as you do in YouTube, I can only toggle between the two in the same pop-up screen. When I try to entre a character in the human input window, I get a "bad key press" sound from windows and nothing happens either in the human interface box or (when toggled to the dash board) on the LCD display.... This is with the simulation running, any ideas?
regards,
Chris

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: Simulation injector (how to use!)

Post by Jay Dee »

Hi,
I got the first example to work OK
I then tried to modify it to work with a circular buffer.
See modified example.
Can I inject data to the RS232 component and read it out via the Circular buffer, all in simulation?
RS232 reader HI_Circular.fcfx
Circular buffer and data injector
(9.51 KiB) Downloaded 281 times

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

Re: Simulation injector (how to use!)

Post by Jay Dee »

I assume the circular buffer simulates.. I have not tried it on its own yet. It stubbornly would not work with the RS232 component.. unless i was doing something silly. I'm back at the office by Sat so if anyone has any ideas to try, they are much appreciated. J.

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: Simulation injector (how to use!)

Post by Benj »

Hello,

The circular buffer component should simulate correctly. You can use the console window to double check it is working.

The problem is probably be that you are using UART Rx Interrupts. This will work fine on the hardware but is not currently supported in the sim.

To work around this you can add a check in your Uart_Rx macro to detect if the .rx byte is less than 255, if it is then add the .rx to the circular buffer as you are currently. Then add a call to the Uart_Rx function from main to allow the sim to run as expected.

Post Reply