I'm trying to drive a small DC motor with a PWM with the circuit below, where I'm using a TIL111 optocoupler and a IRF510N MOSFET. The PWM (50% duty cycle) is generated by a MCU STM32F103C8T6, the +3.3V source comes from this MCU and the +5V source is another one.
The motor drives, but the waveform over the motor looks like the one below (sorry for my oscilloscope). The image isn't clear but what happens is that this output have some waves (resembling coil discharging waves) when it should be off, or 0V (the ON semi-period is working ok). Since I have a +5V source and a 50% duty PWM, I should measure 2.5V over the motor, but, with this signal, I'm measuring 3.55V.
If I remove the motor and put some 120 ohm resistor in its place, I can visualize the correct waveform below. I also verified the waveform over the opto and over the MOSFET's gate, and it's working fine (with or without the motor).
I'm using this dummy dc motor below, but I have tested with other two dummy motors and having the same result. Actually, I tried to drive these motors with a TIP before, using a similar circuit; that time, I changed pretty much all the components (TIPs, resistors, diodes, motors, protoboards) and I still ended with this same result. If someone could tell me some tip about why I'm having this behavior, I would be grateful.