2016-08-08 05:39 AM
Hello folks,
I am trying to implement the LIS3MDL magnetometer. I have a small confusion about its configuration. It have option of +-4 gauss upto +-16 gauss. So for the full scale configuration, i should configure to +-4 gauss or +-16 gauss ? #!stm322016-08-08 08:37 AM
Let's try to keep things related in topic by a single individual in one thread. [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Magnetometer&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=7]Other Thread
You'd pick the smallest full-scale range that you expect to see so as to have the finest granularity in the measurements.If you don't know what the range is that you are likely to see, then you should experiment under expected use conditions to come to some determination. I would perhaps have it as something I could configure, and then have the ability to scale the measurements received into common units, in a floating point representation with more bits and range so the down stream code is agnostic to what the hardware is, and what it is doing.2016-08-09 01:09 AM
Since the temperature sensor works between -40 to +85 C, how can I show the temperature on the LCD. Is it just by converting 2's complement into hexadecimal and display on the LCD ?
Is there more documentation on temperature sensor inside LIS3MDL?2016-08-09 07:41 AM
Also, what should be the values on the register X axis, Y axis and Z axis if configured in continuous configuration and +-8 gauss ? Do I need to convert the values which are 2s complement to hexadecimal ?
2016-08-09 08:31 AM
Do I need to convert the values which are 2s complement to hexadecimal ?
You seem to have some serious confusion about basic numeric representation.From the manual, if I had Z as an int16_t (signed 16-bit integer) thenfloat z = (float)Z / 3421.0f; // Scale Z gauss for +/-8 range. Units in Gauss16384 -> 0x4000 -> 4.78924-16384 -> 0xC000 -> -4.789242016-08-09 08:41 AM
Since the temperature sensor works between -40 to +85 C, how can I show the temperature on the LCD. Is it just by converting 2's complement into hexadecimal and display on the LCD ? Is there more documentation on temperature sensor inside LIS3MDL?
I don't understand this hexadecimal angle here. The numeric representation is in binary, and you want output in base 10 not base 16Manual says it reports in 1/8 degree increments, ie 0.125 of a degreeWhere TEMP is int16_tfloat temp = (float)TEMP / 8.0f;or float temp = (float)TEMP * 0.125f;sprintf(buffer,''%7.3f'', temp);2016-08-10 12:54 AM
Sorry, I am new to programming. Thank you for replying.
I checked with 2s complement interpretation.So I am reading the temperature register by int16_t temp_data = (temp_reg_M<< 8) + temp_reg_L;if it is positive then MSB(15th bit) will be 0 and if the temperature is negative then the MSB will be 1. If the value is negative then I will take 2s complement (flip the bits and add 1) to get the hex value. Then I divide the temperature value with 8.0f.float final_temp = (float)TEMP / 8.0f;
and then display on the UART. Did I get it right ?