I want to ask that how can I use external clock with my arduino since I need a clock much higher than 16Mhz and I saw in the datasheet that one can use external clock by doing pre scaling so I want to ask that it it possible to use a clock much higher than 16 MHz and if someone can suggest that how I can do it?
You can use any external oscillator you want, as long as you pre-scale it to 16 MHz. For example you could use a 64 MHz oscillator and a divide-by-4 external pre-scaler to feed 16 MHz to the ATmega.
Thanks for your reply but actually that's what problem is I need a higher clock than 16 MHz to feed to the arduino as I am reading a pulse width whose resolution is not very good and I cannot measure it accurately since the pulses are between 8 to 15 microseconds and now I am finding a way of either to use a external clock of higher frequency or to use a external fast counter so any ideas?
You can't clock the 328 at a faster clock rate - (there is a 20Mhz version) the chip won't work properly at faster clocks. The internal circuitry won't work much faster. If you are trying to work with something at that high a frequency you probably need a different device.
Thanks for your reply and letting me know about that, that's what I was also thinking that may be I can't use higher clocks so the only solution now for me is to use a external fast counter since I have to measure the width accurately and the pulses are just too short 8-15 microseconds. I have a algorithm in arduino but that is not good since it takes one count every microsecond so it cannot measure widths accurately and I need a high resolution so I need to use some external fast counter with arduino so any ideas about that? Here is my code which is doing a count every microsecond
scorp84:
I want to ask that how can I use external clock with my arduino since I need a clock much higher than 16Mhz and I saw in the datasheet that one can use external clock by doing pre scaling so I want to ask that it it possible to use a clock much higher than 16 MHz and if someone can suggest that how I can do it?
Rather than float multiple potential solutions, and ask how to make them work, how about giving us a nice concise problem statement so we can discuss what a possible solution might look like. If you read the datasheet, then you saw that 20MHz is the maximum system clock frequency. In my book, that's not "much" higher.
If I wanted to measure an 8µs pulse, I might look to the Timer/Counter1 Input Capture Unit. With the timer running at system clock speed (prescaler = 1), that gives a 62.5ns resolution, so a measurement within a couple percent ought to be possible. If orders of magnitude more precision is needed, then I'd look to other hardware.
yes I need a higher resolution as I want to measure even if the pulse width is let's say 5.15 microseconds it should display accurately and I believe I have to use a external fast counter now but unfortunately I am not finding any any ideas about that?
How accurate is "accurately"? When you say 5.15µs, are you implying 0.01µs accuracy? It'd be pushing it to expect even 0.1µs accuracy with Timer1 running at 16MHz.
There's also a bigger picture here, namely, once a measurement is taken, what is done with it? How often do measurements need to be taken? If the intent is to measure each cycle, then that leaves precious little time to do the associated processing.
if my counter which I have developed by doing programming can do one count every 0.1 microsecond means 10 counts in 1 microsecond then even that is going to be good enough so what do you have to say about that?
if my counter which I have developed by doing programming can do one count every 0.1 microsecond means 10 counts in 1 microsecond then even that is going to be good enough so what do you have to say about that?
An Arduino is 16Mhz. suppose the count++ takes one clock cycle and the test if the pin goes high 3 (load register and do a compare and do a jump ) that would mean that you need at least 4 instructions. 4/16 is about 0.25 micros so if you could do this in assembly that would be the ultimate limit in software on an Arduino.
If you use an NXP MBED at 100Mhz (6x as fast) you can get approx 0.1 usec accuracy in software.
its continuous train of pulses and not just one...if I can measure 10 counts in 1 microsecond then I can get much better accuracy but I don't know how can I achieve that I am trying to find some external fast counter but I am not finding any
Can I use the external high speed counter given by the link below with arduino, if I can use this then I would be able to achieve very good resolution and hence the accuracy. So please guide