Created Sun, 29 May 2011 11:48:38 +0000 by xgino
Sun, 29 May 2011 11:48:38 +0000
Hi all, just received a few UNO32 boards yesterday. On some websites it was stated that the uno32 had 28 digital I/O of which 28 should allow PWM, however I did find out that just 5 ports allow PWM on the received boards. Are these sites wrong, or are all ports able to generate PWM and is this just not implemented yet?
Sun, 29 May 2011 15:57:09 +0000
Where did you see that all 28 pins supported PWM?
I wrote the code and at the moment its only the 5.
Sun, 29 May 2011 17:47:57 +0000
Not on your own webpage but on a few sites reviewing you product: http://themakersworkbench.com/?q=node/421 & http://www.robot-r-us.com/arduino-controllers/chipkit-uno32-for-arduino.html
Mon, 30 May 2011 04:39:11 +0000
If you look at Microchip's page for the PIC32MX320F128L http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532439 you find: Output Compare/Std. PWM : 5
the PWM capable pins are referred to as OC1...OC5 in the PIC32 output compare module docs http://ww1.microchip.com/downloads/en/DeviceDoc/61111E.pdf
The pinout in the PIC32MX320F128H datasheet here http://ww1.microchip.com/downloads/en/DeviceDoc/61143H.pdf shows PWM pins OC1..OC5 are pin# 46, 49..52.
Mon, 30 May 2011 15:28:16 +0000
I got that number from the screen printing on the boards. If you look at this photo, the PWM / Digital label has a line indicating all pins on the top as such. I just noticed that PWM is underlined and that 5 of the pin numbers are as well. This was a mistake on my part and I apologize. Maybe this could be made more clear on future boards. I will make the changes to the post on my site right now. With only 5 PWM pins on each board, this is a letdown. My Arduino Mega has 16 PWM and the Uno has 6.
Mon, 30 May 2011 19:34:33 +0000
No problem, should have looked better myself too, and like the boards anyway.
Wed, 08 Jun 2011 07:45:00 +0000
If you guys need more outputs then you might consider software PWM. The chipKIT boards are certainly fast enough...
Wed, 08 Jun 2011 17:32:11 +0000
also, I believe the PIC32 architecture offers 2 sets of 32-bit registers, to make coding interrupt routines easier. This makes designing a timer interrupt PWM service routine even faster / more straightforward.
Wed, 08 Jun 2011 21:50:23 +0000
PWM for a full-range PWM, or for an R/C servo?
Seems a single level of hardware PWM (old PICs, at least) didn't really have sufficient range for R/C servo-type PWM.
How much resolution (1 mS?) will we get?
For the older 18F4620 family of PICs, I used two levels of interrupts, one for the "frame", and one to time out the individual pulse width of (one of 8) servos. (not hardware PWM).
I haven't had time to study the servo library, is it done with hardware?
Alan KM6VV P.S. I REALLY need a working servo library.
Wed, 08 Jun 2011 22:30:13 +0000
> How much resolution (1 mS?) will we get?
The PIC32 has 16 bit PWM registers (one even goes to 32 bit I think -- I have not used it that way, though). So if you're talking about a 50Hz servo pulse, then the "period register" would be set to 65535 for a period of 20ms, so you have the corresponding resolution in the "compare register", or about 0.3us.
In StickOS, the language units (centi-milliseconds) limit you to 10us (not sure why I did that -- now I have to fix it!), but I just verified this shows a 10us pulse and then a 20us pulse, both at 50Hz.
> servo 50 > dim x as pin rd0 for servo output > let x=1 > let x=2 > _
Thu, 09 Jun 2011 02:46:46 +0000
OOPS! I should have said uS.
StickOS? How about on the chipKIT? Can we drive R/C servos already?
OK, .3 uS isn't bad! What LIB is this implemented in?
Thu, 09 Jun 2011 03:40:00 +0000
> StickOS? How about on the chipKIT? Can we drive R/C servos already?
StickOS will be available in a few weeks for the chipKIT and Cerebot boards -- see http://www.cpustick.com/index.htm ... I'm waiting on my Max32 board still (Uno32 runs fine -- basically just a recompile and I'll probably change the pin names to match the silkscreen). It's only a day or two of work, but my day job gets in the way and stretches everything out... :-(
I'll probably change the StickOS servo pins to be specified in us rather than cms, too -- I can't believe I did that... But yes, you can drive servo outputs (as well as analog and frequency) already by just dimensioning a variable and assigning it a value... Analog inputs are just as easy, as, obviously, are digital inputs and outputs.
The nice thing about StickOS is you can interactively do everything logged right into the MCU -- examine/manipulate pins right from the command line, etc., and figure out how the HW needs to work. And it supports full interactive debugging -- even edit-and-continue and performance profiling... For a whirlwind tour of StickOS features, see the Quick Reference at: http://www.cpustick.com/downloads/quickref.v1.82.pdf
> OK, .3 uS isn't bad! What LIB is this implemented in?
I'm not sure what lib it is in, but you can write your own lib if you want -- you can access PIC32 registers right from the sketch, and if you want to see how to program PWM (as well as frequency output, analog output, etc.), you can see it for the PIC32 (and about a dozen other MCUs) in the StickOS skeleton source code project in the file sources/pin.c available at the bottom of the page here: http://www.cpustick.com/downloads.htm -- sorry, tons of #ifdef's there for the various MCUs...
-- Rich (email@example.com)
Thu, 09 Jun 2011 04:47:41 +0000
I looked at the StickOS skeleton source code, and pin.c. saw some good timer init stuff, might give me a start. But I suspect it will take a good bit of study to use code from the project.
I have been able to control 4 servos with relatively simple C code using interrupts and timers (PIC18), so after I get the PIC32 interrupts and timers working, I should be able to do the same. The best solution would obviously be a real servo library. (more study required).
Tue, 26 Jul 2011 15:40:54 +0000
The same mistake appear on the wiki description of the MAX32
Digital I/O 58 / 28 PWM
Please correct this. PIC32 architecture don't provide 28 PWM!
Sat, 13 Apr 2013 07:52:37 +0000
No it does not provide 28 PWM, BUT you can turn one PWM channel into 8 rc servo PWM fairly simply. It is vector assisted PWM.
You have the output of a PWM channel either set to trigger on interrupt, or run a physical line to a pin that does interrupt. Then when it triggers you tweak the PWM pulse width and set the corresponding out to low and set the next channel high.
If you space them at 2mS per channel you can get 8 of them in 16mS. So effectively you have 2mS of servo time with FULL resolution of the PWM per channel. So if the PWM channel is 16 bit or 32 bit that is the resolution of each rc servo channel. It is just multiplexing the output.
I am pretty sure the chipkit can do this as I originally developed this years ago on Rabbit processors. I call it "vector assisted pwm". I have since seen indication that other people have figured this out as well. I think they may have done this on the Arduino.
You just need to have a PWM module, an interrupt pin (preferably one assigned to the PWM module pin, otherwise you have to wire the two pins), and an interrupt routine to manage the 8 output pins. Also, if you don't want to use that many pins you can use 3, and get a 3 to 8 cmos/ttl chip and use that to multiplex the output. That way you can get creative and control a LOT of rc pwm outputs that way. Lets see, 3 x 5 PWM is 15 pins to control 40 rc PWM outputs potentially.