Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Accelerometer (http://www.chiefdelphi.com/forums/showthread.php?t=90641)

ElliotCourant 31-01-2011 19:49

Accelerometer
 
So I'm trying to implement the accelerometer, and i get several errors.

Code:

RobotDemo(void):
                myRobot(1, 2, 3, 4),        // these must be initialized in the same order
                leftstick(1),                // as they are declared above.
                rightstick(2),            // as they are declared above.
                gyro(1,1),
                acc(I2C)
{

and it gives me this

Code:

C:/WindRiver/workspace/Final/MyRobot.cpp:34: error: expected primary-expression before ')' token
How do I implement the accelerometer?

ElliotCourant 31-01-2011 20:17

Re: Accelerometer
 
bump

Alan Anderson 31-01-2011 22:11

Re: Accelerometer
 
Be patient. It was less than a half hour before your "bump".

Have you looked at the documentation for the ADXL345_I2C class? Is there anything you don't understand about it?

basicxman 01-02-2011 14:42

Re: Accelerometer
 
Quote:

Originally Posted by ElliotCourant (Post 1012793)
So I'm trying to implement the accelerometer, and i get several errors.

Code:

RobotDemo(void):
                myRobot(1, 2, 3, 4),        // these must be initialized in the same order
                leftstick(1),                // as they are declared above.
                rightstick(2),            // as they are declared above.
                gyro(1,1),
                acc(I2C)
{

and it gives me this

Code:

C:/WindRiver/workspace/Final/MyRobot.cpp:34: error: expected primary-expression before ')' token
How do I implement the accelerometer?

Which line is 34? What is I2C? A constant? A macro? Full source code would be helpful.

ElliotCourant 01-02-2011 18:03

Re: Accelerometer
 
1 Attachment(s)
Quote:

Originally Posted by basicxman (Post 1013416)
Which line is 34? What is I2C? A constant? A macro? Full source code would be helpful.


line 34 is "acc(I2C)"
Attachment 9918 That is a screenshot of just that part.


And yes I have looked at the documentation but it didn't really help me that much. It just told me that it needed a slot and a PID source. But because the accelerometer is connected to the I2C section I can't get it to work.

ElliotCourant 01-02-2011 18:28

Re: Accelerometer
 
1 Attachment(s)
Here is the deceleration of "acc"

Attachment 9919

But it doesn't give me any errors there

basicxman 01-02-2011 21:58

Re: Accelerometer
 
Quote:

Originally Posted by ElliotCourant (Post 1013615)
Here is the deceleration of "acc"

Attachment 9919

But it doesn't give me any errors there

Are you using the ADXL345? In which case you need to use the ADXL345_I2C class, not the Accelerometer class.

Again, what is I2C? A macro? A constant?

Alan Anderson 01-02-2011 22:10

Re: Accelerometer
 
Quote:

Originally Posted by basicxman (Post 1013821)
Are you using the ADXL345? In which case you need to use the ADXL345_I2C class, not the Accelerometer class.

Quite correct.

Quote:

Again, what is I2C? A macro? A constant?
In the code Elliot posted, I2C is undefined. That's why the compiler choked on it.

basicxman 01-02-2011 22:12

Re: Accelerometer
 
Quote:

Originally Posted by Alan Anderson (Post 1013843)
In the code Elliot posted, I2C is undefined. That's why the compiler choked on it.

Elliot did not post his entire source code, there could be a constant or preprocessor definition above the class definition.


All times are GMT -5. The time now is 13:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi