9
\$\begingroup\$

Essentially, I just need to send some data to the microcontroller via USB, then the microprocessor decodes the data and drives an LED light strip, which runs at 5V. I'm having trouble finding the right microcontroller for the job.

The microcontroller just needs to have 2 serial in ports for USB communication, two serial out ports for communication with the LED strip, and be able to operate at 5V. It seems unnecessary to have a dedicated IC for USB communication when all I need is a serial COM port set up.

For example, here is the snippet of Arduino code that writes a byte to the LPD8806 strip:

void write8(uint8_t d) {
  for (uint8_t i=0; i<8; i++) {
    if (d & _BV(7-i))
      digitalWrite(dataPin, HIGH);
    else
      digitalWrite(dataPin, LOW);
   digitalWrite(clockPin, HIGH);
   digitalWrite(clockPin, LOW); 
  }
}

To latch the data you send zeros to the strip.

\$\endgroup\$
3
  • \$\begingroup\$ I think you mean one USB connection (they're two way), and one serial connection (also two way). If you're into pic, the 18f4550 family will do the job. \$\endgroup\$ Commented Oct 9, 2012 at 16:29
  • 1
    \$\begingroup\$ What's the protocol for the LED strip? Can you add a link to the datasheet or web site of the strip? \$\endgroup\$ Commented Oct 9, 2012 at 17:25
  • \$\begingroup\$ @Rocketmagnet Its this LED Strip. The datasheet is in chinese, however there is simply a serial in and clock in, and you latch by sending zeros down the line. \$\endgroup\$ Commented Oct 9, 2012 at 18:49

4 Answers 4

7
\$\begingroup\$

I guess that by "two serial out ports" you mean one UART (since you also describe USB as 2 ports). Rocketmagmet indicates that many/most LED strings use SPI, but that will need at least 3 wires. Can you specify which protocol you need?

In general Microchip has the lowest cost microcontrollers, also this time. And Microchip has many microcontrollers in DIL package as well, while many others have ditched that. May be important for DIY. The PIC18F13K50

  • exists in both DIL-20 and SMT packages
  • works at 5 V (for interfacing with the LED strip)
  • is low cost at $2.5 (OK, that's relative, but USB able controllers are a bit more expensive than more basic types)
  • has Enhanced USART for UART interface
  • has an SPI interface in case you meant that
  • has 25 mA source and sink I/O, so you can directly drive a couple of indicator LEDs if needed

Further reading
USB Generic Function on an Embedded Device, Microchip Application Note AN1166

\$\endgroup\$
13
  • \$\begingroup\$ He mentions LED strips, so I assume it's a synchronous protocol (basically SPI without the data return pin). That PIC only has 1 SPI port, so wouldn't be suitable. Although he could bit bang the protocol. \$\endgroup\$ Commented Oct 9, 2012 at 17:11
  • \$\begingroup\$ @Rocket - where does he say it's SPI? And he won't need two SPI buses: SPI is multi-slave. And like Scott commented and I also said at the start of my answer, I think by two ports he means two pins, that's why I thought about UART first. \$\endgroup\$
    – stevenvh
    Commented Oct 9, 2012 at 17:15
  • \$\begingroup\$ Perhaps the PIC18F24J50? But it's a 3.3v part, so I don't know if it will interface to the LED strip. \$\endgroup\$ Commented Oct 9, 2012 at 17:20
  • 1
    \$\begingroup\$ He doesn't say it's SPI, but I have used LED strips before, and they have always been synchronous. I could be wrong. He might mean another kind of LED strip that I've never seen before. I think he means two pins for clock & data. \$\endgroup\$ Commented Oct 9, 2012 at 17:23
  • \$\begingroup\$ Actually, I mis-read the question and thought he said two LED strips! He actually said two pins for one LED strip. So, er, as you were with the original suggestion. \$\endgroup\$ Commented Oct 9, 2012 at 17:24
4
\$\begingroup\$

Your LED strip has a simple serial interface. If you are just trying to control it with a computer, you can use a FTDI chip to wiggle the pins: http://www.ftdichip.com/Products/ICs/FT232R.htm

Then the complexity is on the PC side using libftdi or D2XX libraries. But it's not too bad, similar complexity to your Arduino example.

If you don't feel like making hardware, you can purchase premade cables with the FTDI chip from FTDI distributors like Mouser, or from Sparkfun etc. Cables are available in different voltage configurations, so order carefully.

Of course, if you want the project to be standalone or autonomous somehow, you will want a full microcontroller solution.

\$\endgroup\$
2
  • \$\begingroup\$ I should consider sending raw SPI data to the LED strip via a USB Controller. Microchip makes a USB-to-SPI which sets itself up as a HID device, while FTDI chips are either VCOM or D2XX and i'm not sure which would best suit running a light strip from a c++ program yet. \$\endgroup\$ Commented Oct 10, 2012 at 14:14
  • \$\begingroup\$ I'm not aware of an USB<->SPI bridge that shows up as a virtual serial port like the USB<->UART bridge chips do. Instead you will have to write bit-banging code, which is easy for SPI. \$\endgroup\$
    – markrages
    Commented Oct 10, 2012 at 15:50
3
\$\begingroup\$

Consider using the PSoC3.

PSoc3

They are available with USB, and almost any peripherals you want. (They are configured in software) You'll certainly be able to have two serial ports for the LED strips. You'll probably be able to have 20 if you want.

The development environment is also a joy to use.

PSoC Creator

\$\endgroup\$
9
  • 3
    \$\begingroup\$ Well that seems a bit overkill. But i'll look into it. \$\endgroup\$ Commented Oct 9, 2012 at 16:54
  • 8
    \$\begingroup\$ @Rocket - I see on Digikey that a PSOC costs more than twice the PIC I mentioned. I don't doubt they're worth their weight in gold (as a figure of speech), if you need all those configurable peripherals, for solutions you won't find on any other microcontroller, like 16 UART or so. But OP seems to need just a USB port and a serial port (UART, SPI, or I2C), then it's much cheaper to pick a relatively low-end controller which has just that. \$\endgroup\$
    – stevenvh
    Commented Oct 9, 2012 at 17:24
  • \$\begingroup\$ @stevenvh - I agree, the PSoCs can be painfully expensive. They're only really worth it for production when you can take advantage of their many functions. But for prototyping, they're totally worth it. You never have to go hunting for that special PIC that has just the right combination of peripherals, and you can implement hardware changes at the click of a button! \$\endgroup\$ Commented Oct 9, 2012 at 19:26
  • \$\begingroup\$ @Rocket - " implement hardware changes at the click of a button". Yes, that's what the Cypress guys kept telling me. I don't get it (I discussed this extensively with my colleagues, and they don't either): If I need for instance a timer in my application chances are that I need it all the time, not throw it out for a while because I want to do something different with the hardware. I do appreciate the configuration tools, like in your screenshot, and I've begged Motorola (before they became Freescale) a rhousand times to add a small FPGA to their HC05 controllers, but that was not... \$\endgroup\$
    – stevenvh
    Commented Oct 10, 2012 at 17:16
  • \$\begingroup\$ @Rocket -(continuing)... for in-application reconfiguring, that was to have a more flexible controller during development. We were a big Motorola customer at the time, and they consulted with us for ideas how to clean up the HC05 mess; there were hundreds of different types, some more successful than others. So I suggested 1)the FPGA, and/or 2) a crosspoint switch array to let you connect selected peripherals to (limited) I/O; the hardware was on the die anyway. Neither happened, and Motorola doesn't make controllers anymore... \$\endgroup\$
    – stevenvh
    Commented Oct 10, 2012 at 17:23
0
\$\begingroup\$

It cannot get simpler than this: ATmega8U2.

To top it off, you can even use that with Arduino bootloader...

Datasheet: http://www.atmel.com/Images/doc7799.pdf

(sorry for being a bit concise, I'm typing from phone)

\$\endgroup\$
3
  • 2
    \$\begingroup\$ When you're back behind your PC (shouldn't that be "in front of"?) can you elaborate: how is this the most simple solution? It has to be a good story :-), since the ATmega8U2 is 50 % more expensive than the PIC. \$\endgroup\$
    – stevenvh
    Commented Oct 10, 2012 at 9:11
  • 1
    \$\begingroup\$ I favor the AVR line (esp. ATmega) because one can use the Arduino environment for quick prototyping (poster is familiar with that!), and allows quick testing-fixing cycles. Then I optimize the code manually, or even use a smaller AVR uC, like Tiny2313 (BTW, there are soft-USB libs for AVRs). I wanted to like PICs, but when I looked at them (just before Arduino took off), I chose the AVRs: I found their docs to be better and the community stronger - despite that here in Hungary, PICs are historically more supported. I would choose a shorter dev.cycle to lower cost in low volume production. \$\endgroup\$
    – ppeterka
    Commented Oct 10, 2012 at 10:24
  • 1
    \$\begingroup\$ Exactly why the downvote? Care to explain? \$\endgroup\$
    – ppeterka
    Commented Dec 4, 2013 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.