Saturday, January 28, 2023
HomeElectronicsLow-Value Automation Utilizing PIC16F676 | Full Electronics Challenge

Low-Value Automation Utilizing PIC16F676 | Full Electronics Challenge

Sani & DwivediThere are a lot of kinds of house and industrial automation methods accessible available in the market. These embrace IR distant controller, Bluetooth house automation, DTMF house automation, Wi-Fi house automation, RF house automation, and voice managed house automation. The one introduced here’s a low-cost automation system. It may be used at house or in an industrial setting to modify units on and off.

IR distant controllers and receivers comply with normal protocols for sending and receiving the info. Among the normal protocols are NEC, PHILIPS RC5, JVC, and SIRC (Sony infrared distant management). We shall be utilizing the NEC protocol for this challenge. After understanding the body format of IR distant, we’ll interface IR receiver TSOP1738 with PIC16F676 microcontroller to decode the important thing pressed from an NEC IR distant, as proven in Fig. 1.

VIRE NEC IR remote
Fig. 1: VIRE NEC IR distant

Every bit is transmitted utilizing the heartbeat distance, as proven in Fig. 2. Logical ‘0’ is a 562.5µs pulse burst adopted by a 562.5µs area, with a complete transmit time of 1.125ms. Logical ‘1’ is a 562.5µs pulse burst adopted by a 1.6875ms area, with a complete transmit time of two.25ms.

Pulse distance frame
Fig. 2: Pulse distance body

When a secret is pressed on the distant controller, the message transmitted consists of the next within the order beneath:

  1. A 9ms main pulse burst (16 occasions the heartbeat burst size used for a logical knowledge bit)
  2. A 4.5ms area
  3. The 8-bit handle for the receiving gadget
  4. The 8-bit logical inverse of the handle
  5. The 8-bit command
  6. The 8-bit logical inverse of the command
  7. A remaining 562.5µs pulse burst to indicate the tip of message transmission

The 4 bytes of knowledge bits every are despatched with least vital bit first. Fig. 3 illustrates the format of an NEC IR transmission body for an handle of 00h (00000000b) and a command of ADh (10101101b).

Format of an NEC IR transmission frame
Fig. 3: Format of an NEC IR transmission body

A complete of 67.5ms is required to transmit a message body. It wants 27ms to transmit the 16 bits of handle (handle+inverse) and the 16 bits of command (command+ inverse).

Desk 1 exhibits 32-bit NEC body format and Desk 2 exhibits the entire checklist of IR key codes for the NEC IR distant.

NEC FramePIC16F676 controller

PIC16F676 is Microchip’s 8-bit CMOS PIC microcontroller with flash reminiscence. It is available in a 14-pin package deal with high-performance RISC CPU, which makes it an excellent alternative for many digital purposes associated to embedded methods or industrial automation. This tiny chip incorporates the whole lot it is advisable develop particular person tasks. A few of its options are:

  • The flash reminiscence of high-performance PIC16F676 helps in rising the processing pace of the microcontroller.
  • It is available in PDIP, SOIC, and TSOP packages, all of which can be found in 14-pin configuration.
  • PIC16F676 comprises program reminiscence with reminiscence area round 1.7kB, whereas RAM and EEPROM reminiscences are of 64 bytes and 128 bytes, respectively.
  • One 10-bit ADC module within the gadget comes with eight analogue channels. This module performs an important position for sensor interfacing and changing analogue values to digital.
  • Energy-on reset, comparator, in-circuit serial programming, and grasp clear reset are another options included within the gadget. These assist it keep forward of the opposite onboard chips and removes the necessity of shopping for exterior parts for finishing up totally different operations. Pin diagram of PIC16F676 is proven in Fig. 4.
Pin diagram of PIC16F676
Fig. 4: Pin diagram of PIC16F676

Circuit and dealing

The challenge makes use of PIC16F676 microcontroller and an NEC IR distant to modify on/off any AC load, together with lights and followers, from the consolation of your chair or mattress. The totally different IR indicators from the distant for the totally different lights and followers are obtained by the microcontroller, which then controls the respective relays through a relay driver circuit. These relays are used to modify the lights and followers on or off.

NEC remot listThere are a lot of kinds of IR distant controllers accessible for various units, however most of them work round 38kHz frequency. This challenge requires an abnormal IR TV distant. For detecting the IR indicators, TSOP 1738 IR receiver proven in
Fig. 5 is used. It might probably sense the 38kHz frequency sign.

TSOP 1738 IR receiver
Fig. 5: TSOP 1738 IR receiver

The block diagram of the challenge is proven in Fig. 6.

Block diagram
Fig. 6: Block diagram

On this challenge the digital IO pins RC0, RC1, and RC2 of Port C of PIC16F676 microcontroller are used to regulate the relays to modify the home equipment on/off. These pins are configured as output pins in this system. The IR receiver is related to pin RC4 of PIC16F676, which is configured as enter pin in this system.

The PIC16F676 microcontroller operates at +5V. Therefore, a transformer is used to step down the 230V AC mains provide, which is rectified utilizing a full-wave rectifier. The rectified voltage is regulated to +5V by utilizing regulator IC 7805. The entire circuit diagram is proven in Fig. 7.

part list

The working of this challenge is pretty easy. When a button is pressed on the IR distant, it sends a sequence of codes within the type of encoded pulses utilizing 38kHz modulating frequency. These pulses are obtained by the TSOP 1738 sensor after which learn by the microcontroller. The microcontroller decodes the obtained prepare of the pulses right into a hex worth and compares it with the predefined hex values in this system.

At any time when a secret is pressed on the IR distant, the transmitted IR sign is obtained by an IR receiver and the bottom line is decoded by the software program. On this challenge, all the 32-bit string (4 bytes of NEC protocol) is used for decoding. On this 32-bit string, the third byte is in contrast in this system for controlling the lights/followers. If any match happens, the controller performs a relative operation by triggering the respective relay by way of transistor BC547 and the corresponding result’s indicated by an on-board LED. The three LEDs within the circuit present the standing of the relays.

On this challenge, key numbers 2, 4, and 6 of the IR distant have been used for controlling the three relays. Key 2 toggles relay RL1, key 4 toggles relay RL2, and key 6 toggles relay RL3.

Software program

The circuit makes use of the software program program loaded into the interior reminiscence of PIC16F676. This system is compiled utilizing Mikro C PRO model 7.2.0 for PIC compiler and uploaded into PIC16F676. The software program most important.c is written in embedded C language, which permits writing the code inside a couple of strains. The generated hex code is burnt into the MCU chip utilizing PIC K150 programmer board.

No header, interrupt, or seize and examine mode is used right here to detect IR sign. Digital pin RC4 reads the info, similar to we learn a push button. At any time when sign goes excessive or low, debouncing is adopted and the timer is run. At any time when the pin adjustments its state to a different, the time values are saved in an array.

Fuse bit settings
Fig. 8: Fuse bit settings

IR distant sends logic 0 as 562.5µs pulse and logic 1 as 2250µs pulse. At any time when timer detects 562.5µs pulse, this system assumes it to be 0, and when it detects 2250µs pulse, it assumes it to be 1. Then this system converts it into hex. The incoming sign from distant comprises 32 bits (4 bytes). Program shops all of the bytes within the array after which decodes the third byte to make use of for comparability.

The straightforward programming assertion ‘change’ case is used to detect and management the house home equipment.

Don’t forget to set fuse bits earlier than programming PIC16F676 utilizing PIC K150 programmer. This system won’t work with out setting the fuse bits. The fuse bit settings are proven in Fig. 8.

Building and testing

An actual-size PCB structure for the automation system is proven in Fig. 9 and its element structure in Fig. 10. After assembling the circuit on PCB, enclose it in an appropriate field. Receiver IR1 must be fastened on the entrance panel, in order that the distant can give attention to it to activate any load related to the respective relay. CON1 must be fastened on again aspect of the cupboard. All of the three 230V AC home equipment are related to the circuit utilizing two wires and positioned at their location. The creator’s prototype wired on a general-purpose PCB is proven in Fig. 11.

Actual-size PCB layout
Fig. 9: PCB structure
Component layout of the PCB
Fig. 10: Part structure of the PCB
Fig. 11: Writer’s prototype

Obtain PCB and Part Format PDFs: click on right here

Obtain Supply Code

Pamarthi Kanakaraja is an assistant professor (R&D cell) at Ok.L. College, Vaddeswaram, Guntur district, Andhra Pradesh



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments