Hello all!
We are trying to get a reading from a sensor, the MAE3 from US Digital. Basically it outputs a PWM signial that shows its position by varying the width from 1 to 4096 uS. We're having trouble finding the right code that will grab that pulse width from the FPGA in a stable manner.
We can grab it in OperatorControl to show the signal is there, but the value varies by close to 10%, and often jumps to extreme numbers, assuming because we are in the main teleop loop.
Any pointers to the right object to use to get the PW correctly?
Thanks!!
"bBallAngle" is meant to show the number of microseconds elapsed for the width
Code:
bBallAngleSensor = new DigitalInput(2,11);
...
if (bBallAngleSensor->Get() == 1)
{
// these for loops are to prevent a while lock. if it loops 5000 times it will fall out
// but a legit change will break;
for (int i = 0; i < 5000; i++)
{
if (bBallAngleSensor->Get() == 0)
{
break;
}
}
startTimeAngle = GetFPGATime();
for (int i = 0; i < 5000; i++)
{
if (bBallAngleSensor->Get() == 1)
{
break;
}
}
bBallAngle = GetFPGATime() - startTimeAngle;
}