Sunday, March 21, 2010
Monday, March 8, 2010
PWM speed control (pic18f4550)
here is the ccs code:
#include <18f4550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock = 20000000)
void main() {
unsigned int16 value;// Input variable
setup_adc_ports(ALL_ANALOG);// Input combination
setup_adc(adc_clock_internal);// ADC clock
set_adc_channel(0);// Select RA0
setup_ccp1(ccp_pwm); // Select timer and mode
setup_timer_2(T2_DIV_BY_16,248,1); // Clock rate & output period
while(1) {
value=read_adc();//Get input byte
set_pwm1_duty(value);// Set on time
}
}
everything is exactly same as previous post + a simple potentiometer which is connected to pin2.
here is the execution:
#include <18f4550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock = 20000000)
void main() {
unsigned int16 value;// Input variable
setup_adc_ports(ALL_ANALOG);// Input combination
setup_adc(adc_clock_internal);// ADC clock
set_adc_channel(0);// Select RA0
setup_ccp1(ccp_pwm); // Select timer and mode
setup_timer_2(T2_DIV_BY_16,248,1); // Clock rate & output period
while(1) {
value=read_adc();//Get input byte
set_pwm1_duty(value);// Set on time
}
}
everything is exactly same as previous post + a simple potentiometer which is connected to pin2.
here is the execution:
Driving a motor (pic18f4550)
you can use the information mentioned in previous post as the pic side program to increase or decrease the speed of a motor as an example. now I want to use ULN2003APG driver to drive a motor.
using ULN2003APG :
pin1 ---> MCU output
pin16 ---> Motor
pin8 ---> Motor GND and MCU GND
and connect vcc to the motor.we use mcu signal to connect gnd to the motor to run with separate vcc but common gnd.

using ULN2003APG :
pin1 ---> MCU output
pin16 ---> Motor
pin8 ---> Motor GND and MCU GND
and connect vcc to the motor.we use mcu signal to connect gnd to the motor to run with separate vcc but common gnd.

Subscribe to:
Posts (Atom)