hardware-7 level
simulation -7 level
simulation -9 level
circuit (7 level)
WAVE FORMS
PROGRAM (COMPILER – MIKRO C)
//crystal of 16 MHz
#define s1 LATE.F0 //S1
#define s2 LATE.F1 //S2
#define s3 LATE.F2 //S3
#define s4 LATE.F3 //S4
#define s5 LATE.F4 //S3
#define s6 LATE.F5 //S4
#define s7 LATD.F0 //S4
#define s8 LATD.F1 //S4
void delay(void);
void zero_level(void) ;
void second_level(void);
void third_level(void);
void fourth_level(void);
void second_negative_level(void);
void third_negative_level(void);
void fourth_negative_level(void);
void off_all_switch(void);
void second_half_cycle(void);
void first_half_cycle(void);
void main()
{
TRISE.F0=0;TRISE.F1=0;TRISE.F2=0;TRISE.F3=0;
TRISE.F4=0;TRISE.F5=0; TRISD.F0=0; TRISD.F1=0;
off_all_switch();
while (1)
{
first_half_cycle();
second_half_cycle();
}
}
void first_half_cycle(void)
{
zero_level() ; off_all_switch();
second_level(); off_all_switch();
third_level(); off_all_switch();
fourth_level(); off_all_switch();
third_level(); off_all_switch();
second_level(); off_all_switch();
zero_level() ; off_all_switch();
}
void second_half_cycle(void)
{
zero_level() ; off_all_switch();
second_negative_level(); off_all_switch();
third_negative_level(); off_all_switch();
fourth_negative_level(); off_all_switch();
third_negative_level(); off_all_switch();
second_negative_level(); off_all_switch();
zero_level() ; off_all_switch();
}
void delay(void)
{
delay_us(1200);
}
void zero_level(void) //0v
{
s1=0;s2=0;s3=0;s4=0;
s5=0;s6=0;s7=0;s8=0;delay();
}
void second_level(void) //v1
{
s1=0;s2=1;s3=0;s4=1;
s5=1;s6=0;s7=0;s8=1;delay();
}
void third_level(void) //v2
{
s1=1;s2=0;s3=0;s4=1;
s5=0;s6=1;s7=0;s8=1;delay();
}
void fourth_level(void) //v1+v2
{
s1=1;s2=0;s3=0;s4=1;
s5=1;s6=0;s7=0;s8=1;delay(); delay();
}
void second_negative_level(void) //v1
{
s1=0;s2=1;s3=0;s4=1;
s5=0;s6=1;s7=1;s8=0;delay();
}
void third_negative_level(void) //v2
{
s1=0;s2=1;s3=1;s4=0;
s5=0;s6=1;s7=0;s8=1;delay();
}
void fourth_negative_level(void) //v1+v2
{
s1=0;s2=1;s3=1;s4=0;
s5=0;s6=1;s7=1;s8=0; delay(); delay();
}
void off_all_switch(void)
{
s1=0;s2=0;s3=0;s4=0;s5=0;s6=0;s7=0;s8=0;
}