LED state in simulation (debug)

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
RGV250
Posts: 279
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 30 times

LED state in simulation (debug)

Post by RGV250 »

Hi,
I have a strange issue in a sim(debug), I have a couple of LED's and when I run the sim for the first time everything seems to work as expected.
If I stop the sim and run it again the LED's are the same state as when it was stopped, I have even tried turning them off at the start of the program but that does not work either.
Also, if I put the variables $PORTA2 and $PORTA3 in the watch list they do not change.

Here I have run the program and stopped it with both LED's on after around 16 seconds (SimTime), on the second start they should both be off?
If I reload the program all is OK again until it is run and stopped.
LED error.jpg
LED error.jpg (59.08 KiB) Viewed 208 times
WiFi_Test_4A.fcfx
(24.43 KiB) Downloaded 10 times
Regards,
Bob

chipfryer27
Valued Contributor
Posts: 1195
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 289 times
Been thanked: 418 times

Re: LED state in simulation (debug)

Post by chipfryer27 »

Hi

Whilst I know of LEDs not reinitialising when simulation has been stopped and restarted, I've not came across it not responding to being told to switch off at the start.

Perhaps to narrow it down could you set the pins off (e.g. set output of B1 = 0 or such like)?

Regards

RGV250
Posts: 279
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 30 times

Re: LED state in simulation (debug)

Post by RGV250 »

Hi,
I tried that but no difference. What did puzzle me was the pins i used were not in the output list so I changed them but still no good.
Hope to try on real hardware soon.

Bob

Steve-Matrix
Matrix Staff
Posts: 1277
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 170 times
Been thanked: 285 times

Re: LED state in simulation (debug)

Post by Steve-Matrix »

I've tried simulating your project and I do not see the problem you are describing (unless I misunderstand you).

When I single-step through the project and set 'ReadRequired' to 1, the LEDs both come on within the call to 'Outputs'. The 'Digital Pins' window show pins A2 and A3 at logic 1 and list the LED they are connected to.

When I stop and run your program again, the LEDs switch off and those pins are set to zero when the 'TurnOff' macros are executed. This happens if I step through the simulation and when I run it normally.

I notice you are using the Legacy 2D panel. We don't recommend using this in v10 and you would be better to move the components to a new 2D panel.

RGV250
Posts: 279
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 30 times

Re: LED state in simulation (debug)

Post by RGV250 »

Hi Steve,
I did a library update and it now works as expected, also I found the digital pins window, never noticed it before.
I cannot find out how to change the 2D panel without deleting everything and starting again?

Bob

medelec35
Matrix Staff
Posts: 1471
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 516 times
Been thanked: 474 times

Re: LED state in simulation (debug)

Post by medelec35 »

Hi, Bob.
No need to delete anything.
After you have added one or more 2D panels, if the component is a 2d component, then just right-click on it and select Move to.
Then select the name of the panel you would like to move it to.

If you have 3D components, you can add the equivalent 2D component then delete the 2D component you just added as it will now be in Flowcode's memory.
Right-click the component, then select Selection > Replace

The 3D component should now be replaced with the 2D conversion, if compatible.
Martin

RGV250
Posts: 279
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 30 times

Re: LED state in simulation (debug)

Post by RGV250 »

Hi Steve,
I have managed to move the components to the new panel but in my dabbling I managed to add a 3d panel which I cannot get rid of.
It has a red exclamation mark in the box to the left.
3d panel.jpg
3d panel.jpg (6.67 KiB) Viewed 151 times
Not sure what has happened but now it has the 3 boxes like the 2D one but still cannot remove it.

Bob

medelec35
Matrix Staff
Posts: 1471
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 516 times
Been thanked: 474 times

Re: LED state in simulation (debug)

Post by medelec35 »

Hi Bob.
No, you did not add the 3D System panel, its there by default, so it can't be removed.
The red exclamation mark just means its hidden.
The same can be done with any 2D panels as you can have more than one.
Just right-click on any panel for options e.g. Hide/Unhide (2D panels allow you to rename them as well).
Wiki has information on 2D Panels.
Martin

Post Reply