Simulation: Set components to an initial required state

Please add any feature requests for Flowcode version 6 here

Moderator: Benj

Forum rules
Only feature requests will be considered here. General questions should not be posted in this forum.
Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Simulation: Set components to an initial required state

Post by medelec35 »

Apologies if this already exists.
I would like to see simulation only component icons.
The idea being If i want to start a simulation with say Switches 1,4,& 5 out of a total 6 switches pressed & pot1 start at a value of 128
Then we can grab 4 simulation icons and set first 3 to a value of 1, for the three switches and place them at the start.
Then enter 128 for pot1.
so every time simulation is started switches 1 ,4 & 5 read 1 amd pot1 reads 128 until manually changed.

It can be a pain sometimes keep having to set pot asn switched to a prefered state after pressing F8 or single step.
Martin

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Simulation: Set components to an initial required state

Post by Steve001 »

would be nice to be able to preset the eprom aswell
I have set the contents with write function but didn't appear in eprom on dashboard (I could have done this wrong also)

Steve
Success always occurs in private and failure in full view.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Simulation: Set components to an initial required state

Post by medelec35 »

Hi Steve,
With EEPROM you can preload with data so it does appear on the console:
EEPROM preload.png
(20 KiB) Downloaded 3196 times
Martin
Martin

User avatar
PaulNe
Posts: 27
Joined: Fri Jul 05, 2013 8:36 am
Has thanked: 2 times
Been thanked: 23 times
Contact:

Re: Simulation: Set components to an initial required state

Post by PaulNe »

medelec35 wrote:Apologies if this already exists.
I would like to see simulation only component icons.
The idea being If i want to start a simulation with say Switches 1,4,& 5 out of a total 6 switches pressed & pot1 start at a value of 128
Then we can grab 4 simulation icons and set first 3 to a value of 1, for the three switches and place them at the start.
Then enter 128 for pot1.
so every time simulation is started switches 1 ,4 & 5 read 1 amd pot1 reads 128 until manually changed.

It can be a pain sometimes keep having to set pot asn switched to a prefered state after pressing F8 or single step.
Hi Medelec,

There is a way to do this and I have attached two screenshots that I hope help.

For analogue;
AnalogueChSet.png
(4.33 KiB) Downloaded 3171 times
Here I use a loop to set the analogue challensl to a mid-point (0.5) for 6 potentiometers. This updates the position graphically also in simulation.


For digital;
DigitalChSet.png
(30.81 KiB) Downloaded 3171 times
Here it doesn't work quite as good. The switch component appears to have been designed not to update visually from the SetPort command. It works in that the values are written, but graphically you can't see, unfortunately. To overcome this I connected a series of LEDs to show which bits of PORTB in this example were set.

I hope these help?

Thanks,

Paul

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Simulation: Set components to an initial required state

Post by medelec35 »

Hi Paul,
Thanks.
Although what you have posted is good, If switch looks off but LED is showing on then how is the switch is turned off?
Ideally should be a physical movement.
I would guess if switch is not physically switched on then when component is accessed it would off?
If that is the case then the suggested way unfortunately would not help.
Also, I can't seem to get portB to 255?
Not sure if entered correctly as visually comparing with an image, rather than copy and pasting.
What I have done in the simulation Code (Assuming that's how commands are entered?)is:
test=::Connection.SetPort("PORTB",0xff,0xffffffff)
&
test=::Connection.GetPort("PORTB",0xffffffff)

Martin
Martin

User avatar
PaulNe
Posts: 27
Joined: Fri Jul 05, 2013 8:36 am
Has thanked: 2 times
Been thanked: 23 times
Contact:

Re: Simulation: Set components to an initial required state

Post by PaulNe »

Hi Martin,

I know it's not ideal, so apologies. It seems that it's just a visual thing with the switch not changing graphically. If you use SetPort, and then use a component macro to read the switch it will return a '1', even though graphically it hasn't updated (see screenshot).

As for writing 255 to PORTB, it is working fine for me. What chip are you using? Is PORTB a full port?

We would have to re-work the switch component to achieve the graphical representation, so I will enquire about that and see what we can do.
DigitalChSet2.png
(37.86 KiB) Downloaded 3158 times
Thanks,

Paul

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Simulation: Set components to an initial required state

Post by medelec35 »

Hi Paul,
No need for apologies as it is very interesting and will most definitely come in handy!
Especially I have got it to work now.
When I posted the previous post, I was setting it up wrong.
Will be using your method in the future.
Of course I will still like to see the switch move so to turn off a I/p you need to turn switch on then back off.
But this is the nest best thing.
Thank you.

Martin
Martin

Post Reply