Sensor for distance measurement

Hello everyone!

I am building a small electrical car and I want to be able to monitor the distance traveled and store it on a SD card. So far I have been trying measuring the distance with an encoder and a photointerrupter attached to the axis of the wheels,(by measuring the number of turns of the axis) but the errors are coming up VERY large (double distance etc.)

I have tried with different number of holes (10, 6, 3) but it doesnt seem to work well.
Would you recommend trying with a hall effect sensor and some magnets? Is it in general more accurate?

Note that the spinning of the axis is not that large (about 150 RPM)

I have attached a pic of the setup

The issue is not the encoder, is the lack of precision-resolution of the wheel that you used.

You should use an optical disk, something like that:

mouse disk

Just use the disk.

Or.

index disk

Papajim202:
Hello everyone!

I am building a small electrical car and I want to be able to monitor the distance traveled and store it on a SD card. So far I have been trying measuring the distance with an encoder and a photointerrupter attached to the axis of the wheels,(by measuring the number of turns of the axis) but the errors are coming up VERY large (double distance etc.)

An analog output photo-interrupter perhaps?

You need to condition the outputs from an analog photo detector by using a schmitt-trigger to avoid
multiple transistions due to noise in the signal. This could be done in hardware or software, but it
has to be done.

A hall-switch sensor would be much simpler and robust.

I had a similar problem. It turned out to be EMI from the motor controller. I put .1uf caps on the signal lines at the arduino and that fixed it.