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.

Tomiyama Gearbox and PWM

Status
Not open for further replies.
Okay, a few questions on a bot I'm working on.

I'm using a bulldozer kit with a Tomiyama Gearbox (twin motors rated at 3V dc), 16F876A, and L293D to run the motors. 4 rechargeable AA's run the motors, and a standard 9v battery runs the electronics. I'm using PWM by connecting CCP1 and CCP2 of the PIC to Enable 1 and Enable 2 of the H-Bridge. Here's the code that sets it up:

Code:
;--------
PWMInit
;--------

;--Sets up PIC for PWM outputs on CCP1 and CCP2, sets period and initial duty cycles

	;---Setup CCP/PWM/PORTC pins as outputs
	BANKSEL TRISC	;bank1
	bcf TRISC, 2	;CCP1 
	bcf TRISC, 1	;CCP2
	
	;---Set PWM period for both modules
	movlw .128
	movwf PR2	

	BANKSEL PIR1	;bank0

	;---Setup Timer2
	bcf T2CON, T2CKPS0
	bcf T2CON, T2CKPS0	;prescaler set to 1
	bsf T2CON, TMR2ON	;start timer2

	;---Setup CCP1 for PWM
	movlw .100		;bits 2-9
	movwf CCPR1L		;****duty cycle****
	bcf CCP1CON, CCP1Y	;bit 0
	bcf CCP1CON, CCP1X 	;bit 1
	
	bsf CCP1CON, CCP1M3
	bsf CCP1CON, CCP1M2	;set CCP1 module to PWM

	;---Setup CCP2 for PWM
	movlw .100		;bits 2-9
	movwf CCPR2L		;****duty cycle****
	bcf CCP2CON, CCP2Y	;bit 0
	bcf CCP2CON, CCP2X 	;bit 1
	
	bsf CCP2CON, CCP2M3
	bsf CCP2CON, CCP2M2	;set CCP2 module to PWM

My thinking is that I should never set CCPR1L or CCPR2L to .128 (full on), or I will overload the motors (4 * 1.2V = 4.8v). In the real world, when I run the robot I only see 3v on the motors when I run at "full on". If I set CCPR1L and CCPR2L to 110, it drops to slightly above 2V. With the motors disconnected from the board I get ~5V at the L293D outputs no matter what I set my PWM to, I assume this is because there is no load. What is happening here? My understanding is that I can read how much voltage the motors are getting with a meter on the motors leads, is this wrong? And if I'm right, why do they only show 3V when I'm supplying 4.8 (or as my meter shows 5.12v)? My main concern is not to destroy the motors, but I would also like to understand what is going on.
 
I use almost exactly the same setup in my Mongoose robot. If you use NiMH batteries they're not 1.5V they're closer to 1.25V.

Those Tamiya gearbox motors are fine at 5V, it's the stall current that can hurt them.
 
Don't worry about it, you make considerable loss in the H Bridge IC. In any case, it's common to run motors at higher voltages to gain more power and speed, motors don't just fry if you up the voltage a little.

Motors used in Robot Wars and such programmes are commonly VERY over run - with at least 24V for 12V motors, and sometimes 36V or even 48V!.
 
So the voltage my meter shows on the motor leads is an accurate measurement? And if so, the H-bridge accounts for my voltage loss (1.8-2 volts)?
 
the dude of dudes said:
So the voltage my meter shows on the motor leads is an accurate measurement? And if so, the H-bridge accounts for my voltage loss (1.8-2 volts)?

Probably so, although there's no guarantee how a digital meter will read PWM.

Personally I wouldn't have even tried measuring it!.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top