ChriX
Member
I'm driving a couple of small motors via a L298 from a 16F876 (not via PWM... yet).
I setup a simple loop, where alternate LEDs flash, which works fine, perfectly in time. Then I set one of the input lines to the L298 high, and added the enable for this channel to go on and off at the same time as one of the LEDs.
Some times the motors will go on and off a few times (although the timing seems very erratic), but more often than not, the PIC appears to stop executing when the motors are on, so the motor is left running. I can't work out what would be causing this. I have measured the supply to the PIC when the motor is running, and it is still normal. I am running from 4 AA cells, with a MAX682 providing power to the logic circuits and PIC, with the motors driven directly from the battery, but I get the same problem when running the lot from a 5V lab supply.
Could the motor noise be disrupting my crystal? This is the only thing I can think of, hopefully you will have some ideas!
Thanks,
Chris
C4&5 = LEDs. C1 = one of the enable pins on the L298.
I setup a simple loop, where alternate LEDs flash, which works fine, perfectly in time. Then I set one of the input lines to the L298 high, and added the enable for this channel to go on and off at the same time as one of the LEDs.
Some times the motors will go on and off a few times (although the timing seems very erratic), but more often than not, the PIC appears to stop executing when the motors are on, so the motor is left running. I can't work out what would be causing this. I have measured the supply to the PIC when the motor is running, and it is still normal. I am running from 4 AA cells, with a MAX682 providing power to the logic circuits and PIC, with the motors driven directly from the battery, but I get the same problem when running the lot from a 5V lab supply.
Could the motor noise be disrupting my crystal? This is the only thing I can think of, hopefully you will have some ideas!
Thanks,
Chris
C4&5 = LEDs. C1 = one of the enable pins on the L298.
Code:
LOOP_BEGIN
bsf PORTC,5
bcf PORTC,4
bcf PORTC,1
DELAY_MILLI 250
bcf PORTC,5
bsf PORTC,4
bsf PORTC,1
DELAY_MILLI 250
goto LOOP_BEGIN