Since initially deciding on using a netduino for a tricopter, one of the first concerns I had was over performance with it running on the .Net micro framework with regards to sensor reads, since it was mentioned by others that similar boards were slow to read. So now I've got my hands on one I decided to run an actual test on it. Although no sensors were actually connected the values read were actual reads (just the floating voltage of the pins from background noise), so no real difference from actually having a sensor outputting a voltage. Initial results are very promising:
Four analog pins read, Two digital read, Two digital set, and two pwm (servo) values set, per loop.
With the debugger attached (so running even slower) each loop was completed in 2 milliseconds - 5000 iterations (reading and setting) took around 9 to 10 seconds! about 500 iterations per second.
This leads me to believe there shouldn't be any problems with the netduino in this regard at all.
Here's the very very quickly hacked up code I used for the test:
var axisX = new AnalogInput(Pins.GPIO_PIN_A0);
var axisY = new AnalogInput(Pins.GPIO_PIN_A1);
var axisZ = new AnalogInput(Pins.GPIO_PIN_A2);
var IrFloorSensor = new AnalogInput(Pins.GPIO_PIN_A3);
var out1 = new OutputPort(Pins.GPIO_PIN_D1, false);
var out2 = new OutputPort(Pins.GPIO_PIN_D12, false);
var in1 = new InputPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled);
var in2 = new InputPort(Pins.GPIO_PIN_D4, false, Port.ResistorMode.PullUp);
var servo1 = new PWM(Pins.GPIO_PIN_D9);
servo1.SetDutyCycle(0);
var servo2 = new PWM(Pins.GPIO_PIN_D10);
servo2.SetDutyCycle(0);
var stopWatch = Stopwatch.StartNew();
stopWatch.Start();
int i = 0;
bool digState = false;
while (i < 5000)
{
axisX.Read();
axisY.Read();
axisZ.Read();
IrFloorSensor.Read();
in1.Read();
in2.Read();
digState = !digState;
out1.Write(digState);
out2.Write(digState);
servo1.SetPulse(20000, 1500);
servo2.SetPulse(20000, 1500);
i++;
}
stopWatch.Stop();
Debug.Print(stopWatch.ElapsedMilliseconds.ToString());
the stopwatch class is available on the netduino forums.
Now just to test this running on a background thread to see if it can still perform at the same speed.
Just thought this might help out if anyone else is wondering if a netduino would be fast enough for a tricopter.
You need to be a member of DIY Drones to add comments!
Join DIY Drones