/** * hitechnic-accelerometer.h provides an API for the HiTechnic Acceleration Sensor. This program * demonstrates how to use that API. * * Changelog: * - 0.1: Initial release * - 0.2: Make use of new API calls * - 0.3: Better comments * - 0.4: Fixed display line (thanks Dave) * - 0.5: Removed single axis functions, they're no longer in the driver\n * Removed common.h from includes * * Credits: * - Big thanks to HiTechnic for providing me with the hardware necessary to write and test this. * * License: You may use this code as you wish, provided you give credit where it's due. * * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER.

The code complies, but it doesn't seem to do anything useful. It only looks like a program that outputs text to the screen.

I get the error message from line 55 whenever I run it. I don't know what "HTACredAllAxis()" does. When I comment that entire if-statement out, I only get a screen that reads off all vales as zeros.I don't see where in the program any of the "_x_axis" "_y_axis" or "_z_axis" variables actually read in numbers.

This code also references "hitechnic-accelerometer.h", but I cannot find this library anywhere in my pre-installed files. I am wondering if that could be part of the problem, but since the code compiles, I assume the program got any information it needed about hitechnic-accelerometer.h.

Any help with this, or suggestions about writing my own code for the accelerometer?

Wed Mar 19, 2014 11:14 am

BurningLights

Professor

Joined: Sat Aug 31, 2013 9:15 amPosts: 256

Re: Hi Technic Accel Sensor

AlexJ wrote:

The code complies, but it doesn't seem to do anything useful. It only looks like a program that outputs text to the screen.

That is correct. It is meant as a test program, so that you can see what kind of values you get from the sensor.

AlexJ wrote:

I get the error message from line 55 whenever I run it. I don't know what "HTACredAllAxis()" does. When I comment that entire if-statement out, I only get a screen that reads off all vales as zeros.I don't see where in the program any of the "_x_axis" "_y_axis" or "_z_axis" variables actually read in numbers.

The axis variables get values put into them by HTACreadAllAxis(). That function gets the latest values from the accelerometer sensor and stores them into the variables you pass into it. The fact that you're always getting the error message means that something is wrong such that the NXT is not able to read from the sensor. Is your sensor plugged into port 1?

Sorry what I meant by "doesn't seem to do anything useful" was that I believed it ONLY outputted static text, not actual senor values.

I ran this program with the hi tech compass sensor. The program worked with that sensor (did not display an error message, and displayed values that changed).(I know the values for the compass sensor would be nonsensical, but I wanted to see it if would run).

When I wrote my own program using just SensorRaw(S1) in an while loop, the accelerator gave a reading (1023.0), but it never changes when I move the sensor around, unlike with every other sensor. Is this because a senor with three outputs won't react well with SensorRaw() or is it an indication the sensor is broken? If so, how would I go about testing this?

Who is online

Users browsing this forum: No registered users and 2 guests

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