Main Site Documentation

Can someone with a Fez Hydra do me a favor?


#1

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.


#2

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

#3

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?


#4

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


#5

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

Very strange…

Rob


#6

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!


#7

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


#8

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


#9

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


#10

Express…


#11

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…


#12

Maybe this is the case: http://stackoverflow.com/questions/2644908/visual-c-sharp-2010-express-output-window


#13

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:


#14

So do I :wink:


#15

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.


#16

Ransomhall…

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


#17

@ 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!


#18

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:


#19

@ Gralin

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


#20

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.