Here you'll find some tutorials to write drive code for the ArgoBot (or any robot) using LabVIEW or C++
This project is maintained by FRC1756-Argos
Up until this point, all our controls have been time-independent. A joystick input will generate the same output no matter what has happened in the past.
Sometimes, we need to use time and history to determine control behavior. One of the simplest forms of this is digital debounce
Digital inputs have two values: 0 or 1 (sometimes referred to as “Low” and “High”). In an ideal world, an input would always neatly fit into one of these categories, but that’s not always the case.
Consider the following:
We expect an input (say, a button) to go cleanly from 0 to 1 when we press it. Instead, the value may fluctuate between 0 and 1 for some period before staying at 1. If we want to perform an event when the button is first pressed, this “bounce” would cause our event to happen more often than we want it to.
The solution to this is to add “debounce” logic to eliminate the digital “bounce”.
To remove the bounce, we want to only change the value of a digital value if it maintains the new value for a number of consecutive cycles. This will involve some new blocks to compare old and new values
Debounce.vi
with one boolean input, one integer input, and one boolean outputvariables: Samples, SampleCount, In, PrevOut, Out
if firstRun:
PrevOut = In
SampleCount = 0
if In != PrevOut:
SampleCount = SampleCount + 1
else:
SampleCount = 0 // Zero consecutive new value samples
if SampleCount > Samples:
Out = In
SampleCount = 0 // Reset sample count on output change
PrevOut = Out
Loop
if firstRun
block is known as ‘initialization’ and is necessary to set the values of the feedback nodes at the beginning. The input at the bottom of the feedback node is for initializationSampleCount
and PrevOut
variables in the pseudocode correspond to two feedback nodes in the solutionif
statements can be represented by select blocks in your LabVIEW codeSampleCount = SampleCount + 1
statementGreat! Now that you’re getting more comfortable in LabVIEW, you should be able to translate concepts into code more easily. Don’t worry if you had to look at the solution, but if you try it on your own first the solution may help you learn more. Now let’s use your new code
Drive_Button.vi
and go to the block diagramDrive_Button.vi
into ArgoBot_Main.vi
What did you notice when using the debounced output? Was there a noticeable difference between low and high sample counts?
Congratulations! You’ve completed your first control component with history! Next, we’ll be implementing another component with history, speed ramping!
<-Previous | Index | Next-> |