Shop OBEX P1 Docs P2 Docs Learn Events
PWMx8 object — Parallax Forums

PWMx8 object

JonathanJonathan Posts: 1,023
edited 2009-03-19 05:00 in Propeller 1
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 - Home of the Hydrogen Fuel Cell Robot

Comments

  • virtuPICvirtuPIC Posts: 193
    edited 2009-03-18 15:49
    Is any other cog running other software that could interfere with pin 13?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Airspace V - international hangar flying!
    www.airspace-v.com/ggadgets for tools & toys
  • JonathanJonathan Posts: 1,023
    edited 2009-03-18 16:16
    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 - Home of the Hydrogen Fuel Cell Robot
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-18 17:11
    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
  • JonathanJonathan Posts: 1,023
    edited 2009-03-18 21:53
    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 - Home of the Hydrogen Fuel Cell Robot
  • shanghai_foolshanghai_fool Posts: 149
    edited 2009-03-19 01:21
    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
    
    
  • JonathanJonathan Posts: 1,023
    edited 2009-03-19 05:00
    Shanghai,

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

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Sign In or Register to comment.