Page 1 of 1

Understanding the HT Accelerometer Sensor

Posted: 31 Dec 2012, 05:59
by ggrinton
After being given a Hitechnic Accelerometer Sensor by my dear family for Christmas, I'm trying to make sense of it. Using the test program from the HT web page, written to use the ReadSensorHTAccel routine in BRICX, I see the following strange behaviour.
  • X varies as I rotate the sensor horizontally, returning 0 at approximately north, then increasing to 511, flipping to -511 and increasing to -307 just before returning to zero at the original position (a total range of 818). Tilting the sensor has no effect on the reading.
  • Y always returns a value of 0 or 4.
  • Z always returns a value related to 2*X, as follows:
    • -512<x<-256 z=2*x+1024
      0<x< 256 z=2*x
      256<x<512 z=2*x-1024
None of that seems consistent with the technical description.
I'd be grateful for any comments from someone who is familiar with this sensor.

Thanks.
Geoffrey

Re: Understanding the HT Accelerometer Sensor

Posted: 31 Dec 2012, 16:59
by afanofosc
I have attached a zip with three sample programs that use the ReadSensorHTAccel API function in NXC. It may be that you are getting confused by the way the very trivial sample program draws numbers to the LCD and does not clear the line or the screen between draw operations. This can lead to, e.g., the number 902 being overwritten by the number 4 which will show as 402 on the screen since the 0 and the 2 are left there on the subsequent draw operation. Similarly, e.g., 350 could be overwritten by -4 which would look like -40 or -724 could be overwritten by 6 which would look like 624.

The htaccel.nxc sample program works best if you have the latest BricxCC/NBC test release installed along with the latest enhanced firmware build running on your NXT.

John Hansen
htaccel.zip
(3.59 KiB) Downloaded 310 times

Re: Understanding the HT Accelerometer Sensor

Posted: 31 Dec 2012, 17:02
by afanofosc
I should add, that it is possible that you have a defective sensor - especially if you can't get the Y axis value to return anything other than 0 or 4 regardless of how you rotate the device.

John Hansen

Re: Understanding the HT Accelerometer Sensor

Posted: 01 Jan 2013, 06:16
by ggrinton
Thanks John. I was using the test program from the HiTechnic web page, but get the same results using NXT-G. But I appreciated your helpful advice. I'm suspecting a faulty (or mislabelled?) unit, and will work with HiTechnic support.

Geoffrey