gojkosisa
Junior Member level 3
Hello,
I have some electronic device for process monitoring which is connected to PC via UART. This device use PIC16F887 microcontroller and send all information about process ( sensors reading ) to PC and software display it on PC. Now I want to build another device which I'll use instead of PC. Main hardware parts are 128x64 GLCD and PIC18F4620. My idea is to connect 2 PICs with UART and instead of displaying information on PC I will display it on GLCD. I build the hardware and it works very well but I have problems with programming. To find what kind of data that device send I connected it to terminal and simulate different sensors reading. Here are information from terminal:
Received: 100
Received: 5
Received: 101
Received: 9
.........
This information I receive every 5 seconds. And I found that 100 is signal for pressure sensor and 5 is value, and 101 is temperature sensor and 9 is value. I'm using mikroC and this is my code for receiving data from UART:
This is working but when I press OFF button I receive data in this format:
Received: 100 5 150 10 160 50 131 20 101
Received: 9
Received: 105
Received: 9
or if alarm is activated like this:
Received: 100 5 120 16 149 55 121 20 198 34 109 2 100
Received: 9
Received: 105
Received: 9
I have issues as I loose some data because UART1_read() return only one byte. I try to receive data and put it in array but still doesn't working.
I have some electronic device for process monitoring which is connected to PC via UART. This device use PIC16F887 microcontroller and send all information about process ( sensors reading ) to PC and software display it on PC. Now I want to build another device which I'll use instead of PC. Main hardware parts are 128x64 GLCD and PIC18F4620. My idea is to connect 2 PICs with UART and instead of displaying information on PC I will display it on GLCD. I build the hardware and it works very well but I have problems with programming. To find what kind of data that device send I connected it to terminal and simulate different sensors reading. Here are information from terminal:
Received: 100
Received: 5
Received: 101
Received: 9
.........
This information I receive every 5 seconds. And I found that 100 is signal for pressure sensor and 5 is value, and 101 is temperature sensor and 9 is value. I'm using mikroC and this is my code for receiving data from UART:
Code:
void interrupt ()
{
if (PIR1.RCIF)
{
rxchar = UART1_Read();
}
}
//main
if (flag ==1)
{
uart_rd=rxchar;
if(old_uart==100)
{
Display uart_rd on display (pressure)
}
if(old_uart==101)
{
Display uart_rd on display (temperature)
}
old_uart=uart_rd;
flag = 0;
}
Received: 100 5 150 10 160 50 131 20 101
Received: 9
Received: 105
Received: 9
or if alarm is activated like this:
Received: 100 5 120 16 149 55 121 20 198 34 109 2 100
Received: 9
Received: 105
Received: 9
I have issues as I loose some data because UART1_read() return only one byte. I try to receive data and put it in array but still doesn't working.