Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Controlling Motors in Auto (http://www.chiefdelphi.com/forums/showthread.php?t=135971)

polarvortexrobo 20-03-2015 19:36

Controlling Motors in Auto
 
Hi! I am first year programmer, this is our first year doing robotics. We are using LabView to program our robot.

I have a question about controlling motors in Auto. I looked at the sample code found in the Auto code in LabView. But it's for moving the robot.Now, my question is, is it the same way when you want to move other motors? I tried it but I probably did something wrong. I erased the work that I did.

And if possible, I would appreciate some tips on what not to do in Auto.

Thanks in advance,
from 5637 - Polar Vortex

Greg McKaskle 20-03-2015 19:57

Re: Controlling Motors in Auto
 
The principle idea is the same. You will generally make a sequence of value updates, wait for time, wait for a sensor, perhaps some logic paths based on a sensor input or an auto parameter, and you will tweak it a number of times to tune the values.

I believe the top code shows how to make a literal sequence of blocks that move the robot. It would be pretty easy to update this to move forward to another zone.

The other code, with the loop, is more general in that it executes based on a recipe. The array of movements is perhaps easier to read or generate, and can be enhanced to include other robot actuator elements too.

Auto will automatically stop after 15 seconds, ending any infinite loops or anything else you happen to put into auto. So I'd say the primary things to avoid are side-effects such as closing I/O refnums or setting globals or motors to wonky values that you don't correct during disable or at the beginning of teleOp.

Greg McKaskle

stopyourself 20-03-2015 21:42

Re: Controlling Motors in Auto
 
As another rookie programmer, I can't explain the details to you very well but might be able to help you past some rookie mistakes. This picture would be moving the robot during auto using a flat sequence structure.
You can either use a flat sequence structure or while loops to do autonomous. Make sure you call the motor every 50ms or so -- if you tell it to do something once every 3 seconds or so, it will shut off after 0.5 seconds. Also, I've heard excessive while loops (bad stop conditions?) will bog up the processors and make it run slower. If you encounter this, fix that.

mshafer1 21-03-2015 00:28

Re: Controlling Motors in Auto
 
1 Attachment(s)
Quote:

Originally Posted by stopyourself (Post 1460220)
As another rookie programmer, I can't explain the details to you very well but might be able to help you past some rookie mistakes. This picture would be moving the robot during auto using a flat sequence structure.
....
You can either use a flat sequence structure or while loops to do autonomous. Make sure you call the motor every 50ms or so -- if you tell it to do something once every 3 seconds or so, it will shut off after 0.5 seconds. Also, I've heard excessive while loops (bad stop conditions?) will bog up the processors and make it run slower. If you encounter this, fix that.

Stopyourself has made some good points.

Most important thing I can tell you is comment like crazy - you won't remember which frame is doing what once you get past about frame four.

Also, if at all possible, do not use time for the delay. There are some cases where there is no alternative (drive, unless you put encoders on for some reason), but the output will vary greatly with battery voltage, and even if it holds through qualifier matches, the quick turn around of eliminations will sink the battery, making the robot take longer to move the same distance.

I have tried to show some different simple things that can be used, a flat sequence, a time delay (some times its the only option :( ), and a limit switch, also some of the different places you can put comments.

Feel free to email me for help (click on my username and select send an email)

Greg McKaskle 21-03-2015 17:55

Re: Controlling Motors in Auto
 
A few clarifications:
Single motors do not have safety enabled by default. You can turn it on, and if you do, you will need to update the value by the deadline or the safety timer will zero them and print a message. Robot Drive does have safety on by default, though you can disable it if you are careful how you debug. RobotDrive has a Delay block that internally loops and feeds, and you do not need to disable or use traditional wait function.

As mentioned, you should consider using other sensors and not just time for your auto, though many robots have a reasonably good auto with just time.

Greg McKaskle

polarvortexrobo 24-03-2015 22:12

Re: Controlling Motors in Auto
 
Thank you for the replies and pictures!:) I would try to build an auto program based on all of the information. I will get back to you guys with more questions.


All times are GMT -5. The time now is 18:44.

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