hello,
i am calculating several values for time delay for input output port. From the coding below,i set two conditions which are if the x is even number, s=4500 and if x=odd, s =5000.There is no error when i'm run the code programming,but when i load it into pic simulation it doesn't show any result (the led isn't blinking).Besides, i also want to know how can i display the value of t1,t2,t3,t4,t5 in my simulation instead of using the lcd..anyone please help me and i am using PIC C compiler..thank you very much.
i am calculating several values for time delay for input output port. From the coding below,i set two conditions which are if the x is even number, s=4500 and if x=odd, s =5000.There is no error when i'm run the code programming,but when i load it into pic simulation it doesn't show any result (the led isn't blinking).Besides, i also want to know how can i display the value of t1,t2,t3,t4,t5 in my simulation instead of using the lcd..anyone please help me and i am using PIC C compiler..thank you very much.
Code:
#include <18F4550.h>
#fuses XT,NOWDT,NOLVP,NOPROTECT
#use delay (clock=4M)
#include <math.h>
#define LED1 PIN_B0
#define LED2 PIN_B1
#define LED3 PIN_B2
#define LED4 PIN_B3
#define LED5 PIN_B4
#define LED6 PIN_B5
unsigned int i,x;
int s,w,fm,Vm,dv,t0,t1,t2,t3,t4,t5;
void main()
{
set_tris_b(0x00);
output_b(0x00);
while(TRUE);
{
x=i%2;
if(x==0)
{
s=4500;
}
else if(x!=0)
{
s=5000;
}
dv=1;
Vm=10;
fm=30;
w=2*3.142*fm;
t0=0;
t1=t0+((2*dv)/(s+(((-1)^x)*(w)*(Vm)*(cos((w)*(t0))))));
t2=t1+((2*dv)/(s+(((-1)^x)*(w)*(Vm)*(cos((w)*(t1))))));
t3=t2+((2*dv)/(s+(((-1)^x)*(w)*(Vm)*(cos((w)*(t2))))));
t4=t3+((2*dv)/(s+(((-1)^x)*(w)*(Vm)*(cos((w)*(t3))))));
t5=t4+((2*dv)/(s+(((-1)^x)*(w)*(Vm)*(cos((w)*(t4))))));
output_high(PIN_B0);
delay_ms(t0);
output_low(PIN_B0);
delay_ms(t1);
output_high(PIN_B0);
delay_ms(t2);
output_low(PIN_B0);
delay_ms(t3);
output_high(PIN_B0);
delay_ms(t4);
output_low(PIN_B0);
delay_ms(t5);
output_high(PIN_B1);
delay_ms(t0);
output_low(PIN_B1);
delay_ms(t1);
output_high(PIN_B1);
delay_ms(t2);
output_low(PIN_B1);
delay_ms(t3);
output_high(PIN_B1);
delay_ms(t4);
output_low(PIN_B1);
delay_ms(t5);
output_high(PIN_B2);
delay_ms(t0);
output_low(PIN_B2);
delay_ms(t1);
output_high(PIN_B2);
delay_ms(t2);
output_low(PIN_B2);
delay_ms(t3);
output_high(PIN_B2);
delay_ms(t4);
output_low(PIN_B2);
delay_ms(t5);
output_high(PIN_B3);
delay_ms(t0);
output_low(PIN_B3);
delay_ms(t1);
output_high(PIN_B3);
delay_ms(t2);
output_low(PIN_B3);
delay_ms(t3);
output_high(PIN_B3);
delay_ms(t4);
output_low(PIN_B3);
delay_ms(t5);
output_high(PIN_B4);
delay_ms(t0);
output_low(PIN_B4);
delay_ms(t1);
output_high(PIN_B4);
delay_ms(t2);
output_low(PIN_B4);
delay_ms(t3);
output_high(PIN_B4);
delay_ms(t4);
output_low(PIN_B4);
delay_ms(t5);
output_high(PIN_B5);
delay_ms(t0);
output_low(PIN_B5);
delay_ms(t1);
output_high(PIN_B5);
delay_ms(t2);
output_low(PIN_B5);
delay_ms(t3);
output_high(PIN_B5);
delay_ms(t4);
output_low(PIN_B5);
delay_ms(t5);
}
}