the dude of dudes
New Member
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:
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'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.