08-08-2016 04:28 PM
Hi guys,
So what i'm trying to do is to count a digital input from an arduino,
When the pin is given a high input the loop should increment once, and should continue to increment as long as the pin is written low and then high again.
Basically it will serve to count digital inputs read from an encoder into the arduino input pin, and should increment (only once) each time the digital pulse is sent
Any advice incrementing with a digital input, ive been trying the whole day but cannot get it to work
The VI Any help will be greatly appreciated
08-08-2016 11:25 PM - edited 08-08-2016 11:26 PM
Does this resembles to what you are expecting?(Attachment)
You have to put 'Loop' indicator wire in the shift register
08-09-2016 02:14 AM
I only want it to increment once when the digital input is written to high, not to continually increment.
Thanks for the reply
08-09-2016 02:51 AM
Use the boolean value which you are getting after equal operator as case selector to case structure.
08-09-2016 02:58 AM
Oh..!! I missed that one
08-09-2016 09:35 AM
I still cannot seem to get the counter to increment by changing the digital input,
I included a timeout to allow change of input and arduino to read the change, because if there was no timeout the case structure would never be satisfied as arduino wont be able to read
08-09-2016 10:48 AM
Since the Arduino does not have a "real" counter input that would only count on pulse transitions (rising or falling edge) you might want to consider using one of the analog inputs and watching for the voltage to cross a certain threshold (rising or falling) that way your only get one count per pulse.
08-09-2016 10:59 AM
Did you unerstand how event structure works? Look into some free tutorials.
Coming to your problem:
-Keep the loop variable as shift register like in other images you posted to outer loop.
-Just after the digital read connect it to equal to 0 and then pass to case structure.
-Please don't add another loop or event structure without knowing how it works.