Page 1 of 1

Simulation: Set components to an initial required state

Posted: Thu Oct 01, 2015 10:52 am
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.

Re: Simulation: Set components to an initial required state

Posted: Thu Oct 01, 2015 12:35 pm
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

Re: Simulation: Set components to an initial required state

Posted: Thu Oct 01, 2015 12:53 pm
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

Re: Simulation: Set components to an initial required state

Posted: Fri Oct 02, 2015 10:57 am
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

Re: Simulation: Set components to an initial required state

Posted: Fri Oct 02, 2015 11:16 am
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

Re: Simulation: Set components to an initial required state

Posted: Fri Oct 02, 2015 12:13 pm
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

Re: Simulation: Set components to an initial required state

Posted: Fri Oct 02, 2015 1:35 pm
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