View Full Version : PWMPAL for propeller chip

11-02-2010, 01:57 PM
The documentation for PWMPAL says

The PWMPAL is an intelligent peripheral that adds up to four PWM output channels and up to four
control/counter input channels to the 24-pin versions of the BASIC Stamp® microcontroller.

Has anyone used it with Propeller? If it is not straight forward, is there any hack?

I do not want to use my cog to generate PWM signals. This chip will work beautifully for me to generate PWM signals as well as interface a few. If ths chip wont work, is there an alternative?


Mike Green
11-02-2010, 02:15 PM
The Propeller can certainly do its own PWM generation with as much effort or less than you'll need to use the PWMPAL, but you can connect a PWMPAL to a Propeller if you want.

The PWMPAL is a 5V device, so it needs a source of 5V power (+5V on pin 21 (Vdd) and ground on pin 23 (Vss)). It also needs a bidirectional serial port. You get that by taking a 2.2K resistor and connecting it between the PWMPAL's pin 0 and whatever Propeller I/O pin you want to use. You can use either the Simple_Serial or the BS2_Functions object from the Propeller Object Exchange to send and receive information from the PWMPAL. I suggest BS2_Functions because it mirrors the BS2 statements that you'd use with a Basic Stamp.

If you change your mind, you can use the PWM_32_v2 object from the Object Exchange to generate as many as 32 PWM signals on the Propeller's I/O pins.

11-02-2010, 04:23 PM
That will be actually cool if I could generate pwm signals using PWM_32_v2 object but my concern is how much of an overhead it is gonig to be on the propeller if I want to use lets say 4 PWM outputs.

My other conern is that I want to save pins as well. So lets say I have two inputs and two outputs, PWM module is probably going to serve me better (althogh it will take some space).

Just another question, Can i interface PWM signal (input) with a counter inside propeller? How much of total overhead do you think it will be.

Again I am inclined towards PWMPAL if it can do the job cleanly. Otherwise the choice is really open.

Many thanks

11-02-2010, 04:43 PM
Perhaps you're missing the point that PWM_32 uses its own processor (cog), one of the eight available in the Propeller, hence no overhead is "felt" by your main process. There is no need to connect an external processor when you can use one that's on the same slab of silicon.

Note, too, that the serial connection to the PWMPAL could use another cog and this interface limits its resolution.

Mike Green
11-02-2010, 04:54 PM
Another thing to remember is that the Propeller is really fast, even if you just write your programs in Spin (which is interpreted). One cog of the Propeller is about 100 times faster than the BS2 and you've got 8 of them, all working at the same time. Code written in assembly language runs 20-40 times faster than that and you don't have to write your own stuff in assembly to get the advantage of it. The PWM object, for example, starts up a cog using assembly to do the actual work of generating the PWM signals and you end up calling routines that just communicate with that cog to tell it what to do.

11-02-2010, 05:05 PM
Well I am actually pretty much tight on cogs (I am using almost all of them) so I can not dedicate one cog just for PWM (unless I have too). So I think at this point PWMPAL is a better option for me. But I do like cleaner design, fewer chips, less routing, etc ...

Now if I can interface PWM's inputs in the same COG (PWM_32_v2), then probably I will be tempted to use a cog. I guess I have to explore.

11-02-2010, 05:21 PM
If I where running out of COGS or pins, I'd stick another Propeller on there. Use one or two COGS, and have a few left over for upgrades.

The PWMPAL is $30. vs $8 for the Propeller. Don't get me wrong, the PWMPAL is a great chip.

The max communications speed for the PWMPAL is 38K baud and is half-duplex, (one pin). Intercommunication speed between the Props is much faster and is full duplex.

The speed issues may not be a concern, but I thought I'd bring them up.


11-02-2010, 05:38 PM
The great news about the Propeller is that you can; you can't change the behavior of the PWMPAL. It might take a bit of work but you could create a custom PWM object that does exactly what you want.


Now if I can interface PWM's inputs in the same COG (PWM_32_v2), then probably I will be tempted to use a cog. I guess I have to explore.

11-02-2010, 05:47 PM
Introducing another Propeller instead of PWMPAL is certainly a great idea! Thanks for brinking up the speed conerns as well. This will be great for future upgrades.

I am actually novice with propeller but have good experience with FPGA's. It seems like propeller is as flexible as an FPGA chip. But I think I might be wrong a bit.