Shop OBEX P1 Docs P2 Docs Learn Events
Large amount of pwm — Parallax Forums

Large amount of pwm

Reset_VectorReset_Vector Posts: 55
edited 2009-09-14 02:54 in Propeller 1
Hello from France !


Hi to alls,
For my project , a 8x8x8 RGB led cube, I need 192 bits in memory driven by PWM.
For the first tests, i've used the PWM Object by Beau Schwabe, it works fine but is limited to 32 bits, two layers in one color (16 leds) in my cube
I've tried to modify the PWM Object , but as the cog memory is limited to 512 longs, it's not possible to use it, impossible to reserve enough memory and
put the PWM code and the PWM datas in one Cog memory.
I'm trying to use the HUB memory to store the data, and one or more cogs to run the PWM code.

Any ideas ?


thanks

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-13 14:30
    Hello,

    as you have 512 x 3 = 1536 anodes to drive you need some kind of multiplexing anyway

    If you do the multiplexing by using shiftregisters
    so one solution could be to create the PWM in the multiplexing-hardware instead inside the prop
    this means you switch on/off the bits in the shiftregisters to create the PWM

    you just have to shiftout all the bits not only if a LED is switched on/off in general but all the time
    with the right duty-cycle accordng to the brightness

    with the pasm-commands "RDBYTE" "WRBYTE" you can read / write bytes from / to HUB-RAM
    so you have access to 32kB of ram

    best regards

    Stefan
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-09-13 14:48
    Hi Stephan
    I've made a mistake !
    My cube is 4x4x4 => 192 leds !
    I use multiplexing by using 3 Allegro UCN5818, each one driving 16 anodes, and each one affected to one color.
    But it's not possible to do the PWM by hardware as the cathodes are common by group of 16, so I can't PWM each cathode.
    The anodes (192) are driven by the shift registers and the cathodes are driven by an ULN 2803.
    The wole circuit works well without PWM, and I wonder if the acces times using the Hub will be fast enough.

    RV
  • SeariderSearider Posts: 290
    edited 2009-09-13 15:28
    Have you looked at the TI TLC5940 and TLC5941. The manage the PWM for you and can drive 16 LEDs each. A 4x4x 3 color matrix would use 3 chips. They are easy to interface to and there are a couple of drivers in the ObEx for the chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Searider
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-09-13 16:32
    Hi Searider

    I know this kind of chips, but I want to do the PWM by the Prop.
    Another workaround is to launch multiple cogs, each one driving 32 bits, so I need 6 cogs to drive the 192 bits.
    But it's difficult to synchronize all of them.
    I'm sure there is a simpler way to do it....

    BR

    Reset_Vector
  • TimmooreTimmoore Posts: 1,031
    edited 2009-09-13 17:17
    Since you are pwming lights you can relax the timing from pwm_32, e.g. you should be able to turn on/off the leds in a few ms and still get what you need.
    Can you put your full circuit up so we can understand it fully. Are the uln2803 connected to prop pins? i.e. 12 pins? and you are only using 1/2 of the uln5818?
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-13 18:36
    Hello,
    hm ok as your loginname is Reset_vektor this is the only name I can use

    you can do PWM with anodes or with kathodes it just would need a different circuit

    and to use famous words "Yes you can" create PWM with the shift-registers !

    imagine you want to switch on several LEDs you shift in "1" into the shiftregister
    if you want to switch it off you shift in a "0".

    Now imagine you want to blink the LED 2 seconds on, 2 seconds off
    no problem

    Now imagine you want to blink the LED 1 second on, 4 seconds off
    no problem

    Now imagine you want to blink the LED 0.1 second on, 0.8 seconds off
    no problem

    pwm does just the same at a higher speed
    for example 74HC595 have a switching time of 5 nanoseconds.
    So this should be fast enough to shift in bits at the maximum-speed that PASM can do
    and it should be still fast enough that you do not see the LEDs flicker

    best regards

    Stefan

    Post Edited (StefanL38) : 9/13/2009 6:41:53 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-09-13 19:10
    Take a look at how the PWM_32 PASM is structured. I'll give you a hint....

                  mov      temp,    Ch + 00                 ' Clear and initialize temp
                  or       temp,    Ch + 01                 '   OR the remaining 
                  or       temp,    Ch + 02                 '   channels into temp
                  .  
                  .  
                  .  
                  or       temp,    Ch + 29
                  or       temp,    Ch + 30
                  or       temp,    Ch + 31
                  mov      outa,    temp                    ' Move temp to the IOs
    
    



    Instead of loading outa with the result of temp, send the temp value directly out to an external shift register with a little bit of shiftout code. This object could be modified in that sense to handle 'several' LED's

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-09-13 19:34
    Hi Beau,
    I understand what you said, in my tests, I send the result of the PWM Pasm routine to a long in the HUB memory;
    After that the "Display cog" who drives the UCN chips use this long to shift it out to the UCN5818 drivers;
    As I said, this works fine, but When I try to expand the PWM asm routine to multiple longs (I nedd at least 12 longs for holding my 192 bits (I use only the lower word of each long)) the compiler tell me that there is not enough memory.
    If I count the number of long I'll need to do the PWM on 12 longs, i'm over the 496 longs in a cog memory.
    That's my problem.
    You use several longs to hold the counters and the necessary longs to do the Job and if I expand the PASM by duplicating the necessary longs, I'm out of memory.

    ''
    Defined PWM specific variables

    Mask long |<0,|<1,|<2,|<3,|<4,|<5,|<6,|<7
    long |<8,|<9,|<10,|<11,|<12,|<13
    long |<14,|<15,|<16,|<17,|<18,|<19
    long |<20,|<21,|<22,|<23,|<24,|<25
    long |<26,|<27,|<28,|<29,|<30,|<31





    t1 long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0





    ''
    This Block of memory needs to stay intact

    T_Off_Ch long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


    T_On__Ch long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0



    ''

    Ch long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


    in your code, you use 13 longs for 32 PWM bits
    I need 12 longs of PWM, so 12x13 = 156 longs
    + the place for the code etc... too short !!

    I'm thinking about how to modify your code to do the job ....





    Olivier (aka : Reset_Vector)


    Sorry for my poor English.....
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-09-13 19:41
    Sorry, i've made a mistake :
    You use about 200 longs only for the datas, + the code for the longs .
    I've not made the total, but I think that the Cog memory is not far to be full


    Olivier (aka : Reset_Vector)
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2009-09-13 20:38
    192 leds can be driven with 6 of TI TLC5924 chips arranged in a time-multiplexed circuit. Then your problem becomes a simple programming scheme that feeds the 5924's data inputs to bank switch the leds at 100Hz. If you're lazy, you could even dedicate a cog to each 5924.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-09-13 21:05
    Reset_Vector,

    Looking at it today, the PWM_32 PASM could be greatly simplified. However when I wrote it it made sense to do it the way I initially did. If I have some extra time during an LVS or DRC run, I'll see if I can improve the PWM_32 with the notes mentioned here.

    For example....

                  sub      t1 + 00, #1              wc
    Ch01    if_c  xor      Ch + 00, Mask     + 00   wz
      if_c_and_z  mov      t1 + 00, T_Off_Ch + 00
      if_c_and_nz mov      t1 + 00, T_On__Ch + 00
    '-------------------------------------------------------------   
                  sub      t1 + 01, #1              wc
    Ch02    if_c  xor      Ch + 01, Mask     + 01   wz
      if_c_and_z  mov      t1 + 01, T_Off_Ch + 01
      if_c_and_nz mov      t1 + 01, T_On__Ch + 01
    
    
    



    ...could be reduced to use only 'Ch + 00' rather than 'Ch + 00' , 'Ch + 01' , 'Ch + 02' .... etc.

    This alone would save 31 longs. Further....

                  mov      temp,    Ch + 00                 ' Clear and initialize temp
                  or       temp,    Ch + 01                 '   OR the remaining 
                  or       temp,    Ch + 02                 '   channels into temp
                  .  
                  .  
                  .  
                  or       temp,    Ch + 29
                  or       temp,    Ch + 30
                  or       temp,    Ch + 31
                  mov      outa,    temp                    ' Move temp to the IOs
    
    



    ... could all be reduced down to one line of code, saving a lot of resolution time...

                  mov      outa,    Ch + 00                 ' Move Ch to the IOs
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-09-14 02:54
    Yhank you Beau.

    I'll work in the same sense.I'll post my results if I get some !!

    Fred : It's more amazing to try to do it by software !!!


    For me it's 4:30 AM, time to go to work !

    Have a good day

    olivier (aka ResetVector)
Sign In or Register to comment.