Difference between revisions of "GSM Application Guide"

From Flowcode Help
Jump to navigationJump to search
Line 59: Line 59:
  
 
The GSM modem uses a command terminology known as AT commands. The AT commands always start with the characters “A” and “T” to bring the remote device to attention. Sending a number 13 to represent a carriage return has the effect of allowing the AT command to be executed on the GSM modem. If the command is successful then we should receive an OK back from the modem using the GSM_RCEVE macro. The GSM_DELAY macro simply allows for a delay in between commands.
 
The GSM modem uses a command terminology known as AT commands. The AT commands always start with the characters “A” and “T” to bring the remote device to attention. Sending a number 13 to represent a carriage return has the effect of allowing the AT command to be executed on the GSM modem. If the command is successful then we should receive an OK back from the modem using the GSM_RCEVE macro. The GSM_DELAY macro simply allows for a delay in between commands.
 +
 +
 +
== Example 2: Interactive message sending ==
 +
 +
{{Fcfile|Apps_GSM_Ex2_Keypad_Entry.fcfx|Keypad Entry Example}}
 +
 +
Example 2 is more advanced  text message sending program which allows you to specify both the mobile phone number and the text data using the keypad E-Block.
 +
 +
The Get_Phone_Number macro is used to collect a phone number into a byte array using the keypad E-Block. This array is exactly the same as shown in example 1 but this time we are creating a routine to allow the array to be populated rather then simply hard coding the array.
 +
 +
The code shown on the left scans the keypad for a key press and then checks to see if no keys are pressed ‘255’ or if the key press is the same as the previous key press which means that the key is being held down.
 +
 +
If the key is not being held down and there is a valid press then we check for the “*” or “#” keys being pressed. These keys have the functionality of finishing or resetting the numeric data entry process. Finally if none of the above are true then we know that we have a single data byte which can be added to the array.
 +
 +
 +
== Example 3: Voice call control ==
 +
 +
{{Fcfile|Apps_GSM_Ex3_Voice_Call.fcfx|Voice Call Example}}
 +
 +
Example 3 allows the GSM modem to be used as a phone for voice messages.
 +
 +
The phone call is established by using the ATD command.
 +
 +
The phone call is disconnected by sending the ATH command. This command requires no additional parameters.
 +
 +
The phone number to ring is hard coded into the Flowcode program to demonstrate how the program could be modified into an auto dialing system. For example for use with a fire or burglar alarm system that rings a per-configured number when an alarm is triggered.

Revision as of 14:21, 1 September 2014

Introduction

These examples demonstrate the use of Flowcode and serial AT commands to control a GSM modem.

In particular they make use of the EB066 E-blocks GSM board, connected to an EB006 E-blocks PICmicro multiprogrammer fitted with a 16F1937 microprocessor.

However, the examples are easily changed in Flowcode to support other microprocessors and platforms.

The Matrix TSL EB452SI6 Easy GSM bundle has all the items required for these sample applications and is an ideal introduction to GSM (Global System for Mobile) communication technology.


Setting up the project hardware

Connect the E-Blocks as indicated in the table below.

The GSM, Sensor and LCD E-Blocks all need to be powered via wire connections to the +V on the EB006.

In addition, the GSM board requires the Vpwr terminal connecting to the Vpwr (or +14V) terminal of the EB006.


Hardware Setup
EB006 PICmicro multiprogrammer
EB090 E-blocks Sensor Motherboard Port A
EB005 E-blocks LCD board Port B
EB066 E-blocks GSM board Port C
EB014 E-blocks Keypad board Port D


Example 1: Text message sending

FC6 Icon.png Text Message Sending Example

Example 1 demonstrates how to construct character arrays that are used as text strings for the destination mobile number and the contents text message. These are then used as parameters of the AT commands to be sent to the GSM modem.

The recipient mobile phone number is specified at the start of the program by initializing an array of byte variables with the numeric data. Ensure that you change this data to a valid mobile destination number before you compile to your target hardware!

The text content of the message is specified next in the program. The array must be large enough to allow for the complete contents of the message to be initialized. The number 32 represents an ASCII encoded space character and the number 0 represents a string termination. A line feed is encoded as a number 10 and a carriage return as the number 13.

The GSM modem uses a command terminology known as AT commands. The AT commands always start with the characters “A” and “T” to bring the remote device to attention. Sending a number 13 to represent a carriage return has the effect of allowing the AT command to be executed on the GSM modem. If the command is successful then we should receive an OK back from the modem using the GSM_RCEVE macro. The GSM_DELAY macro simply allows for a delay in between commands.


Example 2: Interactive message sending

FC6 Icon.png Keypad Entry Example

Example 2 is more advanced text message sending program which allows you to specify both the mobile phone number and the text data using the keypad E-Block.

The Get_Phone_Number macro is used to collect a phone number into a byte array using the keypad E-Block. This array is exactly the same as shown in example 1 but this time we are creating a routine to allow the array to be populated rather then simply hard coding the array.

The code shown on the left scans the keypad for a key press and then checks to see if no keys are pressed ‘255’ or if the key press is the same as the previous key press which means that the key is being held down.

If the key is not being held down and there is a valid press then we check for the “*” or “#” keys being pressed. These keys have the functionality of finishing or resetting the numeric data entry process. Finally if none of the above are true then we know that we have a single data byte which can be added to the array.


Example 3: Voice call control

FC6 Icon.png Voice Call Example

Example 3 allows the GSM modem to be used as a phone for voice messages.

The phone call is established by using the ATD command.

The phone call is disconnected by sending the ATH command. This command requires no additional parameters.

The phone number to ring is hard coded into the Flowcode program to demonstrate how the program could be modified into an auto dialing system. For example for use with a fire or burglar alarm system that rings a per-configured number when an alarm is triggered.