View unanswered posts | View active topics It is currently Sun Jul 31, 2016 5:45 am

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Problem with HiTechnic Acceleration sensor
Author Message
Rookie

Joined: Sat Mar 31, 2007 6:11 pm
Posts: 3
Problem with HiTechnic Acceleration sensor
I've got HiTechnic acceleration sensor. Couldn't find any data on it aside from little paper that came with it saying that different addresses contain lower and upper bits. But still doesn't explain how positive or negative acceleration is denoted. Is the upper most bit a sign value?

Sat Mar 31, 2007 6:15 pm
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

To get started with minimal effort, setup the sensor as a standard ultrasonic sensor. That will give you "X" axis values in the range 0 to 255. The following code snipped will give you the signed value.
 Code://// Convert unsigned 0..255 to range -512 to +5111 (i.e. signed 10-bits)//short nSignedValue ;nSignedValue = SensorValue[xx]; // 'xx' is the sensor numbernSignedValue <<= 8;nSignedValue >>= 6;

You'll have to do a bit more "work" to get all three axis. First, you need to write a task that will background poll the sensor for all six-bytes of data and then convert to ten bit values. A sample program that you can simply "#include" in your program should be available soon.

Tue Apr 03, 2007 9:06 am
Rookie

Joined: Sat Mar 31, 2007 6:11 pm
Posts: 3

Thanks Dick!

But I actually want to understand the logic behind it all.

Here's what I did (pseudoCode)
[code]

int upperPart = readSensorRegister(42H); //upper 8 bits
int lowerPart = readSensorRegister(45H); //lower 2 bits
if (upperPart>128)
{
//sign is negative
return (-1)*((upperPart-128)<<4 + lowerPart);
} else
{
return (upperPart<<4)+lowerPart;
}
[/code]

The thing is - if I hold a sensor so that it is positive 1g then I get 200
But if I hold it upside dows - I get 300 value.

Is my path above wrong in making 10-digit signed value?

Tue Apr 03, 2007 8:51 pm
Rookie

Joined: Wed Apr 04, 2007 3:38 pm
Posts: 1

I found the following to work: Do the addition (with shifting) first. Then decide, if the value is above 511. If this is the case, then subtract 1024. This gives the correct results.

Wed Apr 04, 2007 3:42 pm
Rookie

Joined: Sat Mar 31, 2007 6:11 pm
Posts: 3

[quote="eivets"]I found the following to work: Do the addition (with shifting) first. Then decide, if the value is above 511. If this is the case, then subtract 1024. This gives the correct results.[/quote]
Thanks man! This actually works (and makes sense too)!

Fri Apr 06, 2007 8:47 pm
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

I posted a more comprehensive reply on the forums at nxtasy.org. DO a search on those forums for "RobotC acceleration". There's also a sample program for the HiTechnic accelerometer on that site.

The sample program -- Nxt Hitechnic Accelerometer.c -- is included in release 1.05 (firmware 7.15) of RobotC for NXT.

Hope this helps.

Sun May 06, 2007 11:43 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 6 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning