Generating PWM Pulses

I’m thinking of using the Pololu High-Power Driver 36v9 for one of my projects. A Basic Stamp module will control this motor driver.
My question concerns the PWM signal. I don’t want to use the BS to generate these pulses, because that would occupy the BS to much. The PWM-PAL, as sold by Parallax, is too big for my application.
So my question is: Is there a simple and small solution to generate these PWM pulses?


I think the simplest solution might be for you to use one of our motor controllers rather than a motor driver. Specifically, the Simple Motor Controller 24v12 is similar to HPMD 36v9 (do you really need the higher voltage limit?). The benefit of going with the SMC is that it has an onboard microcontroller that generates the appropriate PWM signals in response to high-level inputs, like serial commands, which takes a lot of the burden off your Basic Stamp.

- Ben

Thank’s for your reply Ben. I’ve chosen the 36v9 motor driver because of it’s dimensions. The motor driver you mention would certainly be much easier, but I don’t have the space. The Basic Stamp is soldered on a separate board, about the same size as the 36v9. On this board there is still place to mount a PWM generator.

What voltage does your motor operate at, and do you know its stall current?

- Ben

The motor operates at 6V, the stall current is about 11A.

In that case, the more appropriate driver would probably be the High-Power Motor Driver 18v15 (it can deliver more current than the 36v9 and will generally run cooler, and you don’t need the 36v9’s higher maximum voltage limit).

Just out of curiosity, do you have to use the Basic Stamp as the main controller for your project? There are a number of more capable microcontroller boards out there that can generate hardware PWMs (using timer peripherals). If you are stuck with the Basic Stamp, maybe you can use a secondary microcontroller to take serial commands from your Basic Stamp and generate PWM signals in response. Our Baby Orangutan could be used for something like this, though it looks like that might be the same size as the PWMPAL.

- Ben

To choose the 18v15 sounds like a good thing to do, because it runs cooler. The motor in my application runs at 3-4A continoues and at 6A for 2-3 seconds. You think that the 18v15 still would be the better choice?

I can choose any microcontroller I want, the only problem is that I’m familiar with the Basic Stamp and Basic as programming language. I’m a bit reluctant to choose another microcontroller to have to learn a new programming language. I’ve been looking at Parallax’s Propeller, this chip should be able to generate PWM pulses, but also this one uses another programming language.

The option to use a secondary microcontroller sounds like a plan to me. Do you know of anybody who has done this before and is willing to share this information?

The only reason to go with the 36v9 version is if you need to use a higher voltage than the 18v15 and 24v12 versions can handle. The 18v15 can deliver a continuous 15 A, so that should be fine for your application if your motor really has a stall current of 11 A.

The Basic Stamp is fairly limited compared to a lot of the modern microcontroller boards out there, so this might be a good excuse for you to become familiar with something a bit more capable (and familiar with programming languages that are more widely used). The Arduino is a very approachable development platform for beginners, and there are a lot of existing code libraries and example programs out there to learn from (there is also a relatively large community of Arduino-users out there). The mbed development boards are also fairly easy to get started with. Our Orangutan controllers are not as beginner-friendly, and I wouldn’t recommend trying those until you are at least somewhat familiar with C (there are lots of online tutorials that can help you learn C, if that’s something you’re interested in). I have no personal experience using the Propeller, but it is much more powerful than the Basic Stamp and could be a good alternative for you.

If you still want to use a Basic Stamp with an auxiliary microcontroller, I don’t expect you will find a pre-written example that does exactly what you want, but the program wouldn’t be very complicated. If you took a stab at it and posted it here, we could give you some feedback. Alternatively, you could try asking for help on a forum specifically related to the auxiliary MCU you are using (e.g.,,,

- Ben

Thank’s for your reply Ben, this is very usefull information. It puts my mind in a higher gear, it has to, because electronics is not really my field of expertise.

The motor controller 18v15 sounds like the way to go.

I’ve been looking at your proposed controlers as an alternative for the Basic Stamp. The Baby Orangutan looks like a very good alternative. This is mainly because of the size, compared to the others. This controller fits right in the available space. Besides learning a new programming language, it raises a lot of new questions.

Can you explain a bit more about how this Baby Orangutan can generate the PWM pulses?

Besides controling the motor, this microcontroller has input from 3 force sensing resistors (FSR), 2 myo electrical sensors and controls on/of of a very small electromagnet.
A myo electrical sensor captures very small electrical currents of muscle-movement, the output is (as for FSR’s) an analog signal. When I used the Basic Stamp, I had to use an AD converter before I could use it in the BS.
I read that the Baby Orangutan has analog inputs, does this mean that I can connect the FSR’s and the myo sensors directly to the BO?
How about the magnet (5V, 0.71A), is it possible to connect it directly from the BO?
The motor has a 2 channel digital magnetic encoder, wich

Oops, here’s the rest…

which I use for keeping the speed of the motor to the desired speed when the load increases. How could I incorporate this in the BO?

One question leads to another…

Thank’s for helping me overcome my “fear” for a microprocessor of this age and forgive my ignorance…

- Jos

It probably doesn’t make sense to go into the details about this yet, but the gist is that the Baby Orangutan has three hardware timers (two are 8-bit and one is 16-bit). Both of the 8-bit timers are devoted to the built-in motor drivers; the 16-bit timer is free and can be used to generate two hardware PWM signals. The PWM frequency and duty cycles are controlled by timer registers, and the signal generation is performend entirely by the timer peripheral without burdening the processor. I could help you with the code for configuring the registers properly.

Yes, the Baby Orangutan’s microcontroller has a built-in ADC connected to eight analog input pins. We have a library available that makes the Orangutans a lot easier to use; these libraries let you read an analog voltage with a single function call.

The Baby Orangutan has an integrated dual motor driver that can deliver a continuous 1 A per channel. You should be able to use one channel to power your magnet. The output voltage of the driver is the same as the voltage you are using to power the Baby Orangutan, so you would probably want to power it at 5 V with something that can deliver as much current as your system requires. You would probably want to use our library’s motor functions to control the driver.

Is this an incremental quadrature encoder? If so, our library has functions for reading it; you can just connect the channels to digital inputs and the library will monitor the pulses and keep track of the position. If the signals are something different, you would need to write the code to read them.

I suggest you look into our AVR C/C++ library a bit to see if it seems like something you can handle. You don’t need to be able to follow the how the library source code works, but you should be able to follow our example programs using the library command reference. It also might be a good idea if you look through the Baby Orangutan user’s guide before you decide if this is the right solution for you.

- Ben

This sounds like the way to go for my project.
I will order the Baby Organgutan together with the programmer.
How can I get in contact with you again for help with the programming, can I just post it here?

Thanks for your help!!


Yes, you should just post your programming questions to the Orangutan sub-forum.

- Ben