![]() |
![]() |
![]() |
|
|
|||||||
| Robotics Chat Specific to discussions about robots and the making of. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hi there!
I'm considering to make a line follower and I have made this code: Code:
list p=16f628 #include<p16f628.inc> __CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ERRORLEVEL -302 cblock 0x20 temp temp_s endc ;****************************************************************** org 0x00 goto main ;***********************************INTERRUPT LOOP***************** org 0X04 inter: movwf temp swapf STATUS,w clrf STATUS movwf temp_s btfsc PORTB,0x00 goto loop1 loop2: movlw b'00000101' movwf PORTA btfsc PORTB,0x05 goto loop2 goto loop_x loop1: movlw b'10001000' movwf PORTA btfsc PORTB,0x00 goto loop1 loop_x bcf INTCON,0x01 bcf INTCON,0x00 swapf temp_s,w movwf STATUS swapf temp,w retfie main: bsf INTCON,0x07 ;Globel interrupt enable(we are using interr.) bsf INTCON,0x04 bsf INTCON,0x03 ;RB4-RB7 interrupt on change is enabled/ in other words these pins will also work as ;interrupts and interrupt will occur every time any of these pin changes state ; i.e.:HIGH to LOW or LOW to HIGH, we can not set it to be on eather one state change bcf INTCON, 0x01 bcf INTCON, 0x00 ;Clear RB4-RB7 interrupt flag so, that another interr. can occur. ;**********************************SET UP THE PORTS ***************** bsf STATUS,RP0 ;switch to BANK 1 movlw b'00100001' movwf TRISB ;set RB6 & RB5 as input movlw b'00000000' movwf TRISA ;setPORT A all output bcf STATUS,RP0 ;back to BANK 0 movlw 0x07 ;turn comparators off, so HIGH will be simple ; HIGH rather than +5V (compared to supply) so with the LOW movwf CMCON Loop: movlw b'00001001' movwf PORTA ;set pin 0 of port a HIGH goto Loop END Now what I'm confused is about the H bridge, I don't have much time to spend on this robot as my exams are coming, I was wondering that can't I simply connect motors with the PIC via resistors, will that be relaible ?. I will use photoresistors as sensors (FYI).
__________________
CHRIS Last edited by c36041254; 26th May 2008 at 03:12 AM. |
|
|
|
|
|
|
(permalink) |
|
PIC pins are only 20ma, not enough to drive motors.
|
|
|
|
|
|
|
(permalink) |
|
Does this mean I need to attach H bridge or is there any other easier way ?
__________________
CHRIS Last edited by c36041254; 26th May 2008 at 04:49 AM. |
|
|
|
|
|
|
(permalink) |
|
You need to attach an H-Bridge, a nice simple one is the L293D or SN754410
|
|
|
|
|
|
|
(permalink) |
|
I was trying to understand the H bridge from Build a 5A H-Bridge motor controller! in which there is a truth table given which explains when motors will run in forward and when in reverse etc., but I think that in my programme I just need to attach each output of PIC to one of the inputs of SN754410 and here the SN754410 will work as simply a current source for motor. Do I understand it right ?
As L293D is only a TTL compatible and not CMOS how can I use it with 16f628 ?
__________________
CHRIS |
|
|
|
|
|
|
(permalink) |
|
They'll both work with the 16F628, take a look at the Mongoose schematic on my site or read about h-bridges on Robot Room
David Cook - Robot Room: Robotics, Electronics, and Schematics |
|
|
|
|
|
|
(permalink) |
|
I would suggest using the SN754410 as it is very easy to integrate.
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Robot to robot communication | nuttaphong191 | Robotics Chat | 3 | 22nd September 2007 04:08 PM |
| help with a robot | magee | Robotics Chat | 11 | 25th August 2007 12:00 PM |
| Robot Efficiency & other Robot stuff | williB | Robotics Chat | 56 | 1st May 2005 03:35 AM |
| help with gps robot | muhtar | Robotics Chat | 10 | 12th November 2004 04:08 AM |
| My robot. | Cyborg | Micro Controllers | 4 | 26th May 2004 01:53 PM |