D.T.A http://www.sherv.net/cm/emo/dancing/penguin.gif
Define
Target
Apply
Its here, the thing you have all been waiting for… well, actually, probably not… Let me explain: DTA is a motor control ‘idea’. I personally have found this idea helpful while programming, I hope it can be of help to someone else. This idea is not designed for use in autonomous code, it CAN be used, but it is not recommended, as there are much better solutions to the problem (like just calling autonomous functions). This system is designed to be used in a driver control loop in conjunction with driver input to create toggles and while (held) buttons for mechanisms. e.g. flywheels, arms, intakes.
It works different to your conventional method by not applying speed changes to a motor until the end of the loop, instead of during a loop. This means that D.T.A is not subject to jitter ( for all reasonable applications ) and is elegant and compact, not to mention readable. An example is of the advantages of P.T.A is below.
Lets look at a piece of code to control an intake and a flywheel: ( Note: Code written for demonstration, not an actual piece of code ).
if(vexRT[Btn5U] == 1)
{
motor[tlrfwr1] = 127;
motor[tlrfwr2] = 127;
motor[tlrfwl1] = 127;
motor[tlrfwl2] = 127;
}
// my new stop button
else if(vexRT[Btn5D] == 1)
{
motor[port2] = 0;
motor[port3] = 0;
motor[port4] = 0;
motor[port5] = 0;
}
// Hold Switch
if{vexRT[Btn6U] == 1)
{
motor[intake1] = 127;
motor[intake2] = 127;
}
// Low speed Intake for Michael Bays Film
if(vexRT[Btn6D] == 1)
{
motor[intake1] = 69;
motor[intake2] = 58;
}
// Else doesn't work for some reason. :(
if(vexRT[Btn6D] == 0 && vexRT[Btn6U] == 0)
{
motor[intake1] = 0;
motor[intake2] = 0;
}
Lets look at some issues with this code, firstly the intake motors are subject to JITTER Of course we can fix this by including else:
// Hold Switch
if{vexRT[Btn6U] == 1)
{
motor[intake1] = 127;
motor[intake2] = 127;
}
// Low speed Intake for Michael Bays Film
**else** if(vexRT[Btn6D] == 1)
{
motor[intake1] = 69;
motor[intake2] = 58;
}
**else**
{
motor[intake1] = 0;
motor[intake2] = 0;
}
Another thing is, it is tedious to write out the motor names every time we go to change a motor value. Also if we want to change say, a speed we have to go through and edit all the motor speeds that we want to change individually, of course we can fix this by including a function/subroutine to control the motors.
if(vexRT[Btn5U] == 1)
{
motor[tlrfwr1] = **56**;
motor[tlrfwr2] = **56**;
motor[tlrfwl1] = **56**;
motor[tlrfwl2] = **56**;
}
}
#ImFarToLazyToDoThisEverytimeIWantToChangeASpeed
The original programmer has used “tlrfw” to define a flywheel motor, but another programmer has come along and, confused, just used the port names instead of changing the actual names of the motors which just makes the code even harder to read and understand. D.T.A allows a single easy to understand Variable to run your motors. Not to mention now to change a name we have to tediously go through all of the motors, of course again we can fix this by including a function/subroutine to control the motors.
e.g.
fw_setspeed(int speed)
{
motor[tlrfwr1] = speed;
motor[tlrfwr2] = speed;
motor[tlrfwl1] = speed;
motor[tlrfwl2] = speed;
}
We don’t even need to update the code more than once every 20 milliseconds anyway? so why do we have code that updates during a loop, why not at the end of it.
D.T.A is based off the idea of simple, readable and elegant code. It uses the system: define, target, apply to allow it to not only look nice, but be extremely effective and practical as well. Its up to you if / how you use it, I have found it useful for some of my projects, and you may too.
TL;DR D.T.A is just a way of making motors move that looks nice and is readable. Its also good for lazy people
So how do you apply this to your program?
(will continue on next post)
*P.S. I think I got a bit carried away, this was meant to be a quick info thing. Oh well. You can kill me for wasting 2 minutes of your life if you want *