how to compare to analog signal.... pic184f331

Status
Not open for further replies.

chinusneha

New Member
hi friends ,

i want to compare to analog dc signal & want 2 change the duty cycle of PWM according to the error signal... how can i do that??

if someone having C code... plz help me....
 
You setup the A/D, run the conversion, get the numbers out of ADRESH & L, scale them with a multiply instruction, offset them them with an add or subtract, then load them into the PWM registers.

Usually. If a linear relationship won't do it, you may have to write a big lookup table. If the whole thing needs to be a PID loop, that's even more fun. Start with the basic linear function, though.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…