Shop OBEX P1 Docs P2 Docs Learn Events
Continuous PWM output...no time left in program for other functions. — Parallax Forums

Continuous PWM output...no time left in program for other functions.

Hi,

I am trying to use feedback from a digital tachometer to influence the speed of a motor with the Basic Stamp's PWM command.
The process is a 26" bicycle wheel being driven by windshield wiper motor, geared to a rotational speed of about 10 minimum - 60 maximum RPMs. The digital tachometer is Hall effect based, and proximity with a magnet fixed to the wheel provides a high to low to high pulse, every 1 - 6 seconds based on the RPM. (Signal is normally high). I fed the signal line from the tachometer to I/O pin 0.

I feel that the best way to measure the RPM is to measure the time between pulses in ms with a COUNT, or the total pulse width when the tachometer signal goes low using PULSEIN...then apply a divider and send that variable quantity to a PWM output.

I don't see how I can perform either of those strategies without pausing the PWM output for long enough to cause an interruption in the rotational speed of the wheel. I basically have the Basic Stamp dedicated to PWM, while I somehow need to find time for the feedback signal to influence the output.

I appreciate any ideas. I do have access to other stamps, I am just not sure if adding stamps is the best solution

Thanks

Scott

Comments

  • ercoerco Posts: 20,256
    Wrong use of PWM IMO. You could bit bang PWM manually in calibrated loops with high/low commands, while monitoring your Hall effect sensor. Not easy but possible.
  • ElectrodudeElectrodude Posts: 1,648
    edited 2015-11-01 18:18
    If you need to do multiple things at once, you'd probably be better off with the multi-core Propeller. You could have one cog doing nothing but outputting PWM, and another doing nothing but measuring RPM.
  • s_ash wrote: »
    I appreciate any ideas.
    I do not think I would use a Bstamp for this but rather a closed loop of an RC network to measure the RPM and a 555 or 741 to produce a PWM to control the motor speed.


  • Your stamp is tied up too long waiting for the pulse counting to take place.

    Two possibilities:

    1. Watch the pulse input. While it is HIGH, jump to a loop that will update the PWM, then RETURN. Track how many times the PWM loop is called. When the pulse goes low, check how many times the PWM loop was called. Higher count means the speed is low.

    2. Get more pulses per revolution. Something high enough so at speed, you can just watch COUNT for a very short time then update the PWM loop.

    Tom Sisk

  • Hey, thank you for the responses. I found some luck with what stamptrol suggested. I sent the PWM command in 10ms bursts and added + 1 to a variable each time the command completed. That gave a general idea as to the number of ms between pulses.

  • It can be very difficult to do precise motor speed control in PBASIC. If you can tune your loop to run at the same speed (no matter what path it takes) you could handle the PWM with something like this:
      acc1 = acc1 + speed1                          ' update speed
      Motor1 = acc.BIT8                             ' carry bit to output
      acc1.BYTE1 = 0                                ' clear old carry
    

    As with the built-in PWM, the speed variable is 0..255 (byte). There's an old BS1 app note called "Fun With Trains" that illustrates this technique.
Sign In or Register to comment.