Teensy Architecure

Status
Not open for further replies.

Raphael

New member
hi,

I am using Teensy 3.6 to acquire the data from a triaxial accelerometer adxl 313 (I2C/ SPI) and and analog sensor connected at Analog input.
I have been using arduino uno Atmega 328 and mega 2560 which have clear Registers and Timers from their architecture like ATMEGA 328 pinned https://electronoobs.com/eng_arduino_tut140.php . However, i want to interface 3 adxl 313 in 2 SPI interface mode . One of the big issue is the setting of the sampling frequency at 1Khz, which was done using ATMEGA 328.

MY questions:
1) which best AND EASY way to acquire the data at 1 Khz using Teensy 3.6.
2) ANY ARCHITECTURE OF TEENSY ?

Thank you.
 
MY questions:
1) which best AND EASY way to acquire the data at 1 Khz using Teensy 3.6.

Use an interval timer.
https://www.pjrc.com/teensy/td_timing_IntervalTimer.html
2) ANY ARCHITECTURE OF TEENSY ?
Don't know what you mean, what exactly is the question?
The CPU architecture is ARM Cortex M4.

What is "clear Registers and Timers?", what is meant with this?
You may want to have a look at the reference manual MK66FX1M0 (= Teensy3.6) on this page: https://www.pjrc.com/teensy/datasheets.html
 
1) which best AND EASY way to acquire the data at 1 Khz using Teensy 3.6.

The easiest way is to write your code to always make the measurement in less than 1 millisecond, and then use an elapsedMicros variable to wait until the proper time to begin the next measurement. This page has info about elasedMillis and elapsedMicros.

https://www.pjrc.com/teensy/td_timing_elaspedMillis.html

That is the easiest way.


You asked for both "best AND EASY". Frank's answer to use IntervalTimer would be the best way. IntervalTimer gives high accuracy. But it requires more advanced programming cause your code will run as an interrupt rather that normal code, so it is not the easiest way. This page has details about IntervalTimer and some advice about the more advanced techniques to properly use interrupts.

https://www.pjrc.com/teensy/td_timing_IntervalTimer.html
 
The easiest way is to write your code to always make the measurement in less than 1 millisecond, and then use an elapsedMicros variable to wait until the proper time to begin the next measurement. This page has info about elasedMillis and elapsedMicros.

https://www.pjrc.com/teensy/td_timing_elaspedMillis.html

That is the easiest way.


You asked for both "best AND EASY". Frank's answer to use IntervalTimer would be the best way. IntervalTimer gives high accuracy. But it requires more advanced programming cause your code will run as an interrupt rather that normal code, so it is not the easiest way. This page has details about IntervalTimer and some advice about the more advanced techniques to properly use interrupts.

https://www.pjrc.com/teensy/td_timing_IntervalTimer.html

Thank you for guidance. altough hard, i have to do it to acquire consistent data.

is there any option to visualize the data in realtime not using Serial monitor in arduino ?
 
Any other serial terminal or a display or whatever comes to your mind.

What is hard? That's the job of microcontrollers..
 
IntervalTimer is certainly a lot easier than using that Electro Noobs tutorial for the AVR timers! Instead of requiring a lengthy read about the timer hardware registers, with IntervalTimer you just use myTimer.begin(function, 1000); to cause your function to be called every 1000 microseconds. It is so much simpler.

Both approaches use interrupts. But the Electro Noobs tutorial completely glosses over the things you need to know for sharing data between an interrupt and the rest of your program. Their example only toggles a pin. It doesn't do anything like data acquisition. Compare with the IntervalTimer tutorial which does show use of "volatile", the noInterrupts() function, and copying the volatile variable. If you use the AVR timers, you still must do those things to properly share data between the interrupt and the rest of your program.
 
Status
Not open for further replies.
Back
Top