Help me pls

Discussion in 'General Electronics Chat' started by Youssef_18, Apr 23, 2012.

  1. Youssef_18

    Thread Starter New Member

    Apr 23, 2012
    2
    0
    hello ALL ,
    I build line follower robot -based pic16F877A and ULN2003A when i made the program it is work with isiss, but when i put it in the pic 1 motor rotates and the other 1 no pls check it fot me , i write it with micro pascal , pls help me :)
    This is the program :
    program Robotsuiveurdeligne;
    var x,y : LONGINT;
    v :longint;
    txt: string[10];
    begin
    TRISC:=0;
    PORTC:=0;
    USART_init(9600);
    lcd_config(portb,0,1,2,3,portb,6,5,4);
    lcd_cmd(LCD_CURSOR_OFF);
    lcd_out(1,1,' ROBOT SUIVEUR ');
    lcd_out(2,1,' DE LIGNE M_Y ');
    begin
    if Usart_Data_Ready = 1 then
    begin
    USART_write(Usart_Read);
    end;
    end;

    adcon1:=$80; // activation du convertisseur
    //pwm_init(1500); // activation du MLI
    //pwm_change_duty(180); // changement du rapport cyclique
    //pwm_start;
    while (true) do
    begin
    x:=adc_read(0);
    y:=adc_read(1);
    if (x > (y+40)) then
    begin
    PORTC.0:=1;
    PORTC.1:=0;
    PORTC.2:=1;
    PORTC.4:=0;
    end else
    if (y > (x+40)) then
    begin
    PORTC.0:=0;
    PORTC.1:=1;
    PORTC.2:=0;
    PORTC.4:=1;
    end else
    begin
    PORTC.0:=1;
    PORTC.1:=0;
    PORTC.2:=0;
    PORTC.4:=1; end;
    end;
    end.


    pls help me and i wanna the lcd affiche when the robot turns right ,display right and when turns left , display left .
     
  2. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    One thing that will help is to use the code /code markers:
    Code ( (Unknown Language)):
    1.  
    2. program Robot Follower of Line;
    3.   var x,y : LONGINT;
    4.   v :longint;
    5.   txt: string[10];
    6.  
    7. begin
    8.     TRISC:=0;
    9.     PORTC:=0;
    10.     USART_init(9600);
    11.     lcd_config(portb,0,1,2,3,portb,6,5,4);
    12.     lcd_cmd(LCD_CURSOR_OFF);
    13.     lcd_out(1,1,' ROBOT  Follower  ');
    14.     lcd_out(2,1,' DE LIGNE M_Y ');
    15.     begin
    16.         if Usart_Data_Ready = 1 then
    17.         begin
    18.             USART_write(Usart_Read);
    19.         end;
    20.     end;
    21.  
    22.     adcon1:=$80; // activation of Line ADC
    23. //pwm_init(1500); // activation of Line MLI
    24. //pwm_change_duty(180); // changement of Line rapport cyclique
    25. //pwm_start;
    26.  
    27.     while (true) do
    28.     begin
    29.         x:=adc_read(0);
    30.         y:=adc_read(1);
    31.         if (x > (y+40)) then
    32.         begin
    33.             PORTC.0:=1;
    34.             PORTC.1:=0;
    35.             PORTC.2:=1;
    36.             PORTC.4:=0;
    37.         end else
    38.             if (y > (x+40)) then
    39.                 begin
    40.                     PORTC.0:=0;
    41.                     PORTC.1:=1;
    42.                     PORTC.2:=0;
    43.                     PORTC.4:=1;
    44.                 end else
    45.                     begin
    46.                         PORTC.0:=1;
    47.                         PORTC.1:=0;
    48.                         PORTC.2:=0;
    49.                         PORTC.4:=1;
    50.                     end;
    51.     end; // while
    52. end.
    53.  
    Also, comments are your friends. I've no idea what the IF blocks are supposed to do: activate motors? turn on LEDs? This will also help you to debug your code. "PORTC.0:=0" -- does this activate a motor or turn it off?

    Remember -- what is perfectly obvious to you may not be at all obvious to others.

    --Rich
     
  3. Youssef_18

    Thread Starter New Member

    Apr 23, 2012
    2
    0
    hello i don't now him but this program is mine ; pls give me a link of it and thx my pb is solved
     
Loading...