01-22-2016 09:21 PM
Hello guys,
I am attempting to write code to do the following;
The USB-6501 P0.0 connected to a switch that is held high via a resistor.
The switch is pressed and I can detect the input (my Panel LED changes color).
I need to update a numeric indicator (I think that is the correct vi I should use) everytime the switch is pressed.
Any assistant will be much appreciated.
Solved! Go to Solution.
01-22-2016 09:30 PM
What do you mean by "update a numeric indicator"?
What do you want it to show?
01-22-2016 09:33 PM
Update with what value? Do you want to count the numer of presses?
01-22-2016 09:33 PM
I would like to display the number of times the switch has been pressed. I meant numeric constant.
01-22-2016 09:34 PM
Yes, that is correct.
01-22-2016 09:35 PM - edited 01-22-2016 09:40 PM
actually it is numeric indicator is correct. you can think about the logic necessary to qualify as a change/increment, and that is what you have to program. And actually for the hardware you are using, I believe there are built in counters that you can use to make your life easier: http://www.ni.com/pdf/manuals/375267a.pdf
01-22-2016 09:42 PM - edited 01-22-2016 09:45 PM
Yes, the output of the source is 1D Array (TRUE or FALSE) and the type of the sink (numeric indicator) is a double. I am having trouble connecting them together.
I did notice my device has the event counter as shown in the document. Perhaps I'm approching this in the wrong way since I need to have 8 switches and each has their own numeric indicator.
01-22-2016 09:45 PM - edited 01-22-2016 09:47 PM
You should be able to just use a counter to read in the number of edges so you don't even have to convert from the arrray: http://www.ni.com/f/students/12/7353/en/
But if you want to go that route, you can use a for loop to go through each index of your array. Just make a for loop, then wire your array into it, and you will see that it automatically takes each index for each iteration of the for loop.
edit to answer your edit:
So, if you have 8 switches, it would make sense as to why you might be getting an array of 8 boolean, because it is for each of your inputs.
01-22-2016 09:46 PM
Store the number in a shift register. Use boolean crossing Pt by Pt to determine when the switch changes. When that is true, then add 1 to the value going into the shift register.
01-22-2016 09:48 PM
Pardon my ignorance, what is PT by PT?