TinyIOX - Speedo Input From LM2907-8

http://jbperf.com/io_extender/index.html
http://jbperf.com/io_extender/tinyIOx.html for the TinyIOx
Post Reply
roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

TinyIOX - Speedo Input From LM2907-8

Post by roger » Fri Nov 22, 2019 2:05 pm

Jean,

I make a small circuit for a speedometer signal input using a 12 tooth trigger wheel with a Hall sensor a F/V IC LM2907-8 for my MS2 Extra v3 board (3.4.2 firmware). The Vout voltage is linear with the theoretical data for different frequencies generated by the tirgger wheel.
I currently have your TinyIOx v1.2 board. The Vout (0-6v) will be sent to one of the free ADC pins (AD1) on the TinyIOx board.

Attached is the circuit that I am planning to use for the conditioning before it goes to the ADC pin.
I am wondering if the capacitors are the correct size for this circuit as I would like to reduce as much electronic noise as possible.
Conditioning Circuit for ADC Input using 6 volts maximum Vout from LM2907.JPG
Conditioning Circuit for ADC input
Conditioning Circuit for ADC Input using 6 volts maximum Vout from LM2907.JPG (24.3 KiB) Viewed 83 times
Thanks
Roger

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Fri Nov 22, 2019 2:27 pm

First, what is the purpose of the speedo input? Is it only for data logging purposes? With the MS2, this is the only way to use a speedo input as far as I know. In that case, you could use a timer input instead and ignore the LM2907 circuit.

There is also something I don't understand in your picture, You mention a 0-6V signal, a maximum output voltage and a corresponding maximum ADC count. That doesn't make sense to me. The maximum voltage you want on the ADC input is 5V so you don't want a 0-6V signal. Also, if you do have a 4.947V signal, that will not be 844 ADC count but 4.947/5 x1023 = 1012. Please post your LM2907 circuit and any additional component.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Fri Nov 22, 2019 3:36 pm

Jean,

It's only for logging purposes.
The output from Vout is slightly less than 5 volts with my current maximum frequency that is equivalent to 118.4 MPH based on my tire size and final gear ratio. I put 6 volts in as a buffer in the event that the final gear ratio is reduced resulting in higher frequency and wheel speed.
In the schematic below, the VR is replaced by a Hall sensor with a built in pull up resistor. There is also a 1uF capacitor between the Hall output and pin #1 on the LM2907. The Vcc is limited to 9 volts using a 7809 voltage regulator. R1 is 30K instead of the 100K shown on the diagram because of my frequencies specific to my tire sizes and final gear ratio. All the capacitors in the schematic retain the same values.
The maximum Vout is calculated at 4.754 volts for a frequency of 1800 Hz that corresponds to a speed of 118.4 MPH.
This circuit works on Tunerstudio, however it is not linear below Vout values less than 0.22 volts when I test it on my lathe at different spindle speeds.
LM2907_cr.jpg
LM2907 cicuit
LM2907_cr.jpg (24.76 KiB) Viewed 74 times
It's probably better to use the Vref on the TinyIOx board so that the ADC remains linear.
Would this circuit work using the 5 volt Vref?
I could also go with a R2=10K for a maximum voltage of 4.545 and ADC of 930 for better resolution.
BTW,I referenced the schematic from looking at the various schematics out of the MS2 v3 hardware manual v3.4, specifically the TPS, MAT, and CLT circuits.
Conditioning Circuit for ADC Input.JPG
Circuit Using Vref
Conditioning Circuit for ADC Input.JPG (26.92 KiB) Viewed 74 times
Roger

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Fri Nov 22, 2019 5:09 pm

Roger,

You don't need R2 in your last picture because the output of the LM2907 already provides the voltage. But the rest will work. If you find out that there is more noise than you want, you could increase C2 to 1uF or more. But you can also use the software to increase the filtering by lowering the lag factor.

Having said that, you can use the timer input instead as I mentioned in my previous post. You would need to connect the Hall sensor to a timer input on the TIOx, enable the PWM inputs on the TIOx and enable PWM input on the MS2. You would also need to add the gpiopwmin variable to the datalog which can be done in TunerStudio or through the ini file. Or you can directly datalog the timer value from the TIOx.

You would have a 0.2 to 120+ mph range with about 1mph resolution at the high end (low end resolution is not an issue). You could also have better high end resolution (0.5 mph) but with a 0.4 mph minimum. And the equation for the speed is:

Code: Select all

118.4 * 24000000 / (pwm_in * 128 * 1800)
where 118.4 is your value at 1800Hz
24000000 is the timer clock speed
pwm_in is the clock tick count (gpiopwmin0 if on the MS2 or pwm1 on the TIOx)
128 is the timer prescale
1800 is your 1800Hz

The circuit needed to connect the Hall sensor to the TIOx would be 2 diodes and one resistor like that:
pwm_input_5V.png
PWM input
pwm_input_5V.png (4.42 KiB) Viewed 71 times
Let me know if you want to explore using the timer input and if you need more details.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Fri Nov 22, 2019 5:30 pm

Jean,

I will try the circuit without the R2 as you have recommended and see how it works on the bench using the lathe spindle speeds.
If it works and the resolution is acceptable, I will go with it.
If I'm not happy with the response and resolution, then I will try your timer circuit that you suggested.

In your timer circuit, the PWM is the signal coming from the Hall sensor, is that right?
This timer electronics is "undiscovered country" for me as I have no background in it.

I'm currently waiting for the capacitors to arrive from Digikey, hopefully the shipment arrives this afternoon and then I try the conditioning circuit.

Thanks Jean for your great input.
Very much appreciated.
Roger

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Fri Nov 22, 2019 5:51 pm

Yes, PWM is the Hall sensor signal.

If you want to give it a try, you can simply enable the PWM inputs and use the defaults for the rest of the settings (which will give you the 128 prescale in my computations above). And using your lathe setup, you can connect the Hall sensor to TPM1CH0 on the TIOx using a 1k resistor (you can omit the diodes for a quick bench test as long as this is a 5V Hall sensor). In TunerStudio, you can then check the pwm1 gauge in TunerStudio to see how the value changes with different speeds (right click one your existing gauges to change it to the pwm1 gauge).

The advantage of using the timer input is that it should simplify the whole setup and optimize your inputs. Of course, there is some initial learning curve.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Fri Nov 22, 2019 6:44 pm

Jean,

I like the concept of simplifying things using the KISS principle.
Eliminating the F/V circuit would certainly achieve that.
I will try the F/V circuit since I have spent quite a bit of time in it.
However, I suspect that I will end up using the PWM timing as it eliminates another layer of complexity.
Thanks again for all your comments and input.
You have a wealth of knowledge on this stuff and are great value to the MS community.

Roger

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 12:46 am

Jean,
The bench testing using the circuit conditioner worked. The results is linear except for a little discrepancy of about 0.3 to 0.5 MPH below a voltage of about 0.3 volts.
Using a maximum Vout of 4.78 gives me the same speed as what is calculated based on my tire size and final gear ratio.
There's a uniform offset between the calculated and the measured ADC counts versus Volts by about 6 to 8 counts, which is equivalent to 7 mv.
This is probably the limitation of the LM2907 IC and the support circuits that are included on a separate board.
Overall, I am very happy with the results. Thanks you for all the help. Could not have finished it without your expertise.
MPH and ADC Counts vs Vout.jpg
Bench Testing Charts
MPH and ADC Counts vs Vout.jpg (145.3 KiB) Viewed 61 times

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Sat Nov 23, 2019 1:41 am

Roger,

Glad to see it's working well.

A few mV of difference between the computed and measured results is not unexpected because there are many places where the component tolerance will have a small impact. And I think your results are probably better than what you'd get from many OEM speedo gauge in cars of a certain age.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 12:49 pm

Jean,
I will proceed and try the timer in TinyIOx as you mentioned in several former posts and compare the results with the LM2907.
I have Tunerstudio MS Ultra v3.0.28 that has the "Add Custom Channel Wizard" and "Custom Channel Editor". The Custom Channel Editor allows entry of a new Data Log Field. Once the output channel name has been created for the data log field, is this where I would enter the equation 118.4 * 24000000 / (pwm_in * 128 * 1800) instead of manually editing the custom.ini file?
Custom Configuration Editor.JPG
Custom Configuration Editor
Custom Configuration Editor.JPG (76.74 KiB) Viewed 42 times
I will give it a try and see if I can make it work following your previous comments.

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Sat Nov 23, 2019 1:11 pm

Yes, this is where you would enter it. But you will need to change 'pwm_in' with the correct channel name from the list TunerStudio provides you. If your project contains the TIOx channels then that is the easiest way to go and you would use 'pwm1'. If you only have the MS2 channels then you would need to use gpiopwmin0 but you also need to set the PWM input polling in the CAN parameters.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 3:23 pm

Jean,
Okay, I will make those changes and enable CAN polling and accept those default values.
CAN Polling Parameters.JPG
CAN Polling Parameters
CAN Polling Parameters.JPG (76.31 KiB) Viewed 35 times
I've added the 1k ohm resistor between the Hall sensor signal and TPM1CH0 making sure that I use 5 volt reference for the Hall sensor supply power.
BTW, what are the values and digikey part numbers for both diodes if I decide to go with the timer option instead of the LM2907 circuit?

I will let you know the bench test results using TPM1CH0.

Roger

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Sat Nov 23, 2019 3:42 pm

Actually, it was misleading when I mentioned using all the default values. That was only on the TIOx side. On the MS2 parameters you show, you need to change the CAN ID from 5 to 4 and the offset from 58 to 28. And you can use pretty much any diode but small schottky diodes will do such as SR104.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 5:16 pm

Jean,

The timer option also works using the lathe spindle speed test results.
The timer option provides better accuracy with the higher PWM counts (lower speeds) but it starts to drift higher as the speed increases with lower PWM counts (1.5 MPH higher than actual speed at 21.3 mph test).
This is just the opposite of the LM2907 circuit where its accuracy is about 0.5 MPH below the correct speed but very near the same for the higher speed tests.
I'm not sure how much higher the timer speed would deviate up from the true speed at speeds greater than 40 MPH. There's already a +1.5 mph drift at only 21 mph.
The nice thing about the TinyIOx timer is that it does not require additional circuits.

For your interest, here's the chart and table showing the results for each circuit used.
Speed Comparison.JPG
Comparison Results
Speed Comparison.JPG (71.48 KiB) Viewed 33 times
Thanks
Roger

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Sat Nov 23, 2019 5:37 pm

Roger,

How accurate are the 118.4 mph and 1800Hz you quoted before? And how accurate is your theoretical speed on the lathe? If any of those are not accurate, that will lead to an apparent error. The timer should be much more accurate than this assuming the computation use the correct values and you're comparing with a true speed. As I said before, the maximum error you should see is about 1mph at 120mph.

Is there any noise on the speed when you look at the data with the timer input? And is that the same when you look at the raw data (gpiopwmin0)?

Since this seems to be a linear error, one thing you could try is to adjust the 118.4 value a bit to see if you can get closer to your expected speed.

Jean
Image

jbelanger
Posts: 3736
Joined: Sat Oct 03, 2009 12:24 pm
Location: Quebec, Canada
Contact:

Re: TinyIOX - Speedo Input From LM2907-8

Post by jbelanger » Sat Nov 23, 2019 5:48 pm

And I should add that you can replace the equation with the simpler version:

Code: Select all

12333.3333 / gpiopwmin0
This just does the pre-computation of all the fixed values into a single value. And then you can adjust this 1233.3333 value to get your expected speed. This will have the same effect as what I mentioned before where you only adjust the 118.4 value.

Jean
Image

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 6:03 pm

Jean,

I will only be able to tell by getting the car on the road and logging the speed with my 10Hz GPS and compare to ground speeds.
I definitely prefer the timer method over the LM2907 based on your previous comments.

I still need to press the trigger wheel on the driveshaft slip yoke and make a mount for the hall sensor.

The weather is turning as the old man winter is knocking on the door so I'm not sure if I will get a chance to test it on the road before spring.

BTW, I did check the raw data and at a zero speed it was also zero.
There was very little drift by only a few counts at any of the test speeds, so I don't believe noise is an issue.

Roger

roger
Posts: 12
Joined: Sun Apr 07, 2019 5:24 pm

Re: TinyIOX - Speedo Input From LM2907-8

Post by roger » Sat Nov 23, 2019 6:39 pm

Jean,
BTW, I rechecked my calculations for the speed at 118.4 MPH and also remeasured the tire circumference.
The frequency at 118.4 MPH is 1799.61 Hz or 118.43 MPH at exactly 1800 Hz.
The frequency per MPH = 15.199416.
This is based on a final gear ratio of 5.13, tire diameter of 22.69 inches and 12 tooth trigger wheel.
They are just rounding errors.

Roger

Post Reply