Developing control algorithms for the quadracopter requires a predictable test environment so I built a test bed that allows me to test code changes. The test bed initially consisted of a teeter totter with a single electric motor at one end. Naively I thought I could achieve stability with this arrangement. The results were wildly erratic and over time the main axis bearing became misaligned and stiff. It did however prove useful in developing the sensor code just not tuning the PID algorithm.
The Arduino on the side of the test jig allows me to remotely turn the PC AT power supply on and off. This is a safety measure so that I can cut the power from my host terminal without getting near the propeller blade which can swing wildly if the code is wrong. I am always at least two meters away from the test bed.
To calibrate the sensors and potentiometer I have a test procedure written into the code. First the swing arm is held horizontal so that the sensor offsets can be calculated as well I calibrate the potentiometer at 0o. To make the procedure as reproducible as possible I have a wooden stick with two nails in the side of it. The nails are positioned such that the swing arm will be resting in a horizontal position when supported by one of the nails and at 30o when supported by the other. This means that from test to test I always have the same calibration which is critical when I am trying to tune the sensors to within 1o of accuracy.
The LPCExpresso is powered over a USB port via a processor chip regulator which powers the LPC1769. This arrangement doesn’t work very well because the regulation is relatively poor. When I power the potentiometer the ADC readings of the angle vary with the voltage and seem to be dependant on the VBUS signal level. These changes in voltage meant that my test bed reproducibility was poor so I ended up having to calibrate the potentiometer for each test. The new hardware uses a decent linear regulator so I’m hoping the voltage regulation doesn’t have the same problem as I experienced with the LPC1769 boards regulator.
Take two. My test bed has been enhanced by adding a much more rigid bearing system complete with potentiometers to allow for absolute angle measurements. I also re-worked the swing arm to add two motors instead of one. As you can see I used a new, smaller PCB for the control system. The potentiometers that mount on the main teeter totter axis are wired directly to the control PCB so that I can report the IMU results along with the potentiometer reference angle. The IMU has a USB CDC link to the host so that I can dump diagnostic data easily. In fact I have printed the data dump as a comma separated array so that it can be copied directly to a spreadsheet for analysis.
One issue with running a CDC serial link on the quadracopter is that there is a fair bit of latency in sending the data. This process can interfere with the timing of the sensors interrupts. While this is not an issue while flying since the USB in not connected; it is an issue when trying to analyze the critical timing of the code. My solution is to record all data to SRAM and dump it after the test is complete so that the CDC is not running during the test. With 64K of SRAM I can easily record 10 float variable to a depth of 1K . Depending on the sample rate I use 1ms or 10ms I can set the test windows time and the resolution.