Looking for help with microcontroller basics

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Looking for help with microcontroller basics

Postby kevinrs » Tue Feb 28, 2012 1:16 am

I've got an arduino, and done almost all of the arduino tutorials and the adafruit ones. The project I'm looking to do is using the Warm white LED waterproof flexi-strip for undercounter lighting, using the 12V 5 A switching power supplies for power, and an attiny of some sort for PWM dimming. I'm going to have to do it in 2 sections, to stay under the 5A that each supply provides, and avoid fishing wire through the walls.

My questions are, on the differences between different attiny models, there are 25 stocked atmel microcontrollers on mouser under $2.00. I've not yet seen a chart comparing them. Little charts comparing 3-4 in a series, but nothing else. I'm seeing various PWM examples using just about any attiny. Are there any differences that will affect this application? I'm only going to need 1 pwm output, and possibly one analog in. Any differences in how they are programmed?

Finally found a post where someone did almost the same project, http://www.instructables.com/id/How-to- ... de-effect/ so now planning to start with their plan, but use an attiny, since I don't have a mega laying around.
I'm going to have to figure out what changes in wiring and programming have to be made
They did manage to set up 2 levels of brightness with no controls, going to have to look closely at that, and figure out if I want a live adjustment of dimming level. Probably have to get the parts and test in place and see how it looks.

Is there anything else that I'm overlooking? more or different capacitors needed than they used? I'm going to have to order most parts besides resistors anyway, so trying to find out what I need ahead of time. I'm figuring on testing on a breadboard and moving to permaproto, haven't figured out enclosure or mounting location yet, probably keep it thin and hide it under the counter.
kevinrs
 
Posts: 21
Joined: Sun Jul 31, 2011 4:08 am

Re: Looking for help with microcontroller basics

Postby philba » Tue Feb 28, 2012 12:27 pm

Sounds like a fun little project. I, too, get somewhat overwhelmed by the variety of ATTinys. I'd start with the number of pins you'll need. I'm guessing 1 for PWM, 2 for rotary encoder input or 1 for analog from a pot (I'd go with an encoder, though). The project you linked to uses a fairly clever way to have 2 levels of brightness without adding a control though I would prefer more control personally. So, just about any tiny will work ok. 8 pins should be fine. get the package you feel comfortable working with (dip or soic, most likely) with the most memory (8K, I think). Probably an ATTIiny85. Google turns up several pages about programming it for arduino.

On the fade up/down. The eye response is logarithmic so I would use a table to adjust the PWM to better track perception. I used a spreadsheet to compute a 256 entry table using the log function. The fade loop was someting like this (schematic, not actual runing code):
Code: Select all
char dimtab[256] = { init values };

...
for(i=0;i<256;i++) {
    analogWrite(pPWM, dimtab[i]);
    delay(FADEDELAYTIME);
}

Make the table a const and put it in flash.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: Looking for help with microcontroller basics

Postby kevinrs » Tue Feb 28, 2012 8:24 pm

My thinking is more control would be good too. A rotary encoder sounds interesting, but I'm dealing with 2 different setups basically, one could be left powered all the time, and turn off the lights by pushing the encoder(I'm looking at the adafruit one), leaving the controller powered, retaining what the brightness was.

The other setup has a 2 switch setup controlling the AC power already, so if the switch is turned off, the simple ways of controlling brightness with digital control are erased with loss of power, and it would come back on at full brightness, or whatever it's programmed for, when turned back on. My thinking with using a pot, is if it's set at X% brightness, it's still going to be at X% after losing and regaining power.

If there's a way to have the attiny retain the setting when power is lost, looking for 5 minutes into the functions in eeprom.h, it looks like it may be possible.
Having the unlimited rotation of an encoder would allow things like letting the full range of brightness be 2 rotations of the encoder, just as an example.
kevinrs
 
Posts: 21
Joined: Sun Jul 31, 2011 4:08 am

Re: Looking for help with microcontroller basics

Postby adafruit_support_bill » Tue Feb 28, 2012 8:49 pm

I'm going to have to do it in 2 sections, to stay under the 5A that each supply provides

If you are going to be running these at close to rated output, don't bury them in a cabinet somewhere. Leave some room for air flow around them as they do get warm.
User avatar
adafruit_support_bill
 
Posts: 15962
Joined: Sat Feb 07, 2009 9:11 am

Re: Looking for help with microcontroller basics

Postby kevinrs » Wed Feb 29, 2012 3:22 am

I have right about 5 meters total to light, so am going to use the whole 5 meter roll, which would be 6 amps. Unless I found a cost effective 10 amp or so power supply, It's going to be split. Even if I did find one, I'd have to figure out fishing wire up to the attic and back down, across a doorway.
How going to be split, about 2 meters that are not lit in any way currently, so 2.4 amps, and about 3 total that have a 4 foot and 2 ~18 inch fluorescent tubes poorly lighting them. that 3 meters will be 3.6 amps. My thinking is to one way or another(hook and loop or superlock tape, or zip ties fastened to the wood somehow), strap the power supplies to the underside of the cabinets, so they should not have an overheating problem.

I am thinking I probably don't need a full TO-220 style 7805 to power an ATtiny that will only be connected to a pot or rotary encoder and a single mosfet. Haven't looked into that though.
kevinrs
 
Posts: 21
Joined: Sun Jul 31, 2011 4:08 am

Re: Looking for help with microcontroller basics

Postby philba » Wed Feb 29, 2012 10:37 am

kevinrs wrote:...
If there's a way to have the attiny retain the setting when power is lost, looking for 5 minutes into the functions in eeprom.h, it looks like it may be possible.
Having the unlimited rotation of an encoder would allow things like letting the full range of brightness be 2 rotations of the encoder, just as an example.


You are in luck. All the Tinys have eeprom - the 85 has 512 bytes, iirc. You can save anything you want retained across power cycles. I don't know if the arduino eeprom library works for the 85 but it's not that hard to write code to use it (the library should, same interface). There are atmel apnotes with code that help.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 0 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]