I bought a Honeywell SNDH-T4L-G01 (dual differential Hall effect sensor) to basically try and measure the speed of a rotating drum which has gear teeth on it. My background is more computer science then electronics, so I initially just hooked up the channel A output to my Arduino and started trying to get results. The output was pretty much useless, but after days of searching I discovered that you can't just hookup the output directly to your DAQ! The output is described in the datasheet as "push/pull" so I hooked it up with a pullup resistor and started getting much better results.
The problem is that as per that other thread I seem to be missing the odd reading here and there. It may be down to something else, but I'd like to confirm I'm wiring the sensor up correctly first, if anybody can help me with this it would be great!
I guess my key questions are -
Does the 'push/pull' description of the output mean I should be wiring it as pullup?
What size pullup resistor should I be using? There is no info in the datasheet, but remembering back I think I read elsewhere that it's not an exact science anyway (I have a figure of 100 in my mind, 100Ohm, 100kOhm I'm not sure but can check when I get access to the equipment again)
The A and B channel outputs are phase shifted 90 degrees. I know this can be used for determining direction, but is the intention also to use the two outputs to confirm a good signal? ie. Should I not assume a tooth has been seen until A and B go positive?
Is there anything else I should be doing here to guarantee good results? Are perfect results even expected from a sensor like this, should I be coding around the problem?
Any pointers on ANY of this would be great, even if it's not directly related to this particular sensor!
Does the 'push/pull' description of the output mean I should be wiring it as pullup?
No push pull means the output will give a low impedance to both high and low output signals. This means you do not need a pull up resistor. Why this gives better results is a bit of a puzzle.
What size pullup resistor should I be using?
You shouldn't be using one.
but is the intention also to use the two outputs to confirm a good signal?
No it is purely direction.
Is there anything else I should be doing here to guarantee good results?
Make sure you have a good noise free signal, how far away is the sensor. You could be suffering from pickup that is interfering with the signal. You might have to put a driver at the sensor end if, as it look the sensor's output is insufficient to get it through.
Q. So I understand the purpose of the A and B channels is purely for direction sensing, not as some sort of signal confirmation/noise-reduction of the output?
A. CORRECT
Q. Could you confirm if the output of a channel should be connected with a pullup/pulldown resistor (and if so what size is recommended) or is the output push-pull in that it can be connected directly my logic circuit for timing etc?
A. Your circuit needs to have a resistive load of some sort-a 1Kohm pull up is sufficient.
I'll have to check what resistor I was using, when he says 1k is sufficient, is that to say that 10k or 100k will also work fine? Anything else I'm not thinking of with the output of this sensor, or can I literally just wire the output of channel A (with a pullup resistor in place) to a digital input on an Arduino? Any thoughts/warnings gratefully appreciated, I'd love to get this working right and ruling out the sensor seems like the best start :). Thanks!
I didn't have 1k resistors so I assume two 4.7k in series will do the job as a pullup in this case?
Couple of points -
the power supply near the top of the diagram was a lab powers supply set to 5V at one point, at another I was using the power output pins on the Arduino. From what I can tell the sensor and 4040 use much less power then the Arduino can supply so this should be OK?. In the long run it would be best if the whole thing can be powered from the USB port, hence using the Arduino power pins.
As I wasn't sure whether using the Arduino to power this was OK I was using the separate lab power supply, but had the thought that the Arduino being powered from the PC and circuit/sensor from a different source might cause issues so I tired tying their grounds together. No improvement/dis-improvement.
I had the LEDs in to give me an indication of when stuff was happening, but I've read about having to put resistors in parallel/serial with LEDs so maybe just sticking them around my circuit like this causes issues?
The point of the 4040 IC (ripple counter) is to decrease the number of pulses the sensor sends so the Arduino can handle them. So in this circuit I'm giving the Arduino one pulse for every 64 from the sensor.
Anything jump out to anybody there? All help/suggestions really appreciated!
The thing that jumps out is that you have no current limiting resistors on any of the LEDs. This in effect will short out your output from pin 2 and you will not see it from the arduino.
Also you will only get an output every 64 pulses, is that what you want?
There should be a 0.1uF capacitor across the power supply.
There is no need to use an external power supply with this, simply connect it to the arduino +5V line.
4K7 is perfectly fine by itself for a pull up. You have connected two in series giving a total of 9K4, if you want to get closer to 1K the put them in parallel, this gives you 2K3.
Not sure what I was thinking with the resistors for the pullup, I had 470Ohm in mind instead of 4700! Out of interest, can you have too much resistance as pullup or does it not matter within reason? 10k 100k would be fine?
On the LEDs is there a simple way of deciding what resistor to put in there or is it always a matter of figuring out the right size? I tend to stick them in all over the circuit so I can see what's going on, but tbh if there's any chance of them causing issues I'd sooner just remove them altogether.
That's good news on the power supply, makes the whole thing much more mobile! Do I need the cap both if I'm using an external power supply or the Arduino power? What is the purpose of it out of interest?
can you have too much resistance as pullup or does it not matter within reason
The resistance determines how "hard" the lines are pulled up. A value of 1 to 5mA is normally fine. Any less and it becomes more susceptible to noise pickup.
is there a simple way of deciding what resistor to put in there
If it is just for indication I would use 1K as this gives a minimum disturbance to the rest of the circuit. The LEDs will not be so bright but that is not what you are after here.
but tbh if there's any chance of them causing issues
I'll read over the decoupling article later-on and see if I can make sense of it, my computer science brain never really 'clicked' with electronics for some reason :-/ .
Interestingly I had a problem with this whole thing originally where I had a long extension lead (probably 50-75m) that I was using to power the PC and power supply for my setup. I was getting mad results from the sensor/Arduino. You'd get a few good pulses, then a few mad ones and it would go like that. After changing everything I could think of I noticed that shaking (yep!) the extension lead coil (I know, 50m of coiled extension lead is never a hot idea when it's in use) it would go completely mad, then settle back to a regular level of crazy results when I stopped shaking. I replaced the extension lead with a short new one which got rid of a VAST majority of the crazy results, I'm now trying to get rid of the last spurious result that pops up eveyr few thousand pulses.
And yes I only want an output every 64 pulses, the drum is spinning quite fast so the Arduino wouldn't be quick enough to read the pulses and get them across the serial connection if I was taking every pulse, so for now I'm dividing them down by 64. I'd considered adding some buffer memory to the Arduino but tbh I have enough sample points for a good graph at 1/64 so I don't think there's any need for the extra complication (and extra places for me to stick in dodgy pieces of circuitry and unprotected LEDs ).
long extension lead (probably 50-75m) that I was using to power the PC and power supply for my setup.
Yep that's where decoupling helps, it is all to do with noise pickup. Also you actually generate small voltages flexing a long wire so your description doesn't surprise me.
One more thing if you don't mind. Should I be keeping the cables to the sensor as short as possible or anything like that? I mean the sensor is under a large trailer so I really need 3-4m of cable going from the sensor to that circuit which will be at the front of the trailer. Is this OK over standard bell wire or should I be using twisted pair? Or shielded twisted pair (in which case should the shield be connected to the GND pin of the Arduino at one end only?). These are probably basic questions but I have a feeling it's something stupid causing me problems at this stage!
What about the power going from the Arduino to the sensor (again 3-4m to the back of the trailer, if this is OK), should there be a cap across this at the end of the cable near the sensor as well?
I could put the circuit and Arduino right beside the sensor, but I'm concerned about putting electornics so close to the big spinning steel drum etc.
should there be a cap across this at the end of the cable near the sensor as well?
That is a good idea.
Put the pull up resistor at the arduino end and the sensor at the far end of the cable. If the sensors will operate at a higher voltage do that and have a transistor at the arduino end, this is because the bigger the voltage the less prone to interference it is.
You could also try a transistor at the sensor end with the collector and small value pull up at the arduino end. Basically anything to lower the impedance and thus reduce the effect of pickup.
Just wanted to update this thread for anybody following in future. Seems my random number result may have been caused by bad code, upgrading from Arduino 0012 to 0018 and updating my code to suit seems to have removed the random numbers, at least in my test setup, will have to try it with the real sensor to be sure. I've added resistors to the LEDs and a decoupling capacitor as well so hopefully all this together will sort me out. More info - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222726966/32 .