Quantcast
Channel: Clock - Timer Projects - PIC Microcontroller
Viewing all 218 articles
Browse latest View live

PIC Industrial and Domestic Timer (Relay Controller)

$
0
0

Hi Friends,
I hope everyone had a rocking New year I was suppose to give you all a New year gift uploading a new project, but unfortunately it got delayed ‘coz I was busy with my *personal life*

One of our site member, Jeswanth kumar (jeswanthmg ) has submitted his project to me just before the new year eve. It took a little time for me to review this project.PIC Industrial and Domestic Timer (Relay Controller)

Project is titled “Industrial and Domestic Timer” is a time controller or a Time controlled relay project in simple words. Though it seems simple to say but the features of this project adds a great learning curve in both hardware and software part.

This project is buit around Microchip PIC Microcontroller PIC16F877A. Hardware includes DS1307 for time keeping, 16×2 LCD for display, 5 Push buttons and 8 relays. The alarm settings are stored in internal EEPROM of PIC microcontroller. The code for this project is written in C for Hi-Tech C Compiler.PIC Industrial and Domestic Timer (Relay Controller) schematic

Some Highlighting features are:

  • 32 alarm settings for 8 relays including on off but the number of alarms can easily be increased upto 46.
  • 16×2 LCD and 5 push buttons for user interface.
  • Microchip PIC16F877A as controller and DS1307 to manage time.
  • PIC16F877A’s internal eeprom to store alarm settings.
  • PIC’s code is written in Hi-Tech PIC C compiler.

Incase you face any kind of problem in this project feel free to post your doubts in forum.

Download Project: PIC Industrial and Domestic Timer (Relay Controller)

 

 

For more detail: PIC Industrial and Domestic Timer (Relay Controller)

Current Project / Post can also be found using:

  • clock pic
  • pic countdown timer project

The post PIC Industrial and Domestic Timer (Relay Controller) appeared first on PIC Microcontroller.


A Word Clock using PIC16F877 microcontroller

$
0
0

A Word Clock

**************************************************************************

Major updates – A much better enclosure for this clock has been designed, and a better controller using an AtMega controller now exists.  check out

http://www.instructables.com/id/The-Wordclock-Grew-Up/

**************************************************************************

This is a project to tell the time using words.

I saw a cool clock on the Make Blog the other day (http://blog.makezine.com/archive/2009/09/qlocktwo_clock_tells_time_with_word.html), and thought ‘Hey – I can make one of those’, so here it is!

There are two new photos of a completed clock kit, mounted in an enclosure, and hanging in my dining room.  The clock module in the center is 150mm x 150mm, and the enclosure surround is 300mm x 300m craftwood, painted with automotive paint.  I think that it looks really great!

I am now able to sell all sorts of components, ranging from complete clocks, through to kits, through to individual modules and components.  Please visit my web site www.dougswordclock.com for further information.

UPDATE – ARDUINO VERSION

If you want an arduino version of this project, then have a look here:
http://www.instructables.com/id/The-Word-Clock-Arduino-version/

This version uses a PIC microcontroller.
Word Clock
I am in Australia, where the mains frequency is 50 Hz (50 cycles per second). This clock uses mains to ensure that it stays accurate. I have realised that people in other countries (USA) may want to construct the clock, so I have modified the firmware to cater for 60Hz countries.  Just download either the 50hz, or 60hz firmware depending on where you live.

Another update – I have modified the clock to allow Minute LEDs to be used around the edge – Have a look at the last step of this instructable for details.

Construct the Hardware

First, you will have to dowlload the PCB files – they are attached.

I printed the PCBs out using my laser printer, and photocopied the layouts onto PressnPeel Blue film. You can use any PCB manufacturing process you like.

Having etched, and drilled the boards, populate them as shown in the two photos.

I have attached the schematic diagram, and the PCB layout.

Both boards are connected together using jumper wires along the edge.

DO I *REALLY* USE 360R AND 36R RESISTORS?

As an update, I have been using Blue Flat Top LEDs, with a forward voltage drop of about 3.3v @ 20mA.  The supply that I was using was about 10.5VDC.  With the original design, with 2 LEDs, the voltage drop across the LEDs was 6.6v, meaning that 3.9v was being dropped across the resistor (11-6.6).  With a 360R resistor, this limited the current to 10.8mA, and with 3 LEDs, the voltage drop across the LEDs was 9.9v, meaning that 0.6v was being dropped across the resistor (11-6.6).  With a 36R resistor, this limited the current to 16mA.

What I have subsequently discovered is that with supply voltages of 12V, the current through the leds ends up being way too high (15 & 58mA), which is a problem.

In my most recent versions, I have setled on 680R for the 2 Leds and 270R for the 3 Leds, providing 7.9 and 7.8 mA respectively.  Much lower current, and still ample illumination.

Make the Stencil

In this version of the clock, I made the stencil using another fiberglass PCB.

Just etch the board using the same method you used for the controller and display PCB, and lacquer it to protect the front of the display.

In order to reduce light breakthrough to adjacent words, I used 30mm baffels made from spare PCB stock. These were held in place using hot melt glue.

Schematic Word Clock

Step 3: Program the Micro

The next step is to program the Microcontroller.

Just use whatever PIC programmer you use.

The Hex file is attached! Remember to use either the 50Hz or the 60Hz firmware depending on your region.

I have also added support to keep the clock running on battery backup when power is lost.

[Update] – I have updated the 50Hz and 60Hz firmware files – there was a simple coding error that affected the accuracy of the clock.

Make a case for your clock – and enjoy!

Finally, construct a case for your clock. in my case, I will be creating a case from acrylic, that will allow people to see inside the clock . it will also allow light spill from the case to create cool effects on the desk.

The post A Word Clock using PIC16F877 microcontroller appeared first on PIC Microcontroller.

DCF77 clock-thermostat using PIC16F648A

$
0
0

Always at the right time your house on temperature

This project make use of a PIC16F648(A) and a DCF77 receiver from Conrad (Orderno. 64 11 38)
With DCF77 runs the clock from the thermostat always on the right time.
Synchronizing isn’t necessary anymore.

The temperaturesensor is a DS1820 or DS18B20 and on a HD44780 (or compatible) 2×16 LC-Display becomes day, date, time, temperature (with 0.1°C precision) and an indication which temperature adjustment (economy- or comfort temperature) is active.

clock-thermostat

For each day there are 4 ON/OFF times to program, ON means here switch to the comfort temperature and OFF to the economy temperature.
A handy option is for people who work at different times (shift work) because it is possible to program the clock with a 2-weeks scheme.

Control
Controlling the clock-thermostat is very simple, buttons and commands to synchronize the clock are left away because of DCF77.
There are set 2 temperatures, a Low economy– and a High comfort temperature.
Only 4 buttons to control everything.

Button 1 switches manual from L (economy) to H (comfort) temperature and vice versa.
Button 2 sets the comfort temperature higher per 0.5°C.
Button 3 sets the comfort temperature lower per 0.5°C.
Button 4 must pushed for 2 seconds to go to the “timer adjustmentsmenu” (see further).

The economy temperature, (when nobody is at home or at night) stays normally always at the same temperature (±16.0°C).
Set this temperature eventually higher by pushing button 1 and button 2 at the same time or lower by pushing button 1 with button 3, but normally this is never necessary.



When switching the power on, the PIC let see an intro for a few seconds, when the paper manual is lost, then you can see where to find information about this clock thermostat.

After that shows the LCD the version number from the PIC program and in what mode the week-timers are.

Then the PIC waits till it get a signal from the DCF77 module (receiver).

When searching does take more than 45 seconds, the message “No DCF signal” follows.
The PIC stays searching until it have a decent timesignal reception.
The manual control from the heating is working when there is no DCF signal, only the timers don’t work.

 

For more detail: DCF77 clock-thermostat using PIC16F648A

Current Project / Post can also be found using:

  • pic x10 controller
  • projecting clock инструкция
  • RTC Based digital clock using pic 18f4550 projec1 abstract
  • Total time display and power variations options Timers for pic projects

The post DCF77 clock-thermostat using PIC16F648A appeared first on PIC Microcontroller.

PIC16F877 based controllable digital clock using LCD display (Code+Proteus simulation)

$
0
0

This PIC16F877 microcontroller tutorial answers the question,
” How to implement a controllable digital clock using PIC16F877 ? “

PIC16F877 based controllable digital clock using LCD display

Using PIC16 simulator (Proteus) you can verify this digital clock code and change it according to your needs. Using three push buttons (As shown in figure below) you can adjust time as you desire. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

In this article, it is assumed that you know,

  • How to make a simple digital clock using PIC16F877. If you don’t then please read this page.
  • How to interface LCD with PIC16F877 microcontroller. If you don’t then please read this page.
  • How to configure timer0 of PIC16F877 microcontroller.  If you don’t then please read this page.

The following diagram (made in Proteus) shows the PIC microcontroller circuit diagram.

PIC16F877 based controllable digital clock using LCD display schematic

The above figure was taken after setting time to 07:58:54, timer0 is used as the base for digital clock generation. Timer0 is used here to generate 1msec interrupts. After every 1msec a global variable named msCounter increments. When msCounter reaches a value of 1000 then another global variable named secCounter increments and this process repeats itself. Similarly, when secCounter reaches 60, then  minCounter increments. And when minCounter reaches 60 then hrCounter increments. This process continues until hrCounter reaches 24 then all of these variables reset their values. LCD is updated with the new values of hrCounterminCounter and secCounter after every second.

You can set time using three push buttons attached on RE0, RE1 and RE2 pins (As shown in the above figure). By pressing ‘Set Time‘ button one time, code enters in configuration state. Hours value starts to blink and you can modify it using Up and Down buttons. Pressing Up button increments the value and pressing Down button decrements the value. When you are done setting Hours value, press ‘Set Time‘ button again, then Minutes value will start to blink and you can adjust this value using Up and Down buttons. Similarly, after setting Minutes value, you can press ‘Set Time‘ button again, then Seconds value will start to blink and you can adjust this value using Up and Down buttons. When you are done adjusting the time, then press ‘Set Time‘ button for the last time and this clock will start to work normally.

A crystal of 4MHz value is used in this circuit, which makes this PIC16F877 run at a speed of 1MIPS (Million of instructions per second).

Code

The main function code is shown below.

Downloads

Controllable digital clock display code using PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

 

For more detail: PIC16F877 based controllable digital clock using LCD display (Code+Proteus simulation)

The post PIC16F877 based controllable digital clock using LCD display (Code+Proteus simulation) appeared first on PIC Microcontroller.

PIC Based Oscilloscope Clock

$
0
0

For those are not into electronics, you must know that an oscilloscope has basically only one timebase to move the spot horizontally from left to right with the same intensity. The vertical deviation is function to the input voltage. You understand immediately that you can’t directly display 7 segment digits, because you can’t move the spot from right to left.

By using X/Y mode, where the spot is controlled on two axes by two different voltages, it is possible to draw a picture (as in the examples mentioned above), but a fast digital to analog converter with two channels and at least 8 bits of resolution would be needed.PIC Based Oscilloscope Clock

So we have to deal with a spot that always goes from left to right in the same period of time.
If we want to have a 7segment-like display, we have to draw :

vertical segments : easy to do, just change voltage up and down quickly a few times.
horizontal segments : easy to do, just set a voltage level and keep it as long as you need.

By using 2 PIC outputs and a basic R2R digital to analog converter, we can have up to four different voltage levels : 3 for the vertical segment, and another one where to put the spot when it is not in use to draw a segment.

But the problem is that a 7 segment digit may have up to 3 horizontal lines at a time (like 2, 3, 8, 9..) but we can draw only one during one spot deviation.
So we will have to cheat with retinal persistence and use multiple frames : since we can have only one vertical segment per period, three periods will be needed to draw a full 7 segment digit.

Supposing we want to display 12:34:56 on the screen :

During the first period, we will draw all vertical segments, and horizontal upper segments only :

As a game, I let you try to find out the spot trajectory.
Don’t forget the rules :PIC Based Oscilloscope Clock schematic

you can’t go backward
you can’t clear the spot

But you can move so fast vertically that the eye can’t see the spot moving.

The lowest line under the digits is not significant, it his the place where the spot is parked when not used to draw a segment.

 

 

For more detail: PIC Based Oscilloscope Clock

Current Project / Post can also be found using:

  • Mikroc pic timers for hourclock

The post PIC Based Oscilloscope Clock appeared first on PIC Microcontroller.

Lab 3: Four bit binary counter using PIC16F688

$
0
0

Description

Today’s lab session is about binary counting LEDs. The binary 1 and 0 will be represented by turning LEDs on and off. You will make a 4-bit binary counter (using 4 LEDs) that counts from 0 to 15 (0000-1111 binary). The four LEDs are connected to RC0 through RC3 port pins of PIC16F688 with current limiting resistors (470Ω each) in series. A push button switch is connected to pin RC4 to provide input for the counter. The counter starts from 0, and increase by 1 every time the button is pressed. When the counter reaches 15 (all LEDs on), it will reset to 0 on the next press of the button.

binary counter

Required Theory

You should be familiar with the digital I/O ports of PIC16F688 and their direction settings. If you are not, read Digital I/O Ports in PIC16F688. Read previous lab session (Lab 2: Basic digital input and output) to learn about reading inputs from a push button.

Circuit Diagram

The circuit diagram and its construction on the breadboard are shown in figures below. The PIC16F688 microcontroller uses its internal clock at 4.0 MHz.

Software

Define PORTC pins RC0-RC3 as output, and the pin RC4 as an input. Disable comparators (CMCON0=7), and configure all I/O pins as digital (ANSEL=0). Use Button() function to read input from the push button switch.

 

For more detail: Lab 3: Four bit binary counter using PIC16F688

The post Lab 3: Four bit binary counter using PIC16F688 appeared first on PIC Microcontroller.

Alarm Clock using PIC16F74 microcontroller

$
0
0

The idea for this project came from my youngest son who asked me to make him an alarm clock. I put together a simple PIC based design comprising of two interlinked vero-board cards. The design was created using New Wave Concepts’ LiveWire which allows you to simulate the effect of the signals on the components – very useful it you are new to electronics like me – If only it could simulate the PIC too!.

Alarm Clock

The larger of the two circuit boards holds the 5V power regulator, the display processor (a PIC 16F74), the real time clock (Dallas DS1307), 3V backup battery and buzzer. Click here to see a copy of the schematic for the base board in a popup window.

The PIC board looked like this before fitting the ICs and LED/switch wire connections. It is also missing the 1Hz signal, I2C clock and I2C data connections between the PIC and RTC chips. —I used a 4MHz resonator with built in load capacitors instead of the crystal and separate capacitors shown on the schematic. Also I added one more link wire after taking this photo to connect GND  to -ve terminal of the backup battery. (The copper tracks run left-to-right on this board with cuts between the IC pins and in a couple of other strategic places.

The PIC microcontroller  is programmed to read the real-time clock using I2C serial communication several times a second and update the display. It does no time keeping itself. Even the pulsing central pair of LEDs are driven by the real time clock (by means of a 1Hz output signal) and which is read by the PIC.

The PIC performs two other functions; it compares the time against the alarm settings to determine when it should go off and also handles time, date and alarm setting. The 16F74 has no EEPROM of its own so all the settings are stored in the DS1307 and read at power-on-reset. I was planning to mount connectors on the board for all the switch and display wires but in the end there wasn’t enough room so I soldered the wires directly

I ordered a 16F74 microcontroller from Farnell because it had more than enough I/O pins and supported I2C on chip. After I received the chip and read the small print in the data sheet I discovered that the SSP module was only really suitable for an I2C slave. What I really needed was a MSSP module. So my code disables the SSP module and generates the I2C master clock and data signals (on the RC3/SCL and RC4/SDA pins) using a ‘bit-banged’ approach.

 

For more detail: Alarm Clock using PIC16F74 microcontroller

Current Project / Post can also be found using:

  • real time digital clock projects

The post Alarm Clock using PIC16F74 microcontroller appeared first on PIC Microcontroller.

Quozl’s Alarm Clock using PIC16F877

$
0
0

Old Alarm Clock Problems

  • wake’s Quozl’s wife, a side-effect,
  • needs to be armed each evening,
  • 12-hour clock, cannot be armed more than 11.5 hours before alarm time,
  • triggers at plus or minus ten minutes, depending on how it was dropped,
  • battery cover needs to be removed to change time,
  • changing time at daylight saving loses minutes and seconds,
  • immitated by rural birdlife, causing false triggers,
  • second hand has failed from repeated dropping,
  • closed source implementation.

Alarm Clock

New Alarm Clock Features

  • wakes Quozl up each day,
  • doesn’t wake Quozl’s wife,
  • defaults to wake Quozl up the next day, doesn’t need to be told,
  • can be told at any time in the previous day not to wake Quozl up,
  • can be configured accurately without having to hold buttons down,
  • can emit per-second tick noises, or not,
  • can emit tones in response to key presses, or not,
  • can be told that Quozl is on holidays,
  • changing time for daylight saving can retain minutes and seconds,
  • open source, capable of being further hacked.

Not yet features

  • automatic daylight saving transitions,
  • gradual daylight saving alarm time shifts,
  • weekend alarm suppression,
  • recording of how long it took to wake Quozl up,
  • serial port for GUI configuration,
  • synchronisation using NTP or rdate over PPP or SLIP,

 

For more detail: Quozl’s Alarm Clock using PIC16F877

The post Quozl’s Alarm Clock using PIC16F877 appeared first on PIC Microcontroller.


DIAL ALARM-1

$
0
0

This is the lowest cost dialing alarm on the market and shows what can be done with an 8-pin microcontroller. The complete circuit is shown below. You cannot see all the features of this project by looking at the circuit – most of them are contained in the program. So, read on and see what we have included. . .

Dial Alarm-1 has a single input (although a number of sensors can be placed in parallel on the same input line). The circuit requires a trigger pulse to turn on a BC 557 transistor. This delivers power to the microcontroller. The micro starts to execute the program and outputs a high on GP2 to keep the “turn-on” circuit active. It also turns on the LED in the opto-coupler and this causes the line to be “picked up” via a high-gain Darlington transistor. The micro then dials two phone numbers and executes a series of events to alert the called party of an intrusion. The circuit also has a sensitive microphone with a high-gain amplifier. This is connected to the phone line when the alarm is triggered.
When the first number is dialled, a Hee Haw signal is sent down the line to alert the listener of an intrusion in the “target” area. Amplified audio of the room is then passed down the line. This signal is clear enough to detect conversations and/or movement in the target area and the listener can determine the situation. A second number is then called and the process is repeated. The two numbers are then called again and the alarm closes down. Simple but brilliant.

DIAL ALARM-1Use Dial Alarm-1 as a “Back-Up” Alarm

This alarm has been developed in response to a number of recent large robberies reported in the news. Robberies are a constantly increasing crime, but very few are reported, unless they have a “twist.” Recently, the robbers navigated the conventional alarm system and broke into the night safe in the Manager’s office. The haul was quite significant and it’s surprising such a large amount of cash was kept on the premises. The weakest link in most alarm systems are the PIR detectors, used to detect movement. It’s a known fact that they are very easy to foil. It’s so easy we are forbidden to print details of how to do it. But many thieves must be aware of the trick and that’s why a back-up system is essential.

The cheapest back-up system is the use of the phone line. I know what you are going to say. Cutting the telephone line is an easy matter and offers little security. But finding the line in a premises is
not very easy and if there are two or more incoming lines, it’s difficult to know which is connected to the dialler. Nothing is infallible, but for a lot less than $50 you can build this project and have a back-up to protect your property.
The other advantage of our design is the “set and forget feature.” The alarm is designed to ring your mobile and if you keep your phone beside you 24 hours a day, you can have this peace of mind, whether you are in your office, factory, holiday house or quietly dining at your favourite restaurant.

You can protect any area where a telephone line can be installed. This includes houses-under- construction and outlying sheds.
Talking Electronics has been producing security devices for more than 15 years and this project is a culmination of those years of experience.
The high-sensitivity amplifier is our development and comes from our highly successful Infinity Bug. This device connects to the phone line anywhere in the world and when the number is rung, the infinity
bug answers the call and lets you listen in to the activities in the room.  It’s just like being there. We have used the same circuit in this project. When it is activated, you can easily work out if it has been triggered by staff, a family member or an intruder.  At least it prevents 90% of false alarms and offers enormous peace of mind.

The secret lies in the placement of the triggering device.  We have provided only one input (trigger input). And there’s a reason for this. The idea is to place the sensor near the target area or on an actual device, near the microphone.

For instance, it you are protecting a house, a thief always goes to the main bedroom and rummages through the drawers and cupboards. In this case a drawer that is never used should be wired with a magnetic switch (reed switch) or a movement detector such as a mercury switch.  These switches can be housed in a plastic case for easy screwing to a wall or door and are very reliable in operation. When the drawer is pulled out or the door opened, the switch is activated.  If you are protecting a wall safe, the switch is placed near the safe in a clipboard or picture so that when the board or picture is moved, the alarm is activated.  If a room is to be monitored, the switch is placed on the door so that when it is opened, the alarm is activated.  If other valuables are being protected (such as a VCR, scanner etc) a suggestion is to place a clipboard against the item.  The idea is the clipboard has to be moved to get at the “valuables.” The clipboard contains a magnet and the switch is nearby. The clipboard keeps the switch open (or closed) and when it is moved, the alarm is activated.

The ideal arrangement is to avoid touching the clipboard, drawer, door or other “prop” during normal activities and this keeps the alarm activated at all times.
Another suitable trigger device is a pressure mat.  This is something that can be avoided by “those in the know” and you can monitor an area during your absence.  The alarm can be used for other things too. You can determine when your business premises are opened up in the morning by placing a pressure mat or reed switch on a door. The same can apply to a particular room in your establishment.

The purpose of this article is not only to produce the worlds smallest dialling alarm but also show you how the program runs so you can modify any of the routines to suit your own particular requirements.

The program can be re-written to dial only one number for two rings then hang up, or three rings, then again after 2 minutes or any combination to suit your requirements. Many mobile phones identify the caller on the display and you can keep track of the exact time of arrival and departure of different personnel.

The alarm can be programmed to monitor machinery and dial your mobile when a breakdown occurs. It can monitor water level or even your mail box. The possibilities are unlimited and it’s just a matter of modifying the program to suit your own needs.
But before you change any of the program you have to understand what the program does and be capable of changing the instructions without upsetting the operation of the alarm.
Remember: A little knowledge is a dangerous thing.  Before doing any re-writing of the program you need to read our notes on programming and carry out one small modification at a time.
This is really a very advanced project. The fact that is looks simple is the power of the microcontroller. It’s taking the place of at least 10 chips in a normal alarm.

Timing, tones and tunes have all been converted to instructions of a program. And the advantage of a program is the simplicity of alteration. A time-interval can be changed or a phone number altered with a few lines of code. Even new features can be added without the need for additional hardware. This project uses the ‘508A to its maximum and shows what can be done with an 8-pin microcontroller.  Before we go any further we must state that this project cannot be connected to the public telephone system. Only approved devices can be connected to the Public Phone System and any experimental device must be approved for experimentation and connected via a “telephone Line Separating Device.” These are available from Altronic Imports for approx $100.

This is unfortunately the case and when we discuss connecting the project “to the line,” we are referring to an experimental telephone system such as the one we have put together at Talking Electronics, to test and develop projects such as these.
See the section “Testing The Project” on Page 2 for more details of the Test Circuit. It consists of 27v derived from 9v batteries, a 12v relay, a telephone and a socket, all in series. The 12v relay is included to limit the current.

THE CIRCUIT

The circuit consists of 6 building blocks.
1. The turn-on circuit. Click HERE to see the circuit working (or click the red dot in the circuit above).
2. The tone detector. Click HERE to see the circuit working.         (   ”        ”      ”    )
3. The DTMF wave-shaping circuit. Click HERE to see the circuit working. (   ”    ”    ”  )
4. The high-gain audio amplifier. Click HERE to see the circuit working. (    ”    ”    ”  )
5. The opto-coupler. Click HERE to see the circuit working.             (     ”      ”      ”   )
6. The microcontroller.

1. THE TURN-ON CIRCUIT
The project is connected to a 6v supply at all times and to extend the battery life, the circuit turns off after use.  The current drops to less than 1uA and the only components connecting the battery to the project are the “turn-on” items.
These consist of a BC 557 transistor, 2M2 turn-off resistor, 100k bleed resistor, and the top 100u electrolytic. The components to turn on the “turn-on” circuit are the sensing device such as a reed switch or mercury switch, the lower 100u electrolytic and 100k bleed resistor. The components to keep the turn-on circuit ON, are the microcontroller, diode and 100k separating resistor.

It sounds quite complicated but here’s how it works. The trigger device must be AC coupled to the project so the alarm only carries out one alarm operation and resets.  If the trigger device was directly coupled to the turn-on circuit, the project would never turn off, even though we could design the
program to carry out only one dialing operation.
The sensing device must only give a TRIGGER PULSE to the circuit so it can reset after its operation, ready for another trigger pulse.
The only way to turn a reed switch activation into a pulse is to AC couple it. To pass the signal through a capacitor. This is what we mean by AC coupling – it means PULSE COUPLING or NOT DIRECT COUPLING.

The way the turn-on circuit works is this: The top electrolytic is charged very quickly by connecting its negative lead to the negative rail of the project.
This effectively charges the capacitor and supplies a voltage to the base of the BC557 to turn it on.
Energy from the electrolytic passes into the base of the transistor and allows current to flow between collector and emitter leads.

DIAL ALARM-1 SchematicThis flow of current activates the rest of the project. The microcontroller starts up and and the Watch-Dog Timer resets the program to the beginning after about one second (if the program did not start correctly) and takes over the job of turning on the BC 557, by taking GP2 low via the diode and 100k resistor. This action keeps the top 100u charged.
Going back to the action of the tilt switch; instead of taking the top 100u directly to the negative rail as discussed above, it is taken to the negative rail via an uncharged 100u and this is similar to a “piece of wire” when it is in a discharged condition. It gets charged (to approx 3v) and the project turns on.

If the reed switch remains closed and the micro goes through its set of operations and closes down,  the top 100u discharges while the lower charges to 6v. This will take a long time but eventually the transistor will turn off, even though the reed switch remains closed.
When the reed switch opens, the circuit cannot be re-activated until the lower 100u is discharged (or partially discharged) and this will take a long time through the 100k across it (and the upper 100u).

What an enormously complex operation for such a simple circuit!
At the end of an alarm-cycle the micro is placed in a holing loop at Main8. To get the micro to re-start at address 000, the chip must see a definite LOW. This will naturally occur when the project is sitting for a long period of time, waiting for a trigger pulse. If you are experimenting, make sure the rail voltage has been completely removed before re-starting the project.

 

For more detail: DIAL ALARM-1

The post DIAL ALARM-1 appeared first on PIC Microcontroller.

MikroElektronika’s “Ready for PIC” board talks to “Processing” using PIC16F887

$
0
0

Ready for PIC is one of MikroElektronika‘s compact prototyping boards for 28 and 40 pin PIC microcontrollers. The board comes with PIC16F887 microcontroller which is preprogrammed with an UART bootloader firmware and thus eliminates the need of an external programmer. The on-board USB-UART module allows the serial data transfer between the PIC and a PC using an USB cable. It has also got a reasonable size prototyping area to add more functionalities to the board as required. These features make this board an ideal candidate for doing embedded projects that require PC interfacing. This article first reviews the basic features of the Ready for PIC board and then demonstrates how to write a PC application in Processing (an open source programming language) to communicate with the board through the on-board USB-UART module.

Serial Clock

A brief review of Ready for PIC board

Ready for PIC is a compact development tool for 28/40 pin PIC microcontrollers. The board by default is equipped with PIC16F887 MCU placed in a DIP40 socket but it does provide connection holes to accommodate a 28-pin device. To program the MCU you can either use the pre-installed bootloader or an external programmer. For using an external programmer, you need to make a few adjustments on the board. Please read the User’s Manual for further instructions on this. Four 2×5 male header pins are available on the board for easy access to the MCU I/O pins. The on-board FT232RL chip provides a USB to asynchronous serial data transfer interface so that the MCU can communicate with a PC through a virtual COM port using a USB cable. The board has two LEDs marked with Rx and Tx which blink when data transfer via USB UART module is active. The board can also be used with a 3.3 V type PIC microcontroller. There is an on-board jumper for selecting between 5 V and 3.3 V supply voltage for the MCU.

Little about Processing

Processing is an open-source software development environment designed for simplifying the process of creating digital images, animations and interactive graphical applications. It is free to download and operates on Mac, Windows, and Linux platforms. The Processing Interactive Development Environment (IDE) has the same basic structure as that of the Arduino IDE and is very easy to use. The programming language is so simple that you can create an interactive graphics with just a few lines of code. Here we will not discuss much of the graphics capability of Processing. We will rather focus on the Processing Serial library that will allow to transfer data between the PC and the Ready for PIC board.

We will write a simple program in Processing to create a graphics window that displays the current computer time, and will send the same information to the Ready for PIC board through the virtual COM port. The PIC microcontroller will then display the time on a 8-digit seven segment LED display module. The seven segment LED module used here is mikroElektronika’s Serial 7-Seg 8-Digit Board. It uses a MAX7219 chip to drive 8 seven segment LEDs. The chip receives the display data from a microcontroller through an SPI serial interface. An User’s Manual is available for the Serial 7-Seg 8-Digit Board that describes how to use it with mikroElektronika’s various development boards. The LED board comes with an IDC10 connector cable that can be plugged into one of the 2×5 male header connectors on the Ready for PIC board. I connected it to PORTC of PIC16F887 (as shown below) because the SPI data and clock pins are multiplexed with PORTC I/O pins (see PIC16F887 datasheet for detail).

 

For more detail: MikroElektronika’s “Ready for PIC” board talks to “Processing” using PIC16F887

Current Project / Post can also be found using:

  • code c alarm microchip
  • digital clock with alarm pic pic16f84a
  • pic clock project
  • programmable digital timer mikroC pic

The post MikroElektronika’s “Ready for PIC” board talks to “Processing” using PIC16F887 appeared first on PIC Microcontroller.

Rubidium Atomic Clock

$
0
0

Introduction

In the 1970s I worked for a while for the UK Atomic Energy Authority (UKAEA) at a site in Winfrith, Dorset. Amongst a lot of other interesting work, I used a gamma ray density gauge that amounted to a caesium-137 source, in its castle and collimator, the target (various), a sodium iodide detector (from memory), a photomultiplier and a series of counters using dekatrons. Having spent hours taking readings off the dekatron counters I somehow still associate dekatrons with things “atomic”…

Precision frequency generators using the rubidium atomic frequency standard have been around for many years; second hand units have found there way on to Ebay at modest (circa $100 US) prices. I have built a number of clocks of varying accuracy – time set using Internet time standards, time set by GPS and using a humble crystal oscillator. So an alternative would be to use a clock based on a Rubidium atomic frequency standard. This would have the small advantage of being accurate (once set) without requiring external intervention (as the Internet and GPS clocks require).

Having seen other “atomic” nixie clocks (nixiebunny and jthomas as examples) it perhaps came naturally (to me anyway) to use dekatron as the clock display. Dekatrons are not as common as nixies in clocks using glowing neon but examples are around on the net (Bill (about a 3rd down the page), Jason Harper).

Lastly, I wanted a clock with as many switches, buttons and lights as I could manage (as against imagine which could be a nightmare).

Revision history (February 2010 – December 2012)

The first version of this clock I built during 2008 with these webpages first published in February 2009. During the last few year I have tinkered with the clock to resolve a few hardware problems. The main changes have been to

  • work with both 50 and 60Hz mains frequencies
  • improve the chime sequence repeat rate
  • improve the high voltage switching arrangements
  • allow Russian OG4 dekatrons as well as orginally GC10B dekatrons to be used
  • giving the software a complete workover to make it more robust
  • write a series of test programs so individual subsystems could be independantly and fully tested
  • replace the front panel with a laser cut/engraved one
  • rewrite the software using the free GCC-AVR C Compiler

Rubidium Atomic ClockThese changes have resulted in the divider and main microcontroller boards being first adapted and eventually replaced and a few trivial changes to the interboard wiring. Only the new boards and their software will be described below the legacy cards are all abandoned although the old front panel design is still available (within the Eagle file download).

In reworking this webpage I have also added more information on the construction and front panel wiring.

The divider card software, dekatron card software, test software and final clock software are all now available for download.

Atomic Clock

The rubidium oscillator I bought on Ebay is a Datum LPRO.

A microwave signal is derived from a 20MHz voltage-controlled crystal oscillator (VXCO) and applied to the rubidium (Rb 87) vapour within a glass cell. The light of a rubidium spectral lamp also passes through this cell and illuminates a photo detector. When the frequency of the applied RF signal corresponds to the ground-state hyper-fine transition of the Rb87 atom, light is absorbed, causing a decrease in the photo detector current . The dip in photo detector current is used to generate a control signal with phase and amplitude information which permits continuous atomic regulation of the VXCO frequency. The VXCO signal is divided by 2 and fed through a buffer amplifier to provide the standard frequency output of 10 MHz. 

To me it is just a “black box”, feed it correctly and it produces a precision 10MHz sine wave. It does produce some other diagnostic signals to show the unit is healthy:

  • BITE Built In Test Equipment signal to show the VCXO is locked to the atomic transition. As long as BITE is low once the unit has warmed up, the output frequency is within roughly ±5E-8 of absolute frequency.
  • LAMP V signal monitors the inherent degredation of the lamp light pickup; this signal should be >3 volts and < 14 volts.
  • XTAL V MON signal can be used to show if the crystal is drifting out of the available trim range; this signal should be > 0.55 volts and < 12.6 volts.

When I hooked a power supply up to the second hand unit, I was pleased to find the BITE signal when low after a few minutes (lock achieved) and the LAMP and XTAL voltages were both roughly mid range (in my ignorance I assume this is good).

By “feed it correctly” the LPRO requires a 24v peak 1.7A, normal 0.5A; power supply. The clock requires more than a 10MHz oscillator so I originally decided to use the a PCF8583 clock chip. This chip will accept a 50Hz signal (so I need a divide by 200,000 to get 50 Hz from 10 MHz) and communicates with a microcontroller using TWI (I²C) interface. I decided to pinch the nixiebunny idea of using batteries to preserve clock operation during power loss. The batteries would be float charged but capable of running the rubidium oscillator (0.5A at 24V) and the miscellaneous divider chain and clock. Then a thought occurred – why not measure time using mains frequency in a second PCF8583 clock chip so that absolute and long term differences between “mains” and “rubidium” could be measured. This arrangement has one disadvantage – there is no 60Hz mains version of the PCF8583 available and I have received interest from LandOf60Hz in replicating the clock. So I kept the legacy of dividing 10 MHz to 50 Hz (as I explain below I needed to divide to 1 Hz anyway) but swapped the two PCF8583 clock chips with a single ATMEGA168 to count transitions from the divider chain or from filtered mains and to communicate the count using a TWI interface. (On the way I considered using something like a ATTINY13 programmed as a “60Hz” PCF8583 but this seemed an overly complex solution.)

Finally, I wanted front panel outputs of the various frequencies available down to 1 Hz (so the divider chain would be divide by 10,000,000 in total). The first PCB for the clock was now evolved:

  • 24 VDC and 5 VDC power supply
  • Mains (float charged) battery
  • 10 MHz buffer (design from LPRO manual using a LT1016 fast comparator)
  • Divide to 1 Hz in a series of divide by 2 divide by 5 steps (74HC390)
  • Buffered outputs at 10 MHz, 1 MHz, 50 Hz, 1 Hz
  • ATMEGA168 chip linked (interrupt) to rubidium 50 Hz divider output and linked to filtered and squared 50/60 Hz mains frequency
  • Sensing BITE (“locked”), LAMPV (“lamp”), XTAL V MON (“crystal”) signals by the ATMEGA168
  • TWI link to the main microcontroller (clock counts, sensed values)
  • 1 Hz interrupt from the Rb oscillator derived clock
  • LEDs to indicate oscillator lock (BITE low), 1 Hz pulses from the two clock sources and an error status
  • Off board would be a 18 + 18 VAC 50VA torriodal transformer

Divider Schematic and PCB layout

Right click and then “save as” to see these images at higher resolution. The board Eagle files are available for download below. I built the board up first and tested it with an ATMEGA32 based test card to check the mega168 clock could be addressed and that all of the required signals were available. Everything was OK so I moved on to the dekatron display cards.

In electronics, a Dekatron (or Decatron, or generically three-phase gas counting tube or glow-transfer counting tube or cold cathode tube) is a gas-filled decade counting tube. Dekatrons were used in computers, calculators and other counting-related devices during the 1940s to 1970s. The dekatron was useful for computing, calculating and frequency-dividing purposes because one complete revolution of the neon dot in a dekatron means 10 pulses on the guide electrode(s), and a signal can be derived from one of the ten cathodes in a dekatron to send a pulse, possibly for another counting stage. Sending pulses along the guide electrodes will determine the direction of movement.Internal designs vary by the model and manufacturer, but generally a dekatron has ten cathodes and one or two guide electrodes plus a common anode. The cathodes are arranged in a circle with a guide electrode (or two) between each cathode. When the guide electrode(s) is pulsed properly, the neon gas will activate near the guide pins then “jump” to the next cathode. Pulsing the guide electrodes repeatedly will cause the neon dot to move from cathode to cathode. The dekatron fell out of practical use when transistor-based counters became reliable and affordable. Today, dekatrons are used by electronic hobbyists in simple “spinners” that runs off the mains frequency or as a numeric indicator for homemade clocks.

To operate the dekatrons you need several things:

  • High voltage for the anodes (typically 375 – 400 volts above the cathode voltage)
  • An intermediate voltage to hold the guide electrodes positive with respect to the cathodes
  • A means to take the guide electrodes to a voltage much lower than the cathodes so that the glow is transferred on to it
  • A means of detecting that cathode zero is glowing

This circuit shows the principles (from an original design by Mike Moorrees):

The cathodes are held a a positive voltage with respect to ground (this will avoid requiring a negative supply). A signal on one of the two inputs will bring the guide electrode down to a voltage negative with respect to the cathodes and so the glow will transfer onto that guide. Sequencing the pulses onto the two inputs will make the glow rotate in either a clockwise or anti clockwise direction. When cathode zero is glowing (B output on a GC10B dekatron) the cathode 0 lit output will go high.To rotate the glow the following sequence is needed:

  • Starts with inputs G1 and G2 both low
  • Make Input G1 high
  • Wait a few 100 μS – dekatrons are relativily slow – glow moves to G1 electrode adjacent to the glowing cathode
  • Make Input G2 high
  • Wait a few 100 μS – glow becomes “shared” between the two guide electrodes
  • Make Input G1 low
  • Wait a few 100 μS – glow moves to G2 electrode
  • Make Input G2 low – restoring the original state
  • Wait a few 100 μS – the glow moves onto the cathode adjacent to the G2 electrode
  • Success – the glow has moved from one cathode to another!

By sequencing the guide electrodes in the opposite order (G2 first) the glow will rotate in the opposite direction. Since on start up the cathode that glows first is unknown it is simple to rotate the glow using this sequence until a high is detected on the cathode 0 lit output; the dekatron is now in a known state (zero).So six dekatrons (hours : minutes : seconds) requires 12 outputs and 6 inputs from a micro controller. This is fairly heavy demand of I/O pins if I was using a single ATMEGA644P (as intended) which has 32 I/O pins. Since I was already using an TWI interface for the clock chips it seemed logical to look at using TWI port expanders. The PCF8574 expander has 8 I/O pins so irratingly I would need 3 chips. An alternative was to use, say, an ATMEGA168 as an TWI slave. This chip can be arranged to have upto 23 I/O pins – I need 18 for the dekatrons, 2 for the TWI, 1 for the reset (so I can use my usual programmer) and that makes 22 pins used – with 2 spare. I will use the internal 8 MHz RC oscillator which is good enough for this application. I use the “not for profit” version of Eagle which limits me to 160 x 100mm boards. To space the 6 dekatrons out sufficently I needed to space the design across two PCBs (which I actually cut to 150 x 100mm). An early design arranged the dekatrons in a 3 x 2 pattern rather than the straight 6 used here – I din’t like the resulting front panel designs, although the dekatrons the fitted onto a single 160 x 100 mm board. Links connect the first and second boards together. The ATMEGA168 is on the first board. The software would configure the ATMEGA168 as a TWI slave, would handle all the glow movements and accept commands like “move glow on dekatron 3 to position 2”. This would only take 2 bytes on the TWI bus. Other commands would set all glows to position zero (1 byte), set all 6 dekatrons to given positions (7 bytes) and also to force the ATMEGA168 to reset (1 byte). This all looked simple enough but I made the data structure more complex by adding a simple CRC7 checksum to make the communication more robust. This added a single byte to each command.

One spare input pins is arranged to put the card into a self test mode if grounded (eventually I may to use the second pin for some purpose).

GC10B version

Note the orientation of the octal sockets so that pin 6 is uppermost. This pin corresponds to cathode 0 which will then be at the top.

OG4 version

I have also produced a version of the cards to use the Russian OG4 dekatron which are currently in more plentiful supply than GC10/B dekatrons. The OG4 supply (on EBay, at the time of writing this) is for NIB dekatrons whereas the GC10B available tend to be (well) used – often electrode zero is entirely eroded away.

Note the orientation of the octal sockets so that the spline is uppermost. This pin corresponds to cathode 0 which will then be at the top.

Main Power Supply

I chose to use the same power supply I had used successfully with the bookcase clock that used a dekatron as well as four nixies. This would deliver the required voltages for the remainder of this clock when using a 15VA 18-0-18 VAC torroidal transformer. The power supply is physically large compared with other designs but I have plenty of space in the case I planned to use (more on the case selection and final assembly below).

I wanted to be able to turn off the dekatrons (to extend their life) when the clock was not in use but leave the rest of the clock running. I therefore added a relay to switch the AC feed into the voltage multiplier. I added a neon bulb as a warning indicator when the multiplier held a charge: touching the 475 V supply would smart to say the least… Not much else to say about power supply other than I added an on/off switch and fuse on the mains side of the two transformers together with a small (3A) LC filter to remove any rubbish on the mains. QED.

Main Power Supply Schematic and PCB Layout

Right click and then “save as” to see these images at higher resolution. The board Eagle files are available for download below.

Front Panel IO

The penultimate card is the front panel I/O. This uses four PCF8574 8 bit TWI I/O expanders to give 32 control lines. Since I was planning on a large number of front panel switches and neons I knew I was going to go beyond the I/O capabilities of the micro controller I planned to use. An alternative would be to use a third microcontroller as another TWI slave but I have a tube of PCF8574 chips available and they would provide the required I/O together with an interrupt signal to the main microcontroller when a switch was moved so I would not have to poll all of the switches in the software to detect changes. The main clock mode switch (clock, timer, alarm, sync, spinner etc) was to have 12 positions so I have used a GAL16V8 as a 12 to 4 encoder – there are many ways of achieving this kind of encoder but I have a good supply of these and other GALs (bought cheaply on Ebay). On the output side, I intended to have 7 neons to show the day of week (as well as some diagnostics) but only one of these would be lit at any time, so I used a second GAL16V8 as a 3 to 8 decoder. To generate the JEDEC data for the GALs I use the free Atmel WinCUPL compiler and a second hand programmer (again bought on Ebay). The WinCUPL input and output files are available for download below.

One last tweak was that I wanted all of the front panel switches to have their common pole connected to ground whereas the power supply needs a 5V positive signal to switch the HV relay on. So I used two free pins on the first GAL to form an inverter so grounding its input produces a 5V output (this output is unused after the 2010/11 revision).

Rubidium Atomic Clock SchematicMain Microcontroller

The last board to describe is the main micocontroller board. The board has the following facilities:

  • RS232 interface to be able to synchronise the rubidum clock with an external time source such as a GPS unit or NTP Client, to link to a PC for diagnositics and other setup and to provide a serial link to a data network (for example using RS485)
  • SAE800 gong chip to generate tones for alarms, hour chimes etc
  • A TWI interface for use within the clock to communicate with the front panel controls, the dekatrons and the clock TWI slaves (all described above) (brought out on two headers)
  • Interrupt inputs from the rubidium oscillator timed clock to give an accurate 1 interrupt per second and an interrupt from the front panel I/O expanders that will interrupt to signal that front panel switch has been moved
  • 4 way DIL switch to options that I would not anticipate changing very often (in that you need to open the case)
  • 3 LEDs for simple diagnostics and testing purposed
  • A rotary encoder to be able to adjust clock alarm and timer settings
  • A hardware reset button
  • A whole spare port (Port A) brought out to a box header
  • Finally, a programmer socket (in-situ programmer or ISP)

I selected an ATMEGA644P-20 (to be slightly overclocked at 22.1184 MHz) as it contains a genererous amount of flash, SRAM, EEPROM (not that I envisaged using much EEPROM use in this project) and sufficient I/O pins, UARTs etc for all of the facilities listed above. Again, here is the schematic and PCB layout (another double sided board) to view and the designs are in the Eagle download file.

Main Microcontroller Schematic and PCB

Right click and then “save as” to see these images at higher resolution. The board Eagle files are available for download below.

SAE800 Gong Chip

The gong chip is probably worth a special mention as it is a simple way to get single, dual or triple gong tones. In the triple tone mode the notes, for example can be arranged as the minor and major third: e2 – c# – a, corresponding to 660Hz, 550Hz and 440 Hz.

The gong chip allows the tone fundamental frequency and volume to be adjusted by setting two resistor values, so I decided to bring these out as variable resistors on the front panel (well why not?). Here is a (crude) recordings with a microphone of the gong chip in action:
The gong chip is simple to use and triggering it is easy in the software. The downside is that it is a bit municipal rather than musical.

 

For more detail: Rubidium Atomic Clock

The post Rubidium Atomic Clock appeared first on PIC Microcontroller.

Almost No Parts’ 12/24hrs LED Clock using pic microcontroller

$
0
0

A 12hr/24hr LED Clock with display control, uses a microcontroller PIC 16F84A or 16F628A and a few parts. (August 25, 2009)

This LED clock may not be the easiest to build but surely it is the one with fewer parts that you can find, for that reason I call it “The ANP LED Clock”. (ANP stands for Almost No Parts.)

Using the micro controller PIC 16F84A or the 16F628 (same pinout), this clock have more and improved features than my previous LED Clock.

Almost No Parts' 12 24hrs LED ClockHere are the features on this ANP LED Clock

 

  • Can use common cathode or common anode 7-segment LED displays.
  • Displays time as 12 hours or 24 hours format.
  • Allows to enable or disable the display for battery-operated circuits.
  • Can control the display brightness to reduce power consumption
  • 7-segment LED displays are charlieplexed to reduce I/O ports usage.
  • PM LED indicator (optional)
  • Only 10 parts needed: 1 PIC 16F84A, 2 22pF Capacitors, 2 n.o. switches, 1 4Mhz Xtal and 4 CA or CC 7segment LED displays.
  • Operates from 2.5 to 5.5 Volts, it can even work with a 3V coin batteryBecause all this features, the applications for this ANP LED Clock could be:
  • Inexpensive LED Clock to replace the expensive broken one from your luxury car.
  • “vintage” LED wristwatch – Using some LED display from old calculators and 3 Volts coin battery, it’s possible to build a small clock.
  • Jumbo Clock – Non-inverting buffers can be used to drive more voltage and lit giant 7-segment led displays.
  • Compact clock for your appliances or projects

 

Even more:

 

  • Desktop Clock as gift for a friend
  • Nice clock to keep your 4-years old niece distracted for a while
  • A piece of trash after your 4-years old niece were playing with the clock.

Almost No Parts' 12 24hrs LED ClockPin 1 to VDD for 12Hrs, VSS for 24Hrs
Pin 2 to VDD C Anode display, VSS for C Cathode
Pin 3 to VDD Enable display, VSS disable display
Pin 4 to VDD Normal operation, VSS Reset
Pin 5 VSS Ground or
Pins 6..13 To multiplexed display
Pin 14 VDD or +
Pins 15 & 16 Xtal Oscillator (4Mhz only)
Pin 17 to Display Decimal Point
Pin 18 PM LED indicator (optional)

 

For more detail: Almost No Parts’ 12/24hrs LED Clock

The post Almost No Parts’ 12/24hrs LED Clock using pic microcontroller appeared first on PIC Microcontroller.

Long Period Astable Timer using PIC12F629

$
0
0

Description

This software functions as a long period astable mutivibrator.  The mark and space period can be set from 1 second up to a maximum 65535 seconds (18h12m15s). Using the internal 4Mhz RC oscillator delays with an accuracy of 99% or better can be achieved 

The code also implements an edge triggered reset and an active low hold function.  The reset edge can be configured for rising or falling edge.  The hold function is active low and stretches the timed period for as long as the hold input is held low.

Long Period Astable Timer

In addition to this up to 450 mark/space time pairs can be used which are executed sequentially allowing complex pulse trains to be generated.

By connecting the hold input to the Q output, the code can also be made to function as an edge-triggered monostable timer, using the reset input as the trigger.

The code will run on a PIC 12F629 or 12F675.

At power on and after an edge triggered reset the outputs enter a mark state with the Q output going high and the notQ output going low.  The first time entry is then read and the code waits for the number of seconds specified.  When this period has elapsed a Space state is entered with the Q output going low, notQ output high and the next time entry is read. 

When the Hold input is taken low the output remains unchanged and the timer is stopped, effectively stretching the current time period. When the Hold input returns high, the timer continues.

If the Reset input is triggered while Hold is low, the outputs are reset to Q == high, notQ == low and the timer is loaded with the first entry from the LongDelayTimes.inc file. It them remains in the Hold state until the Hold input returns high.

Accuracy of timings

Since the timings are generated from the PICs internal 4Mhz RC oscillator the accuracy is subject to the tolerances specified in the Datasheet with respect to operating voltage and temperature. The software itself will generate an accurate timing but any deviation in the RC oscillator from 4Mhz will result in the time period deviating.  You should therefore test the accuracy before committing it to an application.

Since the PIC calibration word can only be correct at a specific supply voltage and temperature it is advisable to calibrate it at the supply voltage it will operate at in the final application.  This will help considerably in obtaining accurate timings.

My investigations with a number of PICs from different batches suggest that Microchip calibrate the PIC at a supply voltage of 3.5 volts.  Therefore if you’re operating it from a 5 volt supply it will be running slightly too fast.  

In the trace below the factory calibration value was 0x2C, the value when recalibrated with a 5 volt supply was  0x34.  For a programmed delay of 60 / 300 seconds it is showing 59.85/ 299.3 seconds which is 99.7% accurate.  This would result in an error of 3m16s over 18h12m.

For more detail: Long Period Astable Timer using PIC12F629

Current Project / Post can also be found using:

  • MICROCONTROLER CLOCK
  • microcontroller timer preprogrammed

The post Long Period Astable Timer using PIC12F629 appeared first on PIC Microcontroller.

PIC based WWVB clock

$
0
0

Introduction

There are many DIY versions of WWVB clock designs available on the web. Commercial “atomic” clocks are inexpensive and widely available, but I wanted to try my hand at designing one to gain insight into WWVB reception and to learn a little about programming a PIC microcontroller. My version is not the simplest available, but it works well and I think it offers a few unique features.

PIC based WWVB clock

WWVB Clock Features

  • Receives time broadcast from WWVB, Fort Collins, CO
  • Auto synchronizes internal time with WWVB time
  • Maintains local time when WWVB signal is lost
  • This version is for Pacific Standard Time, and auto detects/corrects for Daylignt Savings Time
  • 6-digit display of hours, minutes, seconds using 1″ seven-segment LED displays
  • WWVB sync indicator
  • Time display is in 12-hour format
  • PIC 16F628 microcontroller
  • Software written in C
  • All tools (schematic editor, C compiler, PCB layout software, PIC programmer are free and available for download on the web.

A complete description and specification for the WWVB broadcasts is available (free), document # 432, attf.nist.gov/general/pdf/1383.pdf The WWVB signal is broadcast as a 60 kHz carrier that is AM modulated with a time code frame that is updated once per minute. The data rate is one bit per second. Along with time code information, the data frame also contains synchronization bits, calendar data, UT1 correction, leap year, and leap second data. The clock design presented here only decodes the time data and daylight savings correction data. The software could easily be modified to include decoding of the other information bits, if desired. The the low frequency WWVB signal strength is weak and reception can be problematic. Signal acquisition time is variable, depending on location and atmospheric conditions. Reception is usually best at night between 8pm – 4am. To use the clock, just apply power and wait for reception of the WWVB signal. When the clock receives a complete error-free frame of data, it will automatically reset the display to show the correct time. After the initial time correction, the clock will maintain time even if WWVB reception is lost.

Hardware Description

Schematic PIC based WWVB clock

As shown in the schematic (pdf format), the heart of the clock is a PIC 16F628 microcontroller running at 4 MHz. Decoded time data is sequentially output from the microcontroller (RA0 – RA3) to the 7-segment decoder/drivers on a 4-bit data bus. The data is output sequentially as seconds, 10s of seconds, minutes, 10s of minutes, hours, and 10s of hours. The microcontroller outputs (RB1, RB2, RB3) route a 10 uSec stroble pulse from RB4 out to each of the 7-segment decoder/drivers at the proper time to latch the data bus values. Seconds and 10s of seconds display values are updated once per second. Minutes, 10s of minutes, hours, and 10s of hours are updated once per minute. The display consists of 1″ red-orange LED 7-segment displays. The decimal points on the displays are used to form colons to separate the seconds, minutes, and hours. The 10s of seconds and 10s of minutes displays are mounted upside down to form the upper colon dots. The WWVB receiver is a C-MAX model CMMR-6 and is available from Digi-Key (www.digikey.com) as part # 561-1014-ND complete with loopstick antenna. Data output from the receiver is sampled by the microcontroller on RB0.

For more detail: PIC based WWVB clock

The post PIC based WWVB clock appeared first on PIC Microcontroller.

Digital & Binary clock with thermometer & hygrometer

$
0
0

Here we have a clock. It’s not “another clock”. It has digital and binary output. It also has a thermometer and a hygrometer. It’s not “another thermo-hygrometer”. It display’s absolutely humidity (gr/m3) also.

Digital & Binary clock with thermometer & hygrometer

SchematicSchematic Digital & Binary clock with thermometer & hygrometer

 

MCU

I build it around Microchip PIC16F917, with internal Oscillator at 4MHz. I also build a serial port programmer, so I can programming it on-line, using the DL4YHF WinPic.

Clock

I use a RealTimeClock Maxim DS1305. The RTC backup power is a supercapacitor (0,22F). I test  it for 4 weeks, works fine. For this reason it don’t have the capability to change the time, but you can do small-corrections. Once you push the button, the seconds change to 30, with no effect to minutes, hours etc. The routine is in lines 1878-1887 “sec30“.

You set the time when you program the PIC. You have to program two times. The first time without line 91 (goto  rdtime). The routines setDS andsettime is execute.

SetDS is setting RTC’s control and trickle charger registers. In the settime routine, you set the time. After this, you add line 91 (goto  rdtime) and you reprogram it. Now the routines do not execute. RTC can keep the setting and time at least for 28 days. The routines DST3 and DST10 are for DaySavingTime. The check register is flag, 1. The checking routine is in lines 434-460. In the last Sunday of March, the 02:00 o’clock became 03:00 o’clock. In the last Sunday of October, the 02:00 o’clock became 01:00 o’clock. I set the RTC for 12H mode, leds for 12H and display for 24H.

Temperature – Humidity

I use a digital humidity and temperature sensor Sensirion SHT11.
I bought it in a PCB, with the pull-up resistor and decoupled capacitor ready in place.
Measurements make every 10 seconds.
At 00, 20 and 40 seconds it measures the temperature and calculate the temperature and Absolutely Humidity (“gr/m3” grams at cubic meter of air).
At 10, 30 and 50 second it measures the humidity and calculate the Relative Humidity (%).
The check register is flag, 0. The checking routine is in lines 464-475.
The measure temperature routine is in lines 477-514 “measTEMP” and lines 625-714 “measure“.
The calculate temperature routine is in lines 1793-1820 “calcTEMP“.
The measure Relative humidity routine is in lines 560-590 “measRH” and lines 625-714 “measure“.
The measure Absolute humidity routine is in lines 515-555 “measAH“.
The calculate Relative humidity routine is in lines 717-1470 “calcRH“.
The calculate Absolute humidity routine is in lines 1473-1728 “calcAH“.

For more detail: Digital & Binary clock with thermometer & hygrometer

The post Digital & Binary clock with thermometer & hygrometer appeared first on PIC Microcontroller.


PIC 18F4550 Timer And Interrupt Example Video Project

$
0
0

Welcome back everybody! This video covers multitasking via timers and interrupts with the PIC 18F4550.

A few notes on this video:
-To keep the pace of the video going I added fast forwarding more than in the previous videos. Please let me know in the comments if this was helpful or better compared to the previous videos with less fast forwarding.
-I recorded a substantial part of this video, especially the first third of the video, on July 2nd in the evening, you can hear fireworks going off in the background, not much I could do about that. Hopefully this does not detract from the viewing experience to much.

 

Current Project / Post can also be found using:

  • DIY countdown timer PIC12F629
  • pic clock timmer circuit

The post PIC 18F4550 Timer And Interrupt Example Video Project appeared first on PIC Microcontroller.

2 Digit 99 Seconds Timer

$
0
0

2 Digit Count Down Timer is a utility Count Down timer project for upto 99 seconds of countdown time.  This project can find many uses in your shack and home.  The relay output remains on during the Count Down period, allowing you to interface load or alarm that you want to keep it on for a certain amount of time (in seconds).

2 Digit 99 Seconds Timer

Specifications

  • Microcontroller based design for greater accuracy and control
  • Power supply input 12 VDC 200 mA
  • Two 0.5″ display segments to display time
  • 12V SPDT (Single Pole Double Throw) relay for alarm use
  • Single key start and dual key alarm time set function
  • Power and Relay-On LED indicator
  • Terminal connectors for connecting power supply input and relay output to the PCB
  • Onboard regulator for regulated supply to the kit
  • Crystal resonator based design for better accuracy
  • PCB dimensions 72 mm x 81 mm

This is a microcontroller based 2 Digit (99 Seconds) Count Down Timer.  This Count Down Timer is very easy to use and easy to configure.  This project can find a lot of application areas where you need a device to remain ON (or OFF) for a certain period of time (upto 99 Seconds).  Power to the circuit is applied at CN1 (12 VDC).  D1 provides the reverse polarity protection to this kit.  LED D2 confirms DC Power Supply to the board.  S1 and S2 displays Count Down time.  J3 provide an easy way of connecting external switches to this board.  LED D4 confirms the relay status.

Operating Instructions:

The setting up of countdown period and START Function for this kit is accomplished with the help of 3 tactile switches shown as SW1, SW2 and SW3 in the schematic and labeled as UP, DOWN and SET on the PCB respectively.

  1. Setting Time : The default value is shown on display S1 and S2 respectively. You can change this value by simply pressing the UP and DOWN key.
  2. Start : You can start the Count Down by pressing SET key. When the Count Down starts the relay is energized, indicated with the glow of LED D4. Once the Display (S1 and S2) reaches 0 the relay is de energized.

SchematicSchematic 2 Digit 99 Seconds TimerFor more detail: 2 Digit 99 Seconds Timer

Current Project / Post can also be found using:

  • pic led clock circuit

The post 2 Digit 99 Seconds Timer appeared first on PIC Microcontroller.

Miniature Real-Time Controller using PIC16F84

$
0
0

Introduction
The F84 MRTC was my second design of a miniature real-time controller. This version uses PIC16F84 running with a low power X-tal 32,768Hz. The scheduler for 6-channel output was saved in EEPROM. No terminal for serial downloading of the scheduler. It’s suitable for fixed scheduler job. Two AA size battery provides +3V backup for clock operation when main power has failed. Time setting at 19:00 is set only once by pressing S1 button. The 6-channel open collector output provides max. 30mA @30V load.

Real-Time Controller

Hardware

A circuit diagram of the F84 MRTC is shown in Figure 1. The controller is  PIC16F84, Flash based RISC uController running with a low-power X-tal 32,768Hz. The 6-channel output is RB2 to RB7 connected to a 74LS07 open collector buffer providing approx. 30mA @30V suitable for driving a homemade opto-triac shown in Miniature Real-time Controller 2051 version. D1 and D2 forms a simple switch between main supply and +3V battery. As can be seen, D1 may be silicon signal diode 1N914 or 1N4148. D2, however, can use a Ge diode having lower V forward. S1 is a momentary switch when pressed, it set current time to 19:00. The small LED at RB0, indicates functioning of the controller, after reset the blink rate is 1Hz, after press S1 set time to 19:00, it will blink at 1/3Hz or every 3 second.

Software
The original source program for the F84 MRTC was written using ‘C’, RTC.C with header file RTC.H. The hex file, RTC.HEX was compiled by PICC PCW V2.666. Daily scheduler is resided in 64-byte EEPROM data space. Editing for your scheduler can be made under PicPro by Nigel Goodwin. As shown in Figure 2, each byte may edit and enter into Nigel’s Picpro buffer before write the code and EEPROM data into the F84 chip. See details of setting scheduler in RTC.C

 

For more detail: Miniature Real-Time Controller using PIC16F84

Current Project / Post can also be found using:

  • microcontroller cblock
  • pic for making clock projwct with lcd#spf=1
  • Pic16F72 Timer circiit
  • pic16f876a clock projects

The post Miniature Real-Time Controller using PIC16F84 appeared first on PIC Microcontroller.

Digital clock ds1307 using PIC microcontroller

$
0
0

igital clock using ds1307 and pic16f877a microcontroller is designed in this project. Digital clock using ds1307 displays time and date on LCD. PIC16F877A microcontroller is used to design digital clock. I2C communication protocol is used to read time and date from digital clock ds1307. PIC16F877A microcontroller is interfaced with LCD to display time and date. Digital clock ds107 use I2C serial communication proctol to send data to microcontroller. pic16f877a microcontroller receives data from ds1307 through I2C serial communication protocol. I will discuss it detail in later part of this article. Before reading this article further, you should know how to interface LCD with PIC16F877A microcontroller. If you don’t know, I recommend you to read following article first.

Digital clock ds1307 using PIC microcontrollerigital clock DS1307

DS1307 is an integrated circuit based real time clock. It counts minutes, seconds, hours, date of month, days and years. It also have functionality to include leap year compensation up to 2100. It is binary coded decimal clock (BCD). This clock operates in either in 12 hour or 24 hour format. Indication of Am and Pm can also be included on LCD display through programming. It also have automatic power failure circuit. Automatic power failure circuit detects power failure and switch to 3 volt battery to keep record of time. It have battery back up. Battery back up is used to keep record of time in case of main power failure. It have 56 bytes non-volatile RAM for data storage. DS1307 use two wire serial communication I2C. It consumes very less power and current in the order of 500nA.  It can operate in harsh temperature environment in the range of -40ºC to +85°C.

  • SQW/OUT : Square wave and output driver pin
  • SCL: Serial clock used for I2C communication
  • SDA : Serial data pin for I2C serial communication
  • GND: Ground pin of power supply is connected with this pin
  • VBAT : It is 3 volt back up battery. It is use in case of main power failure
  • X1 and X2 : 32.768 crystal connects with these pins
  • Vcc : Main power supply connects with this pin

Digital clock ds1307 using PIC microcontroller SchematicIn I2C serial communication, one device acts as a slave and other device acts as a master. Slave only respond to instructions of master. Slave can not give instructions to master. Digital clock DS1307 acts as a slave and respond to instructions of microcontroller. Built in register in ds1307 is used to respond to instructions of microcontroller. As shown in above circuit diagram, SCL pin of ds1307 is connected to SCL pin of microcontroller. It is used to synchronize serial data on serial wire. SCL stands for serial clock input. SDA stands for serial data input/output.  SDA pin of ds1307 is connected with SDA pin of microcontroller. SDA is used as a serial data input or output for 2 wire serial communication. SDA pin of ds1307 is open drain that is why its required external pull up resistor as shown in figure above. Standard 32.876KHz quartz crystal is used with real time clock ds1307.

 

For more detail: Digital clock ds1307 using PIC microcontroller

Current Project / Post can also be found using:

  • applications of countdown timer using 8051
  • big led calendar clock projects using pic
  • clock watch using pic16f877a
  • pic16F877a make clock with alarm buzzer

The post Digital clock ds1307 using PIC microcontroller appeared first on PIC Microcontroller.

DIY Digital Clock with Temperature Display using PIC Controller

$
0
0

One of the most enjoyable part of being an electronics person is creating your own gadgets and using them in daily life. In this article, we are building one of those with the help of SoloPCB design tools, a digital desk clock with temperature display feature.

DIY Digital Clock with Temperature Display using PIC Controller

The brain of the circuit is a Microchip PIC18F252 microcontroller. It acquires precise time information from DS1307 real time clock via I2C interface and displays it on four digit 38 mm seven-segment display with the help of MAX7219CNG display driver. The temperature data is read by the on-chip ADC module of the microcontroller from LM335 temperature sensor which outputs 10mV per kelvin degree linearly. The temperature data is also displayed periodically.

The PIC microcontroller and the peripheral ICs mentioned above needs 5V regulated supply to operate. The step-down converter in the power section of the circuit, LM2574N-5.0, converts 12VDC input voltage to 5VDC and lets to draw 500mA without any significant heating problem.

There are two LEDs on the board indicates power and functional status and the buttons let the user adjust the time and display the temperature manually.

The Circuit and the PCB Design

The circuit and the PCB of the project are drawn in SoloPCB. SoloPCB is a very powerful tool which integrates the circuit design to the PCB design and the fabrication. You can download SoloPCB from FabsSream for free. The circuit and the PCB files of the project are provided in SoloPCB format. You can download the design files including the symbol and the footprint libraries by using the download link below.

The circuit schematic of the digital desk clock and a screenshot from its PCB can be seen below.

After the PCBs fabrication, the components listed below are assembled on the board.

Bill of Materials:

Quantity Part Description Designator
1 CR2032 Battery Holder B1
1 22uF 16V Tantalum Capacitor C1
1 10uF 16V Electrolytic Capacitor C10
1 220uF 16V Electrolytic Capacitor C2
5 100nf 63V Ceramic Capacitor C3 C6 C7 C8 C9
2 22pF 50V Ceramic Capacitor C4 C5
1 MBR-150 1A 50V Schottky Diode D1
1 3mm Red LED D2
1 3mm Green LED D4
1 LM335 Temperature Sensor D3
1 BAT42 200mA 30V Schottky Diode D5
1 DC-001 Power Connector J1
1 1×5 2.54mm Male Header J2
1 2×4 2.54mm Male Header J3
1 150uH 850mA Inductor L1
4 38mm Common Anode 7 Segment Display LD1 LD2 LD3 LD4
3 330R 1/4W Resistor R1 R2 R11
6 10K 1/4W Resistor R3 R4 R5 R7 R8 R10
1 2K 1/4W Resistor R6
1 27K 1/4W Resistor R9
3 SPST-NO 6mmx3.5mm Tactile Switch SW1 SW2 SW3
1 LM2574N-5.0 0.5A Step-Down Converter U1
1 PIC18F252-I/SP Microcontroller U2
1 28 Pin DIP Socket 300mil U2 Socket
1 MAX7219CNG 8 Digit Display Driver U3
1 DS1307+ Real Time Clock U4
1 32.768KHz Crystal Y1
1 10Mhz Crystal Y2

 

All the components are through hole type so there is no need for a very good soldering skill.

 

Read More:    DIY Digital Clock with Temperature Display using PIC Controller

Current Project / Post can also be found using:

  • pic in clock

The post DIY Digital Clock with Temperature Display using PIC Controller appeared first on PIC Microcontroller.

Viewing all 218 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>