I have created a test harness, with a Maestro to contol a servo and the LPY510AL mounted on the servo arm.
The Wixel reads the gyro in a tight loop and outputs to the virtual com port the gyro readings X and Z and a time stamp.
I can then capture the output with a terminal program and graph the results in Excel.
What I see is not what I would expect.
The Maestro is running this simple script:
- Code: Select all Expand
# gyro testbed
begin
2000 8000 0 servo delay 2000 3840 0 servo delay
repeat
So the servo swings right pauses then left pauses and repeats. At zero speed and zero acceleration.
I would expect from this motion to get values above resting a pause then values below resting and a pause.
I let the capture run for 10 times through the loop. I expect a graph to look more like a sine wave.
Can you explain this data?
The Wixel code is longer and much is commented out to remove any outside the gyro issues.
- Code: Select all Expand
/* wireless_gyro_tracker app:
* James Graham Software Specialites
* Allows you to make a wireless pan tilt tracker using two Wixels,
* and a gyro
*
* One Wixel should be running the wireless_maestro_link app and be
* connected to a Maestro via serial. The other Wixel should be running this app,
* and be connected to the gyro.
*
* The Maestro is connected to a Pan servo on 0 and a Tilt servo on 1
* == Pinout ==
* P0_1 = Gyro Z analog input
* P0_2 = Gyro X analog input
*
* == Parameters ==
* param_radio_channel
*
*/
#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <radio_com.h>
#include <radio_link.h>
#include <math.h>
#include <stdio.h>
#define TX_INTERVAL 10 // time between transmissions (ms)
void updateLeds()
{
usbShowStatusWithGreenLed();
LED_YELLOW(vinPowerPresent());
}
void txGyroState()
{
static uint8 lastTx = 0;
static uint16 lastPan = 6000;
static uint16 lastTilt = 6000;
//uint8 servo;
//uint16 target;
uint16 fx, fz;
fx = adcRead(2);
fz = adcRead(1);
if (usbComTxAvailable() >= 30)
{
uint8 XDATA report[30];
uint8 reportLength;
reportLength = sprintf(report, "%1u,%1u,%1lu\r\n", fx, fz, getMs());
usbComTxSend(report, reportLength);
}
/*
if ((uint8)(getMs() - lastTx) > TX_INTERVAL )
{
target = lastPan;
servo = 0;
if(fx > 850)
target = 7200;
else if(fx < 670)
target = 4800;
if (target != lastPan)
{
lastPan = target;
if (radioComTxAvailable() >= 4) // thanks David
{
radioComTxSendByte(0x84); // command byte: Set Target.
radioComTxSendByte(servo); // channel number.
radioComTxSendByte(target & 0x7F); // byte holds the lower 7 bits of target.
radioComTxSendByte((target >> 7) & 0x7F); // byte holds the bits 7-13 of target.
}
}
target = lastTilt;
servo = 1;
if(fz > 850)
target = 7200;
else if(fz < 670)
target = 4800;
if (target != lastTilt)
{
lastTilt = target;
if (radioComTxAvailable() >= 4) // thanks David
{
radioComTxSendByte(0x84); // command byte: Set Target.
radioComTxSendByte(servo); // channel number.
radioComTxSendByte(target & 0x7F); // byte holds the lower 7 bits of target.
radioComTxSendByte((target >> 7) & 0x7F); // byte holds the bits 7-13 of target.
}
}
lastTx = getMs();
}
*/
}
/*
* listen for data returning from Maestro
* not implemented as nothing is requested
* will read and echo to com port
* future use includes position data from servos
*/
void rxMaestro()
{
uint8 readBytes;
readBytes = 0;
while(radioComRxAvailable() && usbComTxAvailable())
{
usbComTxSendByte(radioComRxReceiveByte());
readBytes++;
}
if((usbComTxAvailable() > 2) && (readBytes > 0))
{
usbComTxSendByte(13); // \r
usbComTxSendByte(10); // \n
}
}
void main()
{
systemInit();
usbInit();
radioComRxEnforceOrdering = 0;
radioComInit();
//disable pull-ups on inputs hooked to Gyro outputs
setDigitalInput(1, HIGH_IMPEDANCE);
setDigitalInput(2, HIGH_IMPEDANCE);
while(1)
{
updateLeds();
boardService();
usbComService();
txGyroState();
//rxMaestro(); // not in use yet no data expected
//radioComTxService();
}
}
I get the same data with or without the commented code executing.
I am attaching the log file from Terminal and the graph from Excel.

