Electronics > Beginners

Counting Pulses Using Interupts - Teensy 3.6

(1/1)

threephase03:
Hi all.
I'm trying to count pulses using interrupts on the Teensy 3.6. I can count 430000 pulses in 30s. I am generating the pulses using an Arduino Uno and have maxed out its ability to pulse, I need to count up to 800000 pulses in a 30s period and trying to test its ability to be able to do it.

Thanks for any advice

JS:
  That's 26 kHz, easy for a micro tunning at a few megs but nterupts isn't the way to do it.

  Use hardware counters and pulse generators, periphericals all micro has. Both are likely in the timers modules, a counter would use an external pin as clock source and you stop the count after the time is fine and read the value.
  The pulse generator is another timer togglin a pin every N counts, something like pwm is generated but slightly different configurations for the peripherical registers.

 This applications is when arduino often falls short and you need to use conventional programming, good thing is you can do it inside the arduino enviroment. Often just writing registers directly using their names, in arduino due you need to add a prefix (IIRC "REG_") but you can keep using the arduino functions with some caveats, like if messing with timers pwm and other timing functions might not work as expected and interfere with your program. But other functions as toggling other pins, math and logic functions, etc. are usually fine. All generic C functions will work without problems.

This is a good time to make the jump, then you can jump to other plataforms wich require a bit more setup than what the arduino enviroment offers but also much more flexibility. I'm using STM32 and is great but still use arduino once in a while for some applications, it's great for small stuff and have a working peototype in minutes, once you want a bit more bare metal, as the people getting out of arduino calls it, is much more powerful.

JS

threephase03:

Thanks for the feedback, and ill keep it in mind. I just put it on a function generator set at 30kHz and timed it with a stopwatch for 30s.
And counted over 900000 calculated to be about right considering the timing by hand. I think for the quick thing I'm building it should be alright.
 

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod