Author |
Message |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Program copying
I copied the program hitechnic-gyro-test2.c.
#pragma config(Sensor, S1, HTGYRO, sensorAnalogInactive) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/* * $Id: hitechnic-gyro-test2.c 123 2012-11-02 16:35:15Z xander $ */
/** * hitechnic-gyro.h provides an API for the HiTechnic Gyroscopic Sensor. This program * demonstrates how to use that API. * * Changelog: * - 0.1: Initial release * * 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.54 AND HIGHER. * Xander Soldaat (xander_at_botbench.com) * 06 April 2012 * version 0.1 */
#include "drivers/hitechnic-gyro.h"
task main () { float rotSpeed = 0; float heading = 0;
// Calibrate the gyro, make sure you hold the sensor still HTGYROstartCal(HTGYRO);
// Reset the timer. time1[T1] = 0;
while (true) { // Wait until 20ms has passed while (time1[T1] < 20) wait1Msec(1);
// Reset the timer time1[T1]=0;
// Read the current rotation speed rotSpeed = HTGYROreadRot(HTGYRO);
// Calculate the new heading by adding the amount of degrees // we've turned in the last 20ms // If our current rate of rotation is 100 degrees/second, // then we will have turned 100 * (20/1000) = 2 degrees since // the last time we measured. heading += rotSpeed * 0.02;
// Display our current heading on the screen nxtDisplayCenteredBigTextLine(3, "%2.0f", heading); } }
I copied the program to a blank one and called t Gyro 1. When I compiled the orginal program, there were no errors. Then, when I compiled Gyro 1 it had errors: **Severe*:Couldn't open '#include' file 'new folder/hitechnic-gyro.h' **Error**:Undefined procedure 'HTGYROstartCal'. **Error**:Too many parameters specified. Call to 'HTGYROstartCal'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'. **Error**:Undefined procedure 'HTGYROreadRot'. **Error**:Too many parameters specified. Call to 'HTGYROreadRot'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'.
I don't know why that happened. hitechnic-gyro-test2 is not in the same folder as drivers/hitechnic-gyro.h and neither is gyro 1. Someone please explain this. Thanks
|
Mon Jan 14, 2013 3:01 pm |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Program copying
Errors 2-5 are caused by the computer's not understanding of the incude file location. I got the dexter industries IMU and experienced similar problems. I fixed it by taking off the "drivers/" part of the file name. Hopefully this helps!.
Coder A
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Mon Jan 14, 2013 3:29 pm |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
Thanks but it didn't make it work. The errors are: **Severe*:Couldn't open '#include' file 'hitechnic-gyro.h' **Error**:Undefined procedure 'HTGYROstartCal'. **Error**:Too many parameters specified. Call to 'HTGYROstartCal'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'. **Error**:Undefined procedure 'HTGYROreadRot'. **Error**:Too many parameters specified. Call to 'HTGYROreadRot'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'. So not that much of a difference. Just to restate the problem, the same program is in sample program hitechnic-gyro-test2 as in Gyro 1 and Gyro 1 has errors. The program reads the degrees the gyro sensor is turning and then displays it on the NXT screen.
|
Mon Jan 14, 2013 8:20 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Program copying
Since you are running Xander's test program, you must have downloaded Xander's driver suite (which includes the test programs). In the same folder where the test programs are, there should be a "drivers" sub-folder. Make sure it's there. Inside that "drivers" sub-folder, you should be able to find the hitechnic-gyro.h file. If you can't find that sub-folder, that will be the problem.
|
Mon Jan 14, 2013 10:34 pm |
|
 |
MikeJMcFarlane
Rookie
Joined: Thu Sep 13, 2012 9:43 am Posts: 47
|
 Re: Program copying
Did you install the Driver Suite as per Xander's instructions at http://botbench.com/blog/robotc-driver-suite/? (You will need to ensure the include file locations are setup in View>Preferences>Detailed preferences>Compiler>Include directories, which is slightly different to Xanders tutorial but reflects changes to the newer version of RobotC)
|
Tue Jan 15, 2013 3:06 am |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
There was a drivers folder. I copied and pasted Gyro 1.c into the 3rd party sensors, which is the folder where hitechnic-gyro-test2.c was and tried to compile. There were errors. I also compied and pasted Gyro 1.c into the drivers folder and got the same result. I also copied and pasted the program from the hitechnic-gyro-test2.c into Gyro 1.c just to make sure. I looked at the link and it was kind of comfusing. I think we're making progress though.
|
Tue Jan 15, 2013 11:05 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program copying
I'll update my driver suite howto today. I'll keep you posted.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Mon Jan 21, 2013 2:03 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program copying
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Mon Jan 21, 2013 2:14 pm |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
I compiled the Gyro 1 program with the same code as hitechnic-gyro-test2 and it compiled. I downloaded it and it did the same ting as hitechnic-gyro-test2! Thanks Xander!  Anyway, now I'm trying to calibrate the gyro. Is the best way to change to offset changing all the 620s in the driver?
|
Mon Jan 21, 2013 11:52 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program copying
No, the best way is to calibrate your gyro. The values are defaults, but if you run the calibration function, it will change those values. You'll have to do this every time you start your program.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 22, 2013 3:45 am |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
At first I was completely stumped but then I found this code: // Offset Calibration int offset = 0; for (int i = 0; i <10; i ++) ( offset = offset + SensorValue (GyroSensor) ); offset = offset/10; nxtDisplayCenteredTextLine (4, "Offset:% d", offset); wait1Msec (3000); at http://blog.electricbricks.com/en/2010/ ... giroscopo/I changed the GyroSensor to HTGYRO and added it to hitechnic-gyro-test2. Now I have a calibrate gyro program! Now I will create amazing things.
|
Tue Jan 22, 2013 2:38 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program copying
In hitechnic-gyro.h there's the following function: Did you try using that? = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Jan 22, 2013 3:37 pm |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
Well, in the program, it runs HTGYROstartCal. WIth HTGYROstartCal and the program clip in my last post, I acheived more accuracy with the Gyro than ever before. Still, I would like to make it more accurate. Would repeating HTGYROstartCal or the other calibrating program make the gyro more accurate?
|
Sat Jan 26, 2013 1:10 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program copying
No, not likely. If you figure out what your drift rate is, and constantly compensate for that, you will probably gain extra accuracy.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Sat Jan 26, 2013 4:11 am |
|
 |
firecannons198
Rookie
Joined: Mon Jan 14, 2013 2:50 pm Posts: 12
|
 Re: Program copying
Well, the drift rate seems to be different every time. The Gryo seems to lose some accuracy when it is moved fast. I'll keep testing...
|
Sat Jan 26, 2013 8:31 pm |
|
|