Shop OBEX P1 Docs P2 Docs Learn Events
PWM help — Parallax Forums

PWM help

eagletalontimeagletalontim Posts: 1,399
edited 2008-11-29 18:32 in General Discussion
I am working on a new project that controls 3 motors but I am having problems getting one of the motors to run at a certain speed until I need it to shut off. I was hoping to use the PWM command to start MotorA off at half speed and then activate the other motors at full speed while MotorA is still running at half speed. After a set time, MotorA will turn off. Any help would be appreciated!

Comments

  • BeanBean Posts: 8,129
    edited 2008-11-29 16:36
    So MotorA ONLY runs at half speed ???

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com

    ·
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-11-29 17:06
    The PWM instruction runs inline, which means its output stops when moving on to the next instruction (this command is best used for charging caps in DAC circuits) -- to keep motors running at a fixed speed you're going to need an interrupt-driven approach.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-11-29 18:18
    No, MotorA does not always run at half speed. Sometimes it is 1/4 sometimes 3/4 and so on depending on the PWM output. I need to be able to press a button connected to the chip and the code start MotorA at the predefined speed, then activate the other motors after MotorA has been activated. A delay will be set after all motors are on and when the delay is ended, MotorA will be turned off.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-11-29 18:32
    The attached framework should be helpful -- it will let you control the speed and direction of up to four motors. The PWM control is in the ISR so your foreground code can set and forget.
Sign In or Register to comment.