16F628A lines with BTrainer
This is the last thing given to me, a car line follower. That is a car that you put a black line on a white background and is following the line.
The truth is simple to do and something more complicated if you want to do well, I'll explain
Starting from the base, not a very good basis for this type of practice, is more difficult to control. The base would be two wheels each with a motor and an idler as a jockey wheel.
This is the bottom where the positions three CNY 70.
This is the first test I did putting them at great distance and mounting them a bit of "that way" on the same chassis ...
did not work ... what good is the circuit if it worked well the problem was being fixed could not regulate the sensors and to what I wanted.
here are already better placement is very important, if not not detect the line, we must align well especially in height. Out there some scheme where they put the CNY 70 with a potentiometer , I have not been proved, but I guess with this we do a setting more "fine." Vibration
If you can take better too.
This is the bottom, where the sensors are CNY 70, as shown are on, this can only be seen with mobile and not if the cameras also happen (This is also useful to know whether the command of the batteries in tele jejeje )
The idea and although I had in mind I've really done a little to do. Some information I have taken from the web of Glafebre who made the Hyperion where you have the most information and the original program, the mine has some variations, but was the one who inspired me.
code in PBP :
@ DEVICE PIC 16F628A, WDT OFF _ ' Watchdog Timer offline
@ DEVICE 16F628A PIC, PWRT _ OFF ' Power - On Timer connected
@ DEVICE PIC 16F628A, BOD _ OFF ' Brown - Out Detect connected
@ DEVICE PIC 16F628A, MCLR _ OFF ' Master Clear External offline
@ DEVICE PIC 16F628A, LVP OFF _' Low - Voltage Programming offline
@ DEVICE PIC 16F628A, CPD _ OFF 'Data Memory Code Protect off
DEFINE OSC 4
'----- PORT CONFIGURATION --------
=% 11110000 PORTB
=% 11110000 TRISB
'------------ ------------ MAIN PROGRAM
pause
3000 loop: IF
(0.5 PORTB = 0) AND (PORTB 6 = 1) AND (PORTB 7 = 1) THEN GOSUB
FORWARD IF (0.7 PORTB = 0) AND (PORTB 5 = 1) AND (PORTB .6 = 1) THEN GOSUB LEFT
IF (PORTB 6 = 0) AND (PORTB 5 = 1) AND (PORTB 7 = 1) THEN GOSUB
RIGHT IF ( PORTB .5=0) AND ( portb .6=0) AND ( portb .7=0) THEN GOSUB PARO
IF ( PORTB .5=1) AND ( portb .6=1) AND ( portb .7=1) THEN GOSUB PARO
GOTO loop
END
'-------------- SUBRRUTINAS -----------------
FORWARD: PORTB
0 = 1 1 = 0 PORTB
2 = 0 PORTB: PORTB 3 = 0
return
BACK:
PORTB 0 = 0: PORTB 1 = 0: PORTB
2 = 0 3 = 0 PORTB
RETURN RIGHT: PORTB
0 = 1 PORTB
1 = 0 2 = 1 PORTB: PORTB 3 = 0
RETURN
LEFT: PORTB
0 = 1 1 = 0 PORTB
2 = 0 PORTB: PORTB 3 = 1
RETURN STOP:
0 = 0 PORTB: PORTB 1 = 0: PORTB
2 = 0 3 = 0 PORTB
RETURN --------- END OF CODE -------------- ------------------------------- -
By PeYuTrOn
0 comments:
Post a Comment