Sistema de abertura de porta de garagem baseado em Zigbee

Zigbee based garage door opener system

ZigBee is a wireless networking standard aimed at remote control and sensor applications, suitable for operation in harsh radio environments and isolated locations. It is based on the IEEE 802.15.4 standard, which defines the physical and MAC layers. Above that, ZigBee defines the application and security layer specifications that enable interoperability between products from different manufacturers. In this way, ZigBee is a superset of the 802.15.4 specification.

With the rapid growth of applications for wireless remote sensing and control, it is estimated that the market size could reach hundreds of millions of dollars as early as 2007. This makes ZigBee a very attractive proposition and one that justifies the introduction of a specific standard .

HARDWARE
EASY BEE TABLE 3
The EasyBee3 board includes the MRF24J40MA module used to easily connect your development board to the 2.4 GHz IEEE 802.15.4 wireless network. The module communicates with microcontrollers via a Serial Peripheral Interface (SPI).
Zigbee based garage door opener system
Main features
· RF transceiver compatible with the IEEE 802.15.4 standard ™
· Supports ZigBee®, MiWi ™ , MiWi P2P and proprietary wireless network protocols
· Integrated 20 MHz 32.768 kHz crystal oscillator circuit
· Data rate: 250 kbps (IEEE 802.15.4); 625 kbps (Turbo mode)
· 4-wire Simple Serial Peripheral Interface (SPI)
· Low current consumption
Operating voltage
· The board is designed to use 3.3V and 5V power supplies. Voltage is selected using the built-in power selection jumper.
Main benefits
· Built-in voltage translators enable compatibility with most development boards
· Extended battery life due to low power consumption
· Supported on all MikroE compilers
· IDC10 cables with connectors allow easy connection to peripheral modules.
· Out-of-the-box examples save development time.
Forms
EasyBee 3 is a great choice for building automation and monitoring, industrial monitoring, automated meter reading, security, inventory management, and more.

EasyBee3 board description

The EasyBee3 board is used for wireless communication over short distances and with low power consumption. Wireless communication is enabled due to a ZigBee MRF24J40MA module provided on the EasyBee3 board. Connection between the add-on board and a microcontroller is established through a 2x5 female connector provided on the add-on board and a 2x5 male connector on the development system. Communication between them is carried out via serial peripheral interface (SPI). As the additional system can be connected to different development system, it is necessary to select the appropriate microcontroller pins to be used for SPI communication. DIP switches SW1 and SW2 on the add-on board are used for this purpose. The bottom of the board provides a table indicating which switches on DIP switches SW1 and SW2 should be used depending on the development system
Zigbee based garage door opener system
The ZigBee module requires a supply voltage of 3.3 V for its operation. Since different development systems require different voltage levels, it is necessary to adjust the voltage level of the add-on board to the voltage level of the development system. It is carried out by a voltage regulator provided on an additional board. Jumper J1 is used to select the additional board supply voltage. If the board is connected to the 5v development system, it is necessary to place jumper J1 in the 5v position. For 3.3V development system, jumper J1 must be set to 3.3V position. In addition to adjusting the voltage level, it is also necessary to adjust the voltage signals provided by the ZigBee module. The add-on board has 74LVCC3245 and 74LVC1T45 transceivers that serve as voltage level translators.

MRF24J40MA Transceiver

Zigbee based garage door opener system
The MRF24J40MA transceiver has an integrated PCB antenna and has a range of 40 meters for internal communication and 100 meters for visual communication line.
· Low current consumption
. Rx Mode: 19 mA
. Tx mode: 23 mA
. Sleep: 2 uA
. Operating voltage: 2.4-3.6V
. Temperature range: -40°C +85°C
. ISM Band: 2.405 to 2.48 GHz
. Data rate: 250 Kbps
. Range: up to 400 feet

Development Framework

Development Framework
· The output we get from the PIC16F887 controller is 5V at its output port.
· As shown in the circuit diagram, port B is for LCD display purpose to display the operation status.
· Here ports A and C are used to interface the EasyBee3 board with PIC16F887.
· When using port C for EasyBeeb3 board only 3 pins are used, so to use other pins of port C we take another output from port C using bus and this port is used to interface external application circuit.
· The figure below shows the development board developed in the laboratory during project work.
Zigbee based garage door opener system
Application-specific circuit (motor driver)
· As shown in the circuit diagram, we use the L293D motor driver IC to drive the 5V motor for demonstration purposes.
· This circuit is used to interface two motors with 600mA current handling capacity to the development board.

PCB Design Process

Zigbee based garage door opener system
ZIGBEE MESSAGE FORMAT
A ZigBee message consists of up to 128 bytes in the following fields:
· MAC Header – This header contains, with other information, the source and destination addresses of the message as it is being transmitted. Note that it may not reflect the actual origin or final destination of the message if the message is being routed. The generation and use of this header is transparent to the application code, and the application code will not need to access these fields.
· NWK Header – This header contains, with other information, the actual origin and final destination of the message. The generation and use of this header are transparent to the application code, with the exception of the source address. A macro is provided to allow the application code to determine the network address of the device that sent the message.
· APS Header – This header includes the profile ID, cluster ID, and destination endpoint of the current message. Macros are provided to simplify the creation of this header when transmitting a message. When a message is received, the stack processes this information automatically to determine which endpoint to notify.
· APS Payload – This field contains the ZigBee frame for the application to process.

Zigbee frame formats

ZigBee defines two frame formats, the Key Value Pair (KVP) frame format and the MSG frame format. Both frame formats are associated with a cluster ID, but KVP frames are designed to transfer information associated with an attribute using a strict structure, while MSG frames transfer information using a free-form structure. The application profile will specify which frame formats should be used to transfer which information and the format of any MSG frames. Due to the difference in frame format, a cluster cannot contain KVP frames and MSG frames.
· KVP Frames
A KVP frame contains the following information, in order:
• Transaction sequence number
• Command type and attribute data type
• Attribute ID
• Error code (optional)
• Attribute data (variable size)
The Command Type indicates what the application should do with the information. For example, the Set command requires the recipient to set the value of the attribute indicated by Attribute ID to the value in Attribute Data, and the Get with Acknowledge command requires the recipient to send the value of the attribute indicated by Attribute ID.
· MSG Frames
An MSG frame contains the following information, in order:
• Transaction sequence number
• Transaction duration
• Transaction data
ADDRESS
There are two forms of message addressing available in ZigBee and IEEE 802.15.4.
· Unicast
In a Unicast message, the address of the destination node is provided in the MAC layer header of the packet (in our application only Unicast is used).
· Streaming
In a broadcast packet, the MAC layer destination address is 0xFFFF. Any RX-enabled transceiver will receive the message. This form of addressing is used when joining a network and when discovering routes on the network. ZigBee implements what they call passive broadcast packet recognition. What is meant by passive acknowledgment is that when a device originates or retransmits a broadcast packet, it will listen to all its known neighbors to retransmit the packet. It will wait for all neighbors to replicate the message or timeout after nwkNetworkBroadcastDeliveryTime seconds.
Note that our stack limits the number of broadcast packets a single device can handle at a given time to 1 packet per device. When transmitting broadcast packets, consider what will happen if another device is offline when the packet is transmitted. The originating device cannot always know if another device is offline and therefore causes a third device to block new broadcast packets until the previous broadcast packet expires. Because of this limitation, an application must wait until nwkNetworkBroadcastDeliveryTime seconds have expired before sending another broadcast packet, even if all neighbors have responded to the original broadcast packet. If the packet transmission radius is 1, this warning can be ignored.

Configuring Mikroelektronika Satck

The Mikroelektronika Stack is configured via two source files, Transmitter.c (to configure the transmitter) and Receiver.c (to configure the receiver). Go through these two files very carefully to define the necessary options for your application. These files are available on the Mikroelektronika website.
An important aspect of these files is the simple caller table for transmitter and receiver. Which allows us to understand how this code works. This caller table for transmitter and receiver is shown on the Code tab.
· According to the caller table, the first ZigBee stack detects power and searches for other devices
· If any device is found, it sends mac id & stat procedure to bind the network
· After connection, both devices can work in full duplex mode.

Application

· Now let's go to the main application “garage door opener”
· Here we are using CD drivers to demonstrate the purpose. CD drivers will act as ports
· To demonstrate we are using a wireless toy car and we kept the transmitter in it and we will run the car at a distance of 100 m
· On the receiver side, the receiver interfaces with the motor driver circuit that will drive the CD driver motors. His figure is shown below.
APPLICATION.jpg
· Therefore, when the car is in range of the receiver, the gates will open according to the code.
· Here if we can run this 5V application then we can successfully run 230V AC motor we just need interface relay instead of motor driver
· Therefore, we can say that we can use it for real-time applications, so that the purpose of designing real-time applications is achieved.

Project source code

Project source code

###


 

Caller table for transmitter

· It is very useful to study the program flow given to the transmitter.c file.

· Shows the different functions used for transmission purposes.

Transmitter.mcppi_callertable.txt

main

_CC2DW

_DoICP

SPI1_Init_Advanced

pin_reset

software_reset

write_ZIGBEE_short

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_wake_from_pin

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZGBEE_short

SPI1_Write

Set_long_address

Write_ZIGBEE_short

SPI1_Write

set_short_address

Write_ZIGBEE_short

SPI1_Write

Set_PAN_ID

Write_ZIGBEE_short

SPI1_Write

Init_ZIGBEE_nonbeacon

Init_ZIGBEE_basic

Write_ZIGBEE_short

SPI1_Write

Write_ZIGBEE_long

SPI1_Write

Enable_PLL

Write_ZIGBEE_long

SPI1_Write

Set_CCA_mode

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_RSSI_mode

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Enable_interrupt

Write_ZIGBEE_short

SPI1_Write

Set_channel

Write_ZIGBEE_long

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_Write

SPI1_reading

Write_ZIGBEE_short

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Nonbeacon_PAN_coordinator_device

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_TX_power

Write_ZIGBEE_long

SPI1_write

Set_frame_format_filter

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_Short

SPI1_write

Set_reception_mode

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_Short

SPI1_write

Pin_wake

Write_TX_normal_FIFO

Write_ZIGBEE_long

SPI1_write

Set_not_ACK

Read_ZIGBEE_short

SPI1_write

SPI1_reading

Write_ZIGBEE_short

SPI1_write

Set_not_encrypt

Read_ZGBEE_short

SPI1_write

SPI1_reading

Write_ZIGBEE_short

SPI1_write

Start_broadcast

Read_ZIGBEE_short

SPI1_write

SPI1_reading

Write_ZIGBEE_short

SPI1_write

Caller to Receiver Table

· Here is the caller table from the receiver.c file which allows the user to understand the code. So study it carefully.

Receiver.mcppi_callertable.txt

main

_CC2DW

_DoICP

SPI1_Init_Advanced

pin_reset

software_reset

write_ZIGBEE_short

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_wake_from_pin

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZGBEE_short

SPI1_Write

Set_long_address

Write_ZIGBEE_short

SPI1_Write

set_short_address

Write_ZIGBEE_short

SPI1_Write

Set_PAN_ID

Write_ZIGBEE_short

SPI1_Write

Init_ZIGBEE_nonbeacon

Init_ZIGBEE_basic

Write_ZIGBEE_short

SPI1_Write

Write_ZIGBEE_long

SPI1_Write

Enable_PLL

Write_ZIGBEE_long

SPI1_Write

Set_CCA_mode

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_RSSI_mode

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Enable_interrupt

Write_ZIGBEE_short

SPI1_Write

Set_channel

Write_ZIGBEE_long

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_Write

SPI1_reading

Write_ZIGBEE_short

SPI1_Write

RF_reset

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Nonbeacon_PAN_coordinator_device

Read_ZIGBEE_short

SPI1_Write

SPI1_Reading

Write_ZIGBEE_short

SPI1_Write

Set_TX_power

Write_ZIGBEE_long

SPI1_write

Set_frame_format_filter

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_Short

SPI1_write

Set_reception_mode

Read_ZIGBEE_short

SPI1_write

SPI1_Reading

Write_ZIGBEE_Short

SPI1_write

Pin_wake

LCD_Init

Delay_5500us

Delay_1us

LCD_cmd

Delay_1us

Delay_5500us

Delay_50us

LCD_out

LCD_cmd

Delay_1us

Delay_5500us

Delay_50us

BytetoStr

Div_8x8_U

Debauns_INTn

Read_ZIGBEE_short

SPI1_write

SPI1_reading

Reading_RX_FIFO

Read_ZIGBEE_short

SPI1_write

SPI1_reading

Write_ZIGBEE_short

SPI1_write

Reading_ZIGBEE_long

SPI1_write

SPI1_reading

LCD_chr

LCD_cmd

Delay_1us

Delay_5500us

Delay_50us

###

Circuit diagrams

Development Framework

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.