Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

GPIO speed (MHz)


  • Please log in to reply
18 replies to this topic

#1 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 10:22 AM

Hi there,
What is the normal and max toggle (On/Off) speed of GPIO of netduino?

Thanks

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 10:59 AM

If you want to toggle GPIOs rapidly, you're looking at something along the lines of: C# code: A few milliseconds C++ code: ~60-70 nanoseconds or less (<=0.7us) <-- updated from previous conservative estimate of ~1000ns You can mix the two if you'd like (do your GPIO activations in native code, and your logic in C#). And since Netduino is 100% open source, you get access to the rich internals of .NET MF in your native code--not just a subset. Then again, if you want to toggle a GPIO on and off as fast as possible...there's hardware PWM. Welcome to the Netduino community, Chris

#3 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 11:18 AM

Thanks Chris
I just read your previous posts as well where you were able to get GPIO speed upto 6MHz with netduino.
But my question is even after accessing the PORTs directly what could be the maximum speed is possible for toggling GPIOs?

For example, I'm able to get max 8MHz by direct PORT addressing in Arduino running at 16Mhz.
It takes only 62.5nS to execute one instruction.
While netduino is running 48MHz ARM7 my expectations are high!!

Posted Image


Please advice
Regards





If you want to toggle GPIOs rapidly, you're looking at something along the lines of:

C# code:
A few milliseconds

C++ code:
~1 microsecond

You can mix the two if you'd like (do your GPIO activations in native code, and your logic in C#). And since Netduino is 100% open source, you get access to the rich internals of .NET MF in your native code--not just a subset.

Then again, if you want to toggle a GPIO on and off as fast as possible...there's hardware PWM.

Welcome to the Netduino community,

Chris

Attached Files



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 11:32 AM

While netduino is running 48MHz ARM7 my expectations are high!!


48MHz is 3x faster than 16MHz. GPIO ports may run a bit slower than native MCU instructions...but they will still probably be faster at 48MHz than 16MHz when using native C code accessing memory registers.

If you have a Netduino and a copy of GCC, grab Atmel's SAM7X-EK software examples and put together a quick test using their GPIO "set output" code. You should be able to measure the speed on your oscilloscope (or logic analyzer if it has a high enough resolution).

Chris

#5 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 11:59 AM

Chris thanks once again
I know what do you mean.

I don't have a netduino but I wanted to get one.
So want to know its performance before I buy one.
Basically I want to drive 64 pixels of RGB LEDs with 8-bit greyscale and 30 frames/sec and I need to decide between AVR32 UC3 and ARM SAM7.

Appreciate your help
Regards



48MHz is 3x faster than 16MHz. GPIO ports may run a bit slower than native MCU instructions...but they will still probably be faster at 48MHz than 16MHz when using native C code accessing memory registers.

If you have a Netduino and a copy of GCC, grab Atmel's SAM7X-EK software examples and put together a quick test using their GPIO "set output" code. You should be able to measure the speed on your oscilloscope (or logic analyzer if it has a high enough resolution).

Chris



#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 12:48 PM

Dirty Bits,

You're looking at a maximum of around 60-70ns for a full rise-and-fall of a pulse using native code on the Netduino's AT91SAM7X microcontroller. I built a test using FIQ timer-based interrupts, generating a high-low pulse every 1 microsecond. You can see the full details here and the screenshot of the 1us FIQ (with <=70ns pulse) below.

I have updated my conservative number in the first response above to reflect this (<=70ns vs 1000ns).

Chris

Attached Files

  • Attached File  fiq.png   63.06KB   74 downloads


#7 Mark H

Mark H

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationPerth, Western Australia

Posted 25 February 2011 - 12:50 PM

Dirty Bits, NetMF isn't designed as a real time, high speed pin toggler, it's designed to make complex high level code simple and fast to write. If you need ultra high speed, very tight timings, get an Arm Cortex chip and program it in C. If you want to implement complex functionality that is not time sensitive (ie: a few milliseconds don't matter) then NetMF is going to get you where you want to go ultra fast. If you want to dump data out really fast, you can abuse some bitshifters and SPI to do it insanely fast - this is going to require some very good programming skills and a good level of electronics expertise however.

#8 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 01:04 PM

Nice work Chris!

So it takes approx 1 microSec to go back into loop and 82 nSec to execute 1 GPIO instruction.
Thats great stuff!

Thanks a lottt, you made my day!!

P.S. its time to upgrade your Saleae to ver 1.1.4 ;-)




Dirty Bits,

You're looking at a maximum of around 60-70ns for a full rise-and-fall of a pulse using native code on the Netduino's AT91SAM7X microcontroller. I built a test using FIQ timer-based interrupts, generating a high-low pulse every 1 microsecond. You can see the full details here and the screenshot of the 1us FIQ (with <=70ns pulse) below.

I have updated my conservative number in the first response above to reflect this (<=70ns vs 1000ns).

Chris



#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 01:04 PM

Basically I want to drive 64 pixels of RGB LEDs with 8-bit greyscale and 30 frames/sec and I need to decide between AVR32 UC3 and ARM SAM7.


To echo what Mark H said, if you're looking to decide between AVR32 UC3 and ARM SAM7 for native code programming, you may want to look at ARM SAM3 instead. They don't have anywhere near the flash and RAM of the SAM7 used on the Netduino, but they're faster than either of those two options since they're Cortex M3.

Then again, we always love new community members who like programming Netduinos in C/C++. We can't provide a lot of support for non-.NET programming, but Netduino is made for hacking.

Chris

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 01:07 PM

So it takes approx 1 microSec to go back into loop and 82 nSec to execute 1 GPIO instruction.
Thats great stuff!


Actually, it takes much less than 1 microsecond to loop. It takes less than 100ns to loop. The 1 microsecond period you were seeing there was the time it took to activate an FIQ interrupt based on a timer, call the interrupt method, toggle a pin on and off, exit the interrupt, wait a while, and then start over :)

#11 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 01:09 PM

Yes Mark I realized that but I wanted something easy to use and powerful like netduino... Thanks for your help...I will check ARM cortex too.. Regards

#12 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 01:13 PM

me too I'm fan of netduino as its .net based there so many things can be done with it. :)

#13 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 01:16 PM

Really :o
Woww..

I gotta get netduino then..


Actually, it takes much less than 1 microsecond to loop. It takes less than 100ns to loop. The 1 microsecond period you were seeing there was the time it took to activate an FIQ interrupt based on a timer, call the interrupt method, toggle a pin on and off, exit the interrupt, wait a while, and then start over :)



#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2011 - 01:36 PM

Really :o
Woww..

I gotta get netduino then..

Just remember...if you want to toggle pins on and off really quickly, you'll need to do it in native C++ code. Which means that you'll either wipe .NET MF off the device and write code from scratch, or you'll need to get comfortable compiling the Netduino firmware with GCC...and adding native code using .NET MF interop.

I'm looking forward to seeing what you build!

Chris

#15 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 February 2011 - 01:49 PM

Thanks
:)

Just remember...if you want to toggle pins on and off really quickly, you'll need to do it in native C++ code. Which means that you'll either wipe .NET MF off the device and write code from scratch, or you'll need to get comfortable compiling the Netduino firmware with GCC...and adding native code using .NET MF interop.

I'm looking forward to seeing what you build!

Chris



#16 Corey Kosak

Corey Kosak

    Advanced Member

  • Members
  • PipPipPip
  • 276 posts
  • LocationHoboken, NJ

Posted 26 February 2011 - 05:11 PM

For example, I'm able to get max 8MHz by direct PORT addressing in Arduino running at 16Mhz.

After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.

If you are interested, my writeup is here

#17 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 27 February 2011 - 07:29 PM

Hmm... now its getting interesting!
Well I did tried that (serial data transfer - SPI) with Arduino few months ago (that time I wasn't that good with using Arduino) and get data transfer speed > 2MHz (Mega bits/Sec). I haven't tested it further because I needed only 1.4MHz. However this data was achieved by...
1.Using Arduino's standard SPI library without any tweaking
2.Arduino was running at 16MHz
3.I have used Matlab's SPI function to send Data from PC to Arduino and not the standard Serial Monitor.

If you just want simple arbitrary serial data transfer (not SPI) on a single out-put pin on Arduino than you can get > 4MHz (Megabits/Sec provided Arduino's running at 16MHz clock).

In a nutshell we need to find a way to use the processor to the max!!
Same goes with Netduino. And I want to know more ways to use Netduino to the maxx! :)


After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.

If you are interested, my writeup is here



#18 Dirty Bits

Dirty Bits

    Member

  • Members
  • PipPip
  • 10 posts

Posted 27 February 2011 - 09:32 PM

After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.

If you are interested, my writeup is here


I just read your write-up..Interesting work..well done for that!
I don't have Netduino at the moment so I can't try to improve that however I will try with Arduino and will post the result. Hopefully it shouldn't outperform Netduino else I will be in trouble because I'm planning to use ARM MCUs instead AVRs in my next project.

Stay tuned!

#19 Christopher Gilmore

Christopher Gilmore

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationBurlington, MA

Posted 06 October 2011 - 03:59 AM

If you want to toggle GPIOs rapidly, you're looking at something along the lines of:

C# code:
A few milliseconds

C++ code:
~60-70 nanoseconds or less (<=0.7us) <-- updated from previous conservative estimate of ~1000ns

You can mix the two if you'd like (do your GPIO activations in native code, and your logic in C#). And since Netduino is 100% open source, you get access to the rich internals of .NET MF in your native code--not just a subset.

Then again, if you want to toggle a GPIO on and off as fast as possible...there's hardware PWM.

Welcome to the Netduino community,

Chris



Chris,

I was wondering if there are some step by step instructions to say have some type of "Native Code" mixed in with a typical Netduino project...

What I am looking to do is have an function run every 20u seconds (like a timer). In this function I would like to do things like to check the status of some variables and potentially write out a high/low to a port. I don't think using the standard C# i could do it that fast but I haven't tested it yet. Are there any code examples on how to do something like this?

Thanks,




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.