Pages: [1]   Go Down
Author Topic: Faster Than A Blink  (Read 1123 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I'm very new to this technology so please forgive me for what might be an inappropriate question. I'm trying to take a step up from using a 555 timer. I require some rather fast switching speeds. Perhaps a high on time of 50 us. I've tried changing the parameters in the Blinking Diode Sketch but it seems as though I can only do about 1ms high. Is it possible to get a higher frequency with the Arduino Atmega 328? Any help or direction would be appreciated.
DadHav/John H
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use a function called delayMicroseconds().

If switching the pins with digitalWrite() takes too long for what you need, look at direct port manipulation in the playground.

http://www.arduino.cc/en/Reference/PortManipulation

Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a comprehensive discussion of "Maximum pin toggle speed" over at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Gentlemen. I'll look into both of the suggestions. I'm just discovering how many places there are for help. So much th learn and so little time.
John
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, Just as an added note: I was also directed to a tutorial on timer 1. The following code worked well with my Deumilanova. I was able to get an on time of about 1 us and off of about 10 us. I think I'll be able to find what I need to operate with from this. I didn't want to post this on the other forum link because they all probably know about it already and I didn't want to interrupt with my amateur remarks.
DadHav/JohnH

/*
 *  Timer1 library example
 *  June 2008 | jesse dot tane at gmail dot com
 */

#include "TimerOne.h"

void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(10);         // initialize timer1, and set a 1000000= 1 second period
  Timer1.pwm(9, 100);                // setup pwm on pin 9, 512=50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
}

void callback()
{
  digitalWrite(10, digitalRead(10) ^ 1);
}

void loop()
{
  // your program here...
}

Merry Christmas Everyone!
Logged

Pages: [1]   Go Up
Jump to: