Highest blink rate?

Hi,
I´m working on a project where making an adjustable pulse is essential. Since i´m a newbee i so far tried
"blink without delay" but it seems that i cant make a higher frequency than about 450Hz. Is that the limit for "digitalWrite"? I´ve done a lot of searching but can´t find a code or library that meet my request of making a adjustable pulse in the region of 50-2000Hz. Hopefully some of you can enlighten me?

regards

Please post the code that was limited to 450Hz. It seems very low but will be influenced by how you change the state of the output pin. Direct port manipulation will be faster than using digitalWrite, for instance.

Let me guess - you don't know about delayMicroseconds or micros.

I´ll definitively post the code when i´m back home! And you are right; there is a hole in my knowledge about delayMicros!

I´ll be back! and thank´s so far!

If you take over one of the timers (as in, control it directly using the registers as described in the datasheeet, rather than using the arduino abstraction; while easy to use and understand, the arduino functions expose a very limited subset of the chip's capabilities), you can get PWM at almost any frequency you want (up to 8MHz - though at very high frequencies, you have fewer options for duty cycle)

You can also generate single pulses with the timer (by putting it into CTC mode, start it off when you start the pulse, and end the pulse in the ISR).

However, if you're only interested in frequencies up to 2kHz you can probably do it the way you're doing it with micros() instead of millis. The disadvantages to this are that if your sketch as to do other stuff, that can introduce jitter to the timing, and the maximum frequency you can get out of it is much lower than with the above methods.

Also, be aware that digitalRead()/digitalWrite() is surprisingly slow, due largely to the process of looking up which registers correspond to the arduino pin number. "Direct port manipulation" can be used if the speed of those functions is a problem.

(up to 8mhz

He either means "down to 8mHz", or "up to 8 MHz".

GrooveFlotilla:
He either means "down to 8mHz", or "up to 8 MHz".

Sorry for not capitalizing it right. I do not think that harping on this is helpful, as millihertz is almost never used, and 99+% of the time, when "mhz" is written, "MHz" is what was meant. On the rare occasions when millihertz is used, it is almost invariably written mHz, because the person writing knows it's an unusual unit, and that someone who saw "mhz" would assume they meant megahertz.

DrAzzy:
Sorry for not capitalizing it right. I do not think that harping on this is helpful, as millihertz is almost never used, and 99+% of the time, when "mhz" is written, "MHz" is what was meant. On the rare occasions when millihertz is used, it is almost invariably written mHz, because the person writing knows it's an unusual unit, and that someone who saw "mhz" would assume they meant megahertz.

So, what you're saying is that we should abandon precision and best practice, and rely on assumption?

I can only hope you're not the kind of doctor with access to dangerous drugs or chemicals.

GrooveFlotilla:
So, what you're saying is that we should abandon precision, and rely on assumption?

I can only hope you're not the kind of doctor with access to dangerous drugs or chemicals.

Not at all, and of course MHz is the preferred abbreviation. But I am saying that we should use common sense and recognize common usage ("mhz" for megahertz is extremely common across the internet) when interpreting ambiguous capitalization. Feigning ignorance of what was meant doesn't aid the cause of communication, it just gives people an excuse to make snide remarks. Heck, in the rare event that I did want to talk about millihertz, I would not even use mHz without explanation, as I would expect readers to think I meant megahertz by it.

Of course I am; If I were to prescribe you 100MG of placebonol - would you take one 100mg tablet, or try to consume 100 tons of it? (100 megagrams). When there are 9 orders of magnitude between two units, it's almost never unclear which is meant.

"mhz" for megahertz is extremely common across the internet

Sigh. Many abominations are common on the internet ("alot" instead of "a lot" "should of" instead of "should have" ...), but it doesn't excuse them.

If I were to prescribe you 100MG of placebonol - would you take one 100mg tablet

No, of course not - I'd ask you what SI unit has the symbol 'G', then I'd question your competency to prescribe anything stronger than a lemonade.

BTW, here we are discussing human-visible blink rates, so milliHertz are entirely suitable and appropriate in this context

GrooveFlotilla:
Sigh. Many abominations are common on the internet ("alot" instead of "a lot" "should of" instead of "should have" ...), but it doesn't excuse them.

Nor does it mean that it's necessary to disrupt a conversation by make snide comments every time you spot an "error".

I'd say these forums should be about trying to understand what people mean and helping them with their Arduino problems. Not pedantically correcting their (perfectly understandable) English. There must be English language prescriptivist forums available somewhere for that.

Steve

Can I ask why you thought it necessary to quote the word error?

No. Actually, I'm not going to ask permission.

Why did you quote the word error?

Or are we going to sidestep all problems by avoiding precision and accuracy?

DS21:
I´ll definitively post the code when i´m back home!

Excellent!

(The next post will be from @DS21. No exceptions.)