|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Connecting an FRC Dashboard project to an FRC cRio project
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
|
|
#2
|
|||
|
|||
|
Re: Connecting an FRC Dashboard project to an FRC cRio project
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.
|
|
#3
|
|||||
|
|||||
|
Re: Connecting an FRC Dashboard project to an FRC cRio project
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. |
|
#4
|
|||
|
|||
|
Re: Connecting an FRC Dashboard project to an FRC cRio project
Quote:
|
|
#5
|
|||||
|
|||||
|
Re: Connecting an FRC Dashboard project to an FRC cRio project
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. |
|
#6
|
|||
|
|||
|
Re: Connecting an FRC Dashboard project to an FRC cRio project
Alright, thanks, I've got the slider values hooked to a case structure in our autonomous code, and it's working!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|