I am building a POV display, where all modules work with 5V (Raspberry Pi / apa102 LED strip / motor).
First I built an ESC module using a universal PCB which uses 5V from the power supply and a PWM signal from the Raspberry.
There is also a speed sensor (encoder) circuit that uses a Schmitt-trigger IC (assembled on a breadboard) to adapt the signal to the Raspberry.
At this stage everything was good and there was no problem with the sensor and the Raspberry GUI was printing speed values without any problem. But when I assembled everything on the PCB, the speed values glitched sometimes and gave wrong measurements.
I noticed also that when I shut the motor down the measurement became correct (slow-down speed was right and smooth). It appeared that the motor is the cause of this. Maybe it was making noise. All this happened when I was testing at home. But the big surprise is that this does not happen at my university where the values are correct anyway. Even the oscilloscope shows very little noise.
My question is: why didn't my PCB work properly at my house but works alright at my University?
Did I make a mistake by assembling everything on one PCB? Especially the ESC?
The following picture is my PCB:
The following is the electronic schematic of the ESC section and sensing section: