Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control stepper with L297 with 8051 microcontroller,HELP PLZ, URGENT! 1

Status
Not open for further replies.

Va5h15t

Electrical
Jan 30, 2009
6
Hi, I am trying to control a stepper motor with an 8051 microcontroller(using C) which should be able to send commands to the motor and make it move a certain number of steps either CW or CCW depending on the key pressed.
It is a colour wheel motion.
10 colours = 360deg = 200 steps using a 1.8deg step angle motor.
I am not being able to choose which motor to use: Bipolar or Unipolar? I know it doesnt matter in this case, but I would like to control it using the L297 and a driver to make the software from the microcontroller shorter and use 2 pins of the microcontroller, rather than 4 pins.
In case of using Bipolar and L297, I read the datasheet of L297, but its quite ambiguous. My motor would be driving at less than 1A/ phase. So I should choose to use L293E rather than L298, though I dont find any reason why I should not be able to use L298? Please advise.
Next step is to make the connections.
I found a really useful connection here:
According to that circuit, my microcontroller should be sending a set of 1s and 0s with 5ms in between per step for one colour movement, and then, after 20 steps(meaning that it has eached the next colour), a delay(which could be 1second) is sent and then the 5ms clock pulse are sent again. To choose CW or CCW, this should be connected to a pin on the microcontroller to be set high or low according to the key pressed.
I have a few questions:
The wheel will have a small part cut out(an opto switch interrupter to sense the reset position) Once, the opto switch receives the signal from the emitter, it sends a HIGH to the microcontroller which should then make the motor stop. This is the RESET position of the motor.
Is there any way to make the motor, driver, translator 'remember' that reset position so that whenever a single colour change is desired, it goes back to the reset point and then the motor turns according to the number of times the key for 'next colour' is pressed. Please note that there should be two keys: one for next CW colour and one for next CCW colour.
One key should be making the motor turn at a specific speed per colour, its the speed the wheel changes from colour A to B, not from 1 step to the other. so basically, its the delay between every 20 step commands sent to the motor.
While the motor is moving,say CW, it moves step 1 to step 200 until the optoswitch sends a HIGH to the microcontroller. At this specific point, the motor must stop(all wires should be 0000) and then turn CCW until the optoswitch again sends a HIGH to the microcontroller where the motor then turns CW...this goes on continuously.
Please note that the optoswitch is primarily there for the RESET position so that a 'good' colour change takes place rather than a messed up effect.
If you have a suggestion to the movement of the wheel, you are warmly welcome to advise me please.

My main question:
Will this circuit above work according to my specifications? Any changes you may suggest? Im quite reluctant in choosing the driver, L293E or L298?
Lets say im going to use a 12V 2-phase Bipolar stepper with a 1.8 step angle with a rated current of 0.48A per phase.
So, for a delay of 1 second between colour:
The input to Clock should be, since it is 'Pulse Low to step', a low from the microcontroller will make the motor move 1 step:
0(5ms)1(5ms)0(5ms)1(5ms).....x 10, then (1 second high-stops the motor completely)0(5ms)1(5ms)0(5ms)1(5ms).....
This sequence goes on for 200 steps until the opto switch sends a HIGh.

Please advise on the softwre and circuit side of the motor movement?
I read about using the ULN2003 transistor arrays, but this would implement tougher programming, i presume. Whereas I just need these movements:
1.....Move from 1 colour to the other with 1 second delay, 0.5second delay, 0.1 second delay, 0.05 second delay, 0.01 second delay and then 5ms delay: these are basically the different speeds I will make the motor move, 1 second being slowest and 5ms being the fastest.
Here is the motor:

2.....After moving all 200 steps, move back in the opposite direction to reach back to the RESET point.

3.....If the 'RESET' key is pressed, the motor should move clockwise until the optoswitch sends a high to the microcontroller and then the motor stops.

4.....If the 'CW NEXT COLOUR' is pressed, the motor should move to the next clockwise colour.

5.....If the 'CCW NEXT COLOUR' is pressed, the motor should move to the next anticlockwise colour.

That is all I could find out that my colour wheel and motor would do, improvising for a hopefully small program..:-(

Please help me decide on the chips to be used because I need to order the motor, the L297 and the driver by today evening!

Thank you very much for your patience for reading such a long message.

Thank you very very much in advance for helpful.
 
Replies continue below

Recommended for you

zero replies?
:-((
please pity me and reply...
 
I hate those stupid translator chips. They make everything harder than it really has to be.

First problem: 0000 puts a stepper in an odd position. Similarly, powering it up moves it a little, a quarter step I think.

They're really not difficult to drive in software.
Full stepping requires sending one of four patterns to four outputs. Going to the next step requires sending the next adjacent pattern. The timing is determined by the timing of the output changes and nothing else.

So you need four outputs and one input to do what you want with only drivers external.

In assembler, your program should take a couple hundred bytes. Do it in small subroutines that just do one thing, and your top level program becomes a list of subroutine calls.

;----------
Don't worry about this yet...

Okay, I like to use six bits for output.
Four to low-side drivers on a 5V stepping motor, with two resistors on the high side to a 12V supply, and two PNPs to short the resistors for a few ms at the start of every step.

I might use higher value resistors to keep the motor voltage and steady state current down when the motor is going slow or is stopped.





Mike Halloran
Pembroke Pines, FL, USA
 
>2200 step/sec on a 2MHz 8080, nearly that on an 8741.

I had an 8741 that could turn a stepper direct driving a plug valve, 90 degrees in 50 ms, including ramped motion.

During development, I had >4 complete programs in an 8741's 1k eprom, including one that did a stupid search for how fast it could drive a given load (with an interrupter) without error.

I brought that board to a guy demoing a digital scope. In five minutes of trying, he couldn't sync to it, because the pulses changed width continuously for the ramp, and more for the search, and then some real craziness hunting around to measure the width of the interrupter slot to find the center.

It's actually amazing what variety of behaviors you can squeeze into 1k of program space.



Mike Halloran
Pembroke Pines, FL, USA
 
Va5h15t; Your proposal looks pretty good. I would go the route Mike suggests on your particular application. I'd only start looking at "stepper drivers" if I had a hard application like CNC machine tool positioning or some other maximum power situation.

I think otherwise you're on the right track. Just take one step at a time.

Keith Cress
kcress -
 
Thanks guys..
I am actually simulating the whole circuit with Proteus on a virtual pc, taking lots of resources...proteus didnt work on vista, so I had to go back to xp and use the software.
I will let you know the results and the software code for the 8051 that Im gonna actually download onto the processor.

Thank you very for the suggestion mike. Im not quite sure about the circuitry u r sayin, wud u kindly please, if tme allows u, send me a schematic or a link to the design or sumfin please. even if its handwritten, its fantastic for me.

thanks once again everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor