CodilX 0 Posted June 26, 2015 Share Posted June 26, 2015 Hello, I was wondering, if it was possible to control a RGB LED strip using the MSP430? I found this tutorial for Arduino, I copied the circuit and the code, changing the pins to 14, 13 and 12, however it just fades the on board LED. https://learn.adafruit.com/rgb-led-strips/usage Quote Link to post Share on other sites
chicken 630 Posted June 26, 2015 Share Posted June 26, 2015 I was looking at the same example for my little project, but haven't built it up yet. What MSP430 board are you using? What MOSFET's are you using? Quote Link to post Share on other sites
CodilX 0 Posted June 26, 2015 Author Share Posted June 26, 2015 I found some TIP31C's laying around. The board itself not 100% sure at the moment. I called my buddy who's into electronics and project such as this, he told me that the MSP430 only has 1 PWM output pin, so it seems this can be done easily only on the Arduino Quote Link to post Share on other sites
enl 227 Posted June 26, 2015 Share Posted June 26, 2015 Absolutely. The style of strip you are using is about the easiest to control. Without getting into details of what you did (since you didn't provide the code, say what processor you are using, etc), I'll go over a few things related. Assuming that you understand how PWM works, the key questions are polarity for the drive (is the LED on when the output is high? or when it is low? The adafruit sample should be on when high), what gate voltage is needed to enable the MOSFET (assuming you are using the same device as the tutorial), what pins can you use for PWM, and are the outputs properly set for PWM. There are other things to look at, but these come to mind first, as they are all relevant to the difference between a 5V AMTEL processor and a 3.3 (or 3.6)V MP430 I can't address the last two questions without seeing the code you used and knowing the processor you are running on, but the second may be key: The STP16NF06 drain current is essentially 0 until Vgs exceeds 3.6V (see fig6, P6/14 of http://www.st.com/web/en/resource/technical/document/datasheet/CD00002501.pdf) Without some gate voltage boost, the MOSFET won't turn on. This isn't an issue with a 5V processor, as at 5V Vgs, drain current is approx 8A, if Vds is sufficient. I would suggest a level shifter to drive the gate if you want to use this MOSFET, or changing to a bipolar driver. I have used an assortment of methods over the years, but the easiest is something like a ULN2803 or similar. It isn't that hard to cob up a level shifter to drive the gate of the MOSFET with an npn small signal transistor and resistor, though that will invert the polarity of the drive signal, which you can compensate for in software. You can also use one of the many 74HCT devices as a level shifter. The inputs are comaptable with the 3.3 or 3.6V outputs of hte MSP430 (actually, down to about 2.5V reliably) when powered by 5V. Quote Link to post Share on other sites
enl 227 Posted June 26, 2015 Share Posted June 26, 2015 You followed up while I was typing. Using the tip31c will require a different setup to drive it, as they are relatively low current gain. Darlington using a 2n3904 for the first stage will do fine. Also, you CAN do more than one PWM, even on the most basic MSP430g devices. The 'g2452 has two hardware driven outputs for the single timer_A (each of which can be one more than one pin), for example. Other higher level devices allow more hardware PWM. That said, using software, you can do as man as you want. Somewhere in the past ( http://forum.43oh.com/topic/4511-ended-oct-2013-43oh-halloween-contest/) I have a project that does 8 PWM for a similar purpose. Not quite the resolution of hardware PWM, but does a dandy job for many things. edit: typo in part number Fmilburn 1 Quote Link to post Share on other sites
CodilX 0 Posted June 26, 2015 Author Share Posted June 26, 2015 So it is possible to control RGB LED strips with the MSP430? Maybe someone could share the process involved? With the Arduino it looks really simple, would it be difficult to achieve the same thing on the MSP430? Quote Link to post Share on other sites
Fmilburn 445 Posted June 26, 2015 Share Posted June 26, 2015 I learned the hard way about checking the datasheet for the threshold of Vgs a while back when I had a circuit that worked on an Arduino but not on a LaunchPad. I haven't tried it yet myself but @@chicken is using the FQP30N06L MOSFET in his project elsewhere with strip LEDs. They look like you can control them directly with 3V3. I am about to try TIP120 darlingtons since I happen to have some on hand. Quote Link to post Share on other sites
enl 227 Posted June 26, 2015 Share Posted June 26, 2015 Code is attached to the post in the halloween contest thread. Take a look at that first (about halfway down.. the file is "main_revised.c") Note principally the setup at the start of main, and the timer interrupt service function. The interrupt function outputs new state, then counts clock ticks. At the end of PWM cycle, it resets the counters for a new cycle, loads PWM values for then new cycle, and raises a flag for the main to update the PWM values for the next cycle to follow. Note that the first thing done is update the outputs. This minimizes jitter. Not as good as hardware PWM, but close. Quote Link to post Share on other sites
chicken 630 Posted June 26, 2015 Share Posted June 26, 2015 @@enl Given the reference to the Adafruit poject I think the intent is using Energia, i.e. using analogWrite(). @@Fmilburn is probably on the right track regarding the voltage required to turn on the MOSFETs. Another thing worth checking out is, what pins actually support analog (i.e. PWM) output. This depends a bit on the LaunchPad @@CodilX is using. See the pin map images on Energia.nu. Pins capable of PWM are marked in violet. Quote Link to post Share on other sites
chicken 630 Posted June 26, 2015 Share Posted June 26, 2015 So it is possible to control RGB LED strips with the MSP430? Maybe someone could share the process involved? With the Arduino it looks really simple, would it be difficult to achieve the same thing on the MSP430? It definitely is possible, with the exact same setup as the example at Adafruit - as long as the chosen MOSFET turns on at 3.3V or less (it's 5V or less for Arduino), and the pins do support analogWrite() in Energia (color violet, all MSP430 LaunchPads have more than 3). Quote Link to post Share on other sites
CodilX 0 Posted June 26, 2015 Author Share Posted June 26, 2015 It definitely is possible, with the exact same setup as the example at Adafruit - as long as the chosen MOSFET turns on at 3.3V or less (it's 5V or less for Arduino), and the pins do support analogWrite() in Energia (color violet, all MSP430 LaunchPads have more than 3). I'm checking the TIP31C data sheet (https://www.fairchildsemi.com/datasheets/TI/TIP31A.pdf) and it shows Collector Current (DC) at 3V. But the Collector Current (Pulse) shows 5V. So I'm guessing that's the reason why it didn't work correct? This transistors requires 5V? Quote Link to post Share on other sites
chicken 630 Posted June 26, 2015 Share Posted June 26, 2015 The currents are maximum ratings and in A (ampere). So no, that's not the problem. The problem with these transistors is, that they can amplify current which flows coming from the MCU into the base of the transistor only by about 10-50 (hfe parameter in the datasheet). The current provided by the MCU is limited by the resistor, and typically is in the 10-20 mA range (if you tell us, what resistors you use, we can do the math). The LED strip might require 1 A or more, which would need a transistor with at least 50-100 gain. The TIP120 Adafruit recommends in their tutorial has a gain of 1000. Quote Link to post Share on other sites
CodilX 0 Posted June 26, 2015 Author Share Posted June 26, 2015 The currents are maximum ratings and in A (ampere). So no, that's not the problem. The problem with these transistors is, that they can amplify current which flows coming from the MCU into the base of the transistor only by about 10-50 (hfe parameter in the datasheet). The current provided by the MCU is limited by the resistor, and typically is in the 10-20 mA range (if you tell us, what resistors you use, we can do the math). The LED strip might require 1 A or more, which would need a transistor with 50-100 gain. Honestly I have little to no idea what I'm doing I used these TIP51C for a lighting effect from an audio source. I had them laying around and just tried wiring them up the same way I found in that tutorial, I'm not using any resistors. My LED strip is less than 1M long, I've just cut off some to try out. I'll try and figure out what transistors would be best for this Quote Link to post Share on other sites
chicken 630 Posted June 26, 2015 Share Posted June 26, 2015 Honestly I have little to no idea what I'm doing And I just pretend I usually try to build and sanity check things step by step. My approach would be to first connect individual external LEDs to the pins I want to drive the strip with. Something like this multiplied by 3: http://energia.nu/guide/sik-for-launchpad/circuit1/ Once that works, I'm sure the software and PWM side works. Then I would move on to figure out how to turn on something that needs more power than the pin can provide, i.e. how to use a transistor or MOSFET. You can still do that with an individual LED instead of a whole strip. It will require less current and might work with your transistors. Quote Link to post Share on other sites
Fmilburn 445 Posted June 27, 2015 Share Posted June 27, 2015 I'm working on a project where I plan to try out RGB LED strips but don't have them in hand yet. So I've taken the advice of @@chicken and did a trial using what I have on hand. I've used the Adafruit circuit and sketch with the following exceptions:* used Adafruit's circuit for the TIP120 except except that I used 5mm LEDs to stand in for the strip (also put a resistor in front of each LED so it wouldn't burn out)* used Adafruit's sketch except I substituted pins 11, 12, and 13 for the Arduino PWM (used a MSP430G2553)* used a 4.5V battery pack for external power to the LEDsIt is working: For my project I am thinking I'll need at least 2 strips running 2 different colors so 6 TIP120s. I only have 5. Even better would be to have 3 strips and 3 colors - then I'll have the added complication of not enough PWM pins. Or I could skip the PWM and have constant brightness. Anyway, it looks like there is another order in my future. chicken 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.