Search This Blog

Loading...

Translate

[TC] Heart rate monitor using 8051

This article is about a simple heart rate monitor using 8051 microcontroller. Like the previous 8051 projects, AT89S51 is the microcontroller used here. The device senses the heart rate from the finger tip using IR reflection method and displays it on a three digit seven segment display in beats per minute. The circuit has an accuracy of 4 beats per minute and it is very easy to use. In medical terms, the technique used here for sensing heart rate is called photoplethysmography.

Photoplethysmography.

Photoplethysmography is the process of optically estimating the volumetric measurement of an organ. Pulse oximetry, cardiovascular monitoring, respiration detection, heart rate monitoring etc are few common applications of photoplethysmography. Let us have a look at the application of photoplethysmography in heart rate monitoring from the figer tip. When the heart expands (diastole) the volume of blood inside the finger tip increases and when the heart contrcats (systole) the volume of blood inside the finger tip decreases. The resultant pulsing of blood volume inside the finger tip is directly proportional to the heart rate and if you could some how count the number of pulses in one minute, that’s the heart rate in beats per minute (bpm). For this an IR transmitter /receiver pair is placed in close contact to the finger tip. When the heart beats, the volume of blood cells under the sensor increases and this reflects more IR waves to sensor and when there is no beat the intensity of the reflected beam decreases. The pulsating reflection is converted to a suitable current or voltage pulse by the sensor. The sensor output is processed by suitable electronic circuits to obtain a visible indication (digital display or graph).

Heart rate monitor using 8051.

Circuit diagram.


Working of the heart rate monitor

LTH1550-01 photo interruptor forms the photoplethysmographic sensor here. LTH1550-01 is simply a IR diode – photo transistor pair in single package. The front side of the IR diode and photo transistor are exposed and the remaining parts are well isolated. When the finger tip is placed over the sensor the volumetric pulsing of  the blood volume inside the finger tip due to heart beat varies the intensity of the reflected beam and this variation in intensity is according to the heart beat.
When more light falls on the photo transistor it conducts more, its collector current increases and so its collector voltage decreases. When less light falls on the phototransistor it conducts less, its collector current decreases and so its collector voltage decreases. This variation in the collector voltage will be proportional to the heart rate. Any way this voltage variation is so feeble and additional signal conditioning stages are necessary to convert it into a microcontroller  recognizable form.
The next part of the circuit consists of a two active low pass filters using opampLM324.  The LM324 is a quad opamp that can be operated from a single rail supply. Resistor R23, R17 and capacitor C5 sets the gain and cut off frequency of the first filter. With the given component values, gain will be 101 and cut off frequency will be 2.5Hz. The gain and cut off frequency are determined using the following equations.
Voltage gain Av =1 + (R17 / R23)
Cut off frequency Fc= 1/(2π *R17*C5)
The second low pass filter also have the same parameters. The two low pass filters form a very critical part of the circuit as any noise or false signals passing to the microcontroller stage will produce disastrous results. The output of the filter stage will be a voltage level fluctuating between 0 and 0.35 volts and this fluctuation is converted into a 0 to 5V swing using the comparator  based on the third opamp (IC1c). The reference voltage of the comparator is set to 0.3V. When ever the output voltage of the filter stage goes above 0.3V, the output of the comparator goes to zero and whenever the output voltage of the filter stage goes below 0.3V, the output of the comparator goes to positive saturation. The result will be a neat pulse fluctuating between 0 and 5V at a rate equal to the heart rate. This pulse is fed to the microcontroller for counting.

Program.

ORG 000H // originMOV DPTR,#LUT // moves starting address of LUT to DPTRMOV P1,#00000000B // sets P1 as output portMOV P0,#00000000B // sets P0 as output portMAIN: MOV R6,#230D // loads register R6 with 230D SETB P3.5 // sets P3.5 as input port MOV TMOD,#01100001B // Sets Timer1 as Mode2 counter & Timer0 as Mode1 timer MOV TL1,#00000000B // loads TL1 with initial value MOV TH1,#00000000B // loads TH1 with initial value SETB TR1 // starts timer(counter) 1BACK: MOV TH0,#00000000B // loads initial value to TH0 MOV TL0,#00000000B // loads initial value to TL0 SETB TR0 // starts timer 0HERE: JNB TF0,HERE // checks for Timer 0 roll over CLR TR0 // stops Timer0 CLR TF0 // clears Timer Flag 0 DJNZ R6,BACK CLR TR1 // stops Timer(counter)1 CLR TF0 // clears Timer Flag 0 CLR TF1 // clears Timer Flag 1 ACALL DLOOP // Calls subroutine DLOOP for displaying the count SJMP MAIN // jumps back to the main loopDLOOP: MOV R5,#252DBACK1: MOV A,TL1 // loads the current count to the accumulator MOV B,#4D // loads register B with 4D MUL AB // Multiplies the TL1 count with 4 MOV B,#100D // loads register B with 100D DIV AB // isolates first digit of the count SETB P1.0 // display driver transistor Q1 ON ACALL DISPLAY // converts 1st digit to 7seg pattern MOV P0,A // puts the pattern to port 0 ACALL DELAY ACALL DELAY MOV A,B MOV B,#10D DIV AB // isolates the second digit of the count CLR P1.0 // display driver transistor Q1 OFF SETB P1.1 // display driver transistor Q2 ON ACALL DISPLAY // converts the 2nd digit to 7seg pattern MOV P0,A ACALL DELAY ACALL DELAY MOV A,B // moves the last digit of the count to accumulator CLR P1.1 // display driver transistor Q2 OFF SETB P1.2 // display driver transistor Q3 ON ACALL DISPLAY // converts 3rd digit to 7seg pattern MOV P0,A // puts the pattern to port 0 ACALL DELAY // calls 1ms delay ACALL DELAY CLR P1.2 DJNZ R5,BACK1 // repeats the subroutine DLOOP 100 times MOV P0,#11111111B RET DELAY: MOV R7,#250D // 1ms delay DEL1: DJNZ R7,DEL1 RET DISPLAY: MOVC A,@A+DPTR // gets 7seg digit drive pattern for current value in A CPL A RETLUT: DB 3FH // LUT starts here DB 06H DB 5BH DB 4FH DB 66H DB 6DH DB 7DH DB 07H DB 7FH DB 6FHEND

About the program.

For the counting purpose both the timers of 8051 (Timer0 and Timer1) are used. Timer 1 is configured as an 8 bit auto reload counter for registering the number of incoming zero going pulses and Timer0 is configured as a 16 bit timer which generate the necessary 1 second time span for the Timer1 to count.For counting the number of beats Timer0 and Timer1 are used. Timer1 is set as an 8 bit auto reload counter for counting the the number of pulses (indicating the heart beat) and Timer0 is set as a 16 bit timer which generates a 65536uS delay. When looped 230 times it will produce a 15 second time span (230 x 65536uS =15S)  for the Timer 1 to count. The number of counts obtained in 15 seconds is multiplied by 4 to obtain the heart rate in beats per minute.
 The Timer 0 which generates the 1 second time span is configured in Mode 1 (16 bit timer). So the maximum it can count is 2^16 and it is 65536. In 8051 the crystal frequency is divided by 12 using an internal frequency divider network before applying it as a clock for the timer. That means the timer will increment by one for every 1/12th of the crystal frequency. For an 8051 based system clocked by a 12MHz crystal, the time taken for one timer increment will be 1µS (ie; 1/12MHz). So the maximum time delay that can be obtained using one session of the timer will be 65536µS. Go through this article Delay using 8051 timer for a better grasp.
Setting up the circuit.
When power is switched ON, the indicator LED D4 will glow an continues in that state. Now place your finger tip over the sensor and adjust preset R14 so that the LED D4 starts blinking. After you got the LED blinking, reset the power and wait for 15 seconds. The display will show your heart rate in beats per minute.
Source: http://www.circuitstoday.com/heart-rate-monitor-using-8051

5 Microcontroller Based Projects You Must Not Miss!

Looking for a microcontroller based project? From our collection of microcontroller based projects, we bring to you 5 super cool projects. Have fun!








A tachometer is nothing but a simple electronic digital transducer. Normally, it is used for measuring the speed of a rotating shaft. The number of revolutions per minute (rpm) is valuable information for understanding any rotational system. For example, there is an optimum speed for drilling a particular-size hole in a particular metal piece; there is an ideal sanding disk speed that depends on the material being finished. You may also want to measure the speed of fans you use.

Here is an easy-to-construct temperature indicator-cum-controller that can be interfaced with a heater coil to maintain the ambient room temperature. The controller is based on Atmega8535 microcontroller, which makes it dynamic and faster, and uses an LCD module to display and two keys to increase or decrease the set values.

Digital wall clocks, table clocks and desk clocks with pointer or LCD display are readily available in the market. Here we present a clock that can be built in a small budget using AT89C2051 microcontroller. Additional feature of the clock is that the time display is visible even in the dark.

Microcontroller-based embedded systems play major role in industrial automation. One such widely used system is the programmable timer.

The circuit that uses microcontroller AT89C51 can control four devices from a distance of upto 30 metres wirelessly. An LCD module is used to show the device number and preset control time at the transmitter module.

Source: http://electronicsforu.com/

Registered "www.todays-circuits.com" For Our Blog


Finally after long patience we purchased Web Domain 
"www.todays-circuits.com
and The Same WIll Be Activated in next 2 days and "todayscircuits.blogspot.com
will be redirected. 

Stay Tuned. 

Thanking You For Your Huge Support.

      Yours Sincerely,
"Admin"

$20 Robot From MIT Wins AFRON Design Challenge Made From Arduino Board



Robots, as anyone who has ever attempted to build or buy or fix a robot knows, tend to be expensive. This presents a problem for people who want to start learning about robotics, because getting a foot in the door with an actual robot to work on generally involves a substantial up-front investment in hardware. And for places where teachers and students don't have huge piles of money to throw at technology, this can mean that robots just don't happen.
The African Robotics Network (AFRON) and IEEE Robotics and Automation Society (RAS) collectively sponsor a biennial design challenge to "collaboratively create an educational robot that is an order of magnitude less expensive than existing products, to inspire young people around the world." For 2013/2014, MIT took home a win with their MIT SEG robot, a 3D-printed, Arduino-based wheeled robot that can be built for $20 in five steps with no training or tools.
The completed MIT SEG is shown in the picture above; below is an image of the unassembled robot in its entirety:
All you have to do to go from this to robot is fold up the chassis (the squareish bits at the lower left), fold the wheels together, fit the electronics in, stick the wheels onto the servos, and that's it, you're done. Here's the bill of materials:
MIT points out that if you don't go with a breakout board for the Arduino and instead wire-wrap the headers directly, you can drop the cost by about $2.50 per bot. You also need a programmer and a charger, which together will run you another $18.20, but these can be shared among multiple robots.
So great, you've got a robot that's easy to make and is dirt cheap. What can it do? Out of the box, MIT SEG includes an Arduino compatible drag-and-drop graphical programming interface. The LED and photosensor can be used to determine whether the robot is looking at something black, white, or gray, meaning that you can do line-following and some obstacle avoidance right away, and MIT has put together a bunch of examples and an entire curriculum that classrooms can follow. Plus, since the robot has an Arduino for a brain, you can leverage all of the hardware (and the community) that's been plugging into Arduinos for the last few years.
Second place in the hardware portion of the Design Challenge went toHarvard's $10.70 AERobot:
The Ultra Affordable Educational Robot Project Design Challenge also includes categories for Software, Curriculum, and Community Challenges.
"The AFRON organizers and RAS sponsors admire the ingenuity of the submissions in all categories," said Ken Goldberg, a roboticist at UC Berkeley who co-founded AFRON with Ayorkor Korsah, a professor of computer science at Ashesi University, in Ghana. Goldberg noted that two winning projects from Africa, PanyaBot (Kenya) and ARX LollyBot (Ghana), continue to make major advances in the Software and Community Challenge categories. "We look forward to connecting all the participants to share ideas and designs for next steps via the AFRON network, which anyone worldwide can join at no cost," he said.

Source : http://spectrum.ieee.org/automaton/robotics/diy/20-robot-mit-wins-afron-design-challenge

[TC] Solar Cell Material Moonlights as Laser

Photo credit: Revolutionary solar cells double as lasers / University of Cambridge Research
Perovskite is the word of the week! This trailblazing new material is being used in cheaper, highly efficient photovoltaics. Commercial silicon-based solar cells (the kind you see on roofs) convert the sun’s rays into electrical energy at about 20 percent efficiency -- and it took two decades of research to achieve that rate. Composed of calcium titanate, perovskite is “dirt cheap” compared to silicon in solar cell production, and perovskite-based technology has already reached 17 percent efficiency after just two years of research. 
 
Earlier this week, we learned that -- in addition to absorbing light -- perovskite is also capable of emitting light, suggesting that it can be used in display screens. Now, University of Cambridge researchers show that perovskite can double up as a laser. 
 
In the 1960s, scientists figured out that if a material is good at converting light to electricity, then it’ll be good at converting electricity to light. By sandwiching a thin layer of lead halide perovskite between two mirrors, the team produced an optically driven laser. They also found that the cells show very efficient luminescence: up to 70 percent of absorbed light is re-emitted.
 
For most commercial solar cell materials, in order to show good luminescence and performance, they first require expensive processing to achieve a low enough level of impurities. These new materials, the authors say, work well even when very simply prepared as thin films using cheap, scalable solution processing. Upon light absorption in perovskite, two charges are formed within 1 picosecond (very, very quickly), but then it takes up to a few microseconds to recombine: that’s long enough for chemical defects to stop the light emission in most other semiconductors, including silicon. But perovskite has a much longer carrier lifetime. 

Source: http://www.iflscience.com

[TC News] New laser promises to make internet faster

Scientists have developed a new laser
that holds the potential to increase by
orders of magnitude the rate of
data transmission on the internet.

WASHINGTON: Scientists have developed a new laser that holds the potential to increase by orders of magnitude the rate of data transmission in the optical-fibre network - the backbone of the internet. 

The laser is the result of a five-year effort by researchers at the California Institute of Technology (Caltech). 

Light is capable of carrying vast amounts of information - approximately 10,000 times more bandwidth than microwaves, the earlier carrier of long-distance communications. 

To utilize this potential, the laser light needs to be as spectrally pure - as close to a single frequency - as possible. The purer the tone, the more information it can carry, and researchers have been trying to develop a laser that comes as close as possible to emitting just one frequency. 

Today's worldwide optical-fibre network is still powered by a laser known as the distributed-feedback semiconductor (S-DFB) laser, developed in mid-1970s, researchers said. 




The S-DFB laser's unusual longevity in optical communications stemmed from its, at the time, unparallelled spectral purity - the degree to which the light emitted matched a single frequency. 

The S-DFB laser managed to attain such purity by using a nanoscale corrugation within the laser's structure that acts like a filter. 

Although the old S-DFB laser had a successful 40-year run in optical communications, the spectral purity, or coherence, of the laser no longer satisfies the ever-increasing demand for bandwidth, researchers said. 

The old S-DFB laser consists of continuous crystalline layers of materials called III-V semiconductors - typically gallium arsenide and indium phosphide - that convert into light the applied electrical current flowing through the structure. 

Since III-V semiconductors are also strong light absorbers - and this absorption leads to a degradation of spectral purity - the researchers sought a different solution for the new laser. 

The high-coherence new laser still converts current to light using the III-V material, but in a fundamental departure from the S-DFB laser, it stores the light in a layer of silicon, which does not absorb light. 

Spatial patterning of this silicon layer - a variant of the corrugated surface of the S-DFB laser - causes the silicon to act as a light concentrator, pulling the newly generated light away from the light-absorbing III-V material and into the near absorption-free silicon. 

This newly achieved high spectral purity - a 20 times narrower range of frequencies than possible with the S-DFB laser - could be especially important for the future of fibre-optic communications, researchers said. 

The study was published in the Proceedings of the National Academy of Sciences.



Source: http://timesofindia.indiatimes.com

[TC] Home Made Movie Maker

Like real movies, this circuit makes use of a characteristic of the human eye and brain known as the persistence of vision. A sequence of still pictures is projected onto a screen in rapid succession. The pictures differ slightly from one another and the brain interprets the succession of still pictures as continuous motion.
Here the pictures are shadows cast by low-voltage lamps. There are four Lamps in all, which glow in sequence cyclically. This gives the illusion of a simple but realistic movie.

Fig. 1 shows the circuit for the movie maker. It is driven by clock pulses provided by NAND gates N1 and N2. The flickering frequency is adjustable through preset VR1. A suitable rate for perceiving continuous motion is 16 Hz. The clock pulses are fed to counter IC CD4022 (IC2). IC2 has eight outputs, but only the first four (0-3) are used in this circuit. The outputs go high one at a time, in sequence. The fifth output (output 4) is connected to the reset input so that the counter is immediately reset at the fifth count and the first output (output 0) goes high.

The counter outputs are fed to CD4049 hex buffer (IC3). The buffer outputs drive transistors T1 through T4 in a sequence. As each transistor conducts, the lamp connected to it glows. The lamps are rated at 0.3A so these provide enough light to operate the movie show in a dimly-lit room.

Fig. 1: Circuit for movie maker

Assemble the circuit on a general-purpose PCB. Power-on the circuitusing switch S1 and make sure that the outputs of IC2 (0 through 3) are normally low but briefly go high three-four times within a second. Also ensure that the lamps flash one at a time in a repeating sequence. If the sequence appears to be wrong or any of the lamps fails to glow, check the wiring. The light shield and film holder can be made of a thin card, sheet metal or plywood. Strictly adhere to the various dimensions as shown in Fig. 2. Otherwise, the shadow images may fail to register properly when projected.

Use a plastic cabinet as shown in Fig. 3 to hold the circuit board and battery. Owing to the power requirements of the lamps, it is more economical to use four 1.5V cells in a battery box. Else, you can use a 6V power adaptor. 




Fig. 2: Assembly arrangement

There are two ways of mounting the lamps. The more satisfactory but more expensive method is to bolt the four lamps. Alternatively, drill four 1cm dia. holes on the front of the cabinet, wedge the base of the lamps in these holes and solder wire to the bases.


Fig. 3: Plastic case with assembled circuit 

The easiest way to prepare the film frames is to photocopy the desired drawings onto transparent films. Alternatively, trace them on a transparent acetate film or draughtsman's film, using a fine marker pen. Align all the drawings on the frames and project onto the screen. 

  
Fig. 3: Flim making

Working of the circuit is simple. First of all, fix the clock frequency at about 16 Hz. Place the film on the holder. Ensure a distance of 12 cm between the screen and the assembled unit and power-on the circuit using switch S1. Now you can see your drawings as a short movie clip on the screen.

EFY note. We have tested this circuit without the mechanical arrangement.


Source: 
  http://electronicsforu.com/

[TC] Clock Using 8 Seven Segment LED displays


The 8 times seven segments display induced me making this clock device. The design principle is: show the wiring and the electronics!
After testing with the Arduino and a breadboard I decided to make some examples on PCB. Also the scripting went on and on and on, making all kinds of variations and fun. This has made this instructable quite big! Also, this instructable invites you to explore further...

Day of Month - Hour - Minutes - Seconds
Because there are 4 positions I decided to show day of the month, hour, minutes seconds. Generally I can still remember the month I live in. The seconds makes the thing "alive". But because most of these clocks show month, day, hour, and minutes and blink with a semicolon, the displays still feels a bit "strange": sometimes people say: the hour is wrong, because they mistake the first two digits as "hour", not as day of the month.

The main problem is not showing the time, but doing the interfacing: doing settings on two buttons available are always a bit clumsy.

The challenge for me is to do more with the display then just showing time: making as much of the alphabet and words appear on the screen as possible or play with some nice patterns.



Step 1: Testing setup


Programming the ATmega328 is done on the Arduino. (Later on this programmed chip is plugged into the PCB.)

Testing is done as close to the Arduino as possible with the modules either connected to the Arduino, or using a breadboard. Although I know this myself and write it here, again I went too quickly making the PCB's and inserting the chips. So discovering a flaw or adding to the possibilities I had to change the chips over and over again. My advice (to myself) is to test longer using the Arduino and breadboard!

In the picture you see the basic connections, for the two timer modules.
Later there are two push buttons added connected to PINS 8 and 9. And if you like dimming then an LDR is connected (paired with a resistor) to PIN 14 (A0). These basic connections are (of course) the same for the PCB's in later steps of this instructable.

Since I have two time devices, one with an ds1302 and one with a ds1307, the connections with the timer module may differ. Also there are two scripts in the repository, depending on your time module, because ds1307 uses I2C and ds1302 uses a 3 wire connection.

Step 2: Electronic components














The component list is rather reduced, since most of the wiring is already done on the modules.

Arduino

The usual, with a breadboard and some jumper wires this is great prototyping. For the time pieces I reduced to a stand alone Atmega chip.

Stand alone atmega328.
For the "barebones" PCB later on. I added a cap for the voltage suspecting that powering it up was giving a problem with the timer module. See step: "Your Own PCB instead of Arduino" for components on the PCB:
Atmega328
holder for this chip
100micro F cap
2 resistors 1K
2 pushbuttons for the settings
female connectors with 5 PINs.
connector for the power cable
extra:
LDR for dimming, together with a 2 K resistor

display (8 seven segment number displays)
http://dx.com/p/8x-led-display-digital-tube-module...
This display communicates with 3 wires (plus voltage and GND) with the arduino. I have used the usual POV structure, using the timer interrupt to provide each number display very fast pretending to have written to all the displays. (See code.)
This display started of this project!

time keeping chip / timer module
I had a ds1307 from dx.com:
dx.com/p/i2c-rtc-ds1307-24c32-real-time-clock-module-for-arduino-blue-149493
at $2.99
This chips communicates using I2C rpotocole, using the PINs A5 and A6 as SDA and SCL.
The code is pretty standard.
http://learn.adafruit.com/ds1307-real-time-clock-b...

I also bought a ds1302 from dx.com:
http://learn.adafruit.com/ds1307-real-time-clock-b...
at $2.40, the cheapest!
This chip needs another script using a 3-wire interface.
I found example code here:
http://playground.arduino.cc/Main/DS1302

Later on you can consider adding other sensors yourself...

Step 3: Tools and download

Making the PCB requires a soldering device.
Programming is done using a laptop with Arduino environment.
Of course, you need some normal tools like pincher, cutter, for doing the wires.

Downloads: scripts
https://github.com/contrechoc/clock
There are different scripts:

  • basic clock scripts for ds1307 and ds1302
  • knight rider script, where the comma goes left and right (ds1307)
  • a script with words coming in from the right and the left side (ds1307)
  • a script for words going up and down (ds1307)
  • a script which combines these up and down words words with the time from the clock (ds1307)
The scripts change from the basic to the more complicated due to demands on the arrays holding the words and the time. A bit of pointers to char arrays was unavoidable.
You can further develope other possibilities or improve on script efficiency. Also, for the lovers of framework like scripting there are enormous improvements to achieve! Go ahead!

Step 4: Your Own PCB instead of Arduino













If you want to advance from the Arduino to your own contraption you have to make a PCB.
You have to solder the ATMega328 holder, the resonator (or crystal) and connections for the display and the timer module. After that, the buttons and the LDR.

This PCB is not totaly bare bones: because you program using the Arduino you need an oscillator or a crystal on your board to be able to let the Atmega328 function. Changing the fuses is possible, but then you change the max speed of the ATmega328 from 16 to 8 MHz, which might alter the way the clock functions.

The way you do this is "free". It depends on your thoughts where to put the components and how you want to make the dispay float in space or on the PCB.

Step 5: The adaptor for your own PCB

c35.jpg
















Very practical: if you have your own board, so you have to power it - it is a stand alone.

You could try with a lipo, but then you still have to make your script saving as much energy as possible, still you have the display of LED's eating the Watts away. So this set up (in contrast with the purple gadget clock later in this instructable with a LCD display) needs an adaptor. In fact you ahve many adapters lying around, chargers of mobile phones etc. Look at the specs and if this is 5V it is ok.
The USB adaptor is nice - you have to hack a USB cable:
http://www.instructables.com/id/Hack-that-holy-USB...
but also older adaptor/chargers will do. Pratical problem is the wires: if these are too thick the wires tend to pull your clock from the table.
You can either connect the wires directly to the PCB, or use a plug, The plug solution is nicer, more versitile.

A "dangerous" solution is buying a cheap power supply of 5V at dx.com: (4 dollar)
http://dx.com/p/power-supply-switch-module-green-8...

From the design concept (show the electronics as it is) having an open power supply is consistent, but you have two open wires from the mains - this is a risk!

With the blue foam stuff (see image) it is possible to insert the dangerous part of this open adaptor; half way solution.

Step 6: Basic Scripts

The script is where the complexity enters.

Normal clock indication:


The script can be divided into a few main parts:
1. Talking to the timer module, using protocoles like I2C
2. Talking to the display
3. Interaction, setting hour, minutes, days in month
4. add-ons, like an LDR to regulate the brightness, maybe a temperature sensor
5. funny things, like patterns and text

1. Talking to the timer module
The protocoles can be found on the internet.
In the scripts I have used a protocole for the DS1307 and another for the DS1302. You can use the example scripts as black boxes. You have to understand the format of the data coming out or going into these black boxes.
So the DS1307 uses the DateTime format of the RTC.lib. For the DS1302 you have a struct (C programming thing) with different kinds of formats for the same data.

2. Talking to the display
I did a "talking to the timer module" and transferred the data in the DateTime variable to an array "myNumber". This array was used to transfer the digits two by two to the display.

so:

DateTime now = rtc.now();
    myNumber[2] = now.hour()/10;
    myNumber[3] = now.hour()%10;
    myNumber[0] = now.day()/10;
    myNumber[1] = now.day()%10;
    myNumber[4] = now.minute()/10;
    myNumber[5] = now.minute() % 10;
    myNumber[6] = now.second()/10;
    myNumber[7] = now.second() % 10;
You see I have to separate the tens and the ones, using the modulo and the division operators.
(For the ds1302 I had to do the same trick, but using the rtc struct.)

Then I used a timer to get the number digits to the display one by one, but so fast that your eye sees these digits all at the same time:
setting up the timer:



  noInterrupts();           // disable all interrupts
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;
  OCR1A = 5; //10 - 200    // compare match register 16MHz/256/2Hz
  TCCR1B |= (1 << WGM12);   // CTC mode
  TCCR1B |= (1 << CS12);    // 256 prescaler 
  TIMSK1 |= (1 << OCIE1A);  // enable timer compare interrupt
  interrupts();             // enable all interrupts
In the timer routine I transfer the digits:


ISR(TIMER1_COMPA_vect)          // timer compare interrupt service routine {

  ledCounter++;// counting from 0 to 7

  ledCounter = (ledCounter)%8;
  digitalWrite(slaveSelectPin,LOW);

  SPI.transfer(1<<(ledCounter));
  unsigned char num = myNumber[ledCounter];//getting the array member 

  letterTransfer(num); //using the coding and doing the transfer

  digitalWrite(slaveSelectPin,HIGH); 

}


Step 7: Interaction and some other ideas

After the basics we have a display that tells the time.
We have two script parts left:
3. Interaction, setting hour, minutes, days in month
4. add-ons, like an LDR to regulate the brightness, maybe a temperature sensor
5. funny effects or text

3. Interaction, setting hour, minutes, days in month
The interaction is necessary to set the time, when starting up without an Arduino. Or when the time is running not accurately anymore.

We need two buttons, one for going into the setting mode, and the other for changing the digits.

I decided to add two bigger push buttons. Simply connect the buttons to GND and through a 10K resistor to a PIN and do a pull up on that PIN:

  pinMode ( 8,INPUT_PULLUP);
  pinMode ( 9,INPUT_PULLUP);
or do it the old way:
  pinMode ( 8,OUTPUT);
  digitalWrite(8, HIGH);
  pinMode ( 9,OUTPUT);<br>  digitalWrite(9, HIGH);
(I was later thinking of something more fancy:
use a magnet and a Hall sensor for instance. Maybe for clock design version 3?)


4. add-ons, like an LDR to regulate the brightness, maybe a temperature sensor
The display is rather bright during the night. I used an LDR to regulate the brightness. The brightness can be regulated setting the speed of the timer. This is done by giving OCR1A another value.
So I connected a resistor and an LDR to analog PIN A0 and created some steps of brightness.
(GND - LDR - PIN 14 - RESISTOR 2K - GND)



//dimming or brightening 
   if ( tCounter%100 == 0 ) { //do not check every loop but only once in a while
      int hhh = analogRead(0)/4;
      if ( hhh < 150 ) hhh = 0; 
      else if ( hhh < 175 ) hhh = 10;
      else if ( hhh < 200 ) hhh = 20; 
      else if ( hhh < 250 ) hhh = 50;
// do the dimming by way of the frequency of the interrupt
      noInterrupts();
      OCR1A = 10 + hhh ;
      interrupts();
5. funny effects or text
This is where you can make a difference with the more "normal" clocks.
Insert text now and then:
From the right or the left some words appear randomly, like hello, ciao, ...
To do this you need a lot of array shifting. You need pointers because this Arduino script is based on C.


I also tested adding a moving comma with another timer, timer0

  TCCR0A = 0;
  TCCR0B = 0;
  TCNT0  = 0;
  OCR0A = 50;            // compare match register 16MHz/256/2Hz
  TCCR0B |= (1 << WGM02);   // CTC mode
  TCCR0B |= (1 << CS01);    // 256 prescaler 
  TIMSK0 |= (1 << OCIE0A);  // enable timer compare interrupt
Together with a second array, we can alternate or even play at the same time the two arrays.

Step 8: FUN Design on display

Where can I make a difference with the normal clocks?

Knight rider

One of the first ideas was to add a "knight rider" effect, playing with the comma:
But this was considered not relaxed...

(The comma of the knightrider is done using a second array, with one comma sign and the rest "empty". With a second timer this array is inserted at the same time as the first array of time digits. So in the knight rider script you find two timers.)

You could add funny text or transitions.

The second idea was adding words - coming in from the sides, or from the top and the bottom.

The coding of the segment display:
Without the comma you have 124 possibilities. 2^7

/*
   -*-       0000 0001
   *-*  0010 0000  0000 0010
   -*-       0100 0000
   *-*  0001 0000  0000 0100
   -*-       0000 1000
   comma:              1000 0000
*/
With the 7 digits number display you cannot make the whole alphabet, but you can make pretty much all the letters. It's clumsy but funny.
Here you have the code, maybe you can find even more creative solutions and complete the alphabet! (I am proposing to use for an m three horizontal strokes: the MI in Japanese ミ and for the N two horizontal strokes: the NI in Japanese: ニ.
But I am afraid not everybody in Europe will recognize this, eg BEAミ as my name :-)

A lot of words are already possible like: HELLO HOUSE PLUS CIAO STAR ...
PEACE is also possible (hurrah!)

As long as we don't have a one digit solution for V, we have a big problem: LOVE...is not possible!
(But we as Dutch people have an advantage there: LOVE = LIEFDE in Dutch, and this last word is indeed possible :-)

Interesting, there is even a wikipedia entree about this:
http://en.wikipedia.org/wiki/Seven-segment_display...


Or effects like funny patterns (under circles, upper circles, a dotted line around the display.

here is my coding table, maybe you can still improve!

//numbers
  if ( num == 1 )  SPI.transfer(255 - B00000110);//1
  if ( num == 2 )  SPI.transfer(255 - B01011011);//2
  if ( num == 3 )  SPI.transfer(255 - B01001111);//3
  if ( num == 4 )  SPI.transfer(255 - B01100110);//4
  if ( num == 5 )  SPI.transfer(255 - B01101101);//5
  if ( num == 6 )  SPI.transfer(255 - B01111101);//6
  if ( num == 7 )  SPI.transfer(255 - B00000111);//7 
  if ( num == 8 )  SPI.transfer(255 - B01111111);//8
  if ( num == 9 )  SPI.transfer(255 - B01101111);//9
  if ( num == 0 )  SPI.transfer(255 - B00111111);//0
  //comma
  if ( num == 10 )  SPI.transfer(255 -B10000000);//comma
  //some letters
  if ( num == 11 )  newNum =  B01110111;//A
  if ( num == 12 )  newNum =  B01111111;//B like 8
  if ( num == 13 )  newNum =  B00111001;//C
  if ( num == 14 )  newNum =  B01011110;//D small like 6 without upper stroke
  if ( num == 15 )  newNum =  B01111001;//E
  if ( num == 16 )  newNum =  B01110001;//F
  if ( num == 17 )  newNum =  B01101111;//small G like 9
  if ( num == 18 )  newNum =  B01110110;//H
  if ( num == 19 )  newNum =  B00000110;//I like 1
  if ( num == 20 )  newNum =  B00011110;//J
  // K?
  if ( num == 21 )  newNum =  B00111000;//L
  //M -- the m as two digits does not really convince me
  //N
  if ( num == 22 )  newNum =  B00111111;//O like 0
  if ( num == 23 )  newNum =  B01110011;//P 
  if ( num == 24 )  newNum =  B10111111;//Q like 0.
  //R
  if ( num == 25 )  newNum =  B01101101;//S like 5
  if ( num == 26 )  newNum =  B01111000;//t small
  if ( num == 27 )  newNum =  B00111110;//U
  //V
  //W
  //X
  //Y ...something like a 9 is possible, mirrored? It does not look too good
  //Z

  //special signs
    if ( num == 40 )  newNum =  B01011100;//under circle
    if ( num == 41 )  newNum =  B01100011;//upper circle
    if ( num == 42 )  newNum =  B00000000;//empty
    if ( num == 43 )  newNum =  B10001000;//for a .-.-.-.-.-.-.-. line 

    //square sequence
    if ( num == 44 )  newNum =  B00001100; // under + side under right
    if ( num == 45 )  newNum =  B01000010; //middle side upper right
    if ( num == 46 )  newNum =  B00000011;
    if ( num == 47 )  newNum =  B01000100;

Step 9: Design of the object




I like "Minimal design", where you can see the components. That is why I made this bare bones atmega and the stick in display and timer module.

You start with a PCB.
Add the ATmega328 and solder the necessary wires for GND and Voltage. (You could add a resonator.)
Add the caps if you like to the GND and Voltage coming in.

I added the parts for connecting the display and the timer module. (For the ds1307 and the ds1302 the PIN connection is different.)
You add and connect the two pushbuttons. (Pull up PIN and button connect with a 1K resistor.)
You add and connect the LDR. (GND - LDR - PIN - Resistor 2K - V)

Standing upright 1.
For this I first used a piece of MDF or wood. It is easy to put the PCB into the saw line in the wood. Instead of wood you can also make a "foot" using a piece of metal.

Standing upright 2.
With colored pieces of polyester (or whatever it is exactly) you get a more exciting effect (I think). You can easily stick the PCB in it using a knife. I thought it would tumble, but the setup remain stable.

Of course, you should experiment with your own customized base!

Adapter
Is the adapter part of the electronic components or part of the design? Do we show or hide the adapter?

Step 10: Alternatives

Other kind of Displays
Alternatives are the Liquid Crustal displays, or even the graphical screens:
http://www.instructables.com/id/LCD-Magic/

Another clock which runs out of the box is this sequence of LED matrix blocks:
http://dx.com/p/jy-mcu-3208-lattice-clock-ht1632c-...


Gadgets
You know clocks!
They are everywhere...The purple one is one of my favorites, it has 4 functions, even a temperature sensor. It works one year, two years on its batteries (great work saving energy!). It costs only 1.30 euro's or something.

Why make one yourself?
If electronic clocks are soo cheap?
For the fun?
For the experience?
For admiring the cleverness of the solutions for soo little money?
For trying to add something yourself, either more design or more fancy sillyness?

Probably because all of this!

Step 11: Further Improvements (or more complications)









When you have words and transitions between time and words, you can add other data, like temperature.
For temperature you can use a sensor like
The next thing which could be interesting is air pressure.

But also pollution can be measured and displayed.

On the other hand data from sensors becomes much more interesting with a graphical display, or uploading the data to for instance COSM.

Uploading requires a connection to the internet. This can be done having a set of RF12 transceivers and for instance a Raspberry Pie which is connected to your router.

So, starting with a rather simple segmented display you make a clock and ends up wiring your home together making it self tracking!


Source:

http://www.instructables.com/id/In-your-own-time/?ALLSTEPS

Write For Us

Submit a Guest Post

Find us on Facebook

Categories

555 Timer IC 7 segment Display 8051 Project AC Circuits Adafruit Alarms Amplifier Circuits Analog Circuits android Arduino arm processor Atmel Audio Circuits augmented reality Automotive Circuits avr Battery Circuits Bicycle Gurad bluetooth Cable TV Circuits Cambridge University Camera Technology Circuit Boards Clipping And Clamping Circuits Clocking And Timer Circuits Computing contact lens Contact Us Form Contests Controller Circuit Conversion Circuits Counter Circuits Digital Electronics diy circuits Downloads EFY EFYTimes Electronic Books Electronic Components Electronic Locks And Keys Fan Circuits Filter Circuits Fire Alarm free Fun And Game Circuits future Google Hack n Mod Ham Radio Circuits heart rate monitoring High Voltage Circuits Home Circuits IC Guide ieee Industrial Circuits Infrared Instructables ipad lcd Led Circuits Light Related Lighting Circuits Medical Circuits Meter Clocks Microcontrollers Microprocessors Mini Projects modules Movie maker Navigation Notice Optical Fiber PC Circuits PCB Boards pnp transistor Power Supplies Printing Projects Programmer Project Ideas Projectors Protection circuits Proximity Detectors Radar Radio Circuits Radio Transmitters Raspberry Raspberry Pie Remote Circuits Retis Lab RFID Robot Cars Robotics Security And Safety Sensor Circuits Servo Motors Smartwatches sms Software solar cell sound application Spectram Technology News Telephone Related Television Related Test And Measurement Circuits Thermal Projects Tone generator circuits Touch Screen Tutorials Wearables Wi-Fi Wireless
Like us on Facebook
Follow us on Twitter
Recommend us on Google Plus
Subscribe me on RSS