I installed two hall effect sensors AN503 that I have soldered around a magnetic wheel glued on the axis of a dc motor to create an encoder. Tried my best to aligned them so there is half a phase signal between them. I think it's not too bad. The problem is that I am struggling to have an overlap of digital highs and lows because the signals stay much longer in the highs than in the lows. If I look at the analog reads, along with digital reads, I noticed that the median analog value is 500. And the analog signal coming from the sensors goes from 400 to 1023. So I have 100 in the lows and 523 in the highs. Obviously the ideal would be half-half. I tried to add different resistors between signal and vcc/gnd but witout satisfying results. But I am lacking method and knowledge in this area. Any one has a good method to do this ? Or maybe could I move the median value of the digital read ? Note that I am using an encoder library which uses the signal pins as arguments , and interrupts.
It sounds like all the magnets have the same polarity facing outwards. Flip half of them around so you have alternating polarities.
I am not sure what a magnetic wheel is, can you explain it. I think it is a single circular magnet. If it is several magnets then you can take another magnet to each of the poles and as stated below they should be of alternating polarity. Preferably you have an even number of poles. If the polarity is opposite they will attract each other, if the same they will repel. This response is to help you get started in solving your problem, not solve it for you. Good Luck & Have Fun! Gil