ROV Controlling Using RS232 and pic MCU 18f452

Discussion in 'Embedded Systems and Microcontrollers' started by shoptodip, Jul 12, 2013.

  1. shoptodip

    Thread Starter New Member

    May 6, 2011
    5
    0
    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
    Code ( (Unknown Language)):
    1. void main() {
    2.        unsigned char receive;
    3.        
    4.        TRISD = 0x00;
    5.        PORTD = 0x00;
    6.        UART1_Init(9600);
    7.        
    8.        while(1) {
    9.                 // If data is ready, read it:
    10.                 if (UART_Data_Ready() == 1) {
    11.                          receive = UART_Read();
    12.                 }
    13.                 if(receive == 'A') {
    14.                      PORTD.F0 = 1;
    15.                 }
    16.                 else if(receive == 'B') {
    17.                      PORTD.F0 = 0;
    18.                 }
    19.                 // lcd receive
    20.                 PORTD.F1 = ~PORTD.F1;
    21.                 UART1_Write_Text("PI");
    22.                 Delay_ms(250);
    23.                 PORTD.F1 = ~PORTD.F1;
    And the code for Remote module
    Code ( (Unknown Language)):
    1. // Lcd pinout settings
    2. sbit LCD_RS at LATD0_bit;
    3. sbit LCD_EN at LATD1_bit;
    4. sbit LCD_D7 at LATD5_bit;
    5. sbit LCD_D6 at LATD4_bit;
    6. sbit LCD_D5 at LATD3_bit;
    7. sbit LCD_D4 at LATD2_bit;
    8.  
    9. // Pin direction
    10. sbit LCD_RS_Direction at TRISD0_bit;
    11. sbit LCD_EN_Direction at TRISD1_bit;
    12. sbit LCD_D7_Direction at TRISD5_bit;
    13. sbit LCD_D6_Direction at TRISD4_bit;
    14. sbit LCD_D5_Direction at TRISD3_bit;
    15. sbit LCD_D4_Direction at TRISD2_bit;
    16.  
    17.  
    18. void main() {
    19.       unsigned char receive;
    20.       unsigned char received_text[12];
    21.       TRISB = 0b10000000;
    22.       PORTB = 0x00;
    23.       LATB = 0x00;
    24.      
    25.       Lcd_Init();
    26.       Lcd_Cmd(_LCD_CLEAR);
    27.       Lcd_Cmd(_LCD_CURSOR_OFF);
    28.       UART1_Init(9600);
    29.  
    30.       while(1) {
    31.                if(PORTB.F7 == 1) {
    32.                       UART1_Read_Text(received_text, "OK", 10);
    33.                }
    34.                Lcd_Cmd(_LCD_CLEAR);
    35.                Lcd_Out(1,3,received_text);
    36.                
    37.  
    38.       }
    39. }
    BUt I count not write code for PWM and receive temperature data from Host module to remote module. PLz Help
     
Loading...