The reed switch for the wheel sensor bounces and caused erroneous readings, so this needed to be cleaned. As an example left below good (80-100km/hr) and right bad (20- 1700 The first issue was that it was probably due to using connections that are floating - below is the new config showing a 10K resistor holding down FIO4 down to GND, with the reed switch connecting +5V when switched. This should have worked better than just wiring up the reed switch with no pulldown but it was worse! So I played around with a capacitor to clean up the readings using my lathe as a test driver. I hooked a 0.1uF capacitor across the resistor above (GND - FIO4). Below is the difference - left no cap, right 0.1 uF - there is still a bit of bounce but the smooting removed all errors in the readings, so for now is it good enough to run with!
Below is a test log using the 0.1 uF capacitor debounce method (plotted in Excel) - a 20 minute ride with not one error (recorded at 2 samples per second)
NextThe above is a hack and it was just what I had lying around the lab - this really needs to be improved with a proper debounce circuit... Debounce circuit http://www.labbookpages.co.uk/electronics/debounce.html Update: 19/07/2011I ordered a MAX6816EUS+T debounce IC which "should" have been perfect as it is a debounce unit which just requires a capacitor. Trouble is that when it arrived I discovered it is tiny surface mounted device, great for a production circuit board but not for wiring up manually (it's about 3mmx3mmx1mm in size)... time for a visit to JayCar. Update: 16/08/2011I got the diodes etc above and tried a trial but couldn't get it to work... then realised the "ICIC" wasn't referring to the LabJack input but an additional IC, the 74HC14 Schmitt trigger, which I hadn't purchased. Since I am streaming now I might go with a combination of software debounce and what LabJack recommend (below). Since I am measuring every pulse it should be pretty obvious if I get a double trigger (an I can add the value to the trailing time). Update 21/08/2011And the result of the above... a pretty good falling edge to trigger off and it looks like one that I will keep. Above: Debounced signal from reed switch driven by a lathe. Update (23/08/11)OK all though I get a clean signal I an still getting wavering results. I think this is due to the reed switch itself. I am seeing a few microseconds but this is enough to throw out my calculations. The animated diagram below is from http://reed-switch-info.com todo - add reed switch debounce animation Update (10/09/11)After still experiencing issues with jitter and incorrect reads (even buying and trying a signal generator), I posted a question on the LabJack forum. After working with the support guys there, we worked out that there was a few issues:
Below is the thread for reference: |