Documente Academic
Documente Profesional
Documente Cultură
#include <avr/io.h>
#include <util/delay.h>
#include <string.h>
//////////////// variable
declarations////////////////////////////
The logic is to find out how many number of pulses should be applied to motor so that it can rotate till desire angle
value. So to do this, every time when user selects rotation angle, the number of pulses to be applied to motor is
found from the equation given below
Number of pulses = 4 × (new set angle value – previous set angle value) / 15
e.g. lets take previously set angle value was 45o and new set angle value is 75o. That means actually the motor has
to rotate for 30o. Putting values in above equation
If new set angle value is lesser than previous set angle value then subtraction will be reversed and motor also rotates
in reverse (CW) direction.
Software Program
Program is written in C language. It’s compiled and simulated using AVR studio software. Complete program is made
up of different functions.
display_value() function takes integer angle value as input. Convert its all digits into ASCII and displays it as angle
value on LCD
rotate_motor function rotates stepper motor CW or CCW as per entered angle value till motor reaches that angle
position.