Am I able to code the Arduino so that I can change cycles/sample of an input waveform and a number of samples/period configurations? I would like to modify these parameters in order to be able to store a high-frequency sinusoid but taking into account Arduino's 16MHz clock. For examples, I have a 40,000kHz sine wave. I would like to sample it at 10 samples/period and having 10 cycles/sample. As a result, I need a (40,000kHz * 10samples/period * 10 cycles/sample = 4MHz clock, which Arduino can supply). Compared to a more standard 128 samples/period and 256 cycles/sample, which would require a 1.3GHz clock.

  • No, an Arduino cannot do this. – Chris Stratton Apr 3 '18 at 4:10
  • @Chris Stratton So does it mean you always have a fixed sample/period of 128 and cycles/sample of 256? – Bogdan Raspopin Apr 3 '18 at 4:14
  • 1
    It means you can't come anywhere near your goal, so adjustability is beside the point. – Chris Stratton Apr 3 '18 at 5:02

The limitation is in the ADC which by default takes 104 µs to make a sample. Now you can speed up the ADC, sacrificing accuracy, but even then you can probably practically only reach a sampling time of 13 µs. Plus you would have the issue of where to put these 400,000 samples in the 2KB of RAM you have.

To sample at 400,000 times a second you would need to sample every 2.5 µs, which you can see is way shorter than 13 µs.

Plus, you not only need space to put these 400,000 samples, but it would take time to store them.

For more information see my page about the ADC which has a lot of details about sampling times, frequencies, accuracy, etc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.