From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

A button, led and switch

It might also be a good idea to have a look at the 'Getting Started with LabWindows/CVI' manual, it's latest version can be found here

 

Exercise 1 should have answered most of the questions discussed here ...

0 Kudos
Message 11 of 16
(909 Views)

Hi again :). I tried to make my led blinking if the switch is on but I failed. I don't how to make a loop to run the 2 states of that led until the switch is on. Can you help me with this ?

0 Kudos
Message 12 of 16
(873 Views)

You may use a timer control. You may want to start with looking at the example timer.cws

0 Kudos
Message 13 of 16
(870 Views)

int CVICALLBACK switch_f (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{

switch (event)
{
case EVENT_COMMIT:
GetCtrlVal(panelHandle, PANEL_switch, &switchstate);

break;
}
return 0;
}

int CVICALLBACK timer_f (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int state;
switch (event)
{
case EVENT_TIMER_TICK:
GetCtrlVal ( panel2, PANEL_2_LED, &state);
if (switchstate == 1)
{
state ^= 1;
SetCtrlVal (panel2, PANEL_2_LED, state);

break;
}
else if (switchstate ==0)
{
SetCtrlVal (panel2, PANEL_2_LED, 0);
}
}
return 0;
}

 

I solved.

Led is on another panel: panel2(PANEL_2)

Switch is on : panelHandle(PANEL)

state ^= 1; change to the opposite state

 

Thanks Wolfgang

 

0 Kudos
Message 14 of 16
(865 Views)

Now I have another problem. I have a picture ring(control mode: hot) and a another picture ring (set to indicator). First picture ring have 2 pictures and second more pictures. When I run the program and change the picture of first, the picture ring 2 must change  with another picture. I put values on pictures on every ring but doesn't work. I tried with GetCtrlVal and SetCtrlVal. I think i need to use another function. Any idea?

0 Kudos
Message 15 of 16
(857 Views)

SetCtrlIndex

 

In general it is a good idea to consult the help file that comes with CVI; in this case there is a section called Programming with Picture Ring  Controls

0 Kudos
Message 16 of 16
(854 Views)