Performance of netduino reading analog and digital

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.




E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • I have had some encouraging results with Tiny CLR on a tricopter Kiwi Tricopter the >NET may be slow but it seems fast enough lease see Hover Test 1

     

     

  • Developer
    500 iterations/sec for reading 4 analog inputs, might be acceptable but hardly impressive. Even a cheap 8 bit atmel chip will do about 2000 iterations/sec when reading four adc inputs.
    I would suggest that you start using ADC interrupts, to prevent locking up the main loop waiting for adc conversions to finish.
  • Real cool input! I plan to make a quad with a netduino! and that give me some confidence in the netduino! Still one glitch, the missing of EEPROM, but, ill figure something!

    thank
This reply was deleted.