- Configuring an ESP8266 for Battery PowerPosted 3 days ago
- Creating a Telegram Bot for ESP32Posted 4 days ago
- Mini Course on BlynkPosted 5 days ago
- Creating a Unique Electronic Musical Instrument: The Sound WallPosted 7 days ago
- Building a Laser MicroscopePosted 7 days ago
- Grand Piano Keys with ArduinoPosted 1 week ago
- Wireless Power TransferPosted 2 weeks ago
- Robot Punchers with ArduinoPosted 2 weeks ago
- A minimal 3D-printed scalePosted 2 weeks ago
- Expanding the pins of a microcontrollerPosted 2 weeks ago
GSM Remote Control – Part 2
Let us start by describing the device’s electric scheme in its entirety, that is, along with all its components; we should also state in advance that the module we call GSM is, in reality, the small board hosting the cell phone, so the pin numbers refer to the contacts of the pin-strips that have been used. In the next issue, we will describe the small board in detail, including its internal scheme –that is, the connections to GSM modules which it can host.
The entire remote control is handled by a PIC that controls the GSM/GPRS module’s activity, reads the room temperature through a Dallas DS1820 smart probe, controls the logical state of two opto-isolated inputs, and gives commands to the two relays. In addition, the circuit is equipped with a DTMF decoder whose purpose it is to identify the bi-tones involved in the phone selection found within modern telecommunication systems –bi-tones which every phone emits and sends out on phone lines when its keyboard keys are pressed. The identifier is necessary in order for the DTMF functionality to work.
Having said that, let’s take a better look at the electric scheme: power is supplied by continuous voltage, not always stabilized (applied to PWR + and -) at a value between 5 and 32V; such voltage is filtered at the bottom by the diode protecting against polarity inversion (D1) through condensers C1 and C2. Fuse F1 enables us to protect both the circuit and the power source in case of a short circuit in the integrated regulator discussed below, which is necessary to obtain the 4 volts needed for the rest of the circuit to work. The switching regulator is based on a MC34063 chip, utilized in the classic configuration of series PWM regulators charged by inductance, whose output voltage depends on the energy stored in L1; the regulator is stabilized by the component demoted from resistive divider R2/R3, which is needed to set at 4V the component leveled at the top of both C4 e C5. The 4 volts at the bottom of the abovementioned condensers are sufficiently filtered by other condensers placed on the power lines of the microcontroller and of the GSM module; which presents, during transmission, absorption peaks compensated for by C7, C8, C13, C14, C15 e C16, thus avoiding that an impulsive current request may cause the microcontroller to be disturbed.
The microcontroller used to handle the whole system is a powerful PIC18F46K20-I/PT by Microchip, which we use in its configuration with an internal clock oscillator; both the scheme and in the printed circuit are nevertheless equipped with external quartz, which we included for those who may want to modify the firmware and develop specific applications requiring an external oscillator.
Once the I/O lines have been initialized, the microcontroller verifies the logical state of the opto-isolated inputs at voltage level (RB4 and RB5) as well as that of lines RC4, RC5, RD0, RD3, RX, which are needed to receive the main notifications from the cellular module; more specifically, RD3 is used to detect incoming calls (it interfaces with RI of the cellular module), while RC4 controls the GSM’s reception led , whose output (dubbed STATLED) pulsates at a frequency of 1 Hz when the module is searching for the radio-mobile network, and supplies impulses at logical zero, lasting 0.5 seconds and followed by a 2-second pause, when the module has grasped the signal. The frequency and duration of the impulses enable the PIC to understand the conditions of the radio-mobile network range and to behave accordingly; for example, if the opto-isolated input goes off and it needs, therefore, to send SMSs or make calls, but detects that the cellular module has no reception, it waits for the Telit module to get reconnected to the GSM/GPRS network before making any calls. The attempt to make calls or send SMSs is repeated only three times, after which the device gives up.
The microcontroller contains a UART accessible via pins 44 (transmission) and 1 (reception) which it uses in order to communicate with the cell phone; more precisely, through the first pin (TX), it cyclically questions the module in order to check whether any SMSs have been received, whereas both TX and RX are used to communicate with the GSM module when making calls and receiving or sending messages. Regarding the UART, it is important to note that the following control signals are used: CTS (Clear To Send), RTS (Request To Send) and DCD (Data Carrier Detect), which correspond to those of the cellular module being used. They complete the set of I/Os destined to the cell phone, the RC5 and RD0 lines: the former controls the turning on and off of the GSM (though a transistor placed in the small board of the cell phone), while the latter takes care of resetting the cell phone. The button for locally handling this device’s working modality is read through line RA3, configured as input and equipped with an external pull-up resistor (R11) –and therefore active at a low level.
Inputs are read through lines RB4 and RB5, both of which are configured as input and equipped with an internal pull-up; each one of them reads the state of the output transistor of the corresponding photocoupler (the optos used here are TLP181). Each of the two available inputs (IN1 and IN2) is active when under a voltage between 3 and 30V. When a 3V (at a minimum) is applied to input IN1, the photocoupler’s LED is switched on and the output phototransitor is in conduction state; therefore, the collector (pin 5) is at about zero volt during I/O configuration, due to the fall on the resistor of the internal pull-up that was configured. If the input is not polarized, the opto-isolator gets inhibited and its pin 4 shows a high level.
As for the relays, they are controlled by the microcontroller’s RC0 and RE2 lines, through two NPN transistors driven by current amplifiers; line RE2 controls transistor T1, while line RC0 controls transistor T2. A high logical state causes the transistor to saturate, thus determining the amount of current flowing in the coil of the corresponding relay. Each instance of activation is signaled with a LED, powered along with the coil. In order to protect the transistors’ collector junction as it goes from saturation to inhibition, when the relay’s coil inductance generates peak inverse voltage, we connected a diode parallel to the coil, and such diode eliminates unwanted impulses. The entire relay exchange is available so as to allow for the handling of circuits requiring a normally closed contact or a normally open one. Still regarding the relay, we should note that, although it is a 5-volt-coil type, in our circuit it works on just 4 volts; this is possible because the model we chose can prompt relay exchange even at less than 3.5 volts.
The room temperature is detected by the microcontroller with the aid of an extremely accurate probe DS1820 produced by Dallas Semiconductor, which is capable of taking temperatures in the range of -5÷150 °C with an accuracy of just ± 0,5 °C (in field 10÷85 °C), and then of digitizing and making them available on a unidirectional serial line connected to the microcontroller’s RC0 pin. This probe communicates using protocol One-wire, which allows for bidirectional dialogue on a single thread; for this to be possible, pull-up R19’s resistance must be present.
The PIC is programmed in-circuit, through the ICSP connector, which is attached to lines MCLR, PGU and PGC; the microcontroller’s power and mass are also connected to the ICSP. But we didn’t think that was enough, so we included a serial communication interface enabling users to program data related to the various functions (e.g., list of phone numbers, handling of input levels, text of SMSs sent by the circuit following commands, etc.) through a PC: this allows users to program their remote control before activating it, thus avoiding having to send configuration SMSs, which can be used at any time, but are best used only once the system has been installed in situ. Since the UART is already busy communicating with the cellular module, serial communication occurs via lines RE0 and RA5, exploited, respectively, as TX and RX; AN3, assigned to the internal A/D converter, is needed to detect the presence of the 5 volts and therefore the connector insertion. The serial interface is at a TTL level and can easily be connected to a USB converter USB such as FT232 by FTDI (www.ftdichip.com), in order to interface the microcontroller with a PC equipped with USB. For the interface, you can use FT782M, a small module produced by Futura Elettronica (www.futurashop.it), already equipped with a pin-strip connector at a pitch of 0.10 inches that can be directly inserted in our circuit, on the TTL connector, a female SIL at a pitch of 0.10 inches.
Still regarding the device’s configuration, it is important to note that the corresponding data are not saved in the microcontroller’s EEPROM, but in an external memory chip, dubbed 24FC256-SN; it is a 256- kbit EEPROM CMOS with serial access, and with an I²C-Bus interface. In order to communicate with such chip, the microcontroller initializes its I/O lines RD4 and RD5, used, respectively, as SDA (data line) and (clock line). Moving the remote control’s configuration data into an external memory allows us to exploit the entire internal EEPROM to enhance its available functions. Let’s now take a look at the section related to the identification of DTMF bi-tones, performed with the aid U7, an MT8870 chip capable of discerning standard 16 bi-tones thanks to a complex scheme of active filters put together through the clock signal generated by its internal oscillator, which is connected to pins 7 and 8 as well as to quartz Q2. Whenever it identifies a bi-tone, U7 displays, in binary format, the bi-tone’s corresponding number on outputs Q1 (least important bit) Q2, Q3 e Q4 (most important bit); all the numbers from 0 to 9 are represented with binary combinations from 0000 to 1001, while A, B, C, D, * and # are expressed with the remaining combinations, going from 1010 to 1111. The MT8870 chip has an output latch that helps maintain the logical combination corresponding to the last read bi-tone on Q1÷Q4; in order to avoid that the device may be deceived in the event that two like bi-tones are received consecutively, the chip is equipped with an STD line (pin 15), which changes from one to a logical zero when a bi-tone is identified. Our microcontroller reads the STD through line RD1 so that it can tell whether like bi-tones have been received consecutively and correctly identify possible codes sent out by the cell phone. Note that the MT8870 input has been connected to the GSM audio output precisely because those bi-tones transmitted from a landline phone or cell phone travel on phone channels rather than on the data line.