Gyro interface to software

Posted by Erik at 03/26/2001 1:08 PM EST

Engineer on team #381, Trenton Tornados, from Trenton High School and Princeton University.

Can someone give me a heads up on how to interface the gyro with software, how to set up a variable to act as the input, is it digital or is it an analog signal, and if so is a simple if statement htat checks to see the value of the analog variable sufficient to use as a conditional starter for some automatic control of the robot? Any help and guidence appreciated.

-engineer forced to program

Posted by Lloyd Burns at 03/26/2001 2:20 PM EST

Engineer on team #188, Woburn Robotics, from Woburn Collegiate and TorDistSchoolBrd, ScotiaBank. OntPwrGen, Enbridge.

In Reply to: Gyro interface to software
Posted by Erik on 03/26/2001 1:08 PM EST:

: Can someone give me a heads up on how to interface the gyro with software,

’ Use the connector or solder directly to the pins of the gyro, but use pin 1 on the RI for 5 V, gnd on any analog gnd pin listed in the RI part of the manual, and signal to any input you like on the RI analog. The signal is contiuously variable from 0 V (variable “sensor#” = 0, where # is the number of the input corresponding to the pin in the Dx25 analog connector you’re using - again, see the RI manual) to 5 V (sensor# = 254), and the output voltage is 2.5 V (sensor# = 127 give or take [connect up and take measurements on yours])when not turning.

’ The manual should be downloaded and printed for study. It’s on the Innovation First web site.

: how to set up a variable to act as the input,

’ set c_sensor# = 1 in the list, include sensor# in the list of variables (in the right order) in the SERIN command. If you want you can make an alias like “pitch VAR sensor#” or “yaw VAR sensor#” for easier programming. Samples are given in the manual, and the default program from the InnoFirst site.

’ the PBASIC manual should also be studied. Goto www.parallaxinc.com for details.

: is it digital or is it an analog signal,
’ YES :slight_smile: , but see above

: and if so is a simple if statement htat checks to see the value of the analog variable sufficient to use as a conditional starter for some automatic control of the robot?

’ Yes, but you’ll have trouble unless you specify a minimum value of pitch change - your robot may bounce enough, or the centre value may drift enough to trigger your balance routine.

’ You might worry about direction of the pitch, too.
"if (pitch > 147) then (goto) enoughthatway
"if (pitch