View unanswered posts | View active topics It is currently Thu Oct 18, 2018 10:20 am






Reply to topic  [ 8 posts ] 
HTAC--HiTechnic Accelerometer/Tilt Sensor Help 
Author Message
Rookie

Joined: Sun Dec 27, 2015 7:50 pm
Posts: 11
Post HTAC--HiTechnic Accelerometer/Tilt Sensor Help
I just recently got a Hitechnic Accel sensor. I have looked around a lot, but I still can't find out how to read all inputs from the sensors. I know SensorValue() won't work. What is used to get all information from the Accel Sensor?

Also, I have tried the sample program for the Sensor, but it won't compile. Here is the Code:

Code:
#pragma config(Sensor, S1,     HTAC,                sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/**
 * 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 4.10 AND HIGHER

 * Xander Soldaat (xander_at_botbench.com)
 * 20 February 2011
 * version 0.5
 */

#include "hitechnic-accelerometer.h"

task main () {
  displayCenteredTextLine(0, "HiTechnic");
  displayCenteredBigTextLine(1, "Accel");
  displayCenteredTextLine(3, "Test 1");
  displayCenteredTextLine(5, "Connect sensor");
  displayCenteredTextLine(6, "to S1");
  sleep(2000);

  playSound(soundBeepBeep);
  while(bSoundActive) sleep(1);

  // Create struct to hold sensor data
  tHTAC accelerometer;

  // Initialise and configure struct and port
  initSensor(&accelerometer, S1);

  while (true) {
    eraseDisplay();

    // Read all of the axes at once
    if (!readSensor(&accelerometer)) {
      displayTextLine(4, "ERROR!!");
      sleep(2000);
      stopAllTasks();
    }

    displayTextLine(0,"HTAC Test 1");
    displayTextLine(2, "   X    Y    Z");

    displayTextLine(3, "%4d %4d %4d", accelerometer.x, accelerometer.y, accelerometer.z);
      // Alternatively, you can read them like this:
    displayTextLine(4, "%4d %4d %4d", accelerometer.axes[0], accelerometer.axes[1], accelerometer.axes[2]);
    sleep(100);
  }
}


The compiler found tons of errors, including:

**Severe*:Couldn't open '#include' file 'hitechnic-accelerometer.h' (Line 28)
**Error**:Undefined variable 'tHTAC'. 'short' assumed.
**Error**:Expected->';'. Found 'accelerometer'
**Error**:Undefined variable 'accelerometer'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'initSensor'.
**Error**:Undefined procedure 'readSensor'.
**Error**:'accelerometer' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'x'
**Error**:Expected->';'. Found 'x'
**Error**:Undefined variable 'x'. 'short' assumed.
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found 'y'
**Error**:Undefined variable 'y'. 'short' assumed.
**Error**:Expected->';'. Found 'z'
**Error**:Undefined variable 'z'. 'short' assumed.
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated
**Error**:'accelerometer' is not a reference to a 'struct'
**Error**:')' missing. Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'axes'
**Error**:Expected->';'. Found 'axes'
**Error**:Undefined variable 'axes'. 'short' assumed.
**Error**:LValue for '[]' operator must be a pointer
**Error**:'[]' operator requires pointer value on left hand side [2].
**Error**:Expected->';'. Found ','
**Error**:Unexpected ',' during parsing
**Error**:Missing ';' before ')'
**Error**:Unexpected ')' during parsing
*Warning*:Meaningless statement -- no code generated

Is the sample code outdated, or is there something else wrong?
I would really appreciate it if you could tell me how to read all the outputs from the Hitechnic Accelerometer/Tilt Sensor.
Thank you!


Mon Dec 28, 2015 6:21 pm
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
So where did you put the.h file?


Mon Dec 28, 2015 7:44 pm
Profile
Rookie

Joined: Sun Dec 27, 2015 7:50 pm
Posts: 11
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
To tell the truth, I really don't know. I don't think I even have the file.
I'm mainly trying to figure things out, so I don't know much.
So, what is the file, where should it be, and where can I find it?


Mon Dec 28, 2015 9:18 pm
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
Okay so what is happening is there is an additional file required to work the sensor. The first error you have is ROBOTC saying it can't fine the file, the rest of the errors are because ROBOTC can't find the functions and variables the file would have created.

Download this file and put it in the same folder as the sample program.
http://botbench.com/driversuite/hitechn ... ource.html


Tue Dec 29, 2015 12:38 pm
Profile
Rookie

Joined: Sun Dec 27, 2015 7:50 pm
Posts: 11
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
All right, that makes sense. The program is trying to "#include" the "hitechnic-accelerometer.h".

However, I have that file, and it seems to be in the right folder too. That is, the example program is in 3rd Party Driver Library/examples and the .h file is in 3rd Party Driver Library/include. I tried copying the .h file into the examples folder, but the program still could not find it.

What file are you specifically talking about, the "hitechnic-accelerometer.h" file, or others?
And what folder do you mean? Both example and include files are in the 3rd Party Driver Library folder, but they are not both in example or include.


Wed Dec 30, 2015 11:54 am
Profile
Rookie

Joined: Sun Dec 27, 2015 7:50 pm
Posts: 11
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
Okay, I moved all the "include" files to the "example" folder and the program seemed to work fine. Thank you for your help!
One more thing, is there someplace that I can learn about advanced robotC programming, such as stucts, #include, #define, and other things not explained in robotC Help?
Thanks again.


Wed Dec 30, 2015 6:14 pm
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
RobotLego wrote:
Okay, I moved all the "include" files to the "example" folder and the program seemed to work fine. Thank you for your help!
One more thing, is there someplace that I can learn about advanced robotC programming, such as stucts, #include, #define, and other things not explained in robotC Help?
Thanks again.

Okay so I hadn't realized it was in the include folder. Off the top of my head I can't remember how to ensure it is included. I will look into it later today and get back to you. Just to make sure the solution is a little cleaner.

I will also look around for a good resource for more advanced techniques. For the most part ROBOTC acts very much like the C standard so tutorials for arduino etc will all give a good backround explanation.


Fri Jan 01, 2016 11:40 am
Profile
Rookie

Joined: Sun Dec 27, 2015 7:50 pm
Posts: 11
Post Re: HTAC--HiTechnic Accelerometer/Tilt Sensor Help
Okay, thank you for your help!


Sun Jan 03, 2016 12:19 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.