Page 1 of 1

LED state in simulation (debug)

Posted: Sun May 05, 2024 7:08 pm
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 7328 times
WiFi_Test_4A.fcfx
(24.43 KiB) Downloaded 523 times
Regards,
Bob

Re: LED state in simulation (debug)

Posted: Sun May 05, 2024 7:36 pm
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

Re: LED state in simulation (debug)

Posted: Sun May 05, 2024 9:24 pm
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

Re: LED state in simulation (debug)

Posted: Mon May 06, 2024 10:03 am
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.

Re: LED state in simulation (debug)

Posted: Mon May 06, 2024 4:02 pm
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

Re: LED state in simulation (debug)

Posted: Mon May 06, 2024 6:28 pm
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.

Re: LED state in simulation (debug)

Posted: Mon May 06, 2024 10:08 pm
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 7271 times
Not sure what has happened but now it has the 3 boxes like the 2D one but still cannot remove it.

Bob

Re: LED state in simulation (debug)

Posted: Tue May 07, 2024 8:16 am
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.