Pages: [1]   Go Down
Author Topic: Stepper motor "Turns Counter" and interrupts question...  (Read 1259 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

I have just joined this forum, and have been doing some work with an arduino mega over the last couple of months.  Rather new to this, and I have been drinking from a fire hose....I have a couple of questions which I am hoping someone an help me with, or point me in the right direction...

I want to use stepper motors for my project, but I have the need to implement a "mechanical turns counter" if you will, with an arduino mega....in other words, I want to be able to count how many turns my stepper motors turn in one direction, and increment the counter, and then how many turns they turn in the opposite direction, and decrement the counter..in this way, I can calculate how far the servo has traveled, and then display that on an LCD...and do further calculations in my application.

I am thinking, that the way to do this, is to use a dual shaft stepper, and then couple a rotary encoder to one shaft, and have the encoder provide feedback as to the stepper rotation, as well as direction, and count the rotations this way....does this sound correct?

here is where it gets interesting....now, when I shut the arduino mega down, I then also want to be able to recall the last values of the encoders, so that when the program starts up again, I know where the steppers are, in other words, their positions when the unit was last powered down....this is like a mechanical counter as I said....which counts then displays the digits, but has the digits displayed next time you look at it.... I would rather not have to go through an indexing routine each time I power up, but have a means of determining where the steppers are last time the unit was powered down...hope this makes sense?

Since the encoder will start again from neutral when the board gets powered up, how can I determine where it last left off?

Also, I have the need to use the Frequency counter library in my application to read freq., but as I understand it, it uses interrupts and slaves them to pin 47 (on a mega), and if used with any other code which uses interrupts, it does not work.  I have confirmed this by using the servo library (NOT the softservo), and this library does NOT work, if I am also using the Freq. Counter library....I know the mega has many more interrupts, but my head is spinning trying to figure how to make the two work together....

Any suggestions?  Where can I get some insight on this?

Thank you all in advance for your guidance and help!!
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12164
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are stepping the motors can you not just keep a count of the steps?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply MarkT...yes I guess that will do, but I would rather not have to index the stepper every time...

I am not sure I Follow you....so say I count the steps, for example, on a 200 micro-step motor, pulsing it 1600 times will provide me with a full rotation...pretty easy I guess to do the math, and then find out how many turns the stepper has advanced, forward or backwards...ok..

Now, how do I keep this value, next time I power up?  In other words, if I have say told the stepper to go 40 turns forward, how do I know the position, next time I power up the board? so that I can start from THAT previous position?

am I missing something obvious?  I would really appreciate an example....

For a servo, this is pretty easy, since it's internal potentiometer, keeps track of its position, not sure how to do that with a stepper..

thank you again!
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12164
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

EEPROM library?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Duaahhhh.... smiley  That is why I am new to this.....

Thanks Mark!  I will let you know how it turns out....now gotta go do some more reading as to how to use the library to store the stepper positions!

thanks again!
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3693
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you going to be able to guarantee that the steppers haven't been moved while the power to the Arduino was off?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

interesting question....well, if I enclose them in some sort of an isolated thing, probably....but unless someone decides to move them by hand, then no....that is why I will also have some sort of an indexing routine...

I am curious, as I think you have something in mind??
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3693
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was just thinking that it would be dangerous to assume that you know where the motors are - safer to always perform some power up zeroing operation with limit switches or the like to establish the index position definitively.
Logged

Pages: [1]   Go Up
Jump to: