Temperature sensor

User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Temperature sensor

Post by Bigpie »

What's the procedure for getting values for a currently unsupported sensor? Im guessing it's a case of taking a value at known min max temperatures and some values inbetween?
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Temperature sensor

Post by johu »

I will try to describe it. The first 3 steps are the most work and even if you stop there I can continue with the remaining steps
  1. If possible try to find a data sheet for the sensor
  2. Otherwise take samples like every 10°C in a temperature range thats feasible
  3. Even if you only have some samples say from 20 to 60°C you can try to extrapolate the shape of the curve graphically
  4. Look at this file: https://github.com/jsphuebner/stm32-sin ... ensors.ods . It has formulas for converting sensor resistance to voltage and voltage to ADC digits
  5. Add your temperature sensor in a new sheet - keep in mind motor temp sensor has a different formula than heatsink temp sensor
  6. Either just post the file on the forum or continue like below:
  7. Fork stm32_sine project to your github account
  8. Copy the digits from the ods file to temp_meas.h in a way that you find the others
  9. Add your sensor to the enum - heat sink temperatures go from 0 to 10, motor temp sensor from 12 to open end. Increase NUM_HS_SENSOR if necessary
  10. Add your sensor to param_prj.h: Increase the "max" value by one, and add to SNS_HS or SNS_M define, respectively
  11. Add an array to temp_meas.cpp (static const uint16_t my_temp_sensor[] = { MY_DEFINE };
  12. Add your array to "sensors" descriptor array and fill in min_temp, max_temp, step_size, len, PTC/NTC, array
  13. Make a new branch like "temp_sensor_kty_xxx"
  14. Commit & push your changes
  15. Make a pull request in my original stm32-sine project
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

Thanks. I'll see what we can come up with.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bobby_come_lately
Posts: 465
Joined: Sun May 03, 2020 5:39 am
Location: Manchester, UK
Has thanked: 33 times
Been thanked: 36 times
Contact:

Re: Temperature sensor

Post by bobby_come_lately »

It's one thing using the oven for desoldering @Bigpie but you might get in real trouble if you try sticking a motor in there 😉
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

I've had a cylinder head in there before and rocker arm shaft in the freezer :D I almost didn't survive that.
Old single cylinder air cooled Yamaha. Had it been more recent I wouldn't have bothered with the engine rebuild, I'd have just stuck a motor in.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

I have updated temp_sensors.ods with the Toyota motor sensor thermistor 47k NTC, beta 3900K. To use this sensor you will need to modify the components on your board.
Johannes: Please add this to the next release.
Attachments
temp_sensors.ods
(95.44 KiB) Downloaded 183 times
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Temperature sensor

Post by johu »

Nice, thanks :)

Would you mind if I changed R1=1k2 (default part) and R2=2k2? Then the resistor on board needs not be changed. Accuracy above 0°C would still be more than a digit per °C.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

johu wrote: Sat Oct 17, 2020 5:15 pm Would you mind if I changed R1=1k2 (default part) and R2=2k2? Then the resistor on board needs not be changed. Accuracy above 0°C would still be more than a digit per °C.
No, I don't mind at all. It's a great idea to follow standard and accuracy will be good where needed. Thanks!
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Temperature sensor

Post by johu »

New release has the sensor :) with 1k2/2k2 that is
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

That was very quick! Thanks!
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

Does the prius gen 3 inverter have a 47k NTC thermistor on MG2?
I've pull one out of a dead inverter and dunked it in a mug of water, and done some extrapolation and come up with these values:

T R
0 56884
10 51815
20 46745
30 41676
40 36606
50 31537
60 26467
70 21398
80 16328
90 11259
100 6189

I've put them in to the spreadsheet and calculated the ADC values, probably wrong

#define TOYOTAHS \
128 ,\
140 ,\
155 ,\
174 ,\
197 ,\
227 ,\
269 ,\
330 ,\
425 ,\
598 ,\
1008

It's wildly out using EVBMW gen3 board.
processed (1).jpeg
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

Looks like a 47kohm termistor, or close anyway. The resistance specified (47k) is usually at 25 degree celsius.
How have you connected the sensor and what resistors are on your PCB?
image_2021-08-08_085214.png
image_2021-08-08_085214.png (7.44 KiB) Viewed 11629 times
R1 should be 1,2kohm and R2 2,2kohm and Th is the sensor. On early toyota boards you will need to do some patching to get this to work.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

Screenshot 2021-08-08 at 11.57.30 am.png
I don't know what the Toyota has before it gets to the mini Damien/Johannes brain, but this is what's on the Gen 3 board.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

Yes and no. Isn't that for the inverter temperature sensor? MG2_TEMP seem to come from the 50-pin connector to the gate driver board.
To what pin(s) do you connect your MG2 sensor?

Or do I misunderstand and you want to measure the MG2 side of the inverter? I thought you were after the MG2 stator temperature?
That would make sens as the temperatures you have sampled does not exactly match up to what I expected from the motor sensor, as seen below.
mg2t.jpeg
I'll have a look in the spreedsheet and get back.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

I'm trying to add the MG2 heatsink sensor to the firmware.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

To be able to calculate the resistance to temperature relationship I need measurement values at two temperatures. Which of your values are measurements and which is extrapolations?
Do you have any measurement at 25 degrees?
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

https://docs.google.com/spreadsheets/d/ ... sp=sharing
I didn't have a temperature probe, but I did have a 100k NTC from my 3D printer, so took measurements of all 3 at once and looked up the 100k temperature sensor using excel FORECAST to get the temperatures.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

I don't have access to view the spreadsheet.
Is the other end of the NTC connected to +5V or to GND and are there any other connections to GND or +5V via a resistor on the gate driver board?
The circuit on the logic board seem to be only a voltage division to decrease +5V to +3.3V level.

NTC are not the most accurate temperature sensors but it should still provide a resonable value. I think a ordinary household outside thermometer is a better reference. Will proably still be ok though.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

NTC C
5.54k 100.7
7.25k 96.4
9.08k 93.4
11.77k 89.3
13.1k 83.8
13.8k 83.7
16.k 81.1
17k 79.5
18.3k 75.2
22.2k 70.2
24.2k 67.2
25.8k 64.1
28k 58.5
28k 55.7
38.5k 34.3
45k 24.9
51k 9.1

Not sure what's going on with the circuit before the logic board. May I should modify the firmware to be able to output the adc value to get an idea of the value at ambient temperature?
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

I checked my Yaris inverter and I got 4,4V at MG2_temp, resulting in 2,85V at MG2_tmphs_24. Don't know if that helps.
If you want to find out the correct values to add to firmware, the complete circuit is needed. The NTC and all resistors connected to it on the IGBT-driver board.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

How are you working out the ADC values? I'm looking at the motor one now as it's simpler, maybe. The resistance values in the service manual match that of a 50k NTC thermistor datasheet. https://www.te.com/commerce/DocumentDel ... F4050DPHFS
Screenshot 2021-08-13 at 8.50.56 am.png
The voltage divider has a capacitor and that is above my understanding.

Example of 20 degrees, resistance is 62.5k, so (62.5k + 1k + 1k) for R1 but I don't know how to calculate the value for R2 to plug in to Vo= Vs * R2 / (R1 + R2)
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
ZooKeeper
Posts: 507
Joined: Mon Mar 30, 2020 10:23 pm
Location: USA

Re: Temperature sensor

Post by ZooKeeper »

The way I was told to do this for my Weather Station project was to either obtain or calculate the "transfer function" of the sensor, then write that into code with the sensor input tied directly to one of the (RPi) input pins. That worked very well, but I have no clue if this is possible in this code.
Huebner VCU controlling a Gen2 Prius Inverter powering an MGR
"Talent is equally distributed but opportunity is not." - Leila Janah
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Temperature sensor

Post by bexander »

The graph I posted above should be the toyota motor temperature sensor temperature vs resistance.
You then need to reconfigure the circuit board so that you get the same wiring as depicted in the spreadsheet under the "Toyota 47k" tab.
IMG_1630_scale.jpg
The temperature sensor (NTC) should be connected between MG2_STATOR_T1 and GND i.e. in parallel with the 2k2 resistor.
Then just select the toyota motor sensor in the web interface and you should be good.

If you want to do it in another way you need to calculate the expected voltage for any given temperature and then convert that to the corresponding ADC value.
For the connections as above the voltage is 5V*(2200*NTC-resistance/(2200+NTC-resistance))/((2200*NTC-resistance/(2200+NTC-resistance))+1200) and then the ADC value is (voltage from above)/3,3*4096.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Temperature sensor

Post by Bigpie »

Awesome, thanks, I think I should be able to do all this externally to the inverter so I don't have to take it out again. Will add this info to the wiki page once I've got my head around it.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
yaroslav
Posts: 176
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol
Has thanked: 14 times
Been thanked: 5 times

Re: Temperature sensor

Post by yaroslav »

HI. I want to add a new engine temperature NTC sensor EPCOS B57861-S 103-F40 these sensors are convenient to embed in the stator winding of the engine. I filled out the table.
Attachments
temp_sensors.ods
(95.09 KiB) Downloaded 130 times
Post Reply