ayushextreme
Member
I am thinking of buying a teensy soon. The Teensy++ 2.0 is costlier than the Teensy 3.1 but the Teensy 3.1 is so much faster and has more memory! Can someone explain why? 
I'll speculate: Amazingly, ARM Cortex M3/M4 cost less; I see distributor pricing of $7.50 or so for the K20 256KB vs. 10.50 for the Atmel USB 128K 8 bit. Partly due to competition among dozens of ARM-based vendors. Partly due to age of Atmel's 8 bit and its process, and it's sole-source.
And the PCB for the T2++ is larger.
The Atmel AVC/mega vs. ARM Cortex are really apples-vs-oranges.
Most people accept that technology becomes less expensive over time as things improve. The process by which that happens involves newer, more capable things replacing older, less capable, more expensive things. Often the new isn't a perfect replacement for the old, despite the fact it's superior. There's usually a pretty long transition, where both are available, so people still depending on the old way can get it. The old version doesn't actually get any cheaper. It slowly becomes obsolete as newer versions offer better performance and people migrate to using it.
Teensy 2.0 & ++2.0 vs Teensy 3.1 is a perfect example.
The AVR chips were mostly designed in the late 1990s and early 2000s. They're some of the last and best 8 bit chips, from the end of an era where everything ran on 5 volts.
Cortex-M is a relatively new processor design, made by ARM within the last 5 years. Freescale introduced these chips to the market only a few years ago. Teensy 3.0 was created right when the first of the lower cost ones became commercially available, in September 2012.
Regarding the timers, you certainly can directly access them in Teensy 3.1 if you really want. That's fairly common practice on AVR and Arduino, partly because the chips have been around for so very long that many people have learned how those timers work (actually, only a subset of their features is really well known - hardly anyone uses the ICP register), and partly because the speed of those AVR chips is so much slower that certain types of projects really need to resort to that type of direct access.
But a huge reason why so many projects directly access the AVR timers is because Arduino never published a timer API for people to access the timers. That's a real shame, because a well designed API could have made accessing timers easier, and made the code more easily portable to other chips.
The vast majority of programs that access the timers directly do so for only 2 reasons: running an interrupt at a regular interval, and changing the PWM frequency and resolution. For Teensy 3.x, I created Arduino extensions to do these. There's IntervalTimer for running interrupts, and analogWriteFrequency() and analogWriteResolution() for control of the PWM waveform. If you're wanting the timer access of those 2 common needs, please save yourself a lot of trouble and use those nice functions.
Usually more advanced timer stuff is done deep within libraries. Just recently I wrote a PulsePosition library that makes extensive use of the Teensy 3.1 FTM0 timer. You could look at PulsePosition.cpp for some idea of how to access the timer hardware directly. In concept, it's pretty much the same as AVR. The chip's documentation explains how the hardware works and has a list of registers you can access to control it. Even on AVR, the timers have a lot of features. On Teensy 3.1, the timers are dramatically more capable, which means there's a LOT more to read and learn to use them. You won't find a lot of writing online about this, because the chip is so new that relatively few people have done so and written about it (or perhaps lived to tell the tale...) Because of IntervalTimer, analogWriteFrequency and analogWriteResolution, probably fewer people will do so (as probably should have happed with Arduino many years ago, but never did, causing so many people to have to dig into the hardware).
If you really want to learn the hardware timers, you certainly can. I might even be able to answer a few questions, since I've written code for all of them, though some features I still haven't used....
must you do motor control starting with a chip? versus
http://www.pololu.com/product/713 $4.95, logic voltatage 2.7 V to 5.5 V
more
http://www.pololu.com/search?query=h+bridge&x=0&y=0
Yes, you can drive a motor to full speed using 3.3V logic from the Teensy 3/3.1 if your driver's logic level allows 3.3V, as that Pololu board does. It's purely a logic level going into the board, the only thing that matters is the PWM duty cycle because it is a PWM input, not an analog input. You are not dealing with an analog voltage until you get to the output (motor) side of the driver.Yes I understand, The L293d is basically the same thing. You can just wire it up and it will act like the same module. The logic voltage level is between 2.7v to 5.5v. For speed control I get max speed at 5v and half speed at 2.5v if i am suppying a pwm instead of a HIGH or LOW. But can a 3.3 v pwm can't run the motors at the max rated speed?