Monday, 5 March 2012

AT Command

AT Command is a set of instructions used to control a modem. It is the abbreviation of ATtention. Each and every command of the set starts with “AT”. That's why modem commands are called AT commands. Many of the commands that are used to control wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to online data state), are also supported by GSM/GPRS modems and mobile phones. Besides this common AT command set, GSM/GPRS modems and mobile phones support an AT command set that is specific to the GSM technology, which includes SMS related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages).

Table 1: Common AT Command

Figure 18

Click here for more AT Command Classification information

Sunday, 4 March 2012

UART Circuit

Figure 16: UART circuit contain of MAX232 circuit and the DB9 pin socket

For this post, there will be discussing on the UART circuit which enable for the GSM Modem connection to the PIC16F877A.

Figure 17: DB9 Serial Port Female Connector and MAX232 IC

A serial port is used to connect devices or computers, and therefore it should be connected to another serial port. An external device or modem that is connected to the serial port has an identical built-in serial port. It is possible two connection types between serial ports: straight (pins2 on both sides are connected) or null-modem (pin2 is connected to pin3 on another side). First connection type is used between DTE (Data Terminal Equipment) and DCE (Data Communications Equipment) devices (for example, a computer and modem), and the second connection type is used between two DTE devices (for example, two computers or a computer and an external device).

All signals of the RS232 port is are unidirectional. For example, if pin 2 outputs data, then it is unable to receive any signal using this pin. Therefore, two devices that can send data out (DTE-DTE connection) can’t connect using a straight cable. If not, then they would both send out signals on the same wire but neither would be able to receive any signal. Initially, RS232 ports were used for connecting a dumb terminal (DTE) to a modem (DCE). Nowadays computers used as DTE instead of a terminal. The meaning of the pins is the same on both Data Terminal Equipment and Data Communications Equipment. The names: "receive" and "transmit" should be interpreted from the "point of view" of the computer (DTE).

For this project, the microcontroller works on TTL logic; Logic 1= 5V and Logic 0 = 0V. The MAX232 IC is used to convert the TTL/CMOS logic levels to RS232 logic levels during serial communication of PIC16F877A with GSM Modem. It is a dual driver/receiver that includes a capacitive voltage generator to supply RS232 voltage levels from a single 5V supply. Each receiver converts RS232 inputs to 5V TTL/CMOS levels. These receivers (R1 & R2) can accept ±30V inputs. The drivers (T1 & T2), also called transmitters, convert the TTL/CMOS input level into RS232 level. The transmitters take input from controller’s serial transmission pin and send the output to RS232’s receiver. The receivers, on the other hand, take input from transmission pin of RS232 serial port and give serial output to microcontroller’s receiver pin. MAX232 needs four external capacitors whose value ranges from 1µF to 22µF.

Friday, 2 March 2012

GSM / GPRS Modem

Figure 15: GSM Modem

A GSM modem is a wireless modem that works with GSM networks. A wireless modem behaves like a Hayes compatible dial-up modem. The main difference between a standard Hayes modem and a GSM modem is that a Hayes modem sends and receives data through a fixed telephone line while a GSM modem sends and receives data through radio waves. A GSM modem can be an external unit or a PCMCIA card (also called PC Card). An external GSM modem is connected to a PC through a serial cable, a USB cable, Bluetooth or Infrared. Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in order to operate.

GSM/GPRS Modules are similar to modems, but there's one difference: A GSM/GPRS Modem is external equipment, whereas the GSM/GPRS Module is a module that can be integrated within equipment. It is an embedded piece of hardware.

PC's use AT commands to control a modem. GSM modems and normal Hayes modems support a common set of AT commands. A GSM modem can be used just like a Hayes compatible modem. GSM modems support an extended set of AT commands. These extended AT commands are defined in the GSM standards. With the extended AT commands, the things that can be done are like:
  1. Read, write and delete SMS messages.
  2. Send SMS messages.
  3. Monitor the signal strength.
  4. Monitor the charging status and charge level of the battery.
  5. Read, write and searched phone book entries.
The number of SMS messages that can be processed by a GSM modem is pretty low, approx. six messages per minute.
A GPRS modem is a GSM modem with additional support for GPRS technology for data transmission. GPRS means: 'General Packet Radio Service'. It is based on a packet-switched technology, as an extension to GSM (note that GSM is a circuit-switched). An advantage of GPRS over GSM is that GPRS has a much higher data transmission speed. GPRS can be used as the bearer of SMS. If SMS over GPRS is used, an SMS transmission speed of about 30 SMS messages per minute may be achieved. This is much faster than SMS over GSM. A GPRS modem is required to send and receive SMS via GPRS. Some wireless carriers do not support the sending and receiving of SMS via GPRS. A GPRS modem is typically required for MMS.

Friday, 24 February 2012

TDMA technology

Figure 14: The GSM system uses TDMA to split a frequency into time slots.

Time division multiple access (TDMA) is the access method GSM uses for shared networks. GSM uses TDMA to raise the efficiency of the network. GSM uses TDMA to raise the efficiency of the network.Using TDMA, a narrow band that is 30 kHz wide and 6.7 milliseconds long is split time-wise into three time slots. Narrow band means channels in the traditional sense. Each conversation gets the radio for one-third of the time. This is possible because voice data that has been converted to digital information is compressed so that it takes up significantly less transmission space. Therefore, TDMA has three times the capacity of an analog system using the same number of channels.

Thursday, 23 February 2012

What is GSM?

GSM stand for Global System for Mobile communications. Originally, the acronym GSM stood for Groupe Spécial Mobile, a group formed by the Conference of European Posts and Telegraphs (CEPT) in 1982 to research the merits of a European standard for mobile telecommunications. In Europe and many other parts of the world, GSM is the only type of cellular service available. Commercial service using the GSM system did not actually start until 1991. The technology behind the GSM uses Gaussian Minimum Shift Keying (GMSK) modulation a variant of Phase Shift Keying (PSK) with Time Division Multiple Access (TDMA) signalling over Frequency Division Duplex (FDD) carriers. (How GSM works?)

GSM systems provide a number of useful features:
  • Uses encryption to make phone calls more secure 
  • Data networking 
  • Group III facsimile services 
  • Short Message Service (SMS) for text messages and paging 
  • Call forwarding 
  • Caller ID 
  • Call waiting 
  • Multi-party conferencing

    Thursday, 16 February 2012

    Input & Output Circuit

    In the previous post, the basic circuit is complete but still can't see any result yet. This is because there is no input and output attached to the I/O pins to show any result. Below is the basic input and output circuit for this project:


    Input Circuit
     Figure 7: Input Circuit

    The push button input is a very simple and direct input. It has being put in the circuit replacing the input from J6 connector (signal status from the 1st RCCB) for simulating in the Proteus Software for output generating. As in the circuit above, push button is being pulled up by R4 (10KOhm Resistor) to Vcc. So, when the push button is being released, the voltage will be Vcc (5V, since it is being pulled up to Vcc), and when push button is being pressed, the voltage will be 0V. This type of input is called active low input, where the output voltage is 0V or Logic 0 when it is active (button pressed). Sometime, there is a circuit that will put a resistor before the digital input port. The function of the resistor is to protect the digital input port at the microcontroller, just in case that the digital input port is being configured as an output, and the resistor will limit the current from the port.


    Output Circuit

    There are 3 output circuit for this project:

    1) LED
    Figure 8: Basic Output Circuit

    When OUTPUT 2 receive logic condition from the microcontroller, R10 (330kohm) will limit the current to the D3 LED. The D3 LED will on.


    2) LCD
    Figure 9: LCD Pins Diagram
    
    The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters. Most LCDs with 1 controller has 14 pins. Pin description is shown in the table below:

    Figure 10: Character LCD Pins with 1 Controller

    Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. So whatever user sends on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so whatever user write after 16 chars is written in DDRAM but is not visible to the user.
    Figure 11: DDRAM Address for 2 Line LCD

    2.1) LCD Circuit
    Figure 12: LCD Circuit Connection
    

    Above is the connection diagram of LCD in 4-bit mode, only 7 pins needed to interface with an LCD. D4 - D7 are the data pins connection and Enable and Register select are for LCD control pins. The Read/Write (RW) pin of the LCD will not be using, as the data only writing on the LCD. So, it has to be grounded permanently. If user wants to use it, then they may connect it on controller but that will only increase another pin and does not make any big difference. The unwanted data pins of LCD i.e. Vss, VEE and D0-D3 are connected to ground.
    There are many reasons why use LCD in 4-bit mode instead of 8-bit. One basic reason is lesser number of pins are needed to interface LCD.

    More about LCD

    3) Relay Switching
    Figure 13: Relay Switching Circuit
    

    For the above circuit, when the base of the transistor receive any supply from the microcontroller, it will allow the 5V to the ground without active the relay. Otherwise, the relay will active and create a back e.m.f that will turn the switching from the normally open to normally close (which is turn on the Backup RCCB).

    Thursday, 9 February 2012

    Basic Circuit for PIC16F877A

    There's no point in knowing the PIC16F877A without know how to start up it. There are 7 pin should be connect correctly. 

    Power Supply Pin

    Table 1: Power Supply Pin


    In every single electronic component, the supply pin is the most important thing. Same goes to PIC16F877A. The ideal voltage for this microcontroller is 5V (DC). The current that supply to this microcontroller should not be higher that 5.5V and below then 2V. This is because, the higher current will burn the microcontroller and the microcontroller will not operate if the current is below than it required current. Usually, the supply come from either battery or dc adapter and it's hard to fine normal battery or dc adapter in 5V. This problem can be solve by using LM7805 (Datasheet) voltage regulator which will step down the larger input voltage to 5V. Below is the voltage regulating circuit to regulate a voltage from 7V-20V to a stable 5V by using LM7805:

    Figure 3: Basic connection to step down to 5V

    The circuit begins with J2 which is a 2 pins connector to connect to battery or ac adapter. Pin 1 is negative and pin 2 is positive. The first capacitor C1, cleans up the signal if any (ac) noise is present on this. It shorts this noise to ground and allows the pure DC signal into the regulator. The regulator regulates this voltage down to 5 volts. After it comes out of the regulator, the other capacitor C2, cleans up any high-frequency or ac noise that may come out, again to produce a clean DC signal. Now this DC voltage, clean and crisp, is ready to power the load. D1 is a 5V LED as power on/off indicator and R1 is a resistor to limit the current through the LED.

    Reset Pin

    As being mention before, there are 7 pins to connect in order to operate the microcontroller. 4 pins already connected, so there are 3 more pins left. The other important pin is the reset pin (MCLR-Master Clear Reset at Pin 1). If the PIC read 0V at the MCLR pin, it will reset the program and if the MCLR pin read 5V, the PIC will execute the program. The MCLR can be directly connect with 5V (series with resistor like picture below) but it will unable to reset if something goes wrong with the system.

    Figure 4: 5V direct current connection to MCLR pin

    To solve this problem, a switch and a pull up resistor can be added in between 5V and the reset pin so it can create logic condition which is 1 and 0 to reset the pin.

    Figure 5: Reset connection with switch and pull up resistor

    Table 2: Logic Condition for MCLR pin

    When the switch is not pushed, current will flow trough 10K resistor and MCLR Pin. As a result, MCLR Pin receive 5V and PIC read it as logic 1. But when switch is push, current will flow through 10K resistor, switch and directly to ground. There is no voltage will receive at MCLR Pin. This give 0 logic at MCLR Pin.

    Oscillator

    Five from seven of important pins already covered, now there are only 2 pin left which is pin number 13 and 14. Those pin was named as OSC1 and OSC2. It can been connect  to the crystal osillator from various frequency. Pulse generated from the oscillator will some time have the noise. To reduce the noise, two capacitors in piko farad value is needed. The value of capacitor is depend on the speed of oscillator that you use. Below is the way how to connect the the cristal oscillator and capacitor value table.

    Figure 6: Oscillator connection

    Table 3: Capacitor value refer to the oscillator type