Shop OBEX P1 Docs P2 Docs Learn Events
PWMpal help timing control values — Parallax Forums

PWMpal help timing control values

gth629egth629e Posts: 40
edited 2009-03-02 02:15 in BASIC Stamp
Hello All,

I have a few questions that came to me while working with the PWMpal and a gecko stepper motor driver. Here is the link if interested (www .geckodrive.com/upload/G201-REV-16-MANUAL.pdf). I am currently using the PWMpal to create the desired step and direction pulses required by the stepper motor driver.

The manual dictates the "Step Pulse “0” Time" to be 0.5 uS min no max (Step on falling edge) and the "Step Pulse “1” Time 4 uS min no max. Since I am using the PWMpal the minimum on and off times would be set at 25 uS for the highest frequency of 20000 Hz.

So if I my understanding is correct, to set PWM channel 1 to 20000HZ with a duty cycle of 50 percent, I would use the following code. Of course other command's would proceed.

SEROUT 0, 6, [noparse][[/noparse]"!PWMM1", 1, 0, 1, 0]



and this:

SEROUT 0, 6, [noparse][[/noparse]"!PWMM1", 1, 0, 4, 0]



Would yield 8000 Hz with a duty cycle of 20 percent.


Questions: (please excuse my ignorance, I am still learning)

Why must you declare the low byte for the on and off intervals? Using this as a reference: Use: SEROUT 0, baud, [noparse][[/noparse]"!PWMMx", tOn.BYTE0, tOn.BYTE1, tOff.BYTE0, tOff.BYTE1].

Will the BYTE0 for the on and off intervals always be left as 0 in the code?

Because of the min intervals of 25 uS is there a way to achieve say 15000 Hz? Or is the closest thing going to be 13333.33...?

Lastly, I am pretty sure this can be done but I am unsure where to start. How would constantly change the frequency? Lets say for a ramping application. I realize this information is probably out there but if you could just point me in the right direction I can do the research on my own.


Thank you four your time all.

Regards,

Comments

  • gth629egth629e Posts: 40
    edited 2009-03-01 05:34
    Any takers? Too basic of a question?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-03-02 00:02
    I would think you can leave the off time at 1 unit and adjust the frequency with the on time . To ramp up put your PWM instruction in a loop and subtract a value that will give you a smooth ramp. Say to ramp from min to max you may have to start with 13000 - 1 and ramp up to 1-1. Right off I dont see anything to be gained in your situation by adjusting the off time.

    Jeff T.
  • gth629egth629e Posts: 40
    edited 2009-03-02 01:45
    Jeff,

    Thanks for the response. That is currently how I am experimenting with ramping. I did not know if there was an easier way. Why would you suggest stabilizing the off time vs the on time? Wouldn't this have the same overall effect? I am genuinely asking as I am unsure myself. I guess I can experiment and see.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-03-02 02:15
    Well it doesn't really matter whether its the on or off time thats adjusted the point was that the whole frequency range can be·covered by adjusting only one of the two word variables. It's easier to work with only one·as opposed to·two. Adding or subtracting from the word value is the easiest way I can think of to adjust frequency.

    Also one of the word values will have a value in the upper and lower bytes at times· (one of your previous questions)

    regards

    Jeff T.

    ·EDIT: I just had a thought, you are using two word variables for the on and off time aren't you? There would be a saving on variable space if you used only one word variable and made the second value (high.byte and low.byte)·a constant


    Post Edited (Unsoundcode) : 3/2/2009 2:29:12 AM GMT
Sign In or Register to comment.