It seems I made a bit of a mistake in how I thought the dsPIC could drive its PWM module. Consequently, there will have to be some changes.First, what can’t change is the need to use T1CK and T2CK as external inputs to count motor pulses. There are no other choices on the dsPIC30F4011 without using interrupts. Since I anticipate pulse rates of up to 100,000 Hz per wheel, life will be a lot easier not having to service that interrupt rate, even with a fast processor and a very efficient ISR.
Somehow, I had it in my head that the PWM module could use different time bases for each channel. Wrong – and stupid. So, how to produce two independant pulse trains at frequencies from about 500Hz to 125kHz?Well, the dsPIC has a set of Output compare modules. These are quite capable of the job and have a variety of useful modes. Each can use one of two 16 bit timers for its timebase. At first sight, it would be best to use the OC modules for both motors and have each derived from a separate timer. Unfortunately, the two timers we can pick form are Timer2 and Timer3. But we have already committed Timer2 to the pulse counting job. That means that only one OC module can be used and it must be driven from a timebase using Timer 3.This all makes things a bit tacky. The pin assignments are now a little more confusing and earlier posts will need to be edited along with theschematics and such. Hopefully this will be done by the time anyone gets to read this post. Apologies if anyone has done any work based on the errors.

This Post Has One Comment

  1. Alan

    Peter,

    Why do you need two time bases? the way I read it (33F, anyway), the time base is the same for both motor channels, only the PWM changes. Maybe it’s different on the 30F?

    I will get two channels of encoder inputs, which will be nice. I might just try to cram it all into one 33F PIC (maze/nav/sensors and motor control) if I can come up with enough pins.

    Alan KM6VV

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.