kwdckperera
Newbie level 6
Hello all,
I am doing a simulation of sending analog voltage from one place to another place via RF modules. This voltage is an output from a sensor. I am using 2 pic16f877a micro-controllers and RF transmitter and a receiver.
My transmitting side works perfectly fine. It reads the analog voltage, convert it in to digital and then to a string, and sends it through transmitter. (there is a display for reading the voltage too). My problem is with the receiving side. I can only print receiving characters on to display. I can not make a string from them. What i want is make a string from receiving data. Once new data has arrived string has to be modified according to new data. The received data (string) must be shown on the display.
Following is my code and proteus simulation. I used MikroC for coding. Please help me with receiving side code.
Thanks
Transmitting side (works fine)
Receiving side (where the help is needed)
I am doing a simulation of sending analog voltage from one place to another place via RF modules. This voltage is an output from a sensor. I am using 2 pic16f877a micro-controllers and RF transmitter and a receiver.
My transmitting side works perfectly fine. It reads the analog voltage, convert it in to digital and then to a string, and sends it through transmitter. (there is a display for reading the voltage too). My problem is with the receiving side. I can only print receiving characters on to display. I can not make a string from them. What i want is make a string from receiving data. Once new data has arrived string has to be modified according to new data. The received data (string) must be shown on the display.
Following is my code and proteus simulation. I used MikroC for coding. Please help me with receiving side code.
Thanks
Transmitting side (works fine)
Code:
sbit LCD_RS at RD2_bit; // Lcd module connections
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main() {
int analog_value = 0; // define intiger "analog_value" with initial value of 0
int value = 0;
char buf [7];
TRISA.f0=1; // define AN0 pin as input
ADCON1 = 0; // set all pinns in register A as analog inputs with refference to VDD
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100);
while(1)
{
analog_value = ADC_Read(0);
value = (int)((analog_value/204.6)*1000);
intToStr(value,buf);
ltrim(buf);
UART1_write_text(buf);
Lcd_Out(1,1,buf);
Delay_ms(5000);
}
}
Receiving side (where the help is needed)
Code:
sbit LCD_RS at RD2_bit; // Lcd module connections
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
char value ;
void main() {
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1) { // Endless loop
if (UART1_Data_Ready()== 1)
{
value = UART1_Read(); // read the received data,
Lcd_chr_CP(value);
}
}
}