Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help me to fix my program for PIC16F877A

Status
Not open for further replies.

Youssef_18

Newbie level 2
Joined
Apr 24, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Tunisia /mounastir
Activity points
1,305
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 :


Code Pascal - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 display when the robot turns right ,display right and when turns left , display left .
 

Attachments

  • Sans titre.jpg
    Sans titre.jpg
    127.7 KB · Views: 69
Last edited by a moderator:

No one help me but i solve the problem ,and this is the correct program :

Code Pascal - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
program Robotsuiveurdeligne Youssef_18;
var x,y : LONGINT;
  v :longint;
 begin
  TRISC:=0;
  PORTC:=0;
  lcd_config(portb,0,1,2,3,portb,6,5,4);
  adcon1:=$80;
   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;
         LCD_cmd(LCD_CLEAR);
         lcd_out(1,3,'  Turn Right   ');
         lcd_out(2,3,'  --------->   ');
         Delay_ms(9600);
         lcd_cmd(LCD_CURSOR_OFF);
        end
           else
           if (y > (x+40)) then
            begin
             PORTC.0:=0;
             PORTC.1:=1;
             PORTC.2:=0;
             PORTC.4:=1;
             LCD_cmd(LCD_CLEAR);
             lcd_out(1,3,'  Turn Left    ');
             lcd_out(2,3,'  <--------   ');
             Delay_ms(9600);
             lcd_cmd(LCD_CURSOR_OFF);
            end
               else
                begin
                 PORTC.0:=1;
                 PORTC.1:=0;
                 PORTC.2:=0;
                 PORTC.4:=1;
                 LCD_cmd(LCD_CLEAR);
                 lcd_out(1,3,'  ROBOT SUIVEUR  ');
                 lcd_out(2,3,'  DE LIGNE M_Y   ');
                 Delay_ms(9600);
                 lcd_cmd(LCD_CURSOR_OFF);
                end;
    end;
 end.

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top