What does the BAM_INFO report?
Are you using the Cylon example, or something you wrote?
What does the BAM_INFO report?
Are you using the Cylon example, or something you wrote?
DT
Unfortunately varying duty cycle incrementally does not produce linear changes in brightness.
I use brightness level correction in the form of a "gamma" array which contains a smaller set of duty cycle values, which produce linear changes in brightness, spanning the larger PWM duty cycle range. For example, the C program below for a 12F1822 uses the PWM module for a very smooth fading output with 64 brightness corrected levels using duty cycle values in the 64 element "gamma" array which span the 256 step PWM duty cycle range. Unfortunately, I'm not sure how you would implement something like this in PBP.
Good luck on your project... Cheerful regards, Mike
Code:#include <system.h> #pragma DATA _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_ON #pragma DATA _CONFIG2, _LVP_OFF & _PLLEN_OFF #pragma CLOCK_FREQ 8000000 // 8-MHz INTOSC #define r08 const rom unsigned char r08 gamma[] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 34, 36, 39, 42, 45, 49, 53, 57, 61, 65, 70, 75, 81, 87, 93,100, 107,114,123,131,140,150,161,172,183,196, 209,224,239,255 }; void main() { ansela = 0; // make pins digital trisa = 0b00000000; // porta all outputs porta = 0; // all output latches low osccon = 0b01110010; // initialize 8-MHz INTOSC while(!oscstat.HFIOFS); // wait until OSC stable ccp1con = 0b00001100; // pwm mode, p1a active hi ccpr1l = 0; // 0% duty cycle initially pr2 = 255; // t2con = 1<<TMR2ON; // pre 1, post 1, 7812.5 Hz while(1) // { static char duty = 32; // start at ~50% brightness while(duty < 63) // fade up to 100% { ccpr1l = gamma[duty++]; delay_ms(30); // over period of ~1 sec } // while(duty > 32) // fade down to ~50% { ccpr1l = gamma[duty--]; delay_ms(30); // over period of ~1 sec } // delay_ms(100); // pause at 50% brightness } // }
Here's another example using 64 brightness level steps on a 20 LED Charlieplexed matrix with 8-bit (256 level) BAM modulation. While only one LED is being faded in the video, all twenty LEDs could be faded at the same time.
Last edited by Mike, K8LH; - 27th July 2012 at 00:53.
It is something I am writing. I was assuming that the duty in the BIBAM routine was directly related to the brightness level so that a loop from 0 to 255 should be a smooth increase in brightness. All I am doing right now is fading colors up and down to smoothly blend colors together. I will play with it a bit more next week.
Thanks,
Jim
Bookmarks