CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PWM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

PWM
PostPosted: Sat Jan 27, 2007 9:10 pm     Reply with quote

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







PostPosted: Sun Jan 28, 2007 3:35 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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