|
|
View previous topic :: View next topic |
Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
PWM |
Posted: Sat Jan 27, 2007 9:10 pm |
|
|
I want to use 3 channel PWM and when i the PWM on the first channel i want to start the second PWM on the second channel with no delay.My quenstion is ,if i can to write
set_adc_channel(0);
delay_ms(1);
adc_result=read_adc();
set_adc_channel(1);
delay_ms(1);
adc_result=read_adc();
set_adc_channel(2);
delay_ms(1);
adc_result=read_adc();
and after in the loop to write
set_pwm1_duty(adc_result);
set_pwm2_duty(adc_result);
set_pwm3_duty(adc_result); |
|
|
Ttelmah Guest
|
|
Posted: Sun Jan 28, 2007 3:35 am |
|
|
First, what chip?. Most do not have 3 PWM channels. You need something like the 18F6520, to give 3 'real' PWM channels.
Yes, of course you can take three readings, and then update the PWM units. Provided your source impedances for the ADC sources are in spec, you can almost certainly measure much faster than you show (typically 12uSec delay is all that is needed, and some of the chips with more PWM channels have the latter ADC, which only needs about 4uSec to acquire). Read the data sheet.
The PWM update, won't happen when you output the data. The PWMs will update at the end of the next pulse cycle. Basically when it resets at the end of a pulse, it reads the required width for the next pulse. They will therefore all update together on the next PWM clock (assuming they are all fed from the same timer module). This is in the data sheet again.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|