Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

My first ROBOT

Status
Not open for further replies.

c36041254

Member
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

It runs well on LEDs and hopefuly it will run on motors too. Actually the programme reverse one LED lightning the other on interrupt and ther are two such pairs of LEDs, so when motors will be connected on interrupt the respective motor will be reversed. If you don't follow what I mean than kindly see the video which is posted by "futz" who helped me with the codes and circuit..

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).
 
Last edited:
I was trying to understand the H bridge from **broken link removed** 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 ?
 
I would suggest using the SN754410 as it is very easy to integrate.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top