Page 1 of 1

Simulation injector (how to use!)

Posted: Tue May 13, 2014 2:38 pm
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

Re: Simulation injector (how to use!)

Posted: Fri Jun 06, 2014 8:15 am
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

Re: Simulation injector (how to use!)

Posted: Fri Jun 06, 2014 9:24 am
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.

Re: Simulation injector (how to use!)

Posted: Mon Jun 09, 2014 9:23 am
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

Re: Simulation injector (how to use!)

Posted: Mon Jun 09, 2014 9:36 am
by Chris_MIRA
Slightly updated file with lcd Print Ascii (Data) instead of print 0, problem still not changed though :(
Regards, again
Chris

Re: Simulation injector (how to use!)

Posted: Tue Jun 10, 2014 11:17 am
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 7603 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.

Re: Simulation injector (how to use!)

Posted: Tue Jun 10, 2014 6:58 pm
by Benj
Hi Chris,

I made a quick vid which hopefully should help.

[/youtube]

Re: Simulation injector (how to use!)

Posted: Fri Oct 03, 2014 10:01 am
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

Re: Simulation injector (how to use!)

Posted: Thu Mar 03, 2016 11:55 am
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

Re: Simulation injector (how to use!)

Posted: Thu Mar 10, 2016 4:16 pm
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.

Re: Simulation injector (how to use!)

Posted: Mon Mar 14, 2016 11:47 am
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.