Simple + small heartbeat LED

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

Hi guys
I want to make a small gift for my girl :D
For this i need a LED visualizing a heartbeat (fading up and down)
I'm gonna run the circuit from one single CR2032 (if possible) and it shouldn't fill much, as the circuit should be on the back of the coin-cell.
I have google ALOT, without much of luck.. and I'm down to think that the smallest and simplest circuit is a ATtiny-13 whit one resistor...

Please show me I'm wrong and there's a simpler circuit with only a few extra pieces :)

//B4Me

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

How do you get the heartbeat?

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

as stated, it should just fade the led's intensity up and down (via pwm..)

I'm building a small stick-man via resistors ..
so its just so the heart in this stick-man will light up and fade away as a heart in the man :D
fantastic idea ;D

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

You might want to consider the 6 pin tiny4/5/9/10 rather than the 8 pin tiny13. The downside of them is that you either need a C compiler that can limit itself to 16 registers or you need to write in Asm and you also need a TPI programer (AVRISPmkII can do this).

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

clawson wrote:
You might want to consider the 6 pin tiny4/5/9/10 rather than the 8 pin tiny13. The downside of them is that you either need a C compiler that can limit itself to 16 registers or you need to write in Asm and you also need a TPI programer (AVRISPmkII can do this).

Interesting - I hadn't realized the 6 pin tinys had that limitation. Can AVR-GCC do this?

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

I have already a attiny13 laying around... my question is mostly if you guys can come up with a circuit that can fade a LED up and down which doesn't contain an microprosessor

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

Google/Instructables/others say you can do this with an NE555 but if you are putting a small chip of low cost silicon at the centre of this then why not a $1 AVR rather than a $0.50 NE555? If you just want it to flash on/off a simple astable multivibrator built with something out of the 74xx TTL family would do the trick.

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

Can you link to a circuit that can "fade" the led using a 555 ?
I have looked all over google without results :(

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

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

but dude, these are all just going ON and OFF ?
I want fading up and down....
I know how to make stable PWM, but I need a PWM which duty cycle goes from 0%-100%-0% and so on....

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

The 555 just won't die...

The additional components to make it work, and the hassle in getting the R's and C's correct, (as compared to just tweaking a few software values until it looks just like you want it to), means the tiny is the way to go.

Of course some lessons you just have to learn the hard way... :)

JC

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

If it's the only thing the micro needs to do, then this will probably work. If it needs to do other stuff, put the logic in the timer overflow interrupt instead.

int main()
{
    uint8_t i;
    // setup and start timer here
    
    for(;;)
    {
        for(i = 0;i<255;i++)
        {
            OCR0A = i;
            delay_us(50);
        }
        for(i = 255;i>0;i--)
        {
            OCR0A = i;
            delay_us(50);
        }
    }

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

You can make it with 2 astable multivibrator where one control the other. We made them to sound like a police horn when I was a kid, if nothing else a filter could be used to control the amplitude.

Can't you charge over a big cap. so the voltages rise slow and then let the cap slowly drop the voltages again!

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

So instead of one $1 microcontroller and a resistor, you can use a bunch of regular analog chips / large capacitors / resistors you will have to hide somewhere in your design.

I'd go for the controller. Go SMD and you can hide it behind the led...

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

I've done something similar for my daughter. Its a light which turns itself off after a quarter of an hour. There is a button to turn it on and off. It she leaves it on then it switches off automatically.

The light is for one of her toy-houses. I was tired of replacing the batteries every two days because she forgets to turn it off...

Markus

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

then its a micro controller I'll use ... just wanted to know if simpler ICs could do it :D thanks guys

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

One could ostensibly arrange a single transistor oscilator with a poor bias scheme such that the transistor would cease oscilatinting as soon as the tranny bias point drops below a certqain level.
Used this trick many ears ago for very lightweight animal tracking beacons... a squegging xtal oscilator.

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

Actualy, to get a realistic "heartbeat" from an led requires more than a simple fade in fade out. It needs a double beat that slowly fades in, rapidly dims, then medium fade in, then rapid dim again. Again, thats easy with say a Tiny doing the driving, but getting tricky with bare bones analogue / 555 technology.

(you should have seen the long winded discusions on getting the Jaguar XF's heartbeat start button illumination correct, i reckon probably £1m was spent just on tea and biscuits during the discusions.... lol )

(also, it would be cool to add a small temp sensor, and have the heartbeat speed up when it was held ;-)

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

max_torque_2008 wrote:

(also, it would be cool to add a small temp sensor, and have the heartbeat speed up when it was held ;-)

Hahaha that's brilliant !!!

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

The tiny's have a temp sensor on chip. I think you could do it all with sw pwm. Try 64 linear dimming levels x 70 hz... 4480 loops per sec... 225usec per loop

Imagecraft compiler user

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

could you link or describe this about the linear levels .. have never heard about this before... normally i just uses timer-overflow and then changes the output-compare for pwm duty

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

I think the linear Bob is referring to is 64 equally spaced PWM rates, from 0% to 100% duty cycle. I don't think he was referring to an analog linear driver.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  /\  /\
 /  \/  \
/        \___________
|<-  750ms --------->|

feeble attempt at ascii art. Twin peaks is the heartbeat rampin up from 0 to max. 750ms is 1.3 beats per sec, 80 beats per minute. I like the speedup idea. I'll try to send something from home in a couple hrs...

Imagecraft compiler user

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

ahrg now I get it :)
yer sounds perfect Bob :)

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

B4Me wrote:
max_torque_2008 wrote:

(also, it would be cool to add a small temp sensor, and have the heartbeat speed up when it was held ;-)

Hahaha that's brilliant !!!

I thought that is a neat idea too.

Just to let you know, I am new to microcontrollers and I have been learning on a Thames & Kosmos microcontroller kit that utilizes an AVR ATtiny 2313 PU.

Please forgive me for this primitive code that is a hash between basic and assembler code

	Pdir = 1
	A = 0
L1: 
	A = Uin
	B = 2
	A = A / B
	B = 38
	A = A - B
	B = 27
	If A > B Goto L2: 
	PWM = 10
	Delay = 250
	Delay = 250
	Delay = 250
	PWM = 255
	Delay = 250
	Delay = 250
	PWM = 10
	Delay = 250
	Delay = 250
	PWM = 255
	Delay = 250
	Delay = 250
	Goto L1: 
L2: 
	A = Uin
	B = 2
	A = A / B
	B = 38
	A = A - B
	B = 27
	If A < B Goto L1: 
	PWM = 10
	Delay = 250
	Delay = 250
	PWM = 255
	Delay = 250
	PWM = 10
	Delay = 250
	PWM = 255
	Delay = 250
	Goto L2: 
	End

I use s NCT thermistor to switch from a slow heartbeat to a faster heartbeat.

See how it works: http://www.youtube.com/watch?v=Rq0KHKN8PBM

Note that when I pinch the thermistor the heartbeat beats faster.

Unfortunately, an Attiny 13 is insufficient because the program I use is 85 bytes and the ATtiny 13 has only 64 Bytes of EEPROM.

Hope this helps.

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

This goes bumpbump on my stk500 with a mega48pv running on the 1mhz osc

Attachment(s): 

Imagecraft compiler user

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

With my avatar I just had to make one (inspired by DocJC's).
Here's my first version for tiny25. Version 2 will use the built-in temp. sensor.

#include 
#include 
#include 

const PROGMEM uint8_t ecg[256] = {
   45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,47,48,50,
	52,55,58,62,65,68,72,76,80,83,87,91,95,100,103,105,105,
	105,103,100,96,92,89,85,81,78,74,71,67,64,61,58,55,52,
	50,48,47,46,46,46,46,46,46,45,45,45,45,45,45,45,45,45,
	45,45,45,45,44,42,39,35,30,25,22,21,23,27,35,46,63,83,
	105,130,158,188,221,244,255,254,239,214,179,138,102,71,
	46,27,12,3,1,0,0,0,2,6,15,25,34,41,45,45,45,45,45,45,45,
	45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,
	46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,
	48,48,49,50,51,53,54,56,57,59,60,62,63,65,67,68,70,72,
	73,73,74,73,73,71,69,68,66,64,63,61,59,58,56,55,53,52,
	50,49,48,48,47,47,46,46,46,46,45,45,45,45,45,45,45,45,
	45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,
	45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,
	45,45,45,45,45,45,45};

int main(void)
{
	uint8_t i = 0;
	
	// Timer0, Set OC0AB on comp match, clear OC0B. Mode 3: Fast PWM
	TCCR0A = (1<<COM0A1)|(1<<COM0A0)|(1<<COM0B1)|(0<<COM0B0)|
		(1<<WGM01)|(1<<WGM00);
	
	TCCR0B = (1<<CS01);   // 1:8 presc.
	DDRB = 3;             // PB0/OC0A and PB1/OC0B output

	while (1) {
		OCR0A = OCR0B = pgm_read_byte(&ecg[i++]);
		_delay_ms(5);
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And if the uC selected has an ADC input then one could use a small, surface mount, Thermistor, such as this one: Mouser Murata NTC 100K 5% Thermistor for $0.18 USD (18 cents), quantity one, plus a few cents for a 100K fixed resistor, and implement the thermal response easily and inexpensively!

JC

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

Also, what about using a G sensor, and if there is rapidly changing G, (i.e. someone is shaking the device) then increase not just the speed of the LED heartbeat but it's intensity as well??

(use a "scaled" pwm array, where the array is the relative "height" of the pulse curve, and it is multiplied by a scaler to give an intensity that varries, and the scaler is controlled (with a long filter) by the derivative of the G sensor output)

(and ig you're really bored, you could give it a mild heart attack if it gets shaken too much lol)

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

Just a short one...
I cant see anything about the built in temp sensor in tiny13 ? I can only find references about it on the net.. :(

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

I don't think the Tiny13 has an internal temp sensor that is readable by the end user.

The Tiny 25/45/85 DOES have an internal temp sensor. It is mentioned on the first page of the data sheet in the section on its 10-bit ADC, and the details are in the ADC section of the data sheet. XMegas also have temp sensors within them, but that would be overkill and expensive just to flash an LED.

JC

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

I just did a search for "Temperature Measurement" (which seems to be the key phrase) in my collection of PDFs and it hit:

mega16U4_32U4.pdf
mega48_88_168_328.pdf
mega8_16_hva.pdf
tiny24_44_84.pdf
tiny25_45_85.pdf
tiny261_461_861.pdf
tiny43u.pdf
tiny48_88.pdf
xmega_revG.pdf

(I save files with my own naming scheme not Atmel's docNNNN.pdf naming and I don't claim to have ALL the datasheets - just most of them)

Cliff

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

DocJC Thanks for the short answer..
but if its as inaccurate as the one in tiny25, then its a dont-care :P +-10*C is much if it should sense a hands heat!

But I like how this simple heartbeat request have spun alot of nice ideas off by now :D
Thats the great thing about this forum :) lot of inventors :D

uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system

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

Don't give up on the ATTiny25.
It may be very inaccurate, but for your purpose it does not matter.

What you care about is that if someone warms it up by holding it in their hand you can measure the increase in temperature, and have it flash faster/brigher/etc. It doesn't matter what the real temperature is, just that you can sense an increase in temp, (and a decrease when they stop holding it, obviously).

The temp sensor within the uC should be able to trend temps quite well.

That said, the small 0805 SMD thermister is very sensitive to touching it with your finger, and warming it up.

If you use it for this purpose put a ground plane around it, so hopefully one's finger hits the ground before one of the other circuitry leads / PCB traces. Paint the Thermister's leads with an insulating layer. (fingernail polish, or the real stuff...).

JC

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

Quote:
but if its as inaccurate as the one in tiny25, then its a dont-care +-10*C is much if it should sense a hands heat!

It may not be as inaccurate as you think.

I'll bet it reads High?

It is "NOT" an ambient temperature sensor, it is most likely an internal die temperature sensor.

If there is any power dissipation on the chip, and there will be, as no chip is Zero power, then the reading will be offset by the power dissipation.
Ron.