View Single Post
  #4   Spotlight this post!  
Unread 28-02-2012, 01:50
Ziv Ziv is offline
Has code to be writing...
FRC #0125 (Nutrons)
Team Role: Alumni
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Boston
Posts: 39
Ziv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of light
Re: Gyro Autobalancing

Is the difficulty you're having to do with understanding how a PID loop works or understanding how to implement one? Many resources you can find online—especially on this very forum—are great at explaining the former, but details on the latter can be harder to find. I haven't programmed a robot in LabVIEW for a few years, but if I recall correctly there are PID VIs that you can put in your code that do most of the work for you; they just need tuning of the constants. Some FRC teams—including some that use LabVIEW—post their previous years' code here; reading examples is a great way to learn.

A few other things to watch out for:
-As Tom mentioned, nest the case structures and make them manipulate numbers that feed into a single motor command (not just here but anywhere you have motor output).
-The gyro will in practice never give exactly 0; your code as above relies on that to stop the drivetrain from moving.
-If your gyro angle is, say, –20, I don't know if the remainder operation will output –20 or 340. Unless your robot does a somersault (which for all I know might be crucial to your strategy ), the gyro you use for bridge balancing will never be out of the range [–90, 90], so you should be fine without taking the remainder.