Roy Morgan's Posts (2)

Sort by

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.




Read more…

Netduino for a tricopter

Finally got round to getting some time to work on a uav, decided to start with a tricopter as it should be the easiest to work on indoors for now. Initial plan was to go with a couple of boarduinos or an atmega but stumbled across the netduino which is an open source board and software for the micro.net framework, and its available in the uk for around £24 which is a bargain considering its running on a 32 bit arm microcontroller and at 48mhz should give about 40mips so plenty of processing power. Given that I code in C# daily I'm going with the netduino (come pay day next month!)

The advantages seem to be:
Plenty of cpu power
Plenty of ram (70k)
Real time debugging
.net - and all its benefits, e.g. Threading, ease of coding, event handlers
All open source
Somewhat compatible with arduino shields (though won't be using any)
Plenty of digital inputs and two serial

The disadvantages seem to be:
Not realtime - though is this a disadvantage I'm not sure it is?
Only 4 PWM (should be okay, but maybe need to add in a driver)
Hard to design a custom board later on (100 pin package on the chip!)
Not as many analog inputs (only 6)
Only 128kb left for code (rest is taken up by .net micro and netduino code) - same as atmega though.
No existing uav code to base code on

Just installed the netduino sdk and got my class structure set up and starting coding the main thread for managing all the processes....
Read more…