Can someone with a Fez Hydra do me a favor?

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);


Any suggestions would be helpful.

You will get an out of index exception that’s for sure :wink: 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

I just noticed that!

Thanks for that!

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?

So you don’t get anything when you upload a simple helo world ? Try updating the firmware maybe…

Nothing. It is the same for a fez hydra and netduino. Maybe it is a setting in visual studio?

Very strange…

Rob

What is that tickspersecond? Is this firmware 4.2?

I like your coding style by the way :wink:

I could learn a thing or two!

the term “debug screen” is being used. where are you looking for the debug output?

Hej Mike,

I mean the output from debug.print…at the bottom of visual studio. I get no output it runs and closes. No errors or anything.

Rob

@ rgm: Thanks! Are you using VS Express or regular ?

Express…

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....

So I am sure it is getting to the device…

Maybe this is the case: Visual C# 2010 Express Output Window - Stack Overflow

I hit control W as well and made dure that the setting was EXPERT and it worked like a charm.

Thanks!

By the way I am really liking my FEZ Hydra. Finally a microcontroller with NO limits!!! :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

So do I :wink:

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.

Ransomhall…

An apt assumption in my case. Although the beginner would need the debug.print more than anyone… ::slight_smile:

@ Gralin

I finally got it working right (firmware updqate problem)…

Anyways I get 6.3 seconds on mine

And if I change the code to this:



int[] myInt = new int[100000];
            var ain = new AnalogIn(AnalogIn.Pin.Ain0);
            var startTime = DateTime.Now.Ticks;

            for (int i = 0; i < 20000; i++)
            {
                myInt[i] = ain.Read();
                myInt[i++] = ain.Read();
                myInt[i++] = ain.Read();
                myInt[i++] = ain.Read();
                myInt[i++] = ain.Read();
            }
            var elapsedTime = (DateTime.Now.Ticks - startTime) / (double)TimeSpan.TicksPerSecond;
            Debug.Print(elapsedTime.ToString("F2") + " s");
            Thread.Sleep(7000);


I get an insanely fast .87 seconds!!!

It looks as if the analog read is not the thing that takes all the time…That loop is expensive!

We can do benchmarking this way :wink: Mine Hydra seems to be overclocked :wink:

How about you make a program that has no loop but 100000 instructions? :slight_smile:

@ Gralin

How good are you at cutting and pasting and when are you available?

I prefere using macros in notepad++ :wink:

Always :wink: But for sure during work hours :stuck_out_tongue: It’s 8:00 - 16:00 GMT+1.