取消
显示结果 
搜索替代 
您的意思是: 

How can I use 3 buttons to control the transitions of my case structure?

已解决!
转到解答

Hi everyone,

 

Hopefully this will be an easy fix... Although I cannot seem to work it out??

 

I am building a state machine inside a while-loop with the following states:

1. System idle.

2. Self-cal pci card.

3. Run DAQ and do my processing.

4. Stop the vi.

 

I can do this using a enum no problems (with state 1. System idle as the initialising state for the while-loop)... But I really want to have is 4 buttons on the front panel, one for each of the 4 states, so that all the user needs to do is press the button corresponding to the state they want and the appropriate transition ocurrs... For example, when the vi first runs, the idle state is operating... When the user is ready can then hit button 2 for a self-cal... Is self-cal is ok, they hit button 3 for DAQ... Once the DAQ is finished the user can hit button 4 to stop the vi..

 

My problem is that I need the current button to unlatch when another button is hit...

 

Any suggestions?... This is killing me!

 

Thanks,

Jack

0 项奖励
1 条消息(共 14 条)
3,992 次查看

Attached is some reall simple code but I think it does what you want.  Converted to LV 8.0.

 

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 项奖励
2 条消息(共 14 条)
3,982 次查看

Does the sequence always run in the same order?  If so, how about just using one boolean ("next') button to step through each part of the sequence?

 

Otherwise, you can use four buttons.  Just add an event structure to your idle case and handle each button, with the next enum state based on which button was pressed.  You will need to go back to the idle case after each step.

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 项奖励
3 条消息(共 14 条)
3,980 次查看

Hi Matthew,

 

Thanks for your help... This works well... I will need to remove the 1000ms timeout from the event structure otherwise the DAQ code I place in inside will stop after 1 sec..(I tried it with a LED and it turned off after the 1000ms timeout)... Is that ok...? It won't cause an problems?

 

Are you able to problem a quick description of why the idex array and locals variables are needed?... I don't quite get the programming here...?

 

Regards,

Jack

0 项奖励
4 条消息(共 14 条)
3,974 次查看

You can remove the timeout BUT it will not resample the buttons (event loop) until DAQ code is done.

 

Buttons set to "Switch Mode" and local variables are used to reset state of buttons.  Made into arry just to reduce wires.

 

IF buttons were set to "Latch Mode" then event structure would reset buttons automatically without having to use local variables.

 

Simple code but does what you were asking for...

 

Matt

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 项奖励
5 条消息(共 14 条)
3,971 次查看

I would recommend a radiobutton control with four buttons inside.

0 项奖励
6 条消息(共 14 条)
3,959 次查看

Ok... This makes sense... But my DAQ duration is variable and is stopped using the user.... So if I leave the timeout as is the DAQ might stop prematurely... If I remove the timeout the user will not be able to exit by hitting the exit button (as the DAQ code is continous)...? It his right?

 

Thanks,

Jack

0 项奖励
7 条消息(共 14 条)
3,956 次查看
解答
已被主题作者 jcannon 接受

Here's what I had in mind. You can easily add conditions so code only executes once after a control change, for example.

 

 

8 条消息(共 14 条)
3,951 次查看

Hi altenbach,

 

Brillant!.... Thanks heaps....!!

 

Regards,

Jack 

0 项奖励
9 条消息(共 14 条)
3,944 次查看

Hello! I have same sort of problem. But I have 3 inputs and the code applied on them is same. The problem has been illustrated in the diagram attached.

 

 When I will press button 1, source 1 data will pass through black box and the code in vi will apply on it. Same when button 2 is pressed ,source 2 data passes through black box and same vi code applies on it.same thing with button 3.

How can I do this? Help me to do this.

Thank you

0 项奖励
10 条消息(共 14 条)
3,817 次查看