I am working on a project with many starts and stops. I need to know how fast you can write 100,000 analog values to an array. I was using the following code but my new hydra refuses to work…There is no feed to the debug screen…
using System;
using Microsoft.SPOT;
using GHIElectronics.OSH.NETMF.Hardware;
using System.Threading;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
int[] myInt = new int[100000];
AnalogIn ain = new AnalogIn(AnalogIn.Pin.Ain0);
long timer1, timer2;
timer1 = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks;
for (int i = 0; i < 9999009; i++)
{
myInt[i] = ain.Read();
}
timer2 = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks;
Debug.Print((timer2 - timer1 / 10000).ToString());
Thread.Sleep(1000000);
You will get an out of index exception that’s for sure If you run this code:
var myInt = new int[100000];
var ain = new AnalogIn(AnalogIn.Pin.Ain0);
var startTime = DateTime.Now.Ticks;
for (var i = 0; i < myInt.Length; i++)
myInt[i] = ain.Read();
var elapsedTime = (DateTime.Now.Ticks - startTime)/(double)TimeSpan.TicksPerSecond;
Debug.Print(elapsedTime.ToString("F2") + " s");
You will get
Using mainboard GHIElectronics-FEZHydra version 1.0
5.89 s
That means I can read 100,000 analog values at 5.89 seconds. That roughly means if I read 6 analog ports…that means 32000 reads in 10 seconds. That is very fast indeed.
Now if I can just figure out why the debug screen is not printinig my values…
If I run debug.print(“kdjsfhdklsfghdflskgn”);
I get no ouput although I did get an exception form that code! This means that it is connecting but not receiving the debug print…any ideas?
Strangely enough if I run this I get an out of memory exception (well it is not strange at all)…
using System;
using Microsoft.SPOT;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
int[] xxx = new int[100000000];
etc....
The VS Express version do have some funky default settings. Why do we even need an “expert” setting in the first place? Kind of a condescending assumption IMHO.