nasjournal.blogg.se

Ccs c compiler
Ccs c compiler






ccs c compiler

Setup_adc_ports(sAN0 | sAN1) // Configure AN0 & AN1 as analog input pins Setup_adc(ADC_CLOCK_INTERNAL) // ADC module uses its internal oscillator Setup_oscillator(OSC_8MHZ) // Set internal oscillator to 8MHz #fuses NOMCLR, NOBROWNOUT, NOLVP, INTRC_IO

Ccs c compiler code#

Control of 2 motors using PIC16F887 microcontroller CCS C code The PWM frequency can be calculated using the following equation: Timer2 module is configured to generate PWM signals of 1KHz with a resolution of 8.96 bits :ġ is Timer2 postoscaler (not used in calculations) The last interval is ] 523, 1023] where the motor speed is controlled in the other direction and the maximum speed when the analog value = 1023. The first interval is, here the motor stops. In the code there are three intervals after reading and saving the analog value. Each potentiometer controls speed and rotation direction of one motor. In this example we’ve two potentiometers POT1 and POT2 connected to AN0 and AN1. Two motors control using PIC16F887 and L293D CCS C code: In this example PIC16F887 uses its internal oscillator and MCLR pin function is disabled. The 12V power supply source depends on the motor nominal voltage, for example if the motor voltage is 5V, VCC2 pin should be connected to +5V source. The 5V supplies most of the circuit including the microcontroller whereas the 12V supplies one pin of the L293D (VCC2).

ccs c compiler

In the circuit there are two power supply sources, 5V and 12V. The same thing for motor 2 with pins PWM2, IN3 and IN4. If IN1 and IN2 are zeroes the motor stops, if IN1 = 1 and IN2 = 0 the motor rotates in the one direction, if IN1 = 0 and IN2 = 1 the motor rotates in the other direction. Motor 1 rotation speed is controlled by PWM1 and its direction of rotation is controlled by pins IN1 and IN2. The other L293D pins which are IN1, IN2, IN3 and IN4 are connected to RD0, RD1, RD2 and RD3 respectively. PWM1 pin (RC2) is connected to EN1,2 pin (#1) and PWM2 pin (RC1) is connected to EN2,3 pin (#9) of the L293D. Sponsored Links: Our C-Aware IDE provides embedded developers with a suite of tools and an intelligent code optimizing Microchip PIC C compiler. POT1 is connected to analog channel 0 (AN0) and POT2 is connected to analog channel 1 (AN1). In the circuit there are two potentiometers POT1 and POT2 which are used to control the speed as well as the direction of rotation of motor 1 and motor 2 respectively.








Ccs c compiler