Schemes of automatic lighting switches. Automatic street lighting - Designs of medium complexity - Schemes for beginners

Electrical measuring instruments

The first of them (Fig. A-12) is made on four transistors. The light sensor - the sensitive element of the machine - is the photoresistor R1. It is connected to the power source through resistors R2 and R3 and together with them forms a voltage divider circuit, the resistance of one of the arms of which (from the slider of the trimming resistor R2 to the negative power wire) changes depending on the illumination.

The voltage divider is connected to an emitter follower on transistor VT1, which makes it possible to match the relatively high resistance of the voltage divider with the low resistance of subsequent stages of the machine.
A Schmitt trigger made of transistors VT2, VT3 is connected to the load of the emitter follower (resistor R4). Next comes the cascade on transistor VT4 - the control signal amplifier. The emitter circuit of this transistor includes the control electrode of the thyristor VS1, which acts as a contactless switch - it controls the lighting lamp EL1, located in the anode circuit of the thyristor.

The machine is powered from a 220 V network through a rectifier made using diodes VD2, VD3. The rectified voltage is filtered by capacitor C1 and stabilized by a silicon zener diode VD1. Capacitor C2 acts as a damping resistor across which excess voltage drops.

If the illumination on the street is sufficient, the voltage at the output of the divider (motor of resistor R2), and therefore at the output of the emitter follower, is such that the Schmitt trigger is in a stable state, in which transistor VT2 is open and VT3 is closed. Transistor VT4 will also be closed, and therefore, there will be no voltage at the control electrode of thyristor VS1 and the thyristor will also be closed. The lighting lamp is off.

As the illumination decreases, the resistance of the photoresistor increases, and the voltage at the output of the emitter follower decreases. When it reaches a certain value, the trigger will move to another stable state, in which transistor VT2 is closed and VT3 is open. In this case, transistor VT4 will open and current will begin to flow through the control electrode of the thyristor. The thyristor will open and the lighting lamp will flash.

In the morning, when the illumination reaches the threshold value, the trigger returns to its original state and the lamp goes out.

The desired response threshold of the device is set using trimming resistor R2.
With the details indicated in the diagram, a lamp with a power of up to 60 W can be connected to the machine. Instead of FS-K1, another photoresistor with similar parameters is quite applicable. Transistors VT1 - VT3 can be any of the MP39-MP42 series, but with a current transfer coefficient of at least 50, and VT4 - any of the MP35-MP38 series with a current transfer coefficient of at least 30. Instead of the D814D zener diode, D813 is suitable, instead of D226B diodes - any other rectifiers, designed for a rectified current of at least 50 mA and a reverse voltage of at least 300 V.
Trimmer resistor R2 is SPZ-16, the remaining resistors are MLT-0.25. Capacitor C1 - K50-6, C2 - MBGO or other paper, designed for operation in alternating and pulsating current circuits I and with a rated voltage not lower than that indicated in the diagram.

The machine parts are mounted on a board (Fig. A-13) made of one-sided foil fiberglass. A hole is drilled in the board for the thyristor, around which a foil is left—the body of the thyristor, which is the anode, will be in contact with it.

The terminals of the cathode and control electrode are located on top of the SCR - they are connected by insulated mounting conductors to the corresponding points on the printed circuit board. Capacitor C2 is attached to the board with screws (the holes for the screws are not shown on the board).




The board is placed in a housing made of insulating material and connected by insulated mounting wires to a photoresistor, and well-insulated network wires to a network and a lighting lamp. The photoresistor is mounted, for example, on a window, but so that its sensitive layer is not exposed to direct rays of the sun or light from street lamps.

But here is another design (Fig. A-14), containing only two transistors: field-effect VT1 and unijunction VT2. The single-junction one has a pulse generator that turns on at a certain voltage at the emitter. And it, in turn, is determined by the illumination of the sensitive layer of photoresistor R1.

A cascade is assembled on a field-effect transistor, which contributes to a more precise “operation” of the generator. How this happens will become clear from the description of the machine’s operation. In the meantime, let's continue the story about the structure of the structures.
The control electrode of the thyristor is connected to one of the bases of the unijunction transistor, in the anode circuit of which there is an XS1 connector - a lighting lamp is connected to it. The voltage to the thyristor and the lamp is supplied through a diode bridge made up of diodes VD4 - VD7. Thanks to it, the thyristor is protected from reverse voltage at the anode.

The pulsating voltage (ripple frequency 100 Hz) is supplied through resistor R7 to the zener diode VD3, which smoothes out the ripples due to its stabilizing property. Even more ripples of the rectified voltage are smoothed out by capacitor C 4 - from it constant pressure supplied to the machine circuit.

So, the machine is connected to the network, the photoresistor is directed towards the street with its photosensitive layer. While it is light, the resistance of the photoresistor is low, which means the voltage at the emitter of the unijunction transistor is also low. The generator does not work, the lighting pump does not light up.

As the illumination decreases, the resistance of the photoresistor increases, which means that the voltage at the emitter of transistor VT2 also increases.

At a certain illumination of the photoresistor, its resistance becomes such that the generator begins to work. A pulse voltage of positive polarity appears in resistor R6, which opens the thyristor and turns on the lamp. The pulse repetition frequency is significantly higher than the ripple frequency of the supply voltage, so the thyristor opens almost at the beginning of each half-cycle of the mains voltage.

What about the cascade on transistor VT1? The very first pulses of the generator come from resistor R6 through capacitor C3 to a rectifier assembled on diodes VD1, VD2. As a result, a negative (relative to the source) constant voltage appears at the load resistor R2, in other words, at the gate of the field-effect transistor VT1, which closes this transistor. The voltage at the drain increases, and the voltage at the emitter of the unijunction transistor also increases. Thanks to this, the generator operates more reliably and does not turn off even with some fluctuations in the illumination of the photoresistor.
In the morning, when dawn breaks and the illumination of the photoresistor increases, its resistance will drop so much that the generator will turn off. The light will go out. At this moment, transistor VT1 will open and further reduce the voltage at the emitter of the unijunction transistor.
Thus, thanks to the cascade on transistor VT1, the “operation” and “release” thresholds of the generator on transistor VT2 are very clear and slightly different from each other in voltage.

The photoresistor can be FS-K1, SF2-5, SF2-6, fixed resistors - MLT-2 (R7) and MLT 0.125 or MLT-0.25 (others). Capacitors C1 - C3 - KLS, KM, MBM; C4—K50-6 or K50-3. Instead of the KP3O3B transistor, the KP3O3A is suitable, and instead of the KT117B, another transistor of this series is suitable. Diodes VD1, VD2 - any of the D2, D9, KD102, KD503 series; VD4 - VD7 - any rectifier with a permissible reverse voltage of at least 300 V and a rectified current that allows powering a lamp of this power. Instead of the KS518A zener diode (it has a stabilization voltage of 18 V), you can use two D814B or D814V zener diodes connected in series. When using a 100 W lighting lamp, the thyristor can be indicated in the series diagram with the letter indices K-N.


If a lamp with a power of up to 60 W is used, a KU201L or KU201M thyristor is suitable.

As in the previous machine, all parts, except for the photoresistor, are mounted on a printed circuit board (Fig. A-15) made of single-sided foil fiberglass. The board is then secured in a housing made of insulating material. Recommendations for installing a photoresistor are the same as in the previous case.
When checking the machine, the required response threshold is more accurately set by selecting resistor R3. Its resistance should not be less than 10 kOhm.
But not only for the staircase an automatic lighting switch can be useful. It can also be used in an apartment, for example, in a bathroom or other room. And then you can be calm - it is unlikely that you will be able to leave the lights burning aimlessly in these rooms. And now you don’t need to use the switch - the machine will completely replace it and will turn on the lighting itself when it’s really needed.

A diagram of one of the variants of such a machine is shown in Fig. A-16. The automatic switches on the lighting as soon as the door is opened. If the door is locked from the inside, the light remains on. When closing the door from the outside (or from the inside, but not by locking), a time delay of 8...10 s follows, after which the light goes out. The brightness of the light in this machine increases smoothly (in 1...2 s), which significantly extends the life of the lamp.

The sensor device that monitors the position of the door and its lock is shown in Fig. A-17. A reed switch (sealed contact) is fixed in the door frame, and a permanent magnet is embedded in the door opposite it. The reed switch contacts are open when the door is open, which means the magnet is removed, and close when the door is closed due to the action of the magnetic field of the permanent magnet. If the door is locked from the inside, its steel tongue (or an iron plate connected to it) shields the reed switch from the magnetic field and the reed switch contacts are open.




The reed switch (SF1 in the diagram) is included in the charging circuit of capacitor C1. If the door is open (or locked from the inside), the reed switch contacts are in the state shown in the diagram. Capacitor O begins to charge through the chain VD1, C2, VD3. Since the charging circuit is not powered DC, and by trapezoidal pulses of positive polarity (they are formed due to the limitation by the zener diode VD4 of voltage pulses with a frequency of 100 Hz, supplied to it through resistor R7 from a full-wave rectifier on diodes VD5 - VD8), capacitor C1 is charged “portions” from each pulse.

This mode is also ensured by the fact that by the time the next pulse begins, capacitor C2 is discharged. This happens at the end of the previous pulse - then the voltage of capacitor C2 is applied through diode VD2 and resistors R3, R4 to the emitter junction of transistor VT1. The transistor opens and discharges the capacitor. As capacitor C1 charges, transistor VT2 begins to open, and its collector current increases. At a certain value of this current, a pulse generator assembled on a transistor analogue of a trinistor (transistors VT3 and VT4) and a capacitor SZ begins to operate. As soon as the voltage on the capacitor SZ (it appears as a result of charging the capacitor by the collector current of transistor VT2) reaches the threshold, the analogue of the trinistor “triggers” and the capacitor is discharged through the control electrode of the trinistor VS1 and resistor R5. The thyristor opens (and remains open until the end of the half-cycle of the mains voltage), closes the diagonal of the bridge VD5 - VD8, and the EL1 lamp lights up. Its brightness depends on the duration of charging the capacitor SZ to the “trigger” voltage of the SCR analogue.

The duration, in turn, is determined by the collector current of transistor VT2, and therefore by the charging of capacitor C1 to the full opening voltage of transistor VT2. This happens in about 1...2 s - during this time the brightness of the lamp will increase to maximum.

As soon as you close the door (or don’t close the lock when the door is closed), the closed contacts of the reed switch will bypass the charging circuit of capacitor C1. It will begin to discharge through resistors R1, R6 and the emitter junction of transistor VT2. After 8...10 s, the voltage on the capacitor will drop so much that transistor VT2 will begin to close. The brightness of the lamp will gradually decrease, and then the lamp will go out.

In addition to what is indicated in the diagram, you can use thyristors KU201 L, KU202K - KU202N. KT201G transistors are replaceable with a transistor of the same series or with any transistors of the KT315 series; P416B - on P416 P401-P403, GT308; MP114 - ng MP115, MP116, KT203. Together with D220 diodes, D223, KD102, KD103 are suitable. Capacitor C1 - K50-6; S2, NW - MBM, KM-4, KM-5. Resistor R7 is MLT-2, the rest are MLT-0.5. Instead of the D814D zener diode, the D813 is suitable, and instead of the VD5-VD8 diodes - any rectifier diodes designed for a reverse voltage of at least 300 V and a rectified current of at least 300 mA. Reed switch - any other one with normally open contacts and “triggered” by a given permanent magnet at a given distance.

The machine parts can be mounted on a printed circuit board (Fig. A-18) made of foil material and the board can be secured in any suitable housing made of insulating material. It is advisable to place the housing near the switch, so that the connecting conductors from the diode bridge are shorter - they are connected to the contacts of the power switch, and the switch handle is set to the “Off” position. The reed switch terminals are connected to the machine with multi-core installation conductors in insulation.

As a rule, the machine does not require adjustment and starts working immediately. You can change the duration of the smooth increase in the brightness of the light by selecting capacitor C2 (as its capacity decreases, the duration of the increase in brightness increases). To change the delay for turning off the light, you should select capacitor C1 (the delay increases with increasing its capacitance).




The machine is capable of controlling a 60 W lamp. If a higher power lamp is used, you need to install a thyristor on the heat sink and assemble a rectifier using diodes with a large permissible rectified current.
And here is another machine (Fig. A-19) for a similar purpose, which uses only one transistor. The circuit breaker can also be connected in parallel to the terminals of the utility room switch Q1.

The controls of the machine are switch SA1, the contacts of which form an external bolt and bracket on the door frame, and reed switch SF1, installed on the door similarly to the previous version, but in the upper corner of the door frame. When the door is closed, contacts SA1 can be either closed or open (if the room is in use and the valve is open), and contacts SF1 can only be open. When the door is opened, the switch contacts are open, and the reed switch contacts are closed. Through resistor R2 and the reed switch, voltage is supplied to the control electrode of tri-nistor VS1. The thyristor opens, the lighting lamp EL1 lights up.

At this moment, a pulsating voltage appears on resistor R1 (with an amplitude of about 1 V at a lamp power of 40 W and almost 2 V at a lamp power of 100 W). It is smoothed out by the VD2C1 chain. G of capacitor C1, constant voltage is supplied to the generator assembled on transistor VT1. The pulse repetition rate of the generator is 3 kHz. From winding 111 of transformer T1, pulses are supplied to the control electrode of the thyristor, so the thyristor remains open after the door is closed from inside the room and the reed switch contacts are opened.

At the end of using the room, the door is closed with an external latch, contacts SA1 are closed and bypass winding II of the transformer. The generator oscillations are interrupted, the thyristor closes, and the lighting lamp goes out.
Any low-power germanium transistor can operate in the generator p-n-p structures with a static current transfer coefficient of at least 50. Instead of the VD1 diode bridge, you can install four diodes KD105B—KD105G or similar in rectified current and reverse voltage. SCR - series KU201 with letter indices K-N. Capacitor O -K50-12 (K50-6 is also suitable); C2 - MBM; resistors - MLT-2.

Transformer T1 is homemade, it is made on a ring of standard size K10X6X4 made of M200NM ferrite. Winding I contains 2ХО0 turns of PELSHO 0.1 wire, winding II - 6...10 turns of thin mounting wire in polyvinyl chloride insulation, winding III - 40 turns PELSHO 0.1.

A printed circuit board (Fig. A-20) made of single-sided foil fiberglass is designed for these parts. Printed conductors are not made by etching in a solution, as is usually done, but by cutting insulating grooves in the foil with a special cutter or a sharp knife. The board with the parts is secured in a housing, which is placed in a convenient place in the room. As in the previous case, the reed switch (it can be of any kind, but must have normally closed or switching contacts) is connected to the machine with multi-core installation conductors.

If the machine is installed without errors, no adjustment will be required. It may happen that the generator is not excited with a given lighting lamp (after all, the supply voltage of the generator depends on its power). Then you will have to either install resistor R1 with a higher resistance, or another transistor with a higher transmission coefficient.

In the case of normal operation of the generator and the SCR does not open (the light goes out when the door is closed, but the SA1 contacts are not closed), you need to change the polarity of connecting the terminals of winding III.

This device, based on a light sensor and an IR sensor, allows you to automate the lighting switching process, which leads to energy savings.

Rice. 1 Lighting circuit diagram

Figure 1 shows a diagram of the lighting machine. The core of the circuit is the PIC16F628A microcontroller. The connection diagram for a load in the form of a lamp is shown in Figure 2. Figure 3 shows the structure of the device. The algorithm for controlling the device using a button is shown in Figure 4. The program code is written in assembly language, see listing AL\16F628ATEMP.ASM. The device is controlled by one button. By pressing the button, a sequential change of operating modes of the device is achieved. A display with a built-in controller is used to visually display information.


Rice. 2 Load connection diagram in the form of a lamp

The full cycle of in-circuit programming and debugging of the PIC16F628A microcontroller was carried out using MPLAB IDE v8.15 (integrated development environment), the MPASM v5.22 compiler (included in MPLAB IDE v8.15) and MPLAB ICD 2 (in-circuit debugger - “Debugger”). For those who do not have the tools listed above, but have their own program for working with HEX files and another programmer, you can find the file 16F628ATEMP.HEX in the corresponding project. The technical specification of the microcontroller can be found on the website and.

Rice. 3 Device structure

Microcontroller DD1 has functional pins RA0, AN1, VREF, RA3, RB0 – RB7, CCP1, which are used to input and output information. Microcontroller DD1 does not have a forced reset function; the reset pin is connected through resistor R6 to the positive supply potential. An on-chip RC oscillator is used to generate the clock frequency.

Rice. 4 Algorithm for controlling the device using a button

With the help of integrated comparators (in this case one is used) and a reference voltage in the microcontroller, the ability to step-by-step voltage measurement on a conventional 17-point scale is implemented. A photoresistor R1 and a resistor R2 are connected to the input of the comparator AN1. The second input of the comparator is connected to ION – VREF. When adjusting the ION step by step from 1.25 V to 3.594 V, the voltage between R1, R2 and VREF is compared. Takes the value 00 – (V → 0 V, 1.25 V], takes values ​​from 01 to 15 – (1.25 V, 3.594 V], takes the value 16 – (3.594 V, V → 5 V). Where V is the potential between R1 and R2 (i.e. on AN1).


Photo 1

It is worth noting that the light sensor (photoresistor) is connected to the device via an XS1 socket and an XP1 plug. (Photo 1) The light sensor should be located near a window (natural light source). It will be better if the light-sensitive part of the light sensor is directed at the window sill or wall, to measure not direct rays from the sun or light source, but reflected ones.

When setting up the device in the dark, the threshold voltage value at which the light turns on is measured, the display shows information about the “D” setting, D – Dark. When setting up the device during daylight hours, the threshold voltage value at which the light turns off is measured, and the display shows information about the “L” setting, L – Light. The values ​​in the dark should be less than in the daylight. From the described example of setting up the light sensor, it follows that logical “1” will be when the measured conditional light value takes a value from 00 to 02, and logical “0” - from 12 to 16. With intermediate values ​​from 03 to 11, the device does not change the logic of the light sensor , this is necessary so that the lighting device, which, when turned on, adds illumination to the room, does not affect the logic and vice versa, i.e. when the lighting device is turned off.
The IR sensor consists of an IR emitter (IR diode) and an IR receiver; they are connected to the device via an XS2 socket and an XP2 plug and are used for contactless detection of body movement. (Photo 2)
IR receiver DA1 is connected to pin RA0 through current-limiting resistor R4. In the passive state of the information input circuit, resistor R3 simulates a low logic level.


Photo 2

The gate of field-effect transistor VT1 is connected to pin CCP1 (hardware implementation of PWM, frequency 38.15 kHz, duty cycle 2), which generates the carrier frequency of the IR emitter. An IR diode with a wavelength of 940 nm is connected to the drain of field-effect transistor VT1 through current-limiting resistor R5.
Since the IR sensor works on reflection, it sets a logical “1” when the IR receiver DA1 detects the beam of the IR diode VD1 reflected from the body, otherwise it sets a logical “0”.
To expand the capabilities of the device when detecting with an IR sensor, it is possible to hold the logical level set by the IR sensor for a certain time (hold logical “1”). The function P[x], P-Pause is used for this.

  1. P[D]* – the logical level set by the IR sensor is held for 1 second after detection. Therefore, the possible detection sequence is 1 second or more.
  2. P[E]** – the logical level set by the IR sensor is held for 1 minute after detection. Therefore, the possible detection sequence is 1 minute or more.

In order for the logic change generated by the IR sensor to alternately set two stable states, the trigger function T[x], T-Trigger, is implemented. For example, if you install an IR sensor in a doorway, the passage of a person between rooms will be recorded. Thus, when entering a room, a logical “1” is set (the lighting device is turned on), when exiting, a logical “0” is set (the lighting device is turned off). It makes no sense to turn on the trigger when several people are moving around the room.

  1. T[D]* – trigger is disabled.
  2. T[E]** – trigger is enabled.

To compare the logical states from the light sensor and the IR sensor, use the F function, F-Function. The function can take four values.

  1. F-function is disabled. Logical data from the light sensor and IR sensor do not affect the key. The load can only be switched manually by inverting the logic at pin RB2 by briefly pressing the SB1 button.
  2. F - “OR” function, the result of a logical operation is formed at pin RB2***.
  3. F - “Exclusive OR” function, the result of a logical operation is formed at pin RB2***.
  4. F - “AND” function, the result of a logical operation is formed at pin RB2***.

By forming logic at the RB2 pin, they achieve the opening or closing of the solid-state relay U1, which turns on and off the lighting device connected to the X1 terminal block. Solid state relay U1 can switch the load when AC voltage 48-530 V and a maximum current of 3 A (the operating temperature of the solid-state relay U1 should not exceed +60 ° C). The logic level at pin RB2 is shown on the display, K[x], K-Key.

  1. K[D]* - logical “0”, the key is turned off (the lighting device is turned off).
  2. K[E]**- logical “1”, the key is on (the lighting device is on).

*x[D], D-Disable.
**x[E], E-Enable.

***It is worth paying attention to the fact that you can forcibly invert the logic at pin RB2 by briefly pressing the SB1 button. After pressing the SB1 button, the changed logic on RB2 is held until it equals the logic of the function, then the device sets the logical level generated by the function, i.e. switches to normal operating mode (which was before the button was briefly pressed).

Tact button SB1 is connected to pin RA3 through current-limiting resistor R11. In the released position of the SB1 clock button, resistor R12 simulates a low logic level. Microcontroller DD1 recognizes three states of the SB1 clock button:

  1. not pressed;
  2. pressed briefly (less than 1 s);
  3. pressed and held (more than 1 s).

The image on the display helps to distinguish the states of the SB1 tact button. So, in state 1, the microcontroller executes instructions not related to pressing a button, in state 2, settings are executed, which are highlighted in square brackets until the microcontroller recognizes state 3, and in state 3, the display depicts the following adjustable state in square brackets.

The HG1 liquid crystal display is used to display information. Technical specifications for the display can be found on the website. It has a controller that implements the character generation function. Displays two lines of sixteen characters each. The display is controlled through microcontroller pins RB0, RB1, RB4 – RB7. Data is loaded in nibbles through pins RB4 – RB7. "Latch" - RB1. We select the signal register at pin RB0. Using resistors R7 and R8 we set the contrast of the display HG1. The display backlight is connected to power via current-limiting resistor R9. The HG1 display is screwed to the board with 3 x 15mm brass standoffs and 3 x 6mm screws.

The device is powered from an alternating or direct voltage source connected to connector X2. The rated voltage of the power supply is 9 - 15 V. The rated current of the power supply is 1 A. To stabilize the power supply, a conventional circuit is used: a diode bridge VD2, a linear stabilizer DA2, filter capacitors C1 - C6.

The device can be operated in the temperature range from –20 °C to +60 °C.
The microcontroller is programmed in such a way that it has seven operating states.


Photo 3


Photo 4


Photo 5


Photo 6


Photo 7


Photo 8

  1. When the device is turned on, the non-volatile EEPROM data memory is read, where the settings data is downloaded (by default D(00), L(16), P(D), T(D), F(OFF), K[D]). The device goes into the main operating state, i.e. 2.
  2. The device displays on the display the area on which it is working, highlighted in square brackets. In this case, this is the key. In addition, the device performs configured functions that lead to key switching. During operation, the display shows the key status (K[D]-off, K[E]-on) ****. After briefly pressing the clock button, the device forcibly inverts the switch logic and holds it until the set logic level is equal to the logic level as a result of executing the logic function. If the tact button is pressed and held for more than 1 s, the device goes into a state where the light sensor is adjusted in the dark, i.e. 3. (Photo 3)
  3. The device displays on the display the area on which it is working, highlighted with square brackets. In this case, this is setting up the light sensor in the dark. After briefly pressing the clock button, the device measures the level of illumination and displays it on the display. If the tact button is pressed and held for more than 1 s, the device goes into a state where the light sensor is configured during daylight hours, i.e. 4. (Photo 4)
  4. The device displays on the display the area on which it is working, highlighted in square brackets. In this case, this is setting the light sensor during daylight hours. After briefly pressing the clock button, the device measures the level of illumination and displays it on the display. If the tact button is pressed and held for more than 1 s, the device goes into a state where the pause of the IR sensor logic is configured, i.e. 5. (Photo 5)
  5. The device displays on the display the area on which it is working, highlighted with square brackets. In this case, this is the pause setting of the IR sensor logic. After briefly pressing the tact button, the device turns on or off the pause of the IR sensor logic. If the tact button is pressed and held for more than 1 s, the device goes into a state where the IR sensor trigger is configured, i.e. 6. (Photo 6)
  6. The device displays on the display the area on which it is working, highlighted with square brackets. In this case, it is the IR sensor trigger setting. After briefly pressing the tact button, the device turns the IR sensor trigger on or off. If the tact button is pressed and held for more than 1 s, the device goes into a state where the logical function is configured, i.e. 7. (Photo 7)
  7. The device displays on the display the area on which it is working, highlighted with square brackets. In this case, it is setting up a logical function. After briefly pressing the tact button, the device sequentially selects a logical function. If the tact button is pressed and held for more than 1 s, the device saves the settings in non-volatile EEPROM memory and goes into the main operating state, i.e. 2. (Photo 8)

****When the device is turned on, the key state is indicated as inactive (K[D]) even if the key is turned on until the logic changes as a result of a logical operation or a short press of the button (of course, this can be considered a flaw, but this is how the device works).

Files for making a printed circuit board can be found in the folder. The printed circuit board and parts arrangement are shown in Figure 5.



Fig.5 Printed circuit board and parts location

The following parts can be replaced in this unit. Microcontroller DD1 from the PIC16F628A-I/P-xxx series with an operating clock frequency of 20 MHz in a DIP18 package. The HG1 display will fit any of the WH1602x series. Photoresistor R1 is similar to that indicated in the diagram; when selecting resistor R2, its resistance should be no more than 10 kOhm. IR receiver DA1 detecting the carrier frequency of the IR beam 38 kHz TSOP31238.

Voltage stabilizer DA2 domestic KR142EN5A (5 V, 1.5 A). MOSFET field-effect transistor VT1 (N-channel) in an I-Pak package (TO-251AA), an analogue of the nominal value indicated in the diagram is suitable. Solid state relay U1 can be found similar, in extreme cases, replaced with a CX240D5 with other characteristics. IR diode VD1 with a wavelength of 940 – 960 nm. The VD2 diode bridge can be used from any of the 2Wxx series. Angled plugs XP1 and XP2 with 2.54 mm pin spacing. Power connector X2 is similar to that shown in the diagram with a central contact d=2.1 mm. Non-polar capacitors C1-C3 and C6 with a nominal value of 0.01 – 0.47 µF x 50 V. Electrolytic capacitors C4 and C5 have the same capacitive rating, and the voltage is not lower than that indicated in the diagram.

Below you can download the asm source, firmware and printed circuit board in the format

List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
DD1 MK PIC 8-bit

PIC16F628A

1 Search in LCSCTo notepad
DA1 IR receiverTSOP17381 Search in LCSCTo notepad
DA2 Linear regulator

LM7805A

1 Search in LCSCTo notepad
VT1 MOSFET transistor

IRLU024N

1 Search in LCSCTo notepad
VD2 Diode bridge

2W10

1 Search in LCSCTo notepad
C1-C3, C6 Capacitor0.1 µF4 Search in LCSCTo notepad
C4 100 µF 10 V1 Search in LCSCTo notepad
C5 Electrolytic capacitor220 µF 25 V1 Search in LCSCTo notepad
R1 VT43N31 Search in LCSCTo notepad
R2, R12 Resistor

4.7 kOhm

2 Search in LCSCTo notepad
R3, R6, R7 Resistor

10 kOhm

3 Search in LCSCTo notepad
R4, R11 Resistor

470 Ohm

2 Search in LCSCTo notepad
R5 Resistor

43 Ohm

1 1 W

Automatic control of outdoor bathroom lighting.

Once, while connecting an LED strip to a friend, we started talking about lighting, and then he remembered that he had no light in his outdoor bathroom.

Everything would be fine, but sometimes we go to visit him with beer, relax in the gazebo, admire nature, talk about lofty things. And as you know, not all people in the dark have good aiming skills and sniper intuition. Therefore, regularly after our visit, he has to clean the bathroom.

So he puzzled me by assembling a kind of lighting machine from two dead Chinese flashlights (two LEDs in each) and a swollen battery from Nokia (in my opinion, 1200 mAh). We didn't find anything else suitable at his house.

The device algorithm was initially assumed to be quite simple:

The door was opened, the light came on

The door was closed, the lights went out

Reed switch, mosfet - business! But then it turned out that it has a serious drawback! Let's say you went into the bathroom, sat down or stood, closed the door, and the light went out. It doesn't quite work with the door open. I immediately imagined a microcontroller, a circuit, a program... but then the toad pushed me to use the microcontroller for these purposes, which I still had in a single copy. In 5 minutes, a circuit with 2 transistors was drawn on a piece of paper, and the following algorithm was obtained:

The door was opened, the light came on

We closed the door, the light is on for 1.5 minutes, and then gradually goes out.

If the door is open all the time the light stays on.

I think in 1.5 minutes you can do everything you want there, and if someone really wants to read a newspaper, after 1.5 minutes you can simply “distort” the door and the light will come on again.

“Now I need to assemble the model using snot, and select the values ​​of the parts,” I thought. Then I remembered that I have a Proteus simulator!! In 10 minutes, the required part values ​​were selected, and the following diagram was obtained.

In fact, the circuit is a simple single-vibrator with two transistors. As a door opening sensor, a reed switch is used, torn out of some very old glass break sensor, and the sensor was honestly “crammed” somewhere, anyway it would have been thrown into the trash. When the bathroom door is closed, the magnet is located next to the reed switch. The reed switch contacts are closed. Transistor Q1,Q2 are closed, capacitor C1 is discharged, LEDs D6-D4 do not light up.

When the door is opened, the reed switch contacts open, transistor Q1 opens, capacitor C1 is charged through diode D1, Q2 opens and the LEDs light up.


If the reed switch contacts remain open, then transistors Q1, Q2 are open and the light is constantly on. As soon as the door is closed, the reed switch contacts are closed, the discharge of C1 through resistor R1 will begin, after about 1.5 minutes the transistor Q2 will begin to smoothly close, and accordingly the light will go out until Q2 is completely closed. In order to increase the glow time, you can replace diode D1 with a Schottky diode, increase the value of capacitor C1, and if charging C1 takes too long, select the values ​​of R7, R8, R6. The most important thing is that there should be a minimum battery discharge current in standby mode, in this case 2mkA.

In general, we take Proteus and torture the circuit.

Resistors R3-R5 are located inside Chinese lanterns. Transistor Q2 STD17NF03 is soldered from an ancient motherboard, you can use any n-channel mosfet. Because this one seems to be 17A, and you can power a couple of hundred LEDs in the bathroom.

This is what electronics are like in everyday life. After the battery runs out, it is inserted into the phone, charged and put back in place. Huge savings on batteries. The money saved goes towards beer.

The first of them (Fig. A-12) is made on four transistors. The light sensor - the sensitive element of the machine - is the photoresistor R1. It is connected to the power source through resistors R2 and R3 and together with them forms a voltage divider circuit, the resistance of one of the arms of which (from the slider of the trimming resistor R2 to the negative power wire) changes depending on the illumination.

The voltage divider is connected to an emitter follower on transistor VT1, which makes it possible to match the relatively high resistance of the voltage divider with the low resistance of subsequent stages of the machine.
A Schmitt trigger made of transistors VT2, VT3 is connected to the load of the emitter follower (resistor R4). Next comes the cascade on transistor VT4 - the control signal amplifier. The emitter circuit of this transistor includes the control electrode of the thyristor VS1, which acts as a contactless switch - it controls the lighting lamp EL1, located in the anode circuit of the thyristor.

The machine is powered from a 220 V network through a rectifier made using diodes VD2, VD3. The rectified voltage is filtered by capacitor C1 and stabilized by a silicon zener diode VD1. Capacitor C2 acts as a damping resistor across which excess voltage drops.

If the illumination on the street is sufficient, the voltage at the output of the divider (motor of resistor R2), and therefore at the output of the emitter follower, is such that the Schmitt trigger is in a stable state, in which transistor VT2 is open and VT3 is closed. Transistor VT4 will also be closed, and therefore, there will be no voltage at the control electrode of thyristor VS1 and the thyristor will also be closed. The lighting lamp is off.

As the illumination decreases, the resistance of the photoresistor increases, and the voltage at the output of the emitter follower decreases. When it reaches a certain value, the trigger will move to another stable state, in which transistor VT2 is closed and VT3 is open. In this case, transistor VT4 will open and current will begin to flow through the control electrode of the thyristor. The thyristor will open and the lighting lamp will flash.

In the morning, when the illumination reaches the threshold value, the trigger returns to its original state and the lamp goes out.

The desired response threshold of the device is set using trimming resistor R2.
With the details indicated in the diagram, a lamp with a power of up to 60 W can be connected to the machine. Instead of FS-K1, another photoresistor with similar parameters is quite applicable. Transistors VT1 - VT3 can be any of the MP39-MP42 series, but with a current transfer coefficient of at least 50, and VT4 - any of the MP35-MP38 series with a current transfer coefficient of at least 30. Instead of the D814D zener diode, D813 is suitable, instead of D226B diodes - any other rectifiers, designed for a rectified current of at least 50 mA and a reverse voltage of at least 300 V.
Trimmer resistor R2 is SPZ-16, the remaining resistors are MLT-0.25. Capacitor C1 - K50-6, C2 - MBGO or other paper, designed for operation in alternating and pulsating current circuits I and with a rated voltage not lower than that indicated in the diagram.

The machine parts are mounted on a board (Fig. A-13) made of one-sided foil fiberglass. A hole is drilled in the board for the thyristor, around which a foil is left—the body of the thyristor, which is the anode, will be in contact with it.

The terminals of the cathode and control electrode are located on top of the SCR - they are connected by insulated mounting conductors to the corresponding points on the printed circuit board. Capacitor C2 is attached to the board with screws (the holes for the screws are not shown on the board).




The board is placed in a housing made of insulating material and connected by insulated mounting wires to a photoresistor, and well-insulated network wires to a network and a lighting lamp. The photoresistor is mounted, for example, on a window, but so that its sensitive layer is not exposed to direct rays of the sun or light from street lamps.

But here is another design (Fig. A-14), containing only two transistors: field-effect VT1 and unijunction VT2. The single-junction one has a pulse generator that turns on at a certain voltage at the emitter. And it, in turn, is determined by the illumination of the sensitive layer of photoresistor R1.

A cascade is assembled on a field-effect transistor, which contributes to a more precise “operation” of the generator. How this happens will become clear from the description of the machine’s operation. In the meantime, let's continue the story about the structure of the structures.
The control electrode of the thyristor is connected to one of the bases of the unijunction transistor, in the anode circuit of which there is an XS1 connector - a lighting lamp is connected to it. The voltage to the thyristor and the lamp is supplied through a diode bridge made up of diodes VD4 - VD7. Thanks to it, the thyristor is protected from reverse voltage at the anode.

The pulsating voltage (ripple frequency 100 Hz) is supplied through resistor R7 to the zener diode VD3, which smoothes out the ripples due to its stabilizing property. Even more pulsations of the rectified voltage are smoothed out by capacitor C 4 - from it a constant voltage is supplied to the circuits of the machine.

So, the machine is connected to the network, the photoresistor is directed towards the street with its photosensitive layer. While it is light, the resistance of the photoresistor is low, which means the voltage at the emitter of the unijunction transistor is also low. The generator does not work, the lighting pump does not light up.

As the illumination decreases, the resistance of the photoresistor increases, which means that the voltage at the emitter of transistor VT2 also increases.

At a certain illumination of the photoresistor, its resistance becomes such that the generator begins to work. A pulse voltage of positive polarity appears in resistor R6, which opens the thyristor and turns on the lamp. The pulse repetition frequency is significantly higher than the ripple frequency of the supply voltage, so the thyristor opens almost at the beginning of each half-cycle of the mains voltage.

What about the cascade on transistor VT1? The very first pulses of the generator come from resistor R6 through capacitor C3 to a rectifier assembled on diodes VD1, VD2. As a result, a negative (relative to the source) constant voltage appears at the load resistor R2, in other words, at the gate of the field-effect transistor VT1, which closes this transistor. The voltage at the drain increases, and the voltage at the emitter of the unijunction transistor also increases. Thanks to this, the generator operates more reliably and does not turn off even with some fluctuations in the illumination of the photoresistor.
In the morning, when dawn breaks and the illumination of the photoresistor increases, its resistance will drop so much that the generator will turn off. The light will go out. At this moment, transistor VT1 will open and further reduce the voltage at the emitter of the unijunction transistor.
Thus, thanks to the cascade on transistor VT1, the “operation” and “release” thresholds of the generator on transistor VT2 are very clear and slightly different from each other in voltage.

The photoresistor can be FS-K1, SF2-5, SF2-6, fixed resistors - MLT-2 (R7) and MLT 0.125 or MLT-0.25 (others). Capacitors C1 - C3 - KLS, KM, MBM; C4—K50-6 or K50-3. Instead of the KP3O3B transistor, the KP3O3A is suitable, and instead of the KT117B, another transistor of this series is suitable. Diodes VD1, VD2 - any of the D2, D9, KD102, KD503 series; VD4 - VD7 - any rectifier with a permissible reverse voltage of at least 300 V and a rectified current that allows powering a lamp of this power. Instead of the KS518A zener diode (it has a stabilization voltage of 18 V), you can use two D814B or D814V zener diodes connected in series. When using a 100 W lighting lamp, the thyristor can be indicated in the series diagram with the letter indices K-N.


If a lamp with a power of up to 60 W is used, a KU201L or KU201M thyristor is suitable.

As in the previous machine, all parts, except for the photoresistor, are mounted on a printed circuit board (Fig. A-15) made of single-sided foil fiberglass. The board is then secured in a housing made of insulating material. Recommendations for installing a photoresistor are the same as in the previous case.
When checking the machine, the required response threshold is more accurately set by selecting resistor R3. Its resistance should not be less than 10 kOhm.
But not only for the staircase an automatic lighting switch can be useful. It can also be used in an apartment, for example, in a bathroom or other room. And then you can be calm - it is unlikely that you will be able to leave the lights burning aimlessly in these rooms. And now you don’t need to use the switch - the machine will completely replace it and will turn on the lighting itself when it’s really needed.

A diagram of one of the variants of such a machine is shown in Fig. A-16. The automatic switches on the lighting as soon as the door is opened. If the door is locked from the inside, the light remains on. When closing the door from the outside (or from the inside, but not by locking), a time delay of 8...10 s follows, after which the light goes out. The brightness of the light in this machine increases smoothly (in 1...2 s), which significantly extends the life of the lamp.

The sensor device that monitors the position of the door and its lock is shown in Fig. A-17. A reed switch (sealed contact) is fixed in the door frame, and a permanent magnet is embedded in the door opposite it. The reed switch contacts are open when the door is open, which means the magnet is removed, and close when the door is closed due to the action of the magnetic field of the permanent magnet. If the door is locked from the inside, its steel tongue (or an iron plate connected to it) shields the reed switch from the magnetic field and the reed switch contacts are open.




The reed switch (SF1 in the diagram) is included in the charging circuit of capacitor C1. If the door is open (or locked from the inside), the reed switch contacts are in the state shown in the diagram. Capacitor O begins to charge through the chain VD1, C2, VD3. Since the charging circuit is not powered by direct current, but by trapezoidal pulses of positive polarity (they are formed due to the zener diode VD4 limiting voltage pulses with a frequency of 100 Hz, supplied to it through resistor R7 from a full-wave rectifier on diodes VD5 - VD8), capacitor C1 is charged in “portions” from every impulse.

This mode is also ensured by the fact that by the time the next pulse begins, capacitor C2 is discharged. This happens at the end of the previous pulse - then the voltage of capacitor C2 is applied through diode VD2 and resistors R3, R4 to the emitter junction of transistor VT1. The transistor opens and discharges the capacitor. As capacitor C1 charges, transistor VT2 begins to open, and its collector current increases. At a certain value of this current, a pulse generator assembled on a transistor analogue of a trinistor (transistors VT3 and VT4) and a capacitor SZ begins to operate. As soon as the voltage on the capacitor SZ (it appears as a result of charging the capacitor by the collector current of transistor VT2) reaches the threshold, the analogue of the trinistor “triggers” and the capacitor is discharged through the control electrode of the trinistor VS1 and resistor R5. The thyristor opens (and remains open until the end of the half-cycle of the mains voltage), closes the diagonal of the bridge VD5 - VD8, and the EL1 lamp lights up. Its brightness depends on the duration of charging the capacitor SZ to the “trigger” voltage of the SCR analogue.

The duration, in turn, is determined by the collector current of transistor VT2, and therefore by the charging of capacitor C1 to the full opening voltage of transistor VT2. This happens in about 1...2 s - during this time the brightness of the lamp will increase to maximum.

As soon as you close the door (or don’t close the lock when the door is closed), the closed contacts of the reed switch will bypass the charging circuit of capacitor C1. It will begin to discharge through resistors R1, R6 and the emitter junction of transistor VT2. After 8...10 s, the voltage on the capacitor will drop so much that transistor VT2 will begin to close. The brightness of the lamp will gradually decrease, and then the lamp will go out.

In addition to what is indicated in the diagram, you can use thyristors KU201 L, KU202K - KU202N. KT201G transistors are replaceable with a transistor of the same series or with any transistors of the KT315 series; P416B - on P416 P401-P403, GT308; MP114 - ng MP115, MP116, KT203. Together with D220 diodes, D223, KD102, KD103 are suitable. Capacitor C1 - K50-6; S2, NW - MBM, KM-4, KM-5. Resistor R7 is MLT-2, the rest are MLT-0.5. Instead of the D814D zener diode, the D813 is suitable, and instead of the VD5-VD8 diodes - any rectifier diodes designed for a reverse voltage of at least 300 V and a rectified current of at least 300 mA. Reed switch - any other one with normally open contacts and “triggered” by a given permanent magnet at a given distance.

The machine parts can be mounted on a printed circuit board (Fig. A-18) made of foil material and the board can be secured in any suitable housing made of insulating material. It is advisable to place the housing near the switch, so that the connecting conductors from the diode bridge are shorter - they are connected to the contacts of the power switch, and the switch handle is set to the “Off” position. The reed switch terminals are connected to the machine with multi-core installation conductors in insulation.

As a rule, the machine does not require adjustment and starts working immediately. You can change the duration of the smooth increase in the brightness of the light by selecting capacitor C2 (as its capacity decreases, the duration of the increase in brightness increases). To change the delay for turning off the light, you should select capacitor C1 (the delay increases with increasing its capacitance).




The machine is capable of controlling a 60 W lamp. If a higher power lamp is used, you need to install a thyristor on the heat sink and assemble a rectifier using diodes with a large permissible rectified current.
And here is another machine (Fig. A-19) for a similar purpose, which uses only one transistor. The circuit breaker can also be connected in parallel to the terminals of the utility room switch Q1.

The controls of the machine are switch SA1, the contacts of which form an external bolt and bracket on the door frame, and reed switch SF1, installed on the door similarly to the previous version, but in the upper corner of the door frame. When the door is closed, contacts SA1 can be either closed or open (if the room is in use and the valve is open), and contacts SF1 can only be open. When the door is opened, the switch contacts are open, and the reed switch contacts are closed. Through resistor R2 and the reed switch, voltage is supplied to the control electrode of tri-nistor VS1. The thyristor opens, the lighting lamp EL1 lights up.

At this moment, a pulsating voltage appears on resistor R1 (with an amplitude of about 1 V at a lamp power of 40 W and almost 2 V at a lamp power of 100 W). It is smoothed out by the VD2C1 chain. G of capacitor C1, constant voltage is supplied to the generator assembled on transistor VT1. The pulse repetition rate of the generator is 3 kHz. From winding 111 of transformer T1, pulses are supplied to the control electrode of the thyristor, so the thyristor remains open after the door is closed from inside the room and the reed switch contacts are opened.

At the end of using the room, the door is closed with an external latch, contacts SA1 are closed and bypass winding II of the transformer. The generator oscillations are interrupted, the thyristor closes, and the lighting lamp goes out.
The generator can operate any low-power germanium transistor of the pnp structure with a static current transfer coefficient of at least 50. Instead of the diode bridge VD1, you can install four diodes KD105B-KD105G or similar in rectified current and reverse voltage. SCR - series KU201 with letter indices K-N. Capacitor O -K50-12 (K50-6 is also suitable); C2 - MBM; resistors - MLT-2.

Transformer T1 is homemade, it is made on a ring of standard size K10X6X4 made of M200NM ferrite. Winding I contains 2ХО0 turns of PELSHO 0.1 wire, winding II - 6...10 turns of thin mounting wire in polyvinyl chloride insulation, winding III - 40 turns PELSHO 0.1.

A printed circuit board (Fig. A-20) made of single-sided foil fiberglass is designed for these parts. Printed conductors are not made by etching in a solution, as is usually done, but by cutting insulating grooves in the foil with a special cutter or a sharp knife. The board with the parts is secured in a housing, which is placed in a convenient place in the room. As in the previous case, the reed switch (it can be of any kind, but must have normally closed or switching contacts) is connected to the machine with multi-core installation conductors.

If the machine is installed without errors, no adjustment will be required. It may happen that the generator is not excited with a given lighting lamp (after all, the supply voltage of the generator depends on its power). Then you will have to either install resistor R1 with a higher resistance, or another transistor with a higher transmission coefficient.

In the case of normal operation of the generator and the SCR does not open (the light goes out when the door is closed, but the SA1 contacts are not closed), you need to change the polarity of connecting the terminals of winding III.

The photo relay sensor can also be placed outdoors, protecting it from direct exposure to artificial light. Then the relay will operate at night and automatically turn on the power to the street lighting lamp or staircase, and turn it off in the morning.

You can see a schematic diagram of a possible version of such a machine in Fig. 257. It is similar to the photo relay according to the diagram in Fig. 255.6, but is more sensitive, since more is used to power it high voltage- about 18 V. Contacts K1.1 of the electromagnetic relay used in the machine are normally closed.

At night and in the evening, the photoresistor is very dimly lit and its resistance is several hundred kilo-ohms. In this case, the collector currents of transistor V1, in the base circuit of which a photoresistor is included, and of transistor V2, the base of which is connected directly to the emitter of the first transistor, does not exceed the lowering current of the electromagnetic relay. At this time, the lighting lamp, connected to the electric lighting network through the normally closed contacts K1.1 of the relay, is on.

With the onset of dawn, the photoresistor is illuminated more and more and its resistance decreases to 80-100 kOhm.


Rice. 257, Automatic lighting circuit diagram

At the same time, the collector currents of the amplifier transistors increase. When the current flows, the relay is activated and its contacts, opening, break the power supply circuit of the lighting lamp. And in the evening, when the resistance of the photoresistor begins to increase again, and the collector currents correspondingly decrease, the relay will release and turn on the lighting with the closing contacts.

The rectifier of the machine is full-wave. It is made on V6-V9 series diodes connected in a bridge circuit. The rectified voltage is smoothed by a filter capacitor and stabilized by two zener diodes V4 and V5 series (possible), connected in series. The rated voltage of the capacitor should not be less than 25 V. A capacitor, whose role is similar to a resistor, extinguishes excess voltage alternating current, supplied from the network to the rectifier. The capacitor must be paper with a rated voltage of at least 300 V. For a 127 V network, its capacity should be .

The machine uses perine transistors (possible with any letter index), designed for a higher collector voltage than similar low-power transistors. Relay type (passport), (passport 10.171.01.37) or another - with a winding with a resistance of 650-750 Ohms and normally operated contacts.

If the machine is assembled from known good parts, then the only thing that may have to be done additionally is to select the moment to turn off the lighting lamp corresponding to the specific illumination of the photoresistor. To increase the delay time for turning off the lighting lamp, the supply voltage of the machine must be reduced by 3-4 V, and to decrease it, i.e. earlier shutdown, on the contrary, increase it by 3-4 V. This can be done when using zener diodes in the power supply with other stabilization voltages: in the first case - zener diodes or one (instead of two) zener diodes, in the second - three zener diodes or two zener diodes or. The sensitivity of the machine can also be adjusted by selecting a resistor.