DM timing microsecond?


Author Message
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2979
Posted: 01:55am 16 Mar 2012      

  robarino said  
I was wondering if any of you had used the auidio pulse as a counter. I am using the duinomite mega and I need to count with an accuracy of 10 microseconds. I can send a sound out at a frequency of 100 kHz from the audio jack. The question is how do I count the number of cycles in MMBASIC?

Thanks!

Rob


Hi Rob,

Using Geoff's example on the DuinoMite you will need to use Pins 5,6 or 7 as the count input as he has quote Maximite Pin No.s so where he quote pin 13 you need to replace it with one of the others as here

SOUND 100000, 3600000 ' 100KHz for a long time (1 hour)
SETPIN 5,5 ' set pin 13 as a counting input
...
PRINT PIN(5) ' get the count
...
PRINT PIN(5) ' count should have incremented

You will also need to use line numbers,

Hmm, On second thoughts, Maybe all of the above depends on which firmware you are using... If DM firmware (olimex) then what I said above is correct, if using Geoffs 12 pin MM firmware then what Geoff said is correct (I assume pins 10,11,12,13 are the count inputs on Geoff's DM version of MM 3.x)..

Now, depending on exactly what you mean to do 10us is very fast... each basic instruction, I believe, takes 30uS to process so doing something with 10uS accuracy is going to difficult come impossible.

Regards,

Mick