Understanding the HT Accelerometer Sensor

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
ggrinton
Posts: 16
Joined: 24 Feb 2012, 12:18

Understanding the HT Accelerometer Sensor

Post 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
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Understanding the HT Accelerometer Sensor

Post 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 316 times
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Understanding the HT Accelerometer Sensor

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
ggrinton
Posts: 16
Joined: 24 Feb 2012, 12:18

Re: Understanding the HT Accelerometer Sensor

Post 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
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests