Shop OBEX P1 Docs P2 Docs Learn Events
SX speed control — Parallax Forums

SX speed control

Daniel M.Daniel M. Posts: 14
edited 2006-07-20 20:50 in General Discussion
I am currently attempting to build speed controls for the drive motors on my competition robot for school. The motors themselves are running off of 9.6v at about 2 amps. My first idea was to use a few variable voltage regulators and digital potentiometers (to control the regulators). I have been looking at digital potentiometers and have yet to understand how one with "SPI" works and how to use it. I'd appreciate any kind of help with that, and also if there are any better ways to design a custom speed control. Thanks!
Daniel

Comments

  • BeanBean Posts: 8,129
    edited 2006-07-18 01:56
    Daniel,
    That method would be very ineffecient.
    You want to use PWM to control the speed of the motors.
    Of course you will need a high power transistor or FET to interface to the motors.
    Note that the PWM commands in SX/B are meant for generate analog voltages and not for controlling motors.

    Basically instead of lowering the voltage you use full voltage but turn the motor on and off very quickly.
    You control the speed by altering the duty cycle (percentage of on-time to off-time).

    Bean.

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

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • Daniel M.Daniel M. Posts: 14
    edited 2006-07-18 16:56
    Oh, ok. I understand what you mean, however I am confused as to which transistor or FET to use. Do you have any specific recommendations? Thanks.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-07-18 19:52
    Some of the new FETs are specifically designed for digital logic to drive them on or off.· The have an L in their ID.· I think there is an IRL520 Power Fet that would make a nice power switch.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 7/18/2006 8:00:31 PM GMT
  • John R.John R. Posts: 1,376
    edited 2006-07-18 20:09
    Bean (Hitt Consulting) said...
    Daniel,
    That method would be very ineffecient.
    You want to use PWM to control the speed of the motors.
    Of course you will need a high power transistor or FET to interface to the motors.
    Note that the PWM commands in SX/B are meant for generate analog voltages and not for controlling motors.

    Basically instead of lowering the voltage you use full voltage but turn the motor on and off very quickly.
    You control the speed by altering the duty cycle (percentage of on-time to off-time).

    Bean.

    From other threads, including the PWM/Servo controller in the Projects Forum, I thought that PWM from the SX was good for motors, but that the PWM from a Stamp had "issues" with random pulses.

    Does PWM from the SX require assembly to get a series of pulses appropriate for Motor Control?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • BeanBean Posts: 8,129
    edited 2006-07-18 20:49
    John,
    The method SX/B uses is the same as the method the stamps uses. It works better for generating analog voltages, because the pulses are spread-out more.
    But DC motors "like" a longer on and off time.
    Assembly is not required, but if you want to control multiple motors then the assembly will be more effecient.
    Of course it depends on the PWM rate you want. For slower rates, assembly may not be required for multiple motors.

    Usually 8-bit PWM is used, that means that the interrupt would need to be called 256 times for one PWM cycle.
    So if the interrupt was called 100,000 times a second, the PWM rate would be 100,000/256 = 390Hz
    Now if you were running the SX at 50MHz that would allow just less than 500 instructions in the interrupt.

    If you interested I will whip-up an example...

    Bean.

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

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • John R.John R. Posts: 1,376
    edited 2006-07-18 21:03
    Bean;

    Thanks for the feedback. While I'm interested in taking you up on your example, let me look over at the PWM/Servo controller, and see if I can learn from that. I don't just want a sample "done" for me, I want to learn what's happening. In this case, you've given me a clue, using the interrupt clock. Thus far, I have not been using that much, I've been more of a "looper", putting a "pause" at the end of the loop, and adjusting the length based on what I see on the 'scope.

    While I'm proficient at "Business" programming (ERP Systems), I am only starting to catch on to this uProcessor stuff. It's kind of fun learning something new. I'm currently working on a different project using a servo(s), but have some PWM motor control comming up on another project I'm starting to do some mock ups on.

    I hope you enjoyed the beach!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • BeanBean Posts: 8,129
    edited 2006-07-18 22:26
    Okay,
    I'll just give you a quick overview...
    Basically you use a byte variable as a counter that gets incremented each interrupt. (And of course rolls-over).
    Then you just compare the PWM value to the counter. If the PWM value > counter then turn the output on, otherwise turn the output off.
    That's it...

    Bean.

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

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • John R.John R. Posts: 1,376
    edited 2006-07-19 14:58
    Great Pointer Bean, that will get me going!

    Thank you very much.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • Daniel M.Daniel M. Posts: 14
    edited 2006-07-20 19:38
    ok, I've been working on a program to use the PWM command, however I can't find a way for the SX chip to check for a new speed across a serial connection without interrupting the PWM long enough such that it makes a visible change in the motor. Is there a way to speed up a serial connection such that it times out much faster than 1ms? or is there a way to sustain the PWM in the background while the chip checks for a new signal? thanks
  • BeanBean Posts: 8,129
    edited 2006-07-20 20:35
    Daniel,
    You would have to perform either the PWM or the serial (or both) in an interrupt routine.
    The PWM would be easier to do in an interrupt.
    And I DON'T mean to just put the PWM command in the interrupt routine.

    Bean.

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

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • Daniel M.Daniel M. Posts: 14
    edited 2006-07-20 20:50
    hmm, right now i have...

    do
    PWM ra.0, signal_out, 100
    SERIN RB.0, N2400, data_in, 1
    loop while data_in = 0

    such that the PWM is the same until another signal is received. Do I have the SERIN timeout mixed up or something? Also, is there an example of what you mean by putting the PWM in an interrupt routine?
Sign In or Register to comment.