Cheapest AVR for RGB Led kitset

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All

I am looking at developing a kitset for the simple control of RGB led's
I would envisage my kitset having 3 channels of pwm (of course driving R G and B) as well as 3 channels of analog inputs perhaps (as a means of varying each pwm up and down) along with the facility for a lcd screen in 4 bit mode to display the RGB values.
I mainly work with the ATMEGA8535 Controller and think that this would do all of the above easily but I was wondering what is the smallest Avr controller that would do this (to keep the end cost of the kitsets to a minimum)

Many Thanks

Bruce

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the smallest AVR would be the ATtiny24: 4 PWM channels, ADC on board and is available in 14-pin and 20-pin packages.
EDIT: But you have to sacrifice the RESET pin for the LCD, so only high voltage programming is possible then.

An other option is the ATmega48: 6 PWM channels, ADC on board and is available in 28-pin and 32-pin packages. With this chip you can even control two RGB-LEDs.

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Contact miamicanes--I think he'd share his design, or at least the approach. It might even be posted in one of the threads about his project.

https://www.avrfreaks.net/index.p...

I think he used a Tiny13 as the chip.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used software-driven PWM with a Tiny25 (the original hardware design was for the Tiny13, and at the last moment I discovered that the Tiny25 was available and only cost a tiny bit more).

The funkiness with blue and green was because the LEDs I bought had a few with the blue and green elements swapped (probably the reason why they were so cheap -- ~40c/ea from Futurlec for 100+)

/**	PWM-handler for the LEDs.
 *	@changes rBitLengthTimer
 *	@changes rKernelTimer
 *	@reads rRedValue (lower 8 bits of red pwm duty cycle)
 *	@reads rGrnValue (lower 8 bits of green pwn duty cycle)
 *	@reads rBluValue (lower 8 bits of blue pwm duty cycle)
 *	@reads rMode (bit 7 indicates whether blue and green need to be swapped).
 *
 */
KERNEL:						; (4 cycles to arrive)
	push rTemp				; 2 cycles
	in rTemp, SREG			; 1 cycle

	sbrs rBitLengthTimer, 7
	inc rBitLengthTimer

	dec rKernelCounter		; 1 cycle

;------------------------------------------------------ 
	tst rRedValue			; 1 cycle
	breq redOff				; 1 cycle (2 if true)

	cp rRedValue, rKernelCounter ;1 cycle
	brlo redOff				; 1 cycle (2 if true)
	cbi PORTB, REDBIT		; 2 cycles
	brsh doGrnBlu			; 2 cycles
redOff:
	sbi PORTB, REDBIT		; 2 cycles

doGrnBlu:
	sbrc rMode, rMode.BGSWAPBIT
	rjmp doBluGrn

	tst rGrnValue
	breq grnOff
		
	cp rGrnValue, rKernelCounter
	brsh grnOff
	
	cbi PORTB, GRNBIT
	rjmp doBlu	

grnOff:
	sbi PORTB, GRNBIT

doBlu:
	tst rBluValue
	breq bluOff

	cp rBluValue, rKernelCounter
	brsh bluOff

	cbi PORTB, BLUBIT
	rjmp handleGrnBlu1

bluOff:
	sbi PORTB, BLUBIT

handleGrnBlu1:
	// extinguish elements early if desired...
	rjmp kernelDone

doBluGrn: // if we're here, it's because green and blue are swapped in the LED
	tst rGrnValue
	breq swapGrnOff
	
	cp rGrnValue, rKernelCounter
	brsh swapGrnOff
	
	cbi PORTB, BLUBIT
	rjmp doSwapBlu	

swapGrnOff:
	sbi PORTB, BLUBIT

doSwapBlu:
	tst rBluValue
	breq swapBluOff

	cp rBluValue, rKernelCounter
	brsh swapBluOff

	cbi PORTB, GRNBIT
	rjmp handleBluGrn1
swapBluOff:
	sbi PORTB, GRNBIT

handleBluGrn1:
	// extinguish elements early if desired...

kernelDone:

	out SREG, rTemp
	pop rTemp
	reti

There's no place like ~/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks heaps, I will keep working on it. It looks like quite an easy project

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using ATMEGA8 with success, you can see the results at www.xtracolors.com (RGB 3W Leds)

regards,
David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ive done this with a tiny13. Timer based pwm.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Slightly off topic, I am based in New Zealand and get most of my components online off futurlec. They are pretty good price etc but limited variety of avr available, what other suppliers can you all reccomend for avr chips (and components)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ATmega48 easily has all the resources you need (PWM and ADC), and they're damn cheap too. ATMEGA48-20AU = US $2.58 from Digi-key and that's for 1-off!

Hardware PWM might get you power-savings over software PWM because the uC can spend more time asleep. Keeps the firmware simpler too, not that any of it is rocket science!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ATtiny15 is fit for this purpose, though you have to disable ISP programming to get all 6 i/o's.
At digikey $2.24/1