SoftRF - Pitot Static

I've received most of the parts for the SoftRF and compiled the code with the changes to support;

MPXV7002DP will measure pitot preasure analog 0-5v signal.

WitMotion WT901 is a full ADHRS with barometric preassure.  It outputs on a UART in binary at 115kbps.

My first attempt at the static pressure cavity failed.  My v2 was a cleanup of v1.  I then decided to use shark-bite quick disconnects.  That became V3... which I'm waiting to get back from the 3D Printer.  I'll keep you posted.  It looks very simple and promising.










Code to Support WT901 (Untested)


unsigned char buf[11];

unsigned char _readDataFrame()
{
// invalidate the buffer straight away
if(buf[0] = ((unsigned char)Serial.read()) != 0x55)
return 0xFF;

// read a 8 byte frame (with headers and checksum)
// and calculate the checksum
unsigned char checkSum = 0;
for (int i = 0; i < 9; i++)
checkSum += (buf[i] = (unsigned char)Serial.read());

// If it all works out... validate the header
return (checkSum == buf[10]) ? buf[1] : 0xFF;
}

// Get pitch roll yaw temp and baro pressure
AttitudeTempBaro GetAttitudeTempBaro()
{
AttitudeTempBaro _atbT;
unsigned char buf[11];
const int retryCount = 100; // how many failed attempts until we get all the data

unsigned char readAll = 0;

for(int i = retryCount+1 ; i > 0; i--)
{
switch (_readDataFrame())
{
case 0x53:
_atbT.Pitch = (short)(long(buf [3]<<8 | buf [2])*180)>>15;
_atbT.Roll = (short)(long(buf [5]<<8 | buf [4])*180)>>15;
_atbT.Yaw = (short)(long(buf [7]<<8 | buf [6])*180)>>15;
_atbT.Temperature = (short(buf [9]<<8| buf [8]))/340.0+36.25;
readAll |= 1;
break;
case 0x56:
_atbT.PressureAltitude = long(buf [5]<<24 | buf [4]<<16 | buf [3]<<8 | buf [2]);
readAll |= 2;
break;
default:
break;
}

if (readAll == 0x03)
return _atbT;
}

return _atbT;
}

Comments

Popular posts from this blog

VAT - Vario All-In-One Take 2

Lot to catch up on here...

The "un panel"