I'm making my stepper motor rotate using the Arduino Motor Shield. It's continuously rotating back + forth from -55 steps to +55 steps in a forever while loop. I want to count the number of rotations or number of cycles. How do I do that? Is there a special function that counts cycles or steps of a motor? So far, I need code that will do the following below; below is my pseudo-code.
switch-case (my text input):
'1': start counting motor cycles, turn on motor
'0': stop counting, turn off motor
count cycle function: input (my text input of '1')
if total_steps == 55.5: counter++ // 1 cycle is completed
if total steps == -55.5: counter++ // 1 cycle is completed
Is there a function that can give the value for total # of steps rotated?
I'm making my stepper motor rotate using the Arduino Motor Shield. It's continuously rotating back + forth from -55 steps to +55 steps in a forever while loop.
And the code looks like?
I want to count the number of rotations or number of cycles.
Counting the number of steps depends on how you make the stepper step. Counting the number of cycles depends on what you mean by a cycle.
Is there a special function that counts cycles or steps of a motor?
No. There is nothing special about it.
So far, I need code that will do the following below; below is my pseudo-code.
I got another question. Now, my stepper motor's gonna spin really fast, at many cycles back and forth, even up to 10,000+ cycles, maybe up to a million cycles in the duration of a day. The motor will run continuously all day. I have the counter to count the number of cycles (cycle= 1 motion of back+forth). The cycle must always be a whole number. I've called the cycle counter to be an "int", but instead of '"int", there are other variables that can store more bits or numbers, even up to a million. Will "int total_cycle_count" be adequate or should I change that to "float total_cycle_count"?
"Unsigned long variables are extended size variables for number storage, and store 32 bits (4 bytes). Unlike standard longs unsigned longs won't store negative numbers, making their range from 0 to 4,294,967,295 (2^32 - 1). "
great to see people ask question, not that clear find "other" solutions, raise new questions and next solve them.
Perhaps enlighten us a little bit, what are you making ?, we wont need to see your code just out of curiosity
you use this more as a learning blog for yourself.
For questions be a bit more specific for people willing to help what you ask them.
i dont say its wrong or so but.. hm but i'm wondering how to respond to such type of blogging on the forum, as you didnt seem to need help.