PDA

View Full Version : PWMx8 object



Jonathan
03-18-2009, 10:13 PM
Hi All,

I am having trouble getting the PWMx8 object to work on pin 13. It seems to have something to do with which pin I am trying to use. If I set the base_pin to 0, I can get PWM out of any pin 0-7. However, if I try to set the based_pin to 8 and get PWM out of 8-15, no joy. Here is the snip. It works fine 0-7, but nothing out of 8-15. The pins are all fine, I can manually twiddle them. The snip below should PWM all of the pins in the bank. For just pin 13 the pin select byte would be %0010_0000



CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000


base_pin = 8

VAR


byte duty


OBJ


pwm : "PWMx8"


PUB init
freq := 300
duty := 128
pwm.start(base_pin, %1111_1111,freq)
pwm.duty(base_pin,duty)
repeat
Any ideas what I am doing wrong?

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot

virtuPIC
03-18-2009, 10:49 PM
Is any other cog running other software that could interfere with pin 13?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets (http://www.airspace-v.com/ggadgets) for tools & toys

Jonathan
03-18-2009, 11:16 PM
Nope, the is the code, the whole code, and nothing but the code. Oh, except that I forgot to declare freq as a long above, which it is in the real code. I just triple checked.

Thanks!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot

Phil Pilgrim (PhiPi)
03-19-2009, 12:11 AM
Jonathan,

Are you using version 1.1 (17 Jul 08) of pwmx8? It fixed some issues related to base pins > 0. The demo program that comes with it uses a base pin of 16.

-Phil

Jonathan
03-19-2009, 04:53 AM
Phil,

Yes, I am using the latest version. I went ahead and DL'd again just in case, but no luck.

Can anyone try out the code above to make sure it is something I am doing?

Thanks!

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot

shanghai_fool
03-19-2009, 08:21 AM
Jonathan said...
Hi All,

I am having trouble getting the PWMx8 object to work on pin 13. It seems to have something to do with which pin I am trying to use. If I set the base_pin to 0, I can get PWM out of any pin 0-7. However, if I try to set the based_pin to 8 and get PWM out of 8-15, no joy. Here is the snip. It works fine 0-7, but nothing out of 8-15. The pins are all fine, I can manually twiddle them. The snip below should PWM all of the pins in the bank. For just pin 13 the pin select byte would be %0010_0000


You are only assigning duty cycle to 1 pin. It worked using these mods


CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
base_pin = 8

VAR
byte duty
long freq
OBJ
pwm : "PWMx8"
PUB init | i
freq := 300
duty := 128
pwm.start(base_pin, %1111_1111,freq)
repeat i from 0 to 7
pwm.duty(base_pin + i,duty)
repeat

Jonathan
03-19-2009, 12:00 PM
Shanghai,

Bingo! Thanks for the help! Much appreciated. Now I can dim the nixie tubes in my clock. :)

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot