My guess (there's not really enough information for more than a guess) is that the 5V supply rail is collapsing when the motor turns on (motor may be stalled, too powerful for your supply, etc.). To troubleshoot this further, break the problem down:
First, disconnect the PIC and the motor and just focus on the driver chip. Make sure ALL the inputs are defined (pulled high or low) - even the inputs you aren't using. Make sure any outputs you aren't using are floating. Now, with 5V on the Vcc of the driver, take the EN pin high, toggle an A input, and verify that the appropriate Y output goes high and low following the A input. Do that for both A inputs. If it doesn't work, record the voltages on ALL the pins (supply, input, output, even GND in case you miswired something) of the driver and report them here.
After that's working, connect the motor, toggle the A inputs again and verify that the Y outputs change as before and that the motor turns as expected. If it doesn't, record the voltages on ALL the pins of the driver (particularly the Vcc pins) and report them here.
Next, connect the PIC, and repeat the above procedure with the PIC driving the pins.
If you go through it methodically, you will find the problem.
Assumption: Some mechanism exists to sense RPM, either through an encoder attached to the motor shaft, or via back-emf sensing.
An approach to achieve better results that what the question describes, for low RPM operation of a motor, is to use a PID controller algorithm thus:
- Motor is provided maximum rated power at start-up, as specified in the motor datasheet
- As the RPM sensed approaches the desired set-point, the power is systematically reduced my modifying the triac trigger phase
- Once the RPM set-point is achieved, the PID controller continues to sustain that RPM by increasing or decreasing power to compensate for loading effects
- If load drives the motor to stall, or beyond acceptable power ratings, the controller initiates a controlled fail-safe spin-down of the motor, and also triggers an alarm indication.
From the Wikipedia article linked above, this graph might help explain this process visually:
Depending on the acceptability of overshoots (or not) and desired system behavior, the Proportional (P), Integral (I) and Derivative (D) values of the PID algorithm need to be tuned. The diagram above specifically covers tuning the I value: For absolutely no overshoot of RPM, but with greater time to reach set-point, the red line on the graph shows the preferred behavior, as achieved with a Ki = 0.5.
On the other hand, the black trace, with Ki = 2, achieves (and overshoots) the set-point fastest, and then over/undershoots the set-point in diminishing cycles till it settles down.
There exist excellent motor controller ICs which incorporate both back-EMF sensing (if applicable to your type of motor) and PID controlling, in one package.
Also, assuming the OP has limited experience in designing such systems, off-the-shelf PID controllers for motors are available for a variety of power ratings. These allow a set-point to be interactively set, along with tuning parameters or constraints.
There are also several projects by hobbyists out there, designing and implementing PID AC motor control using microcontrollers or microcontroller boards. For instance, see this YouTube video, for one such Arduino-based PID controller for AC motors.
Links to details are provided in the description text of that video.
Best Answer
Although it may seem counter-intuitive, running a DC brush motor efficiently at a low PWM ratio requires that the motor switch between being connected to the supply and being shorted (not open-circuit). It will be necessary to use an H-bridge driver that can switch quickly, with judge enough "dead" time to prevent accidentally shorting the supply itself.
Motors have a certain amount of inductance, so it takes a little while for current to start flowing, and once current is flowing it will take awhile to stop. If you try to drive a motor at e.g. 25% duty cycle then during the first quarter of each cycle, the motor will have supply voltage across it so current will increase as energy flows from the supply into the motor. During the second quarter, the clamp diodes on the H-bridge will clamp the motor at a voltage equal to the supply voltage, but opposite in sign, so the current will decrease as energy flows from the motor back to the supply. During the third and fourth quarters of the cycle, there won't be any energy so the motor will sit with zero voltage and zero current. The average current in the motor will thus be about 1/4 of the level to which the current managed to climb in 1/4 of a cycle--not very much.
If instead of making the motor open-circuit, one made it short-circuit during the off part of each wave, then during the first 1/4 of the first cycle, motor current would increase as above, but during the remainder of each cycle it would decrease only slowly (the rate at which current will decrease depends upon the voltage across the motor inductance, and that would be kept very lower). Then during the first 1/4 of the second cycle, the current would increase a bit more, then drop only a little bit during the next 3/4 cycle, etc. Once the motor starts moving, the back EMF that generates will increase the rate at which current drops during the "off" cycle [energy will be transferred from the inductance to the mechanical load in that scenario]. If there is minimal mechanical loading, the equilibrium current will be achieved when the motor speed is about 1/4 of the motor's full-supply zero-load speed.
Note that when using this technique, it's important that the PWM rate be fast enough that the current doesn't have time to get to zero during each cycle. If the current does get to zero and the motor is turning, the inductor will take rotational energy and use it to build up torque in the direction opposite rotation. If the motor spends half its time producing forward torque and half producing reverse torque, much of the energy directed toward it will get converted into heat.