I need to be able to change the direction and speed of a small dc motor using an PSoC LP5 and a L293D. The motor that was used is one of these: https://www.elecrow.com/dc-toy-hobby-motor-130-size-p-265.html. I was able to change the direction without PWM by changing the inputs, this gave me the following table.
But then I also had to change the speed. The schematics for this project can be found below. The PWM period has been set to 1000.
My code looks like this:
int main(void)
{
PWM_1_Start();
for(;;)
{
DIRECTION_Write(0);
PWM_1_WriteCompare(400);
CyDelay(2000);
// 2 seconds clockwise low speed
PWM_1_WriteCompare(0);
CyDelay(2000);
// 1 second nothing
DIRECTION_Write(1);
PWM_1_WriteCompare(400);
CyDelay(2000);
// 2 seconds counter-clockwise low speed
PWM_1_WriteCompare(0);
CyDelay(2000);
// 1 second nothing
}
}
The motor now only turns counter-clockwise, then stops for 5ish seconds en does the same again. I've tried other combinations such as also using SPEED_Write, but didn't get the result I wanted.
Any help is appreciated, thanks in advance :)