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

Thread: Teensy LC : tlc5940 and shiftpwm libs ?

  1. #1
    Junior Member
    Join Date
    Jan 2016
    Posts
    11

    Teensy LC : tlc5940 and shiftpwm libs ?

    Hi,
    Could the tlc5940 and the shiftpwm libraries be ported for the teensy lc ?
    I am trying to control the 4*4 sparkfun button pads with a teensy lc but it needs several pwm output pins.
    I have bought a tlc5940 (and several 74hc595 as an alternative to test as I am almost a beginner) but it doesn't compile on the Teensy LC.
    Regards
    David

  2. #2
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    If you can specify in more detail what "does not compile" mean we may be able to help.

  3. #3
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    These libs have not be ported for the teensy lc as you can see here : https://www.pjrc.com/teensy/td_libs.html
    But I have discovered this too late.

    Paul told on twitter that these libs are not used often anymore. But all the tutorials I have found used them.
    So I don't know how to finish my project.

  4. #4
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    Why don't you share some details as to what your project entails ?
    There is usually more than one way to accomplish one thing.

    You could easily do this with WS2012b LEDs (Neopixels) , which are individually addressable and use the FastLED library, for example. No need for multiple PWM outputs.

    What hardware have you already purchased other than the tlc5940 ?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Please post links to the button pad and tutorials you mentioned, and any other relevant material about what you're actually building. Context matters...

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,540
    It's simple. You spend a few more bucks and buy a Teensy 3.2.

    I really can't understand why people are so avaricious and buy a Fiat 500 for 11.65$ although they could get a Land Rover for 19.80$...

  7. #7
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    I have already a Teensy 3.1 for a while but it is used for another project.
    I have recently bought Two teensy LC and the audio board for smaller projects.

    It's absolutely not a question of money, it's simply I have these boards and I would have loved to use them to control rgb leds and pads.
    It's also a way for me to learn, the Teensy LC has all the power I need. I simply miss these libs.
    Or maybe I should use another lib I don't know ?

    Here is the tutorial I have followed : http://interactingobjects.com/sparkf...t-1-soldering/
    But I don't have enough PWM pins (same for the Teensy 3.1) so I have begun to explore shift registers and tlc5940.
    And the Sparkfun button pads : https://www.sparkfun.com/products/7835

    I would like to use it to build my MIDI controller/sequencer.
    Regards

  8. #8
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    I have also purchased a 74hc4067 after reading some posts on different forums but I think I was wrong as I can control only a led at once.
    As I said I am almost a beginner and I learn from every mistake I make...

  9. #9
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    edit..
    so basically your trying to use either the TLC5940 or shift-registers to run the leds, the problem you have is that neither library is supported on the LC
    Last edited by Donziboy2; 01-19-2016 at 02:45 PM.

  10. #10
    Junior Member
    Join Date
    Jan 2016
    Posts
    11

    Smile

    Quote Originally Posted by Donziboy2 View Post
    edit..
    so basically your trying to use either the TLC5940 or shift-registers to run the leds, the problem you have is that neither library is supported on the LC
    Yep, that's why I simply had asked to Paul if these libs could be ported on the Teensy LC.
    Nothing more.
    If these libs are obsolete please let me know what else I can use.

  11. #11
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    @localhero
    Post some linlks and info. I have suggested an alternate soluiton already in my post above.

    @Theremingenier
    An Arduino UNO may be a Fiat 500. To stay with the metaphore the Teensy LC is a Land Rover, perhaps without the premium package, but still a land rover ;-)
    If you design a product and not just a one-off project sometimes price does play a role. Granted, that unlikely pertains to this project, but a Teensy LC is more than plenty to light 16 LEDs.

  12. #12
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    Quote Originally Posted by localhero View Post
    Yep, that's why I simply had asked to Paul if these libs could be ported on the Teensy LC.
    Nothing more.
    If these libs are obsolete please let me know what else I can use.
    Not so much obsolete as it takes time to make and test the changes and there is very few people reportedly using either. So Paul just decided to spend his time on other things, there is not much stopping anyone from looking at the github and making the changes themselves and posting them.

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    This is the modern replacement for the (now ancient) TLC5940.

    https://www.adafruit.com/products/815

    TLC5940 is an obsolete part. I know there's a lot of web pages about it, but it's expensive, difficult to use, and the code is horrible. I really do not want to work on that code again (and nobody else ever did... which I why I ended up being the one to port it to other chips).


    I believe ShiftPWM is very close to being able to work on Teensy LC. I'll take a look shortly.

  14. #14
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    Quote Originally Posted by Headroom View Post
    @localhero
    Post some linlks and info. I have suggested an alternate soluiton already in my post above.
    I have already posted what I have built (following this : http://interactingobjects.com/sparkf...t-1-soldering/) :


    So I can't change the leds now.

    I am not sure to be able to understand why the lib doesn't compile on the LC but I will try.

  15. #15
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    Quote Originally Posted by PaulStoffregen View Post
    This is the modern replacement for the (now ancient) TLC5940.
    https://www.adafruit.com/products/815

    TLC5940 is an obsolete part. I know there's a lot of web pages about it, but it's expensive, difficult to use, and the code is horrible. I really do not want to work on that code again (and nobody else ever did... which I why I ended up being the one to port it to other chips).

    I believe ShiftPWM is very close to being able to work on Teensy LC. I'll take a look shortly.
    Oh great

    Thanks Paul for pointing to a replacement part. Didn't know that this TLC5940 was so horrible. Hmmm I have one for sale then.
    The problem is that I live in France and such adafruit products take time to arrive

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    However, these aren't going to help much with the LEDs on that Sparfun button pad. It has 16 LEDs, each with red, green and blue. That's 48 individual LEDs to control.

    But there aren't 48 individual wires routed to the 48 LEDs. So it's incompatible with TLC5940 or Adafruit product #815 or ShiftPWM. All of those would work if you connect a single LED to each pin, but that's simply not the way Sparkfun made that button pad.

    Sparkfun connected it in a matrix manner. It's documented on their site. Here's the schematic:

    Click image for larger version. 

Name:	4x4-schem.jpg 
Views:	135 
Size:	120.6 KB 
ID:	6145

    Instead of 48 wires, this thing has 12 LED wires on the right hand side, and 4 on the bottom. To make this sort of thing work, you need to turn on one of the 4 column (the GND pins) at a time, and then drive the 12 rows with the LED pattern you want for that column. Then you rapidly repeat for each column. The LEDs are on at most 25% of the time, so you need to drive them with 4X as much current. The GND pins need to carry that 4X current times 12, which means a really big NPN or N-channel transistor is needed.

    This type of LED matrix driving is not a beginner level project. It's quite difficult to do correctly. You end up working with circuitry to switch large currents quickly, which is very unforgiving of minor mistakes. I do not recommend attempting the LED matrix drive. It's difficult, even for experts. The odds for success at a beginner level are slim at best.

    Perhaps you could just use that board to hold the parts, but cut away all 12 of those LED row wires, and connect all 4 GND pins direct to ground. Then you could solder 48 wires from 3 of those Adafruit boards to control all the LEDs individually.

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Ok, well that was easy. I've added support for Teensy LC to ShiftPWM.

    https://github.com/PaulStoffregen/Sh...bbdd603df3dbfb

    Just download the latest from github, build up your '595 shift register circuit, and it will work (at least to control LEDs individually... not in a matrix).

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Just so you can see it does indeed work, here's a photo of the Teensy LC on my desk right now, controlling 16 RGB LEDs with the hardware I built years ago for testing ShiftPWM.

    Click image for larger version. 

Name:	shiftpwm.jpg 
Views:	116 
Size:	103.5 KB 
ID:	6147
    (click for full size)

  19. #19
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    Quote Originally Posted by PaulStoffregen View Post
    However, these aren't going to help much with the LEDs on that Sparfun button pad. It has 16 LEDs, each with red, green and blue. That's 48 individual LEDs to control.

    But there aren't 48 individual wires routed to the 48 LEDs. So it's incompatible with TLC5940 or Adafruit product #815 or ShiftPWM. All of those would work if you connect a single LED to each pin, but that's simply not the way Sparkfun made that button pad.

    Sparkfun connected it in a matrix manner. It's documented on their site. Here's the schematic:

    Click image for larger version. 

Name:	4x4-schem.jpg 
Views:	135 
Size:	120.6 KB 
ID:	6145

    Instead of 48 wires, this thing has 12 LED wires on the right hand side, and 4 on the bottom. To make this sort of thing work, you need to turn on one of the 4 column (the GND pins) at a time, and then drive the 12 rows with the LED pattern you want for that column. Then you rapidly repeat for each column. The LEDs are on at most 25% of the time, so you need to drive them with 4X as much current. The GND pins need to carry that 4X current times 12, which means a really big NPN or N-channel transistor is needed.

    This type of LED matrix driving is not a beginner level project. It's quite difficult to do correctly. You end up working with circuitry to switch large currents quickly, which is very unforgiving of minor mistakes. I do not recommend attempting the LED matrix drive. It's difficult, even for experts. The odds for success at a beginner level are slim at best.

    Perhaps you could just use that board to hold the parts, but cut away all 12 of those LED row wires, and connect all 4 GND pins direct to ground. Then you could solder 48 wires from 3 of those Adafruit boards to control all the LEDs individually.
    He could use fets for each column. Run RBG for first column for a cycle, then switch to next column and repeat, the Teensy LC should be capable of switching between 4 fets to run the 4 columns. He would need to run them with higher then normal current since they would be dimmer due to the 1/4 duty cycle. Unlike PCA9685 you can use switching frequencies higher then 1.6KHz with the TLC.

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Quote Originally Posted by Donziboy2 View Post
    He could use fets for each column. Run RBG for first column for a cycle, then switch to next column and repeat,
    Yes, but that's a pretty advanced project. Even experts can struggle with circuitry for driving MOSFET gates rapidly, and getting the timing of everything correct, and along the way not making any mistakes that cause a 4X or 48X too high current from flowing through some part of the circuit for too long. I believe the odds of any beginner getting it working, with a lot of frustrating experiences and blown parts, is virtually zero.

    I'm honestly pretty surprised Sparkfun even sells this board. Their tutorial only really talks about wiring up the buttons... for a good reason.

  21. #21
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    Quote Originally Posted by PaulStoffregen View Post
    Yes, but that's a pretty advanced project. Even experts can struggle with circuitry for driving MOSFET gates rapidly, and getting the timing of everything correct, and along the way not making any mistakes that cause a 4X or 48X too high current from flowing through some part of the circuit for too long. I believe the odds of any beginner getting it working, with a lot of frustrating experiences and blown parts, is virtually zero.

    I'm honestly pretty surprised Sparkfun even sells this board. Their tutorial only really talks about wiring up the buttons... for a good reason.
    Yes, I agree about sparkfun and this board, its advanced and there are much easier ways of doing it. I also believe there are enough examples of different circuits out there that its entirely possible to do this project without having done it before. You cant gain experience if you don't try to release a little magic smoke.

  22. #22
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    Thanks Paul for adding support for Teensy LC to ShiftPWM !
    I've quickly tested it with leds on a breadboard and it works perfectly

    Now I agree that this matrix is not trivial to manage.

Posting Permissions

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