line follower help

Status
Not open for further replies.

owika

New Member
hi Micro Experts.
I`m planning to use a PIC16F877A to make a line follower . I want my line follower to have the feature of saving the path last travelled into memor.i'm using 2 infrared sensor. I set PORTA AS input and PORTB as output. i'm using mplab asm.Micro Experts, how to write the program interface the sensor with output motor . Kindly help me .
 
first you delclare the outputs and inputs then you read PORTA write its state in EEPROM set the motors wait for about 100 ms and repeat

as for the reading its reads from EEPROM sets PORTB wait about 100ms and repet


or do you need help for writing/reading form EEPROM


be shure that you have protection diodes on motors or the back emf will fry your PIC
 
well i program my PICs in mikroBasic not in asembely.

I think basic is much much easyer than asembely.You have a lot more functions,varius functuns for LCDs,EEPROMs,manchester code and even CP cards (you can do this stuf in 3-8 lines of code)
I also like the sound libary that outputs an freq. on the selected pin.

for the stuf you wod think its easyer in asembely you can also put the asm command an write the asembely code right in the midle of basic code.
 
ur project sounds interesting...
I wish i can help with, i m still a newbie and i would like someone if he can give me more information or some step that help me start implementing it .
thanks in advance
 
be shure that you have protection diodes on motors or the back emf will fry your PIC

i want to build a line follower and i'm newb. I saw many schematics where the motor is connected directly to the Pic pins... can you give me a scheme or post a link with protection diodes?
 

You can't connect motors directly to PIC pins!, you MUST use a driver of some sort (commonly an H bridge is used).

If you've seen diagrams with motors connected directly to PIC pins either the diagram doesn't work, or (more likely) you're reading the diagrams incorrectly.
 
UnD3aD said:
http://chanhak.com.ne.kr/line_tracer-circuit.htm
http://chanhak.com.ne.kr/remobot_circuit.htm

Neither of those show a motor connected to the PIC (and I can't read the text, but it CERTAINLY won't say that!). The pins labelled 'motor' feed to driver circuits!.

For speed control you use PWM, it's a HUGE advantage switchign to the PIC16F876, as it has two hardware PWM channels - one of my tutorials shows how to set it up for a dual motor robot, giving 127 forwards and backwards speeds.
 
For the ones that dont know thats PWM it Pulse Width Modulaton.
Its aculy making an freq. but the duty cilce is changing so for 30% motors power you switch on for 30% for the time on then off for 70% of the time.

I wod recomed mikroBasic programing language for newbys.

**broken link removed**

Its easy to leran,reqires litle lines of code to do somting,realy nice libarys for LCD,Sound, EEPROM,CompactFlash cards...

if you alredy lernd asembely i wod recomedn stiking to it but if you dont know any programing language i wod recomed basic
 
i have a pic 16f84a and a pic16f628 .. the last one have only a PWM channel.... can i control 2 motors with only one channel?
 
For a newby i wod sugest control whith no PWM youst use two I/O pins.one for the left motor and one for the right one.This way you wod hav off or on ar full power.
You dont realy need PWM Its wod yust make the robot thurn more smothy.so it starts thurnig slow and then fast.Whis no PWM it simply makes an tight thuurn sudenly changing direction.

ADC (Analog Digital Converter) can be a real pain for a newby since it needs some setings.

As for the hardware you cod make an voltage divider out of two phototransistors and feed it output in the ADC

BTW: nave you newbys made some LED blinkers and stuf like that so get some expiriece (becose LED blikers are the easyest stuf to make)
 
you cod do it whith two power trasistors.Its base coneted to an I/O pin thru a resistor and conet the coletor and emiter to the power rails whith an motor betven (If you nave an PNP emiter to V+ and coletor to motor or if you have an NPN conct the colector to ground and eemiter to motor)

whith this you cod ony thurn the motor one way

DON'T forget the protection diodes on the motors or the PIC will be fryed from the motors back emf (the diodes must conduct the oposite way you conect the power)

you cod also use an H bridge motor driver IC
 
its an general purpuse diode that is in parallel whith the motor an coducts the oposite way that we aply curent.

It aculy an short curcut for back emf.

it dosent need to be big since it dosent have to conduct a lot of curent.
 
thank my man. I will try the MickoBasic. can you give me example of line tracking code in basic.
 
Code:
#include <system.h> 

void main() 
{ 
trisa = 00b; 
trisb = 111b; 
porta = 00b; 
while(1){ 
switch(portb) 
{ 
case 100b: porta = 10b;break; 
case 110b: porta = 10b;break; 
case 010b: porta = 11b;break; 
case 011b: porta = 01b;break; 
case 001b: porta = 01b;break; 
case 000b: porta = 00b;break; 
case 111b: porta = 00b;break; 
} 
} 
}
i made this but i don't know if it works... didn't build my car..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…