Professional Documents
Culture Documents
if your motor is rotating in clock wise direction then the corresponding code will be as follows.
leds are connected to PORT0 of AT89S52 so the logic will be
P0=0x81; delay( );//define this function as per your motor
P0=0x6f; delay( );
P0=0x6f; delay( );
P0=0x6f; delay( );
P0=0x81; delay( );
P0=0xff; delay( );// to make one column gap between letters
if it is anti clock wise then
same code in the reverse order
in this example im using the letter "A" which is symetrical
for other letters you need to follow from down to top of the code algorithm discussed above
P0=0xff;
P0=0x81; delay( );
P0=0x6f; delay( );
P0=0x6f; delay( );
P0=0x6f; delay( );
P0=0x81; delay( );
similarly for active high the following notation must be followed
but the question is how much delay we need to use after each and every colum
follow theses calculations..
DELAY CALCULATIONS
motor speed===1000 RPM
time for one rotation===60 milli seconds
radious =30cm
peremeter=2*3.414*30=204.84~205
width of led column=0.5cm ( this indicated the duration of led glow in terms of length of display)
total num of columns(leds)=205/0.5=410
410 leds=60 milli seconds
one led(column)time=146 micro seconds//
columns for each letter=6
time for a letter=6*146=876 micro seconds
length for letter=6*0.5=3
total leters=205/3=68
THE CALCULATIONS VARIES ACCORDING TO THE GLOW TIME OF LED AND RADIUS OF THE ROTATING ARM
motor speed===1000 RPM
time for one rotation===60 milli seconds
radius =30cm
peremeter=2*3.414*30=204.84~205
width of led column=1cm( this indicated the duration of led glow in terms of length of display)
total num of columns(leds)=205
205 leds=60 milli seconds
one led(column)time=292 micro seconds
columns for each letter=6
time for a letter=6*292=1752 micro seconds
length for letter=6
total leters=205/6=34
THESE ARE ROUGH CALCULATIONS BECAUSE THE MOTOR SPEED IS NOT ALWAYS CONSTANT
BUT THEY HELP IN APROXIMATING THE DELAY
// in this code i did not used lookup tables for reducing the complexity
// i just gave code logic for one letter'A' and sapace ' '
#include<avr/io.h>
#define F_CPU 8000000 // crystal frequency used in the circuit this helps in calibration of delay as per your frequency
//the delay function is ther as default in util package of winavr so use: _delay_us( );
void delay(void)
{
_delay_us(del);
_delay_us(del);
_delay_us(del);
_delay_us(del);
}
//remaining logic will be same for all microcontroller units
void display(unsigned char car);
void main()
{
while(1)
{
display('A'); // this displays a continious rotating"A A A A"
display(' ');
//try to change the del value as per your motor until you get a perfect
//display once you got it then write your code for remaining letters
//once you did this it will be very easy you can do your own fonts
//like "smily" ,"heart" etc
//but the main logic is to achieve perfect "delay".once if you refer to the
//delay calculations you will get it
//direction of rotation is also one important thing(clock wise or anti clock)
// this "A" is simetrical so works on both directions.
}
}
void display(car)
{
switch(car)
case 'A' : // letter A
{
led=0x81; delay( );
led=0x6f; delay( );
led=0x6f; delay( );
led=0x6f; delay( );
led=0x81; delay( );
led=0xff; delay( );// to make one column gap between letters
}
break;
case ' ' : // space
{
led=0xff; delay( );
led=0xff; delay( );
led=0xff; delay( );
led=0xff; delay( );
led=0xff; delay( );
led=0xff; delay( );
led=0xff; delay( );// to make one column gap between letters
} break;
default:
led=0xfe;
// gives an underline when no letter to display blue line in the code
}
// END of program
=======================================================================================
i m giving the example for understanding the logic of this project.you can extend the code by adding number of "switch cases" i made it for active low logic means
logic zero indicates led glowing and one indicates off.
with this technique you can make your own custom designs like "heart " "smile"
by changing the "del" variable value you can change the width of a letter.because no two motors are alike.
i prefer you to go for 1000 RPMmotor from vegarobokits. Which will be around 145 Rs
This propeller LED display can be made stable using an interrupt source. An IR sensor can be used to make it stable. Better to use a IR slot sensor as shown in
the picture it will be a faster compared to an LM358 based sensor. if your motor is faster than 1500 rpm then this sensor is the best.