ROV Controlling Using RS232 and pic MCU 18f452

Thread Starter

shoptodip

Joined May 6, 2011
5
I wanna build a ROV which has two separate microcontroller unit to conduct whole operation. One MCU is in the remote module and another is in the host module . those 2 mcu’s are meant to be operated using RS-232 protocol connected through two wire serial connection. Two motors are controlled by switch which are connected with MCU of remote module and motors are connected to MCU of host module. There are a temperature sensor connected to host module and a 16x2 lcd connected to remote module…. The sensor will sense the temperature and the lcd will show the temperature after remote module have the data collected from host. So please help me to write the code.
i have written some of the code for Host module
Rich (BB code):
void main() {
       unsigned char receive;
       
       TRISD = 0x00;
       PORTD = 0x00;
       UART1_Init(9600);
       
       while(1) {
                // If data is ready, read it:
                if (UART_Data_Ready() == 1) {
                         receive = UART_Read();
                }
                if(receive == 'A') {
                     PORTD.F0 = 1;
                }
                else if(receive == 'B') {
                     PORTD.F0 = 0;
                }
                // lcd receive
                PORTD.F1 = ~PORTD.F1;
                UART1_Write_Text("PI");
                Delay_ms(250);
                PORTD.F1 = ~PORTD.F1;
And the code for Remote module
Rich (BB code):
// Lcd pinout settings
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_bit;
sbit LCD_D7 at LATD5_bit;
sbit LCD_D6 at LATD4_bit;
sbit LCD_D5 at LATD3_bit;
sbit LCD_D4 at LATD2_bit;

// Pin direction
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D7_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD2_bit;


void main() {
      unsigned char receive;
      unsigned char received_text[12];
      TRISB = 0b10000000;
      PORTB = 0x00;
      LATB = 0x00;
      
      Lcd_Init();
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Cmd(_LCD_CURSOR_OFF);
      UART1_Init(9600);

      while(1) {
               if(PORTB.F7 == 1) {
                      UART1_Read_Text(received_text, "OK", 10);
               }
               Lcd_Cmd(_LCD_CLEAR);
               Lcd_Out(1,3,received_text);
               

      }
}
BUt I count not write code for PWM and receive temperature data from Host module to remote module. PLz Help
 

Attachments

Top