Getting Encoder Values in the Dashboard

I am trying to get Encoder Values back into the Dashboard and have no idea where to start. We are working on trying to get PWM values back into Dashboard right now, but I cannot find ANY info this procedure for Encoders.
Please help if you have successfully done this.

I’ve sent arbitrary data to the dashboard. Only the type matters, not the source. Encoders will return either an INT32 or a double depending on if you call Get() or GetDistance(). You can send either one by using the correct data type when you pack the dashboard data.

Thank you, that should help a little bit, but how do you pack the data you receive from a function for the dashboard? Do I have to call another class (like DashboardDataFormat) or is it just another function?

For Example

double dblEncoder1Value;
dblEncoder1Value = encoder1.Get();
then would I do something like:
PackAndSend(dblEncoder1Value);

Forgive me if the questions I have asked sound obvious, I just really can’t figure this out.

The DashboardDataFormat class in the example is just a way to organize the code. The actual library interface is the Dashboard class which you access via the DriverStation class using GetHighPriorityDashboardPacker() or GetLowPriorityDashboardPacker(). Follow the example you see in the code inside the DashboardDataFormat class.

Thanks to everyone’s, especially your help, we were able to get data back to the dashboard last week. Now we are trying to get the actual values of the encoders passed back to the user messages box. We have successfully sent words back to this spot, but cannot figure out how to parse the encoder value to get passed back. Any help?
EDIT:
we have the variable that holds the encoder value declared as an INT32 because that is what the .Get() function returns. We are using the DriverStationLCD class to print the value back to the dashboard (actually the user messages section of the driver station)

Also, we tried setting our loop to only run while the encoder value was less than a specific amount (in this case 500) and it just kept running. Has anyone else had this problem and how did you get it fixed? I noticed something a little strange: When our wheels are turning, the 3rd, 4th, 5th, and 6th light under Digital I/O on the dashboard flash. The first 2 are greyed out. I thought this was strange because our encoders are plugged into ports 11, 12, 13, and 14. I am starting to wonder if this is what is causing the issue because of the way I have the encoders declared/initialized

Has anyone else gotten encoder or other numerical values in this field? How did you format the data?

If you are using the DriverStationLCD class, you can call:

myDS_LCD->Printf(DriverStationLCD::kUser_Line1, 1, "%d", encoderValue);
myDS_LCD->UpdateLCD();

Thank you, we ended up figuring it out. FINALLY THE TROUBLE WITH ENCODERS IS OVER!!

I’d recommend using PrintfLine instead (available in newest version of WPILib), which pads the line with blank spaces. If you just use printf, then if your number grows and then shrinks it will leave parts of the old number there. :slight_smile:

Of course, one could play with formatting options to fix that…