oday_albadarneh
Newbie level 6
- Joined
- Dec 20, 2011
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,380
Have you checked whether the baud rates for the both are same?
Is there is any Software invert in the PIC or the PC?
Did you try the loop test to check the cable?
I have had some problems like this but it was mostly due to some incorrect software settings.
I hope you have time to try all of these out!!
What is the devices oscillator frequency?
What BAUD rate are you attempting to utilize?
Not all BAUD rates are viable for a give oscillator frequency.
BigDog
// variables
float vc1,vc2,vc3,beta;
char vc1_txt[15],vc2_txt[15],vc3_txt[15],beta_txt[15],adder_txt[15],subber_txt[15];
int check;
char uart_rd,adder,lock,add1,add2,subber,receive;
void calculate_beta ()
{
beta = ((5 - vc1)* 1000000) / ((5-.7)*3700 ) ;
FloatToStr(beta,beta_txt);
UART1_Write_Text("Beta = ");
UART1_Write_Text(beta_txt);
Uart1_Write(13);
Uart1_Write(10);
Delay_ms (2000);
}
void Calculate_vc1()
{
vc1 = ADC_Read(0);
vc1 = 0.004887585533*vc1;
FloatToStr(vc1,vc1_txt);
if (vc1 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc1 > 0.2 && vc1 < 4.85 )
UART1_Write_Text("Forward");
else if (vc1 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void Calculate_vc2()
{
vc2 = ADC_Read(1);
vc2 = 0.004887585533*vc2;
FloatToStr(vc2,vc2_txt);
if (vc2 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc2 > 0.2 && vc2 < 4.85 )
UART1_Write_Text("Forward");
else if (vc2 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void Calculate_vc3()
{
vc3 = ADC_Read(2);
vc3 = 0.004887585533*vc3;
FloatToStr(vc3,vc3_txt);
if (vc3 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc3 > 0.2 && vc3 < 4.85 )
UART1_Write_Text("Forward");
else if (vc3 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void lock_check ()
{
PORTD = lock & 0x0F ;
delay_ms (1500) ;
check = PORTD.F4 ;
if (check == 1)
UART1_Write_Text("NO GO");
else if (check == 0)
UART1_Write_Text("GO");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void full_adder (char a , char b)
{
PORTB = ( a & 0x0F )+ ( b & 0xF0 );
adder = PORTC ;
adder = adder & 0x1F;
ByteToStr(adder,adder_txt);
Uart1_Write_Text(adder_txt);
Uart1_Write(13);
Uart1_Write(10);
delay_ms (2000);
}
void full_subber (char c , char d)
{
PORTB = ( c & 0x0F )+ ( d & 0xF0 );
subber = PORTC ;
subber = subber & 0x1F;
ByteToStr(subber,subber_txt);
Uart1_Write_Text(subber_txt);
Uart1_Write(13);
Uart1_Write(10);
delay_ms (2000);
}
void main() {
ADRESL = 0x0F;
ADRESH = 0;
TRISA = 0xFF;
TRISB = 0;
TRISC = 0x1F;
//TRISD = 0xF0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start\r\n");
add1 = 0b00001111;
add2 = 0b10101111;
while (1) {
do {
if (UART1_Data_Ready())
lock = UART1_Read();
calculate_beta();
Delay_ms(500);
Calculate_vc1();
Delay_ms(500);
Calculate_vc2();
Delay_ms(500);
Calculate_vc3();
Delay_ms(500);
lock_check();
Delay_ms(500);
full_adder (add1 , add2);
Delay_ms(500);
full_subber (add1 , add2);
Delay_ms(500);
}
while(1);
}
// variables
float vc1,vc2,vc3,beta;
char vc1_txt[15],vc2_txt[15],vc3_txt[15],beta_txt[15],adder_txt[15],subber_txt[15];
int check;
char uart_rd,adder,lock,add1,add2,subber,receive;
void calculate_beta ()
{
beta = ((5 - vc1)* 1000000) / ((5-.7)*3700 ) ;
FloatToStr(beta,beta_txt);
UART1_Write_Text("Beta = ");
UART1_Write_Text(beta_txt);
Uart1_Write(13);
Uart1_Write(10);
Delay_ms (2000);
}
void Calculate_vc1()
{
vc1 = ADC_Read(0);
vc1 = 0.004887585533*vc1;
FloatToStr(vc1,vc1_txt);
if (vc1 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc1 > 0.2 && vc1 < 4.85 )
UART1_Write_Text("Forward");
else if (vc1 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void Calculate_vc2()
{
vc2 = ADC_Read(1);
vc2 = 0.004887585533*vc2;
FloatToStr(vc2,vc2_txt);
if (vc2 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc2 > 0.2 && vc2 < 4.85 )
UART1_Write_Text("Forward");
else if (vc2 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void Calculate_vc3()
{
vc3 = ADC_Read(2);
vc3 = 0.004887585533*vc3;
FloatToStr(vc3,vc3_txt);
if (vc3 <= 0.2 )
UART1_Write_Text("Saturated");
else if (vc3 > 0.2 && vc3 < 4.85 )
UART1_Write_Text("Forward");
else if (vc3 > 4.85)
UART1_Write_Text("Cut-Off");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void lock_check ()
{
PORTD = lock & 0x0F ;
delay_ms (1500) ;
check = PORTD.F4 ;
if (check == 1)
UART1_Write_Text("NO GO");
else if (check == 0)
UART1_Write_Text("GO");
Uart1_Write(13);
Uart1_Write(10);
delay_ms(2000);
}
void full_adder (char a , char b)
{
PORTB = ( a & 0x0F )+ ( b & 0xF0 );
adder = PORTC ;
adder = adder & 0x1F;
ByteToStr(adder,adder_txt);
Uart1_Write_Text(adder_txt);
Uart1_Write(13);
Uart1_Write(10);
delay_ms (2000);
}
void full_subber (char c , char d)
{
PORTB = ( c & 0x0F )+ ( d & 0xF0 );
subber = PORTC ;
subber = subber & 0x1F;
ByteToStr(subber,subber_txt);
Uart1_Write_Text(subber_txt);
Uart1_Write(13);
Uart1_Write(10);
delay_ms (2000);
}
void main() {
ADRESL = 0x00;
ADRESH = 0x00;
TRISA = 0xFF;
TRISB = 0x00;
TRISC = 0x9F;
CMCON = 0x07;
ADCON1 = 0b10001001;
CVRCON.CVROE = 0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start\r\n");
add1 = 0b00001111;
add2 = 0b10101111;
while (1) {
if (UART1_Data_Ready())
lock = UART1_Read();
calculate_beta();
Delay_ms(500);
Calculate_vc1();
Delay_ms(500);
Calculate_vc2();
Delay_ms(500);
Calculate_vc3();
Delay_ms(500);
lock_check();
Delay_ms(500);
full_adder (add1 , add2);
Delay_ms(500);
full_subber (add1 , add2);
Delay_ms(500);
}
}
char uart_rd;
void main() {
ANSEL = 0; // Configure AN pins as digital
ANSELH = 0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?