LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I count from 10 down to 0 then back up to 10?

Solved!
Go to solution

I'm controlling a stepper motor with LabVIEW and I would like to advance it from a position of 14 to 0 in increments of 1 then back up to 14 in increments of 1 and stop it there. Any suggestions on how I could set up a loop to do this. The routine will be part of a basic state machine and each time I enter this state I would like to do the increment.

 

Thank you.

0 Kudos
Message 1 of 7
(3,647 Views)
Solution
Accepted by topic author chuck72352

14 or 10?  The subject says 10 but the message says 14,Smiley Wink

 

Just keep track of whether you're counting up or down in a shift register.  Put 1 in the shift register if you are to count up, -1 if  you are to count down.  Just add that value to the count you are storing in another shift register.  When you hit one end or the other, take the negative of it and put it back in the shift register.

Message 2 of 7
(3,641 Views)

I"m not sure exactly what you mean, but I'll try and figure it out.

 

Thank you.

0 Kudos
Message 3 of 7
(3,636 Views)

I just figured out what you meant.

 

Thank you!

0 Kudos
Message 4 of 7
(3,630 Views)

Attached is my solution.

0 Kudos
Message 5 of 7
(3,623 Views)

Not exactly what I was thinking, but that works.

 

Another idea.  Search for the Ramp Pattern function. (Actually a polymorphic VI).  It lets you create an array that either ramps up or down by whatever increment  you want.  Two of those back to back (one up, one down) and concatenate the arrays to each other should also get you there.

 

Message 6 of 7
(3,583 Views)

Thank  you.

0 Kudos
Message 7 of 7
(3,567 Views)