-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temp sensors improvements #4282
Temp sensors improvements #4282
Conversation
2b2b3b0
to
59f64b2
Compare
Your a work horse shelli. ; ) These are some idea's to define the External temperature sensor from the Internal barometer temperature reading. |
59f64b2
to
00d484e
Compare
@kardon18 Good idea it will help save space on the screen by replacing labels. Could you make one for MPU and baro temperature ? |
I was hoping to have a descriptive icon for the temperature of the device we are measuring. That way we can look at a glance. When you stated MPU. I assume you were refering to the Accelerometer/Gyro. Not "Micro Processor Unit". Being that both can use internal components to read temperature. Hope that's okay. If not, let me know. |
if its going to be the processor temp, then why MPU not CPU ?
…On Mon, 28 Jan 2019 at 19:45, kardon18 ***@***.***> wrote:
@shellixyz <https://github.com/shellixyz> Good idea it will help save
space on the screen by replacing labels. Could you make one for MPU and
baro temperature ?
I was hoping to have a descriptive icon for the temperature of the device
we are measuring. That way we can look at a glance.
I'm glad you included an ALARM for over temperature in the code 👍
When you stated MPU. I assume you were refering to the Accelerometer/Gyro.
Not "Micro Processor Unit". Being that both can use internal components to
read temperature.
That being said. I wrote MPU and IMU. Because its impossible to fit "MPU"
across 12 pixels. Due to the width of the 'M". But with 'I" it will fit.
Hope that's okay. If not, let me know.
[image: barometer temperature]
<https://user-images.githubusercontent.com/43928973/51875739-416c0c00-23ba-11e9-922d-43d2c3cd8ad1.PNG>
[image: imu temp]
<https://user-images.githubusercontent.com/43928973/51875757-49c44700-23ba-11e9-97ff-29158aceb188.PNG>
Internal temp sensor.zip
<https://github.com/iNavFlight/inav/files/2805518/Internal.temp.sensor.zip>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4282 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABbRAVLOssdJUTpKbG6O4dUh_B9ZjxEKks5vH5mSgaJpZM4aVksu>
.
|
@kardon18 MPU is for Motion Processing Unit (gyro + accelerometer). IMU is good 👍. Thank you the new symbols will fit the purpose. @wx4cb On top of the possibility to connect dedicated temperature sensor we are reading the gyro/acc chip and baro temperature. We are not reading MCU temp. Maybe it is possible, I don't know. |
00d484e
to
3a83118
Compare
We could have a generic temperature character on page 1 and specific ones on page 2. |
I suppose that it depends on how many sensors the model will have on it. What do you guys have in mind for the selection ability? The user would need the ability to select -
|
I was just going to add an option to the |
I think that's perfectly fine. 👍 As you spoke of earlier. To add more sensors, it would require the use of a DS2482-100, I2C interface chip. So most users wouldn't go to that much effort. Although. I do remember reading on the RCG ET Vector forum. Many people requested the desire of an expansion of its temperature sensor ability, out to 4 or 6. So the motor temperatures on their multirotors could be measured. But there is away the possibility for expansion in future releases. |
To be honest adding a DS2482 is really simple with the help of a SO8 breakout and cheap. You can get 10 of them for $5 on AliExpress |
If you are wishing to monitor motors, personally i would suggest blheli32
and wait for the telemetry to get done.
…On Wed, Jan 30, 2019, 17:27 kardon18 ***@***.*** wrote:
I was just going to add an option to the temp_sensor command to chose
between a char to display and the label. Take a look at the description I
added the current syntax for the command.
I think that's perfectly fine. 👍
In reality, most users will be more than happy to have one external temp
sensor. With the ability choose sensor label, and give it a icon for
recognition.
As you spoke of earlier. To add more sensors, it would require the use of
a DS2482-100, I2C interface chip. So most users wouldn't go to that much
effort. Although. I do remember reading on the RCG ET Vector forum. Many
people requested the desire of an expansion of its temperature sensor
ability, out to 4 or 6. So the motor temperatures on their multirotors
could be measured.
But there is away the possibility for expansion in future releases.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4282 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABbRASBLmqszRdil-4ro1N4j2_0qKEnHks5vIhxqgaJpZM4aVksu>
.
|
BLHeli32 does not monitor motors temperature. The temperature of the ESC itself yes, the motor no. |
I realise that, that's what I meant, but i have no clue how you would measure the actual "motor" temp as it's kinda... spinning really fast lol :D |
3a83118
to
2ce4cb8
Compare
What gets hot is the base not the bell. You can put a sensor in contact with the motor base. |
src/main/telemetry/ibus_shared.c
Outdated
@@ -141,8 +141,12 @@ static uint8_t dispatchMeasurementRequest(ibusAddress_t address) { | |||
} | |||
#endif | |||
if (SENSOR_ADDRESS_TYPE_LOOKUP[address].value == IBUS_MEAS_VALUE_TEMPERATURE) { //BARO_TEMP\GYRO_TEMP | |||
if (sensors(SENSOR_BARO)) return sendIbusMeasurement2(address, (uint16_t) ((DEGREES_TO_CENTIDEGREES(getCurrentTemperature()) + 50) / 10 + IBUS_TEMPERATURE_OFFSET)); //int32_t | |||
else { | |||
/*if (sensors(SENSOR_BARO)) return sendIbusMeasurement2(address, (uint16_t) ((DEGREES_TO_CENTIDEGREES(getCurrentTemperature()) + 50) / 10 + IBUS_TEMPERATURE_OFFSET)); //int32_t*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I can suggest, it can be:
int16_t temperature;
if (sensors(SENSOR_BARO)) {
getBaroTemperature(&temperature);
} else {
getMPUTemperature(&temperature);
}
return sendIbusMeasurement2(address, (uint16_t) ((temperature + 50) / 10 + IBUS_TEMPERATURE_OFFSET));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not, done, it now reports baro temp if available, IMU temp otherwise
28cec6f
to
11bda67
Compare
src/main/telemetry/ibus_shared.c
Outdated
} | ||
int16_t temperature; | ||
const bool temp_valid = sensors(SENSOR_BARO) ? getBaroTemperature(&temperature) : getIMUTemperature(&temperature); | ||
if (!temp_valid || (temperature < -50)) temperature = -50; // Minimum reported temperature is -5°C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not realy, ibus temperatue sensor minimum is 40 deg.
0=-40.0 C, 400=0.0 C, 65535=6513.5 C
so proposes change -50 to -400
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I forgot about the offset
int16_t temperature; | ||
const bool temp_valid = sensors(SENSOR_BARO) ? getBaroTemperature(&temperature) : getIMUTemperature(&temperature); | ||
if (!temp_valid || (temperature < -50)) temperature = -50; // Minimum reported temperature is -5°C | ||
return sendIbusMeasurement2(address, (uint16_t)((temperature + 50) / 10 + IBUS_TEMPERATURE_OFFSET)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if getBaroTemperature and getIMUTemperature return temperature in decidegree (0.1) no need to be calculated
Just (uint16_t)(temperature + IBUS_TEMPERATURE_OFFSET)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't match the old code:
return sendIbusMeasurement2(address, (uint16_t) ((DEGREES_TO_CENTIDEGREES(getCurrentTemperature()) + 50) / 10 + IBUS_TEMPERATURE_OFFSET));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesterday I compiled and uploaded the code from Your branch with minimum -400 and (uint16_t)(temperature + IBUS_TEMPERATURE_OFFSET) and got the correct temperature values for both IMU and baro. For baro get -40.0 for a first second after power up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I didn't touch the code reading the baro temperature. Not a big issue I think
342d52e
to
8e12f12
Compare
src/main/drivers/1-wire.c
Outdated
_1WireDev_t ds2482Dev; | ||
#endif | ||
|
||
void _1WireInit(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our convention is to use chip name as a file name and function name prefix.
{ | ||
bool parasitic_power = ds18b20_parasitic_powered_present(_1WireDev); | ||
if (parasitic_power) return false; | ||
bool ack = ds2482_1wire_reset_and_skip_rom(_1WireDev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this explicit dependency. We should either make 1-wire driver abstracted and make ds18b20 call high-level 1-wire read/write functions or merge the ds18b20 with ds2482.
return ds2482_1wire_write_byte(_1WireDev, DS18B20_START_CONVERSION_CMD); | ||
} | ||
|
||
bool ds18b20_wait_for_conversion() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In functions waiting for external sensor to complete the operation protothreads play quite nicely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I need to take a look into it because even though everything works fine on the bench after checking the protocol timing reading the sensor values takes too much time. The reading process will need to yield before all the sensors are read or even during addressing/reading. 1-Wire is pretty slow. Only addressing the sensor takes 7.7ms. Reading the temperature value then takes 8.1ms. So we are talking a bit less than 16ms per sensor to read back the temperature value. Fortunately we can send the "start conversion" to all the sensors at once and that only takes ~2.2ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, even 2.2ms is too much to do in one iteration. I think we should really think into making this ptThreaded eventually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resetting the 1-Wire bus (needed before every command) is taking 1345µs in itself so it looks like we will need to. We need to send the reset command (54µs) then yield and the next iterations check if the bus has been reset (54µs) then send a new command
src/main/drivers/1-wire.h
Outdated
extern _1WireDev_t ds2482Dev; | ||
#endif | ||
|
||
void _1WireInit(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OneWireInit()
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes I don't really like starting names with _
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
8e12f12
to
b0cca40
Compare
that bad data on first read is entirely possible depending on the sensor
they're using. some of the stuff we have for work does the same thing at
first power on takes them a couple seconds to stabilise.
…On Sun, 3 Feb 2019 at 08:09, hali9 ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/telemetry/ibus_shared.c
<#4282 (comment)>:
> @@ -141,15 +141,10 @@ static uint8_t dispatchMeasurementRequest(ibusAddress_t address) {
}
#endif
if (SENSOR_ADDRESS_TYPE_LOOKUP[address].value == IBUS_MEAS_VALUE_TEMPERATURE) { //BARO_TEMP\GYRO_TEMP
- if (sensors(SENSOR_BARO)) return sendIbusMeasurement2(address, (uint16_t) ((DEGREES_TO_CENTIDEGREES(getCurrentTemperature()) + 50) / 10 + IBUS_TEMPERATURE_OFFSET)); //int32_t
- else {
- /*
- * There is no temperature data
- * assuming ((DEGREES_TO_CENTIDEGREES(getCurrentTemperature()) + 50) / 10
- * 0 degrees (no sensor) equals 50 / 10 = 5
- */
- return sendIbusMeasurement2(address, (uint16_t) (5 + IBUS_TEMPERATURE_OFFSET)); //int16_t
- }
+ int16_t temperature;
+ const bool temp_valid = sensors(SENSOR_BARO) ? getBaroTemperature(&temperature) : getIMUTemperature(&temperature);
+ if (!temp_valid || (temperature < -50)) temperature = -50; // Minimum reported temperature is -5°C
+ return sendIbusMeasurement2(address, (uint16_t)((temperature + 50) / 10 + IBUS_TEMPERATURE_OFFSET));
Yesterday I compiled and uploaded the code from Your branch with minimum
-400 and (uint16_t)(temperature + IBUS_TEMPERATURE_OFFSET) and got the
correct temperature values for both IMU and baro. For baro get -40.0 for a
first second after power up.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4282 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABbRAbKbE3J_Y3VKNFzZMZRPxHZmG2XAks5vJt-EgaJpZM4aVksu>
.
|
@wx4cb What are talking about ? |
@shellixyz i was replying to a comment that i got theough email about -40 for a couple seconds at startup. Dunno why it appeared here im guessing it was in another thread |
07d10e0
to
63a0a8f
Compare
- Support for multiple LM75 sensors - Support for the DS18B20 sensors - CLI command temp_sensor to configure sensors - Logging of all temperature sensor values - Display of all temperature sensor values on the OSD with support for alarms - New MSP messages to query and set sensor configuration and read temperatures
63a0a8f
to
4c33402
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have an action item to refactor it further, but in general LGTM.
@shellixyz I was going to wire up a few DS18B20's, in anticipation of the 2.1 release. |
@kardon18 You only need one pull-up resistor. Some FC already include a pull-up resistor on the i2c pin. I'd try it without the pull-up resistor and then add one if needed. A resistor only costs about a cent, and having a few common sizes isn't a bad idea. You could probably remove one from an old piece of electronics even. It doesn't need to be 4.7k, 1k to 10k would probably work just as well. I need to see if the F4/F7 has internal pull-up resistors. Many microcontrollers do. I know the Arduino's Amtel ATmega328 microprocessor has the ability to activate a pull-up resistor on each pin. If the F4/F7 also has this, it could be activated via code. |
That's what I was wondering. If the F4/F7 does have internal pull-up resistors. Will they be used. If not. I'll just solder a 0603 SMD resistor across the VCC and Data pins on the DS18D20. To save space and keep it tidy. |
@kardon18 It does appear that the F4/F7 have internal pull-up resistors. As I would classify temp readings as non-critical, using the known weak internal pull-up resistors would probably be fine (although would need to be activated via software, which I don't believe is happening). You may want to see if your FC design already includes an external resistor. Or, if you have something else already on i2c it probably has a pull-up resistor of it's own, so you don't need another. I'd try it without and only add the resistor if it doesn't work or is unreliable. |
@kardon18 On the I²C side some FC have pull-up resisors, some don't, you have to check on the documentation or with a multimeter. I know Matek FCs already have pull-up resistors on the I²C bus, Omnibus FCs don't. If your FC doesn't have pull-up resistors you have to add them. One for the SCL line and one for SDA to 3.3V, value between 1k and 4.7k. Higher values should work but are not recommended unless the I²C bus is very short. On the 1-Wire side you need a pull-up resistor too, same range of values between VCC and the data line. For now the 1-wire parasitic power mode isn't supported you need to wire VCC to the sensors. |
Closes #3844
temp_sensor
to configure sensorsSyntax of the
temp_sensor
command:temp_sensor reset
to reset the temperature sensor configurationtemp_sensor index type address alarm_min alarm_max label
. Max label length 4 chars. Type: 0=NONE, 1=LM75, 2=DS18B20Configurator part: iNavFlight/inav-configurator#670