accel sensor class does not exist!

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

accel sensor class does not exist!

Postby nat1 » Thu Oct 25, 2007 12:53 am

hi

Is there a class to use the Hitechnic accel sensor not the tilt funticon but the the accel fun. beacuse I cant find it ? btw I'm using 0.4
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby lawrie » Thu Oct 25, 2007 12:51 pm

The TiltSensor class was originally written for the mindsensors version of the Acceleration sensor.

It should work for the HiTechnic sensor as well. It returns an 8-bit value using registers, 0x42, 0x43 and 0x44. For the HiTechnic sensor, you can get an extra 2 bits of precision by reading registers 0x45, 0x46 and 0x47 - see the C code on the HiTechnic site.

If you need this you can call getData to get one byte at a time, or all 6 in one go if you prefer.

As I understand it, there is no difference between Tilt and Acceleration values - they are the same thing. We called it TiltSensor as the name is shorter.
lawrie
leJOS Team Member
 
Posts: 919
Joined: Mon Feb 05, 2007 1:27 pm

Postby nat1 » Thu Oct 25, 2007 9:05 pm

hi

The book maximum lego nxt says there are seprate comands for reterving the tilt and accl values.
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby gloomyandy » Thu Oct 25, 2007 10:47 pm

Hi Nat,
Well the HiTechnic site says that there is only one set of registers for the device....
http://www.hitechnic.com/index.html?lang=en-us&target=d19.html
The Lejos class currently reads three of them (the ones providing the most significant byte). As Lawrie mentioned you can get higher precision by using the other 3 registers as well (gets you 2 more bits per axis). Perhaps you could provide more detail about the differences described in the book....

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3967
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby nat1 » Fri Oct 26, 2007 1:13 am

hi

sorry, these are the commands in the book on page 104

public int getXTilt
public int getYTilt
public int getZTilt

those are the tilt comms then there are the accl comms

public int getXAccel
public int getYAccel
public int getZAccel

the X Y and Z are the axis's for the sensor. The comms are under the Tiltsensor class.
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby lawrie » Fri Oct 26, 2007 9:40 am

Brian wrote the book before we had finished leJOS (to meet publishing deadlines) so not everything in it is exactly how leJOS turned out.

I can add the getX[Y/Z]Accel methods to the TiltSensor class but for the HiTechnic sensor, they will return the same as getX[Y/Z]Tilt.

I will improve the TiltSensor class for the next release so that it tests to see if you have a HiTechnic or a Mindsensors Acceleration Sensor and returns the higher precision values.

The Mindsensors Acceleration sensor has a lot more registers than the HiTechnic one and has different values for acceleration and tilt. I think the tilt value is just a normalized lower-precision version of the acceleration value.

The Mindsensors version also return X/Y/Z offsets and range. I am not sure how these are intended to be used. Mindsensors sell several acceleration sensors with different ranges (maximum g value),and also allow callibration of the sensor, so these offsets and ranges must be related to this, but it is not clear to me exactly how they work without experimentation.
lawrie
leJOS Team Member
 
Posts: 919
Joined: Mon Feb 05, 2007 1:27 pm

Postby nat1 » Fri Oct 26, 2007 5:51 pm

hi

that would be great, but for now how would I use the current comms to find the g's? What I want to do is use the sensor to find the g's while my dad is driving around.
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby lawrie » Fri Oct 26, 2007 9:34 pm

Use getXTilt and divide by 50 or use getData and multiply register x42 by 4 and add it to register x45 and then divide by 200.
lawrie
leJOS Team Member
 
Posts: 919
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Fri Oct 26, 2007 10:49 pm

By the way, when formula 1 drivers corner they generate forces up to 4g. If your dad corners this fast, you will not be able to measure the acceleration, as the HiTechnic sensor only goes up to 2g :D
lawrie
leJOS Team Member
 
Posts: 919
Joined: Mon Feb 05, 2007 1:27 pm

Postby bbagnall » Sat Oct 27, 2007 5:37 pm

Hi Nat/Lawrie,

The methods mentioned in the book are still valid for the iCommand API and the mindsensors.com sensor.

With the mindsensors sensor it delivers both tilt data and acceleration data at the following addresses:

X_TILT = 0x42;
Y_TILT = 0x43;
Z_TILT = 0x44;

X_ACCEL_LSB = 0x45;
X_ACCEL_MSB = 0x46;
Y_ACCEL_LSB = 0x47;
Y_ACCEL_MSB = 0x48;
Z_ACCEL_LSB = 0x49;
Z_ACCEL_MSB = 0x4A;

Lawrie, we could adopt the iCommand code easily for the leJOS NXJ version of the sensor. But if there are differences with the HiTechnic version we could just check the product ID and have it react accordingly, like the CompassSensor.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff