Creating an RPM and Temp Sensor

Development & General Chat for the superb openxvario project.

Moderator: rainer

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 8:26 pm

I could eventually use a 10k but the 100k will draw less current and the voltages out should be similar if wired in series with another resistor between ground and 3.3v. I assume i pick an analog input pin but am not sure how to configure oxs.

mstrens
Posts: 1066
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by mstrens » Thu Apr 21, 2016 8:30 pm

I asked it because it is recomended that impedance of voltage source measured by an analog input is about 10 k or less.

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 8:31 pm

I was not aware.

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 8:38 pm

I would have thought the input pin would have a higher impedance to reduce the current drawn thru the input pin while the source should support a lower impedance to provide that voltage/power without sagging. Additionally, higher resistance will reduce power dissipated in the rtd as heat.

User avatar
Kilrah
Posts: 9099
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Creating an RPM and Temp Sensor

Post by Kilrah » Thu Apr 21, 2016 8:45 pm

raleighcoter wrote:while the source should support a lower impedance to provide that voltage/power without sagging
Correct but precisely 100k is NOT low compared to the ADC input, hence the suggestion of using 10k instead ;)


raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 8:52 pm

But the resistance of the rtd varies from around a few K to over several hundred k over the temp range for 100k ntc rtd, and the important temps happen at the low end of the resistance range for my application.

mstrens
Posts: 1066
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by mstrens » Thu Apr 21, 2016 8:54 pm

If the impedance is about 10k or less in the range of temperature you want to measure, then it is OK.
Do you know the resistances in the range of temp you want to measure?

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 8:57 pm

It... Is on my computer at work. Ultimately i want to use the same rtd that came with my sp-rpm sensors which are 100k ntc rtd devices to measure headntemp on my gas helicopter and to also pick up rpm from a hall sensor. Rpm is easy. Temp is a bit lacking in the literature.

User avatar
MikeB
9x Developer
Posts: 14477
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Creating an RPM and Temp Sensor

Post by MikeB » Thu Apr 21, 2016 9:55 pm

The reason for having a low impedence source is a small capacitor inside the processor needs to be charged to the input voltage quickly (acquisition time), an input impedence of more than 10K is too large.
However you are intending to use a 100K rtd in series with a 10K resistor to provide the voltage to measure. The source resistance for this combination is actually the PARALLEL combination (Thevenin equivalent circuit) of the rtd resistance and the 10K, so will always be less than 10K, so your measurements should be OK.
Since the rate of change of the temperature is slow, compared to reading the value, you may add a capacitor (0.1uF) between the junction of the rtd and the 10k, and ground. This will reduce the effective impedence for charging the internal capacitor.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Thu Apr 21, 2016 9:59 pm

Thanks mike. Are there examples for configuring osx? How are the calibration tables defined?

mstrens
Posts: 1066
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by mstrens » Fri Apr 22, 2016 10:46 am

Currently oXs does not support a full calibration table for temperature.
oXs can only convert ADC reading into some meaningful values (e.g. temperature) using a linear relation.
To set up this linear relation, It allows to fix 2 parameters : an offset and the slope.

If you accept to consider that the voltage provided at the mid point of the voltage divider is linear with the temperature over the range of temperatures you want to measure, then you can use oXs.
Othewise, you should consider replacing the ntc by a IC chip that deliver a linear voltage over the temperature range. Such IC are easily available on ebay and are cheap.

If you use an Arduino 3.3 volt, a 10k resistor connected to 3.3 arduino Vcc and a 100k ntc connected to ground, you do not need additional resistors for the voltage divider. As Mike suggested you could add a capacitor (e.g. 100nf) between ntc and ground.
Then oXs should be configured in order not to use the internal voltresistor of age reference.
So you should use following set up
//#define USE_INTERNAL_REFERENCE // uncomment this line if you use 1.1 volt internal reference instead of Vcc
//#define USE_EXTERNAL_REFERENCE // uncomment this line if you use an external reference instead of Vcc
#define REFERENCE_VOLTAGE 3300 // set value in milliVolt; if commented, oXs will use or 1100 (if internal ref is used) or 5000 (if internal ref is not used)

Then about the "calibration", assuming that you connect the ntc to arduino analog pin 2, and that ntc has a resistor of 5.5 k at 200F and of 1.3k at 300F (those are values that I found in a datasheet but yours are perhaps different so adapt accordingly) you could use
#define PIN_VOLTAGE 2 , 8 , 8 , 8 , 8 , 8 // set this line as comment if no one voltage have to be measured, set a value to 8 for the voltage(s) not to be measured.
// So here I set 2 in first position because I use analog pin 2 to measure a first voltage ; others (unused pins) are set to 8

#define RESISTOR_TO_GROUND 0 , 10 , 30 , 19.8 , 50 , 60 // set value to 0 when no divider is used for a voltage, can contains decimals
// Here I put the first value to 0 because this force a special way of calculation by oXs ; other parameters does not matter


#define RESISTOR_TO_VOLTAGE 0 , 100.1 , 200 , 39 , 500 , 600 // set value to 0 when no divider is used for a voltage, can contains decimals
// Here I put the first value to 0 because this force a special way of calculation by oXs ; other parameters does not matter

#define OFFSET_VOLTAGE 0 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, must be integer
#define SCALE_VOLTAGE 1 , 1 , 1 , 1.004, 1 , 1 // optionnal, can be negative, can have decimals
Now we have to set up the first parameter on each of those 2 lines in order to get a result of 200 (at 200F) and of 300 (at 300F).
Note : the scale parameter must ne negative because voltage goes low when temperature goes high.

To calculate the 2 parameters, I use following meaning (there are for sure other ways).
Assume that Offset is represented by variable OFFSET and Scale by SCALE.
At 200 F:
Voltage on pin 2 will be : 3300 mvolt * 5.5 / (5.5 + 10).
Value returned by ADC will be 1023 steps * mvolt_on_pin2 / 3300 mvolt = 1023 * 3300 * 5.5 / (5.5 + 10) / 3300 = 1023 * 5.5 / (5.5 + 10) = 363
Value calculated by oXs will be : (value returned by ADC * SCALE ) + OFFSET,
So we have a first equation : (363 * SCALE) + OFFSET = 200 => OFFSET = 200 - (363 * SCALE)

At 300F :
Voltage on pin 2 will be : 3300 mvolt * 1.3 / (1.3 + 10).
Value returned by ADC will be 1023 steps * mvolt_on_pin2 / 3300 mvolt = 1023 * 3300 * 1.3 / (1.3 + 10) / 3300 = 1023 * 1.3 / (1.3 + 10) = 118
So we have a second equation : (118 * SCALE) + OFFSET = 300 => OFFSET = 300 - (118 * SCALE)

Now solving the 2 equations we have :
Offset = 200 - (363 * SCALE) = 300 - (118 * SCALE)
=> (-363 + 118) * SCALE = 300 - 200
=> SCALE = 100 / (-363 + 118)
=> SCALE = - 100 / 245 = -0.408

and so replacing SCALE in first equation => (363 * -0.408) + OFFSET = 200 => OFFSET = 200 - (363 * -0.408) = 348

So set up would be
#define OFFSET_VOLTAGE 348 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, must be integer
#define SCALE_VOLTAGE -0.408 , 1 , 1 , 1.004, 1 , 1 // optionnal, can be negative, can have decimals

raleighcoter
Posts: 19
Joined: Mon Apr 18, 2016 10:40 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by raleighcoter » Fri Apr 22, 2016 12:31 pm

Thanks mstrens. That was a great explanation. Just need my arduino delivered and i can set this up.

RightRudder
Posts: 241
Joined: Tue Jan 15, 2013 9:41 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by RightRudder » Sat Dec 10, 2016 3:31 pm

I have enabled RPM sensor on oXs v.5 and tested with a 5v TTL signal generator. I get good telemetry until ~20KHz and then the RPM display drops to zero. I want to use this together with a hobbywing ESC which has an RPM signal output derived from motor commutation pulses. The spec says it has a 17% duty cycle and is 3.3v logic level. Since this is to be used on a helicopter the gear ratio between the motor and main rotor head in this case is 14:1 (typcal ratios might vary from 9:1 to 15:1) So with a head speed of 4000 rpm (small helicopter) and 14:1 ratio the motor is turning 56000 RPM. Since this is a 6 pole motor the commutation speed is 56000 *6/2=168000 hz. Obviously this isn't going to work if oXs can only measure up to 20KHz. But I can measure frequencies with Arduino up into 8 MHz with the freqCount library:

https://www.pjrc.com/teensy/td_libs_FreqCount.html

I don't want to deal with a separate rpm sensor for several reasons, it's a small heli, putting magnets on the gears is asking for vibration troubles at 4000 rpm, optical method would be a mess, since the RPM signal is available from the ESC lets use it! Can anything be done in oXs to up the frequency counting ability to read typical commutation speeds?

Carbo
Posts: 249
Joined: Fri Aug 02, 2013 6:55 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by Carbo » Sat Dec 10, 2016 4:15 pm

Did you miss a division? 56000 RPM equals 933 Hz. 933*6/2 = 2800 Hz.

RightRudder
Posts: 241
Joined: Tue Jan 15, 2013 9:41 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by RightRudder » Sat Dec 10, 2016 7:05 pm

duh. don't I feel stupid. haha

Carbo
Posts: 249
Joined: Fri Aug 02, 2013 6:55 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by Carbo » Sun Dec 11, 2016 2:25 pm

I make this experience regularly ;)

If you succeed measuring RPM, please report. Also how you care for a voltage limitation on the Arduino input.

User avatar
kalle123
Posts: 685
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Creating an RPM and Temp Sensor

Post by kalle123 » Sun Dec 11, 2016 2:56 pm

@ RightRudder.

Tested that rpm senor with success on oXs.
viewtopic.php?f=95&t=8561&p=112207&hilit=rpm#p112207
You can find the circuit diagram in same thread.

br

RightRudder
Posts: 241
Joined: Tue Jan 15, 2013 9:41 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by RightRudder » Sun Dec 11, 2016 7:54 pm

Carbo wrote: If you succeed measuring RPM, please report. Also how you care for a voltage limitation on the Arduino input.

Yes it works when I put the value as:
DEFAULTFIELD , RPM , 10 , 7 , 0 , \

And set blades to 1 in Taranis it reads 4000 RPM for 2800 Hz on signal generator. To answer your question about input protection for the processor on oXs see the attached screenshot:
RPM input.jpg

Carbo
Posts: 249
Joined: Fri Aug 02, 2013 6:55 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by Carbo » Tue Dec 13, 2016 11:36 am

That is similar to the circuit, i have used: Preamp. But i had problems with RF from the RX telemetry. After RF-blocking the input of the preamp with a ceramic cap (100 pF) the signal was clean and it worked flawlessly.

FPV-community thread

RightRudder
Posts: 241
Joined: Tue Jan 15, 2013 9:41 pm
Country: -

Re: Creating an RPM and Temp Sensor

Post by RightRudder » Tue Dec 13, 2016 2:42 pm

If RF is a problem I would suggest you try to put the 100p (or so) in the location shown in this modified version. That will roll off frequencies above about 34KHz
Edit: I rearranged the buffer so that it could work with external hall sensor as well. In my case I have only a TTL level output from esc to worry about but hall sensors are often open collector so this circuit should work for both but I haven't tested.
Attachments
Tach buffer.JPG

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”

Who is online

Users browsing this forum: No registered users and 1 guest