Help me pls

Thread Starter

Youssef_18

Joined Apr 23, 2012
2
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 .
 

Attachments

RiJoRI

Joined Aug 15, 2007
536
One thing that will help is to use the code /code markers:
Rich (BB code):
program Robot Follower of Line;
  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  Follower  ');
	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 of Line ADC
//pwm_init(1500); // activation of Line MLI
//pwm_change_duty(180); // changement of Line 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; // while
end.
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
 
Top