Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: New to teensy

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    6

    New to teensy

    I am working on a project that requires 4 stepper motors, 11 LED pwm dimmers, and 2 or 3 voice channels. I had been working with Arduino Mega and was running into number of timer limitations with running that many channels of PWM and steppers and then definitely hit a wall when I needed more than one voice channel, the poor little 8 bit guy just couldn't do it. So I started looking around and had heard about Teensy, dug in a bit and ordered a 3.5. Well it came yesterday, maybe too quick really, now I am trying to figure out how to proceed without running down 100 rabbit holes. I had thought I saw somewhere that there were many timers on one of these chips but now it seems it may be even more limited for PWM type channels than Mega. Is it just the chip that has these multitude of timers and they are not wired out on the board. I really don't have a clue at this point. I guess what I am asking is what is the best way to proceed to configure to get my 4 stepper, 11 pwm's ?
    Looking at the voice part it would seem to be a piece of cake. It really looks like a complete other world here compared to where I have been with the development and ease of use just over the top really. Kudos to the team there!

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,212
    now it seems it may be even more limited for PWM type channels than Mega
    Why do you say that?

    I haven't used PWM, so maybe there are some limitations I don't know about, but the pinout diagram for the 3.5 shows 19 pins that are PWM capable.

    Pete

  3. #3
    Junior Member
    Join Date
    Feb 2020
    Posts
    6
    Yes I see there are enough pins, but are there enough accessible timers to support the pins? I only see timerone timerthree and flextimertwo, other docs where it states the libraries only support 4 intervaltimer objects???

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    693
    For driving the steppers: https://luni64.github.io/TeensyStep/ (This uses one intervaltimer per motor controller (10 motors per controller) and the FTM0 module (configurable)

    For PWM: https://www.pjrc.com/teensy/td_pulse.html (scroll down to the PWM frequency chapter) The table shows which PWM pins correspond to which FTM modul. If you can live without the pins from FTM0 TeensyStep should do what you want out of the box. If you need exactly the PWM pins handled by FTM0 you can reconfigure the FTM module used by TeensyStep.

    Hope that helps

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,282
    As you can see on that PWM documentation page, Teensy 3.5 has 4 actual FTM timers which generate PWM.

    If you need all 4 timers for motor control, the SoftPWM library might be a good alternative for controlling those 11 LEDs.

    Like with Arduino Mega's timers, the FTM timers have a lot of special features which you can't access from Arduino functions. Libraries like AltSoftSerial and FreqMeasure and PulsePosition use some of those special features, so those might be a good place to start looking at code if you need to access the FTM timers directly. Of course, you'll also need to read the reference manual for the chip, to learn about the FTM timers in detail. But be forewarned, the FTM timers are loaded with a tremendous number of advanced features, which makes for a large amount of highly technical documentation in the reference manual's FTP chapter.

  6. #6
    Junior Member
    Join Date
    Feb 2020
    Posts
    6
    Quote Originally Posted by PaulStoffregen View Post
    As you can see on that PWM documentation page, Teensy 3.5 has 4 actual FTM timers which generate PWM.

    If you need all 4 timers for motor control, the SoftPWM library might be a good alternative for controlling those 11 LEDs.

    Like with Arduino Mega's timers, the FTM timers have a lot of special features which you can't access from Arduino functions. Libraries like AltSoftSerial and FreqMeasure and PulsePosition use some of those special features, so those might be a good place to start looking at code if you need to access the FTM timers directly. Of course, you'll also need to read the reference manual for the chip, to learn about the FTM timers in detail. But be forewarned, the FTM timers are loaded with a tremendous number of advanced features, which makes for a large amount of highly technical documentation in the reference manual's FTP chapter.
    Thanks guys for the expertise.
    With Mega for the steppers I was not using any libraries and controlling 3 motors with each timer using interrupt to fire the step and then adding whatever delay needed to the OCR inside the ISR (not really PWM of course), I am assuming this kind of scheme is what you call SoftPWM. Could I use the 4 PIT timers to do exactly the same thing in the Teensy? I might be able to use the TeensyStep but I think it does not have speed control on the fly which I was using in my project here https://www.youtube.com/watch?v=kjwMQzT41ck that required a more natural movement rather than precise. Is there a library that could help do speed/accel control or would I need to dig down into the chip. I was a bit horrified when I looked at the reference manual, the length alone was daunting.

    Also on the Mega I was using timer direct PWM (Hardware PWM) to control LEDS also 3 channels per timer. I was using the full 16 bits resolution which I found necessary to get a smooth fading effect due to the very non linear visuals from driving leds in this manner. How many channels could I run with each FTM timer on the teensy and what would the resolution be? Alternatively if I use softPWM would I then need some LC type filter on the output to eliminate the flicker at the presumably much lower PWM frequency?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •