Orangutan SVP-324 PWM Frequency

I am trying to use an Orangutan SVP-324 motor output to drive high-power MOSFETs, which power a R/C car motor. It works great at full speed, but the MOSFETs seem to be heating up quickly at intermediate speeds.

  1. What is the PWM frequency of the SVP-324 set_motors command?
  2. Is there some way to lower the PWM frequency to see if that helps?

Thanks,
Tracy

Hello, Tracy.

The motor functions in the Pololu AVR library produce a 10 kHz PWM frequency. It sounds like you are having shoot-through problems with your external H-bridge, so things should get better at a lower frequency (the shoot-through occurs at every PWM transition). You can modify the library code to decrease the PWM frequency.

However, it sounds weird to me that you are using the motor driver outputs as inputs to another motor driver. Can you tell me more about your external motor driver? What is the operating voltage of your SVP, and what is the operating voltage of your external motor driver.

- Ben

Ben,

I am a beginner when it comes to Orangutans and Atmel chips. If you could tell me precisely how to modify the library code for slower PWM frequency, I would really appreciate it.

As for the application, I am trying to use a 4X4 R/C truck as a robotic platform that I am working towards making a Robo-Magellan robot. The Orangutan SVP-324 was a prize in the 2010 Peoria, Ill. CIRC Bot Brawl (Thank you very much!). I am really happy with the Orangutan. The truck has a 540-sized motor rated at 7.2V and probably can pull 25 amps of current. Therefore, directly using the motor outputs of the Orangutan I have is out of the question. I have wired four 80-amp N-Channel MOSFETs (IRFP054N) in parallel to PWM the ground supply to the motor. M1outB is used to drive the gates of the MOSFETs. Since I need +10V to turn on the MOSFETs, the Orangutan is powered by a small 11.1V battery. The motors use a 7.2V battery. The second motor output is used to control direction of the main motor via an H-bridge made from two automotive relays. There are more elegant ways to achieve what I am doing, but I have a tight budget so I am trying to use what I have. :stuck_out_tongue:

Thanks,
Tracy

Well, it generally sounds like you know what you’re doing, though I’m still worried that your shoot-through problems might be a show-stopper, even at lower PWM frequencies. You really should have some dead-time between when you turn off one MOSFET and turn on another, and you aren’t going to get that from the SVP’s motor driver outputs. As an alternative, you could decrease the shoot-through if you can get your MOSFETs to turn on more slowly.

The SVP motor control code is located in the file:

libpololu-avr/src/OrangutanMotors/OrangutanMotors.cpp

and the relevant code is in the initialization method init2():

#ifdef _ORANGUTAN_SVP
	
    // Configure for non-inverted fast PWM output on motor PWM pins:   
    //  Normal port operation, OC2x disconnected (changes later when a non-zero speed is set)
    //  Timer2 counts up from 0 to 255 and then overflows directly to 0.
    TCCR2A = 0x03;
  
    // use the system clock/8 (=2.5 MHz) as the timer clock,
    // which will produce a PWM frequency of 10 kHz
    TCCR2B = 0x02;

If you want to understand these register settings better, you should look at the ATmega1284P datasheet.

The easiest way to change the PWM frequency is to change the prescaler of the timer that generates the PWM, which can be accomplished by changing the three lowest bits of the TCCR2B register. For example, if you set TCCR2B to 0x03, the prescaler changes from 8 to 32, and the PWM frequency is divided by 4 (2.5 kHz). The following list shows the approximate frequencies you can get for different TCCR2B values:

  • 0x01: 80 kHz
  • 0x02: 10 kHz
  • 0x03: 2.5 kHz
  • 0x04: 1.25 kHz
  • 0x05: 625 Hz
  • 0x06: 300 Hz
  • 0x07: 75 Hz

There are other ways to change the frequency, and you can achieve different frequencies from those listed above using those alternate methods, but I figure this is the simplest way to see if your problems go away, or at least become more manageable, at lower PWM frequencies.

While you could edit the library code directly and recompile it, I think the easiest way to try this out is to just overwrite the TCCR2B register after you get the OrangutanMotor code to initialize itself. You could do something like the following:

set_motors(0, 0);  // automatically initializes motor driver routines
TCCR2B = 0x06;  // change PWM frequency from 10 kHz to 300 Hz

// the rest of your code goes here

Does this make sense? Please let me know how this works for you.

- Ben

Ben,

Yes - that worked like a charm. I ran at 300 Hz at slow speeds for about 10 minutes and there is just the slightest hint of warmth. In the past it was getting alarmingly warm, even with the wheels freely spinning. I can live with a little buzz if it keeps the magic smoke away. :slight_smile:

Thank you very much,
-Tracy