View Full Version : Connecting an FRC Dashboard project to an FRC cRio project
Deviator247
06-02-2013, 20:08
I need help connecting a 4 value slider to a cRio project in order to control a case structure in autonomous independent, preferably using Boolean Logic if possible, thanks
toastnbacon
06-02-2013, 22:41
I don't know if this is the most elegant solution out there, but it should work. I also don't know how much you or the people from the future reading this know about programming, so I'll go ahead and explain it. What this will do is look at the analog input 1 slider. It divides it up into four sections (0-1, 1-2, 2-3, 3-5) and will build an array consisting of the Boolean values of if the slider falls in each of these sections. For example, a value of 1.5 would be read as [False, True, False, False]. It then searches for which value in the array is true (at any given point there will only be one true value) and takes the index (0, 1, 2, or 3) of it. This index is then plugged into a case structure (expanded for your viewing pleasure). If it's 0-1, case 0 will run. If it's 1-2, case 1 will run, etc.
Alan Anderson
06-02-2013, 22:53
What part are you having difficulty with?
Creating a 4 value slide control on the Dashboard front panel is straightforward. It'll automatically be a SmartDashboard variable. You can play with its properties to make it an integer with minimum value 1 and maximum value 4.
Reading that variable on the cRIO in the Autonomous Independent vi is also straightforward. Use the SD Read Number function. It'll probably arrive as a floating-point value, so you'll have to turn it into an integer before using it as the Selector for a Case Structure.
Deviator247
07-02-2013, 18:48
What part are you having difficulty with?
Creating a 4 value slide control on the Dashboard front panel is straightforward. It'll automatically be a SmartDashboard variable. You can play with its properties to make it an integer with minimum value 1 and maximum value 4.
Reading that variable on the cRIO in the Autonomous Independent vi is also straightforward. Use the SD Read Number function. It'll probably arrive as a floating-point value, so you'll have to turn it into an integer before using it as the Selector for a Case Structure.
I need help with connecting the dashboard project (PC dashboard) to the cRio project in order to use a slider that I've completed to set a time value, I basically need to use a slider to set a time delay on a while loop for a motor, the slider has 5 positions now, (Off, wait 2 seconds before running, wait 5 seconds, wait 8 seconds, and wait 11 seconds) these are times we need the autonomous to wait before starting our while loops, I was hoping to use a case structure to control the loop, where if the slider on the dashboard project is set to 1, there is no wait, and each other value sets a wait time before the motor in the while loop runs.I hope that clears it up a little
Alan Anderson
07-02-2013, 20:34
I suggest just making a straightforward slider control that ranges from 0 to 15. Since it's going to control a delay time, I don't see any reason to limit it to specific predefined values.
"Connecting" a Dashboard control to a cRIO program is just a matter of letting the SmartDashboard communication do its job. If you make a Dashboard control and don't connect it to anything, it will be picked up as a SmartDashboard value and automatically shared with the cRIO.
Reading the value is just a matter of...reading the value. Use the SD Read Number function and tell it the name of the Dashboard control you created. Then multiply the value you get by 1000 and feed it to a Wait (ms) function.
There are several ways to keep the rest of the Autonomous code from running until the Wait has finished. I'll let you decide how you want to do it.
Deviator247
08-02-2013, 19:23
Alright, thanks, I've got the slider values hooked to a case structure in our autonomous code, and it's working!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.