Shop OBEX P1 Docs P2 Docs Learn Events
Any Stepper/Encoder experts? — Parallax Forums

Any Stepper/Encoder experts?

T ChapT Chap Posts: 4,217
edited 2006-07-02 20:41 in BASIC Stamp
I am designing a circuit to drive a stepper that will be run at low speeds at half steps(400). Because missing a step could be critical, I am thinking of using several products by USDigital. One is an encoder wthat will feed into their own Encoder To Counter Interface IC, which takes the Quadtradture signal on two wires, and outputs Direction and Step Clock output. The concept is to send a step pulse with Pulsout, then read the Encoder Interface Clock output back in on a pin via a SR latch that temporarily holds each output from the IC. That way, the Stamp sends a pulse, the motor moves, results in the encoder putting out a pulse to the interface IC, then the Latch stores the bit. The Stamp will read the bit from the encoder, and allow the next step to pulsout until the specific number of pulses is reached. If one clock does not return from the encoder, the motor stops, and in this case will reverse the motor, as it will be assumed it has been abstructed, and needs to go back to the limit switch at HOME and reset itself. I have never seen code for an encoder, and hoped that somebody may have an idea if this is a workable and reliable concept. The only thing that bugs me is if the EndcoderIn doesnt get back before it looks for the input, but pause times could account for it I suppose. Thanks for any opinions.

Here is a crude idea for programming:

MotorStep VAR OUT0
MotorDir VAR OUT1
Counter VAR WORD
PauseTime VAR NIB 'variable for time between pulses
EncoderIn VAR IN3
EncoderRst VAR OUT2
MotorStep = 1 'active low motor driver input
MotorDir = 0 'move ccw direction active high reset pin

Main:
FOR counter = 1 TO 10000 'move 10000 pulses
PULSOUT EncoderRst, pausetime 'reset encoder latch
PULSOUT MotorStep, PauseTime 'send one pulse out
IF EncoderIn = 0 THEN Problem 'check encoder latch to see if it moved, if not go to problem
NEXT

Problem: 'home motor and reset

Comments

  • BeanBean Posts: 8,129
    edited 2006-06-28 03:10
    Sounds overly complicated.

    You should be able to monitor the current of the motor to see if it is being blocked.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "I reject my reality, and substitute yours." NOT Mythbusters
    ·
  • T ChapT Chap Posts: 4,217
    edited 2006-06-28 03:58
    True, but I am using a PWM chopper on the stepper for current limiting, the shunt is constantly turning the mosfets on and off (20k), so there is no way to use a shunt method that I am aware of while using PWM.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-28 09:59
    originator -

    I may be way off base here, as I'm not sure what you mean by "shunt" above. However, the same current which runs through the + side of the circuit runs through the - side as well. Thus, if due to varying + inputs (as might be the case with a stepper), you can always monitor the - side of the circuit for current.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 6/28/2006 10:10:08 AM GMT
  • bennettdanbennettdan Posts: 614
    edited 2006-06-28 15:06
    The current from the driver curcuit to your stepper even though it is being chopped at 20k should look like a voltage drop across your shunt not a current drop you should be able to monitor the voltage drop which is liner to know when your motor stalls.
  • T ChapT Chap Posts: 4,217
    edited 2006-06-29 05:58
    After talking to US digital for a while yesterday and today, I am going with an encoder and an IC that translates Quadrature into clock and direction. Since there are only 3200 pulses to deal with in any direction for the app, I am looking for something like a 12 bit or 16bit up down counter with serial output that will keep track of the encoders position, and can be extracted at any time to compare output to actual motion.
  • kelvin jameskelvin james Posts: 531
    edited 2006-06-30 06:08
    Use the encoder for the positioning, and missed steps are of no concern. Also, over-rate the motor for the load.


    kelvin
  • T ChapT Chap Posts: 4,217
    edited 2006-06-30 06:17
    Kelvin Thanks for the reply, I am not sure what you mean by "no concern". I would be greatful if you could clarify that. I assume you mean it is easy to deal with in a case of missed steps.
  • kelvin jameskelvin james Posts: 531
    edited 2006-07-01 17:26
    An encoder on the motor shaft will always represent the true position of the shaft. You just treat it like other encoder / motor ( dc or servo ) feedback systems, the encoder controls the positioning of the motor. It is pretty basic, you count the pulses from the encoder to a certain value, and then tell the motor to stop. Even if the motor misses some steps along the way, it will keep going until the encoder ( shaft ) position is reached. But there are some issues to look at as far as operation goes, and mostly on the speed of processing. A stamp cannot handle reading an encoder and driving a motor at the same time. i don't know if you have a seperate stepper controller, but it would be necessary to function properly. The stamp could directly read the pulses from the encoder ( provided it is within the timing range of pulsin, otherwise pulses would be missed ), and the stamp would send operational commands to the motor controller. And the positioning accuracy will only be as good as the resolution of the encoder, so the idea is to try and match it to the motor. One other option is to look at the sx proto board, it should work without the need for a motor controller, and Jon W. has written an encoder input program for it. There are upsides and downsides to everything, you just have to do what you think is right for the application.

    kelvin

    Post Edited (kelvin james) : 7/1/2006 5:30:15 PM GMT
  • T ChapT Chap Posts: 4,217
    edited 2006-07-02 20:41
    Thanks Kelvin

    I am actually rewriting the Pbasic code to run on the Propeller. I needed to advance to a faster chip, and felt like going ahead with the Spin curve would be worth it in the long run. In the Propellers case, my first attempt is to use a cog to run the basic program for reading buttons, sensors etc, then control the motor driver from another cog, and have a thrid cog always counting and updating a variable that can be read by the main program. USdigital recommended on Friday that I use 1000 pulses (microstepping at 5 x 200) for stepping, and use a 400 resolution encoder. The encoder can output can be x1, x2, or x4, so I can actaully get a higher res (based on rising and falling clocks) off the encoders two tows of lines.

    Here is the IC I am using to translate quadreature to up/down counts on seperate pins:

    http://www.usdigital.com/products/ls7183-ls7184/

    I think it will take some trial and error, as I do want the motor to STOP if it misses a count, assuming that there is an obstruction andto avoid damaged. If there are too many false alarms and there really wasn't an obstruction, then maybe use some method of counting whereas if it misses x pulses, then STOP. Using your method of telling the motor to go, then counting till it gets there will have to be modified to what I prescribed above, which is similar.

    Thanks for the advice. I will try to find the Job W post right now, I think that would be very helpful.
Sign In or Register to comment.