1
\$\begingroup\$

I am having a difficult time understanding some of accelerometer register entries, what exactly I need to write to them and what do they mean.

To start with, I am trying to program LIS2DE12 accelerometer, I am working with wake-to-sleep, sleep-to-wake function which basically puts accelerometer to low power mode after some time passes and after significant motion, if it passes threshold value, it will wake up for preset time, after which it will again go to low power mode. I configured sensor for this task, but I don't know what values should I write to ACT_DUR (3Fh) and ACT_THS (3Eh) registers. Explanation is unclear for me:

Register descriptions for ACT_THS and ACT_DUR

Image source: ST - LIS2DE12 accelerometer datasheet

Let's take ACT_DUR for example, I know that LSB is Least Significant Bit, which is right-most bit in this register, so writing just 00000001 to the register would mean that accelerometer would be awake for (8 * 1 * 1 + 1) / ODR time units? What if I write 11111111 to the register? How long will it be awake then and what will the equation look like? Also, could someone explain this equation from Table 87 in the datasheet (shown above)?

equation from table 87 in the datasheet - ACT_DUR description

Should I just fill in my ODR and how many bits are written to this register?

It is overall confusing when I see these LSB registers. What does it mean LSB when I can fill up to 8 bits in register? Do all bits count as LSB? If 1 LSB is 16 mg, then what value would I get when I write for example 11001101? LSB is 1 but second bit is 0, or should I take dec number 205 and multiply it by 16 mg to get my value?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Ok, starting with the convention of using LSb, this is telling you the value of 1 Least Significant bit, from which the register scales. So a simple explanation, let's say I have a 4-bit register Time[3:0].
If 1 LSb = 1 second, my possible values of time range from 0s, to (24-1)s, ie 0 to 15s.
If something changed the LSB value to 2s, my values are now 0 to 30s, in 2s steps.
Or, if LSb = 0.5s, my range is now 0 - 7.5s.
In short yes, you multiply the decimal value of the register, by the value of LSb to get the value it represents

The normal logic, where each bit is always worth 2x the previous bit always follows, but the whole register scales. You end up doing this for all sorts of things, because scaling a binary register is orders of magnitude easier than using floating point maths - if that's even possible. For this accelerometer, where 1 LSb = 16 mg if FS = -+2g, then a value of 205 in the register would equal 205 x 16 mg = 3.28g. This leads nicely onto my next point, that you need to bear in mind a register may be holding a signed number. For an 8-bit signed number, values range from -128 to 127, so actually, the value would be -77*16mg = -1.232g

In this case, you have registers that scale differently depending on how you've set other registers in the device. Acth, has 4 different scales, depending on the 4 different possible values for the FS (full scale) acceleration measurement.
ActD is admittedly a bit odd. ODR, is the operating data rate (I'm assuming that's what the acronym stands for) and you can find it on table 30. Let's start by making it easy and assume the value is 1Hz. Note that it's the real value, not the binary value in the register, as we need to get to a value in seconds, so using 1/Hz gets us that.
At this point, I think the manufacturer should really have bothered to put a sentence explaining the register because it's a bit ambiguous. There's LSb in the equation, making it seem cyclic. I can't figure it out for sure, but I would guess, the sleep-to-wake duration
t = (8 * (ActD+1)) / ODR
where ActD is the value in the register, in decimal, and ODR is the value the register represents. So if ODR is 1Hz, and the value of ActD is 0, then the duration is 8s. Although I have to repeat that this is my best guess, please don't proceed under the assumption I've got this right.
I think probably part of what the equation is trying to convey, is that the duration will never be zero even if you enter a zero into the ActD register. LSb+1 I think is conveying that a zero value in the register is 1, 1 is 2, and so on.

It's not clear, and I'd be verifying this first thing if I was using these devices.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for explanation! Some of these datasheets really lack in explanation for new guys like me, even such basic stuff. Regarding the ActD, I have tried reverse calculate the unknown value of 1[LSB] by writing random value to register, then calculating actual time in us, how long does awake state takes. After that I did some averaging and followed these steps: awake_time/1_LSB_value=value_to_write_to_reg, 1_LSB_value=(8*X+1) / ODR. Since I know approximate awake_time, value I wrote to reg, ODR, I calculated 1_LSB_value and then found X. This kind of worked but your method seems more legit \$\endgroup\$
    – Dominykas
    Jun 23, 2023 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.