sync a motor

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I am just starting on a small project. It is not to be a product or anything like that, but just something to test an idea. I will only build one, and will only use it for a few days.

What I have is a motor that currently turns at 120revolutions per second. It it pretty tight and there is less than 2uS in deviation from turn to turn. If I set timer1 on my mega16 to count on the clock (3.711MHZ) the count is always between 30848 and 30864. The extreme ends seldom happen and it is usually around 30857.

What I need to do is to drive a stepper motor so that it is exactly the same speed as this precise motor. Sounds easy enough, however there is one more thing. I need to be able to select in software the angular difference between them. So, if the encoder pulse that I get from the one is at 0 time, then I need to be able to have the encoder pulse from the other at programmable time N. For example, if they were both rotation a shaft, then the shaft could be programmed to be rotating at exactly the same speed, but (for example) 90 degrees ahead of the other. (Or any other number of degrees.)

The way I was thinking of doing it does not seem very good and so I am asking for suggestions on how to do it.

I had intended to use INTO for the pulse for the first motor, and then use ICR1 for the input of my stepper motors encoder pulse. I could then control the apparent angular difference between the two motors. I could step every 30857/steps_per_revolution.

The problem is that my approach has me resetting the timer at 30857 and I don't think that is a very good way of doing things. Also, it gets kind of complicated if I miss a step during some other interrupt occurance.

Any suggestions on a general approach would be appreciated.

Thanks,

Daniel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I doubt very much if you will be able to drive a stepper motor at 120 revolutions per second. Now if you want to drive one step of the stepper motor every revolution of the other motor, that MIGHT be possible. But that is still 7200 steps/second, and would need very careful motor selection, circuit design, and well-tuned firmware.

Apparenlyly you have a signal into the AVR when the motor completes a revolution. >>IF<< your app is one stepper step per motor revolution, then you gate that input into an external interrupt of the AVR. [The signal must be properly filtered & debounced to avoid false and/or cascading hits.].

Once you get the external interrupt hit you then "schedule" the firing of the stepper pulse. I don't know how you would schedule it >>before<< the event happens :) especially for the first revolution, but in steady-state you can schedule it before the >>next<< motor revolution.

So you might start a timer that will expire at the desired time. Then in the overflow interrupt for that timer, you stop the timer and pulse the stepper. Then do it all again.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow... I don't even think you can get a stepper to run at 7200 rpm, and the number
of steps per revolution may limit your adjustment range also. The first thing I would
probably do would be to use a "normal" dc motor with an optical tach pickup,
and control the speed and *phase* relationship between the two motors. Should
not be all that difficult to closed-loop control the slave motor based on the time
difference between the shaft rotation pulses from an optical pickup on each motor.
A fast PID loop running on the mcu might help as well. Interesting situation!

Tom Pappano
Tulsa, Oklahoma

Tom Pappano
Tulsa, Oklahoma