04-11-2017 02:15 PM
Greetings everyone,
I've got a program with two situations. The situations have to be switched by clicking a button.
So it starts in situation 1, when you click the button it has to go to situation 2, and if you click the button again it should return to 1 and so on.
I can't manage to implement this button in the right way.
Could anyone help out?
04-11-2017 02:50 PM
You can change the mechanical action of the 'OK' button to 'Switch when released' and wire the output to a case structure.
04-11-2017 02:51 PM
You could store the mode in a shift register.
04-11-2017 02:54 PM
Could you show me a small example?
04-11-2017 03:01 PM
04-11-2017 03:10 PM
It doesn't work?
it's stuck in the false case
04-11-2017 03:26 PM
Why did you add another case structure? Just have one that has a true case that does the code inside the true case, and a false case that does the stuff in the false case.
Sorry but the picture I attached is meant to show the different code inside the (singular) case structure.
04-11-2017 03:31 PM
Even that didnt work. I think because its a pushbutton? When you push it, it turns on and off again. How can i fix that?
04-11-2017 03:46 PM - edited 04-11-2017 03:52 PM
Honestly, looking at your code, I have to say I don't think that the first issue is the case structures.
1) Is there a reason that you are using the DLL to perform serial communications? VISA seems like it would be a much easier option.
2) Is this code designed for a single run or to keep running? If the latter then you need a loop somewhere to ensure that the program keeps running. "Run Continuously" should very rarely be used to operate a program.
3) When are you pushing the button? In order for it to toggle it will need to be set before the program is run. That is how it is with the dataflow (see here).
04-11-2017 04:12 PM
@sadiek wrote:
Even that didnt work. I think because its a pushbutton? When you push it, it turns on and off again. How can i fix that?
Set the mechanical action to Switch When Released Rather than Latch When Released.