Large amount of pwm
Reset_Vector
Posts: 55
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
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
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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?
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
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.
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.....
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)
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....
...could be reduced to use only 'Ch + 00' rather than 'Ch + 00' , 'Ch + 01' , 'Ch + 02' .... etc.
This alone would save 31 longs. Further....
... could all be reduced down to one line of code, saving a lot of resolution time...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
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)