|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
We are trying to code a motor in autonomous using an encoder. We aren't getting any feedback from the encoder in autonomous, but we are in teleop. Any suggestions?
|
|
#2
|
|||||
|
|||||
|
Re: Encoder in Autonomous
Is this the code you dropped into Autonomous?
Did you add a loop (with a Wait please)? Otherwise it gets called a single time, then never again in Autonomous. Without an Autonomous loop your Arm will just keep running forever. Teleop itself gets called every 20ms (optimally), so this code in Teleop gets called over and over again. Autonomous is called only once, and you have to supply your own loops to keep it going and checking. I'd also call Config Timer once in Begin, rather than every time you get an encoder value. Last edited by Mark McLeod : 30-01-2015 at 19:09. |
|
#3
|
|||
|
|||
|
Re: Encoder in Autonomous
Thank you! We ended up putting a while loop in and it works! Another problem that we are now having is that autonomous mode only runs when timed tasks is disabled. Do you have any ideas of why this is happening or a way to fix it?
|
|
#4
|
|||
|
|||
|
Re: Encoder in Autonomous
You are probably talking to two things at the same time. Look for motor control or other things that require in input to go or react. If you post both we can take a look and help.
|
|
#5
|
|||
|
|||
|
Re: Encoder in Autonomous
If you do not want everyone to see your code you can email me and I can look through it and give some help. Just message me if you want so help.
|
|
#6
|
|||
|
|||
|
Re: Encoder in Autonomous
Here are pictures of the timed tasks code and the beginning of autonomous. In auto, we're reading buttons from the dashboard to select which version of the code to run, and positions from the driver station as well.
Thank you. |
|
#7
|
|||||
|
|||||
|
Re: Encoder in Autonomous
By setting the Arm motor in two places at the same time the latest set wins.
That would be Periodic (Timed) Tasks because it reSets the motor every 10ms. You have to set it in only one place. Generally, I'd say have Autonomous set a Global variable that Timed Tasks reads and acts on. |
|
#8
|
|||
|
|||
|
Re: Encoder in Autonomous
How would you suggest doing that?
|
|
#9
|
|||
|
|||
|
Re: Encoder in Autonomous
You are starting things in multiple places. If you start the encoder in the periodic tasks then you do not need to do it in the auto loop too. You just need to get the value from the to the Autonomous code. That can be done with a global variable.
|
|
#10
|
|||
|
|||
|
Re: Encoder in Autonomous
We put the code in teleop like you suggested and it worked wonderfully! Thanks for the help!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|