Offline
Newbie
Karma: 0
Posts: 17
|
 |
« on: May 14, 2011, 05:24:42 am » |
Hallo, I am very new to Arduino and to electronics in general, so before I start with the wrong path, I thought I ask here first  I have connect my Arduino Mega to my oscilloscope and upload a simple Blink LOOP with the delayMicroseconds() command. It seems that maximal speed Arduino can do is 62us at an inaccuracy of +/- 300ns (on 1 digital port, port 12 in this case) For my project I will need stable//accurate signals in a range of 60ns - 40ms on 11ports (10 for a LED array and 1 to control another device)... is that even possible with arduinos programming environment or do I need assembler for that? Thanks!!
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 90
Posts: 9406
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #1 on: May 14, 2011, 06:24:35 am » |
Given the fact that Arduino runs at 16 Mhz, it is easy to see that 60ns signals is at the edge/beyond its capabilities.
Imho : for 60 ns signals you need a processor at least in the 100Mhz range, a realistic minimum is 200Mhz I guess.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #2 on: May 14, 2011, 06:49:33 am » |
@robtillaart Thanks for the answer! I can't find the post anymore, but I am sure I have read somewhere that he has a cycle of 2ns.. but I may be wrong on that since I don't understand much of the actual internal work of a MC. Anyway... I would be happy with a stable 40ms signal.
Example: 2ms ON, 38ms OFF, LOOP... even at that speed, he is jigling too much for my taste. Is the delay() command the usualy way to go for that, or is there any better command for that?
The more I google, the more I get the impression that I need assembler for accurate timings for thos signals.
|
|
|
|
|
Logged
|
|
|
|
|
Guildford, UK
Offline
Full Member
Karma: 0
Posts: 217
Arduino rocks
|
 |
« Reply #3 on: May 14, 2011, 07:17:48 am » |
If you're looking for 2ms pulse width you may find delayMicroseconds more to your liking ( http://arduino.cc/en/Reference/DelayMicroseconds) or you may want to avoid using delay and just loop checking micros() to see if the pin needs pulsing. The other thing to be aware of is that digitalWrite() takes quite a while, if you want a faster response you may need to manipulate the port directly.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #4 on: May 14, 2011, 07:34:34 am » |
@sixeyes I got to try DelayMicroseconds tomorow! "you may need to manipulate the port directly" what you mean by that? How do I manipulate the port directly?
|
|
|
|
|
Logged
|
|
|
|
|
Portugal
Offline
God Member
Karma: 5
Posts: 962
|
 |
« Reply #5 on: May 14, 2011, 08:09:44 am » |
Using DDRx, to set direction and PORTx to write to the pin you want. If the 40ms is fixed using a timer is the best way to have 0 jitter, you see jitter because the millis values are returned from an interrrupt routine and the port access's are not atomic, and they can be interrupted in the middle of a write. To learn about direct port manipulation see this: http://hekilledmywire.wordpress.com/2011/02/23/direct-port-manipulation-using-the-digital-ports-tutorial-part-3/
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #6 on: May 14, 2011, 06:19:31 pm » |
@Senso Thanks for the link! I will play around with it on monday... here I have no oscilloscope to test it :/
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 277
Posts: 25512
Solder is electric glue
|
 |
« Reply #7 on: May 15, 2011, 08:08:37 am » |
The jitter on an arduino output signal is caused by the interrupts running in the rest of the system doing things like the real time clock and the handling of the serial ports. To remove this you must disable the interrupts, then delay() will not work and you have to write your own delay loops.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #8 on: May 16, 2011, 05:17:36 am » |
I just tried direct port manipulation and it goes down to ns range completely stable 
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #9 on: May 16, 2011, 05:37:10 am » |
can't find the post anymore, but I am sure I have read somewhere that he has a cycle of 2ns Memory can play funny tricks on you, can't it? I just tried direct port manipulation and it goes down to ns range completely stable Tens of nanoseconds, I could believe. Getting towards the hundreds.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #10 on: May 16, 2011, 06:44:03 am » |
Its 60ns on my signal and 1ms on the loop. Should work just fine.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #11 on: May 16, 2011, 06:46:42 am » |
Its 60ns on my signal In my language, that's tens of nanos.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 90
Posts: 9406
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #12 on: May 16, 2011, 12:01:44 pm » |
If it all works please share your code how you got it to work.
Thanks,
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 71
Posts: 6623
Arduino rocks
|
 |
« Reply #13 on: May 16, 2011, 07:17:34 pm » |
In theory the jitter could be sub nanosecond, its the granularity that's 66ns.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #14 on: May 17, 2011, 09:56:53 am » |
The LEDs and a Camera are controlled by the sync signal of the Arduino. I use the array to measure how long the Camera needs from the trigger signal to the first picture recorded on different frame-rates. I will post the code once its done... its a very slow progressing project since every time I need something, i need to google and play around till it works  ..but its a good way to learn this stuff.
|
|
|
|
|
Logged
|
|
|
|
|
|