|
Re: AnalogModule->GetAverageValue() gives wrong results if polled too fast
Eugene,
Just to clarify: the thread topic is misleading at this point. You can poll at a leisurely 50 Hz, but if you don't stop your thread for .005 sec between data reads you will get the error.
It's getting late here in Philadelphia (2:30 am), so I can't check out the complete modification you suggest tonight, but I did replace the GetBatteryVoltage() call with a 0 in the the code below and I do seem to be running error free without any Wait() at all.
I send plenty of custom data to the dashboard, so it should be no problem to read it myself from channel 8, then pack it up and send it along with the rest of my data to the dashboard. I'll have to move the indicator inside the case statement - I'll try it in the morning.
Here's some code from DriverStation.cpp:
void DriverStation::Run()
{
while (true)
{
SetData(); <--- this reads the battery voltage, see below
Wait(kUpdatePeriod); <--- every .02 sec, see the comment from the header file
}
}
void DriverStation::SetData() <-- no info on setStatusData, header only - FRCComm.h
{
setStatusData(GetBatteryVoltage(), m_digitalOut, m_userStatus,
USER_STATUS_DATA_SIZE, WAIT_FOREVER);
Here's an interesting comment from DriverStation.h, but I'm not sure how relevant it is - since each Read() in GetAverageVoltage() does use a semaphore.
///< TODO: Get rid of this and use the semaphore signaling
static const float kUpdatePeriod = 0.02;
Time to sleep,
David
|