Timer to control the UV exposure setting. Simple timer on PIC16F628A

This is a simple timer circuit built on the PIC16F628A microcontroller and LCD 1602 indicator. The idea of ​​the timer is borrowed from a Portuguese site on radio electronics.

The PIC16F628A microcontroller in this circuit is clocked from an internal oscillator, which is accurate enough for this case, but since pins 15 and 16 are left unoccupied, an external crystal could be used for greater accuracy.

Timer on PIC16F628A. Work description

As mentioned earlier, this project is based on an existing project, but in fact both schemes differ from each other, and therefore the code was almost completely rewritten. There are three buttons to control the timer: "START/STOP", "MIN" and "SEC"

  1. "START/STOP" - to start and pause the timer.
  2. "MIN" - to set minutes. The number of minutes is set from 0 to 99 and then everything starts again from 0.
  3. "SEC" - to set seconds. A second is also set from 0 to 59 and then again from 0.

Pressing "MIN" and "SEC" at the same time resets the timer during operation.

When the timer reaches 00:00, a sound signal(3 short and 1 long beep) and the HL1 LED lights up. An electromagnetic buzzer is used as a sound emitter. After that, when one of the buttons is pressed, the timer is reset and the HL1 LED turns off.

When the timer counts down, pin 13 (RB7) is high, and when the timer is stopped, a low logic level appears. This output can be used to control external actuators. the timer is powered from a stabilized source on.

Jumper J1 is for timer calibration. When it closes, the timer enters the setting mode. Using the "MIN" and "SEC" buttons, you can increase / decrease the value of an internal parameter that allows you to slow down or speed up the timer. This value is stored in EEPROM. If you press the "START/STOP" button while in this mode, this parameter will be reset to the default value.

Code written and compiled with mikroC PRO for PIC.

Project parameters:

  • Generator: INTOSC
  • Oscillator frequency: 4 MHz
  • Watchdog: Disabled
  • Power-up timer: enabled
  • RA5/MCLR/VPP: Disabled
  • Brown-out: enabled

Photo of the finished timer.

Recently I decided to master the technology of photoresistive board manufacturing and for this I needed a UV lamp with a timer. Of course, it would be possible to find a ready-made project and solder it, but I wanted to not only make a timer, but to gain a whole wealth of knowledge and experience. The criteria for the timer were as follows: time indication, user-friendly interface and simplicity. I decided to use a microcontroller as a basis, namely Attiny 13. You can see a list of all the necessary components for creating a timer in the table below this article. Since Attiny 13 has only 8 legs, of which 5 are I / O ports, it was decided to use register shift chips (74HC595) to display the time on the indicators. You also need to connect the control buttons in the most compact way and to solve this problem we will use one interesting solution - we will use the ADC of the microcontroller (the essence of the solution is described below). As a result, the following scheme emerges:

You may not understand the connection of the buttons, I’ll tell you: using voltage dividers (resistors R14 ... R16), when a specific button (S1, S2 or S3) is closed, a certain voltage level is applied to the microcontroller input, which is recognized by the ADC and, depending on its level, the microcontroller understands which button we pressed. R12 and C1 - RC noise filter, since when you press the buttons, there is a bounce of contacts and the microcontroller may mistakenly perceive not one, but more clicks. Resistor R13 is needed to pull up the ADC input when the buttons are pressed, so that the MK does not perceive interference.

Now about the indicator, which, by the way, is with a common cathode. As you can see, the microcontroller controls the register shift microcircuits. It sends a serial code of numbers on two legs, and on the third - the clock frequency. The register shift chip U3 is responsible for the digit of the indicator to which the digit is displayed, and U2 is for entering the digits themselves into the digits. Numbers are displayed sequentially. That is: we determined the U3 microcircuit to output a number to the 1st digit of the indicator, and the U2 register at that time supplies the code of the digit itself to the switched on indicator digit, after that the U3 microcircuit turns on the 2nd digit of the indicator, and the U2 microcircuit displays the next digit in the output number. Similarly, numbers are displayed for the remaining digits. Since the frequency of enumeration of digits is quite large, in the end we will see a single, whether it be a 4 or, for example, 2-digit number.

Manage UV LED matrix we will be using field effect transistor. The first one I came across was an IRF445H in a SOIC8 package, soldered from an old video card board. You can use any other transistor, as long as it can switch a little more than 3 amps.

Since the LEDs are powered by a voltage of about 3.3V, we will need to adapt a separate regulator with a current of more than 3A (since we have 100 LEDs). As such a regulator, I used the MP1584 DC-DC step-down module (regular linear regulators such as L7833 will not work due to the inability to provide more than 3A current). Due to the fact that our module is adjustable, you need to set the required voltage level with a trimmer resistor and then replace this resistor with a constant one of the same resistance. In my case, I put two resistors connected in series: 5.1kOhm and 22kOhm:

Resistor R1 acts as a pull-up on the RESET pin, otherwise our program will arbitrarily stumble with each interference. Resistors R4 ... R11 are needed to limit the current through the indicator LEDs. Well, the rest of the scheme should be clear.

I bred the printed circuit board and circuit in . I had to use a 2-sided textolite using interlayer transitions (I will show you how to do them later)

Concerning program code, then it is simply full of comments, therefore I will not take time for explanations.

With the theory like everything.

Now let's move on to practice:

First, let's upload the firmware to our microcontroller. I will use the AVRDudeProg program. I note that you do not need to configure the fuse bits (just set them by default). By the way, if you are interested, I upload the code using a cheap Chinese AVRASP programmer in conjunction with a homemade debug board:

After the firmware, we will make the basis of our future device - a printed circuit board, or rather boards, since they will be placed on top of each other to save space.

I will make according to . Let's print it, prepare the textolite (I'll remove the oxides on the honey using a clerical eraser) - so that the 2 layers come together correctly - drill control holes - iron - moisten - gently erase the paper - check for breaks or sticking tracks - if we don't find any - we start to etch board (I will etch in ferric chloride) - done - again we check the board for defects - after that, we drill holes (I note that the diameter of some holes is different - for holes for interlayer transitions - 0.4 mm, the rest of the holes - 0.6 and 1.0 mm) - excellent - if you wish, the board can be tinned in a rose alloy - so it will last longer. Now let's move on to layer transitions. We will make these transitions in the following way: First, we drill a hole, then we take a copper wire (wire) with a diameter equal to the diameter of the drilled hole and insert it there so that the ends of the wire stand out a little from the board:

At the end of pressing all the interlayer jumpers, it is advisable to check with a multimeter (diagnostic) whether a connection has appeared between the contacts of the two layers, and it is also worth checking that no track breaks anywhere and unnecessary jumpers are not formed. It is most convenient to do this under a low-power spotlight:

If desired, the places of interlayer transitions can be strengthened with pads from 2 sides of the board. I decided to mess around a little and cover the board with a solder mask. It didn’t turn out very well, but I don’t really want to redo it :)

As I mentioned earlier - the boards will be placed one above the other. They will be fixed with metal racks. For electrical contact between the boards (power for LEDs) - prepare a connecting wire with a connector and a corresponding plug for the board (You can, of course, just solder):

Our boards are ready, so let's proceed directly to the soldering of the components. I advise you to start with small and hard-to-reach elements. Chips in SMD design can be soldered with a soldering iron or a hair dryer. Personally, I prefer a soldering iron. The result is something like this:

As you can see from the last photo, several LEDs have decided not to glow, but this does not play a special role since all the LEDs are connected in parallel. By the way, the value of limiting resistors (there are 100 of them for each LED) is 100-200 ohms.

And finally, we will assemble our device into a case, which I will use as a food box. Here is the final design:

As you can see, I also provided for the cooling of the UV matrix, since the exposure of the solder mask is a long process (takes about an hour, or even more) during which the LEDs heat up quite well.

Now about the power supply: powered by a 12V 1A power supply connected to the power connector (diameter 6mm) on the board. It is also possible to connect power to the terminal block to the right of the connector.

After connecting the power, the device starts working immediately:

It seems to have explained everything. If you have any questions - write in the comments

List of radio elements

Designation Type of Denomination Quantity NoteScoreMy notepad
C1 Capacitor0.01uF1 SMD_0603 To notepad
C2 Capacitor10 uF1 SMD_1206 To notepad
C3 Capacitor10 uF1 SMD_1206 To notepad
HG1 Light-emitting diodeFYQ-5641-AG1 7-segment common cathode indicator (0.56") To notepad
Q1 TransistorIRF445H1 SOIC_8 To notepad
R1, R3 Resistor

10 kOhm

2 SMD_0603 To notepad
R2 Resistor

3 kOhm

1 SMD_0603 To notepad
R4-R11 Resistor

100 ohm

8 SMD_0603 To notepad
R12, R14, R15 Resistor

2 kOhm

4 SMD_0603 To notepad
R16 Resistor

Display feature this device is that a separate shift register is used ( 74HC4094) for everybody seven-segment indicator. The serial output from the first register can be connected to the input of the second, and so on. To fill all the indicators you need to send a special combination of serial data.

The advantage of this approach is that you do not need to update the segments all the time, in fact, you just need to fill in the data in the registers and that's it. This leads to the fact that the display begins to glow brighter, the flickering effect is eliminated and the resources of the microcontroller are freed up, which can be available for other, more important work. Also, only three data lines are needed to control this display, which is very useful if we don't have enough I/O ports. The downside of this approach is that the segments draw more current than in multiplexed mode. On the diagram you can also see a piezo buzzer, a voltage regulator (220V -> 5V) and a relay.

The segments are connected randomly, and this is because the printed circuit board is easier to separate in this way. You can connect the segments however you like, but to the "segment table" in source code appropriate changes must be made.

Device management:
- Two buttons are used to set the countdown time in 10 second increments;
- Third button (start/stop) to start and stop;
- When the countdown ends, the timer turns off the load and turns on the sound signal;
- The first two buttons are disabled during the countdown procedure;
- Last thing set time stored in EEPROM. EEPROM will store the settings after power off, and when power on, the timer will display the previously saved time;
- The microcontroller will go to sleep after two minutes of inactivity, and the current consumption is reduced to less than 5 mA;
- By pressing the start/stop button, it will wake up.

Setting the fuse bits of the microcontroller

Archive for the article "Timer for photoresist exposure on Attiny2313"
Description: Source code (Bascom), microcontroller firmware file, Proteus project, Eagle circuit boards
File size: 298.48KB Number of downloads: 1 068

This device was born "quickly" after several ruined blanks of boards with a photoresist. The device is very simple - it's a timer that allows you to turn on the UV lamps for a period of 5 seconds to 9 minutes 55 seconds (I have a typical exposure time with four Vito 8W lamps is one and a half minutes). I have not experimented with the mask yet, but I hope it will have enough time.
Work with the timer begins by pressing the SET button (entering the setting mode). Next, use the +/- buttons to set the desired time. If nothing is pressed for more than 5 seconds, the device perceives this as the end of input and saves the set time to non-volatile memory. In this case, the corresponding sign is displayed on the screen. Then the device goes into standby mode, displaying the set time in the format "minutes.seconds".
When the START button is pressed, the relay is activated and the lamps turn on. The countdown begins. The process can be observed on the screen. At the end of the set period of time, the timer automatically de-energizes the lamps and displays dashes on the screen - a sign of the successful completion of the cycle. It is exited from this state by pressing any button.
In the archive I enclose the board and firmware for the controller. The indicator is conventional, LED with a common cathode. The board consumes about 15mA in standby mode, about 60mA when the relay is on (depending on the relay used).
To power the lamps, you can use standard chokes with starters, but I used boards from economical low-power lamps. Even if buying new "housekeepers" is cheaper than buying chokes. Yes, and they take up less space and the start of the lamps occurs almost instantly.
The case was made from scraps of furniture chipboard, inside I used ordinary food foil as a reflector. I used holders for plastic pipes as fasteners for lamps. The electronics board is powered by a low power transformer (from a Chinese radio).

It looks like this:

The assembled device looks very simple:

And actually what the lamps look like inside:

In addition, the board and controller firmware:

Firmware with a timer setting resolution of 5 seconds.

Tell in:
Author - Andrey Shabarov aka htscooter. Published on 06/25/2009. After looking around the Internet for printed circuit boards made using photoresist, I also decided to try it. Naturally, several problems immediately arose. Well, such problems as the lack of photoresist, UV lamps, were solved in the market and in the store. Of course, you need to spend money, but what can you do - if you can still make a photoresist yourself, then there’s no way to use a UV lamp. Well, finally, everything is there, you can proceed. And here was the question of selecting exposure exposures. At the stage of the test strips, a watch with a second hand successfully coped with this. But for the constant use of me, a very lazy cat, this did not suit me in any way. The TOR was formed and the search and analysis of existing schemes began (well, I'm lazy - to invent it myself). The search did not give any results, I'm not only a lazy cat, but also a picky one, I had to do everything myself.

The terms of reference are quite simple, but adapted to the needs of photoresistive technology:
- exposure limits 00m 05s -99m 55s;
- control of both lamps and compressor for vacuum clamping;
- light and sound indication of operating modes;
- Ease of controls;
- available or inexpensive components.

Based on the TK, an approximate diagram was drawn, and fine-tuning of the device on the breadboard began, the final diagram of which is shown in the figure below: Actually, everything is very simple, ATMega8 or ATMega8L as a control element, several buttons, a four-digit indicator in dynamic display and a handful of resistors and transistors. As power elements, I used triacs connected through opto-simistors. This, of course, is a purely personal question, I had them, and I put them on. There you can apply a relay, in general - that is. The inclusion of optosimistors according to the datasheet, no frills. The only thing is, if you wish, you can exclude the RC circuit (39 Ohm + 0.1 μF), its absence is not fatal. The power supply of the circuit is also as simple as possible, trans, diode bridge, electrolytes, 5 volt roll. Pullup on the buttons is also optional, the port legs are pulled to the plus, I debugged on the breadboard without external resistors. So what else is on the agenda? Resistors in the bases - plus or minus what they are, current-limiting by segments - depending on the indicator. For some, 510 ohms will be bright, but I have 150 ohms, so the brightness is not enough, the indicators are old, dim. Boozer with built-in generator, 5 volts. NPN transistors for a current of about 100mA - VS547, VS847, KT3102, KT315. Power supply - transformer TP-112-18, diode bridge for 1A. Here I was a little worried with triacs - BT136 could not stand the vacuum cleaner (1300W), I had to change it to BT140. For those cats who will also install triacs and use a vacuum cleaner, I should note that the radiator should be installed more, otherwise you can burn your paws (just kidding, you shouldn’t climb this radiator with your paws, jokes are bad with electricity). More than 10 minutes of exposure my radiator will not pull, but since I plan to use a fan for this purpose, I'm not too worried.

Well, now for the functionality and work. The control is performed by five buttons, three of them are for changing / setting shutter speeds, the other two are for turning on the compressor and starting the timer. When the timer starts, both the compressor and the backlight turn on, but the compressor can be forced on in standby mode to prepare the template board for the backlight. For this, I had to display a separate "air" button to control the compressor. In standby mode, the plus / minus buttons select the saved settings (I did three, there is simply no point in more). When you press the "set" button, the minutes start flashing, the plus / minus buttons change the value of the minutes in 1-minute increments (from 0 to 99); the second press of "set" saves the minutes and the seconds start flashing, their value changes in the same way, but in steps of 5 seconds (from 0 to 55). A step of 5 seconds was chosen as the most optimal - with a step of 1 sec and 10 sec it is not very comfortable to change the values. At a step of 1 sec too slowly, and at a step of 10 the values ​​change too quickly. A third press of the "set" button saves the seconds value and the timer goes into standby mode, showing the freshly changed shutter speed. The timer is started by pressing the start button. At the same time, the compressor and illumination are turned on, a countdown occurs on the indicator and the decimal point between minutes and seconds flashes. After the end of the shutter speed, the backlight and the compressor turn off, the inscription "OFF" lights up on the screen and an intermittent buzzer signal sounds until the "start" button is pressed again, after which the timer again goes into standby mode, showing the value of the selected shutter speed. Among the shortcomings of the timer, an error of 1.5-2 seconds should be noted with a shutter speed of 10 minutes. But since this is not a watch, I did not do anything with it, for me such an error is not critical.

Printed circuit boards timers were made "for themselves" on two single-sided boards - the main one with a controller, power supply and triacs, and a board with an indicator, buttons and LEDs - on the front panel. By the way, if LEDs are not needed, you need to put resistors with a nominal value of 510-1000 Ohms instead of them, otherwise the optocouplers will not work. The boards are connected by a flat 20-pin cable. Both SMD and DIP components are used. Attention! On the ATMega8 board in an SMD package, and in the diagram there is a pinout for a DIP package! Do not confuse! I expect to put all this in the installation for illumination, the case as such was not planned. Firmware for indicators with both OK and OA. When flashing, you need to install the fuses on the internal oscillator 8 MHz (however, you can also use an external quartz of this denomination, I did not touch the corresponding legs of the controller). Firmware consists of two files - Flash and EEPROM. If the firmware program sews with only one file, this is not fatal, everything will work anyway, but the first time you turn it on, you will need to manually “drive” each of the presets to bring it to its proper form. And, of course, pictures.
Collected boards:
Standby timer:
And in work (exposure 2 minutes, 10 seconds have passed):
Files:
PCB in SL5.0 format
MK firmware All questions - in the Forum. Chapter: