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.
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.
03-24-2013 02:41 PM
Hi,
Hope somone can help me with this. I have an analog gear position sensor, which outputs a voltage between 0 and 10V depending on which gear is selected. (I'm simulating this input voltage in the attached VI using a numeric control, and the levels aren't set correctly yet) Because the gear selector is powered by pneumatic cylinder supplied by an small tank, I'd like to count the number of gear changes.
How would I go about setting up a counter which increments whenever the gear selection changes up or down, and which can be reset while the VI is running using a button?
(PS: What I have at the moment to display gear position works, although I'm sure it could be done in a simpler manner. The entire code runs through for each iteration which isn't very efficient at all. Not sure what would be the best way to improve this as I'm relativley new to LabVIEW.)
Thanks for your help.
Kevin
Solved! Go to Solution.
03-24-2013 03:37 PM - edited 03-24-2013 03:41 PM
when you see a redundant amount of functions in your programming....think "array" , otherwise it's rube
03-24-2013 03:49 PM - edited 03-24-2013 03:53 PM
I recommend to use arrays instead of gigantic code with many duplications. Here's one possibility.
We keep the count of gear changes in a shift register and increment whenever the gear is different to the previous value using a feedback node. Modify as needed.
03-24-2013 03:52 PM
@apok wrote:
when you see a redundant amount of functions in your programming....think "array" , otherwise it's rube
You did not answer the main question about counting the number of gear changes.
03-24-2013 03:59 PM - edited 03-24-2013 04:06 PM
i meant to,lunch time, wife called...
my suggestion, shift reg,comparison,add, select...
03-24-2013 04:17 PM
Thanks guys, that's absolutely fantastic! I'm using feedback nodes and shift registers in other parts of my project, and played around with them in this VI after posting up but I couldn't get it to work how I wanted. Thanks for suggesting that I use an array - it really has tidied up the code.
I'll have a good look through the solution, and see what I can learn from it!
Regards,
Kevin