Home

Atmel AT06700: LED Commercial Lighting Kit

image

Contents

1. 42236A MCU 02 2014 Table of Contents bk ENN 3 1 1 Coordinator Gateway kit uuuasnmnnmseeieenm mettede hevenduekbnmd innte 3 12 Device Lighting Kil sccic iccceceieacusdescteusrccsvaceiiudimesauanieusiendhcuameesdendidediacacaecdneddoudes 3 1 3 CED Light Adapter EEE EEE VE 3 1 4 The Whole System Topology nnnnnnnoannnsnnnnsnrnnsnrnnsnrnnsnrensrrensrrresnrrnsrrersnrernne 3 2 Development Tools r rnnnnnnnrnnnnnnennvenvernrnnvennennvennennnnnnenuvenvnnnennvennenusener 4 3 Gateway Firmware Introduction rrnrrrrarernnrrnaneranernnnrrnnrnranennnnnnnnennne 4 3 1 Inside the Applications L nustesmeidksiss temntm dusk jesinuiseenbinssdeaakde ben 4 3 1 1 Lightweight Mesh Task EE 5 3 1 2 Lightweight IP Task Lunnneneisn ditkmusmnjibjiavnemtk mn pibndde 6 3 1 3 Application Layer TASK LL unssrmeinikuertneseeeik he 8 32 MAMAFI INMCOUCHIOMN EEE EE EN 9 3 2 1 Lightweight Mesh APIS uusanemmeleeennske miin duken ae 9 322 Lightweight PARIS Luumssesemreamemneietei eeknidvvie 9 3 3 Software Package Content rrannrnnnnnnrnrnnnnvnrnnnrnvnnnnrnrnnnernrnnnrnnnnnnrnsnnnsrnnnssnnnnn 11 4 Device Firmware Introduction cccccccceecceeeceeeeeeeeeeeeeeseeeseeeeeeeaees 12 4 1 Device LINK Mechanism ccccscccseccseeccececeeeceueccuceceueceueeeueeseeecsueseuseseeesaaes 12 22 LED LIGNE WaNAGE MGI sissies saisies aiita aiiai REEE 12 43 Main API UO OAC ON EEE eaten emdaraalluioobanes 13 4 4 Software Pac
2. Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 5 A t el 42236A MCU 02 2014 SYS Init is called to initialize lightweight Mesh system stack and specific hardware interface configuration Function NWK SetAddr is used for lightweight Mesh Device address initialization APP ADDR Macro has two functions one for configuring Device address another is to identify the Device is a Router lt 0x8000 or an End device gt 0x8000 For Gateway Macro APP ADDR must be 0 Coordinator In order to create communication between Gateway and Device The Gateway and Device must be configured as same Personal Area Network ID Physical Channel and Application Endpoint through function NWK SetPanld PHY SetChannel and NWK OpenEndpoint Macro APP PANID with a range of 0 65535 is to predefine Personal Area Network ID number Macro APP CHANNEL must be in the range of 11 26 for configuring communication Physical Channel number for the specific channel frequency refers to AT86RF231 or Atmega256RFR2 datasheet Macro APP ENDPOINT with a range of 0 15 is to set the Application Endpoint number the callback function of lightweight Mesh data receive handle rf_rx_handler is also initialized through function NWK_OpenEndpoint nwk_data_req confirm rf_tx_finish_handler is used to set lightweight Mesh application layer data send finished callback function Function SYS TaskHandler is responsible for r
3. conf uart serialh To start communication between End device Router and Coordinator the same APP CHANNEL frequency band APP PANID Personal Area Network ID and APP ENDPOINT Application Endpoint should be set The default configuration of End device Router and Coordinator in this application is 1 APP CHANNEL 0x0D 2 APP PANID 0x1234 3 APP ENDPOINT 1 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 14 A t el 42236A MCU 02 2014 5 2 Polling method in the Gateway is used to query the device information in the list So the Device quantity would affect the scan efficiency of the Gateway In this application the maximum Device quantity is 200 50 for Router and 150 for End device You can revise the predefine value through the Macro MAX ROUTER NUM and MAX END DEVICE NUM in LwIPApp h in Gateway project The specific configuration requirement is as below e End Device LED light 0x8000 lt APP ADDRESS lt 0x8096 e Router LED light APP ADDRESS lt 0x0033 e Coordinator Gateway APP ADDRESS 0x0000 The End device or Router configuration is only used for LED light Note that same device address APP ADDRESS in same network is not allowed Lightweight IP Parameters Configuration Refer to Figure 5 3 directory open the src apps config Conf eth h file The MAC address local IP address and network mask configuration are as follows Note that every devic
4. a Output Files al Libraries gr Calendar b gt mega gt O services LS Dali gt Lay common gt dali_bit b gt dali timer gt mega E dali top h Lg DimmingControl gt aj mega b gt services E LwMesh t O LwMesh1 01 E config h leds h Og Sensor apps command h apps config h CommercialLight c Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 13 42236A MCU 02 2014 5 Getting Started Guide In this chapter it gives a step by step guide to configure the lightweight Mesh and lightweight IP and run the preprogrammed firmware It would have two sections for lightweight Mesh and lightweight IP configuration and preprogrammed firmware 5 1 Lightweight Mesh Parameters Configuration Open the config h file Figure 5 1 Device Lightweight Mesh Configuration gl Solution CommercialLight 1 project 9 Commerciallight gt Ea Dependencies gt Ea Output Files Libraries 3 libm Qa Calendar Lg Dali Lg DimmingControl ug LwMesh hr hr hr gt Sensor apps command h apps config h CommercialLight c Figure 5 2 Gateway Lightweight Mesh Configuration rs Solution CommercialLight Gateway ASF 1 project Commeciallight Gateway ASF gt Ea Dependencies gt Ea Output Files sa Libraries lg sic gt ij apps t ia asf 4 config conf board h conf clock h conf eth h conf sp master h FG
5. Erase now Device information Flash 8KB 2KB BOOT Memories D BuckE5 elf v Fuses V Erase Flash before programming z Lock bits Y Verify Flash after programming Program veiy Read Production Signatures EEPROM 512bytes Production file L Erase EEPROM before programming 7 Verify EEPROM after programming User Signatures 128bytes v Erase User Signatures before programming Read 4 Verify User Signatures after programming Reads Reading device ID OK 5 4 Connecting to Ethernet In the preprogrammed firmware the Gateway Ethernet is configured as below e TCP IP client e Server IP 192 168 1 58 Port 4008 e Gateway static IP 192 168 1 102 Sub net mask 255 255 255 0 Default Gateway 192 168 1 1 The Server IP and Port can be changed in the Gateway firmware file LwIPApp c function tcp_client_init The Gateway TCP IP client setting can be changed in file config_eth h To directly connect the Gateway to PC via Ethernet see the following steps 1 Configure PC IP address to 192 168 1 58 Sub net mask 255 255 255 0 Default Gateway 192 168 1 1 as shown in Figure 5 7 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide Atmel APPLICATION NOTE 18 42236A MCU 02 2014 Figure 5 7 PC Server IP Address Configuration Internet Protocol Version 4 TCP IPv4 Properties 2 ee You can get IP settings assigned automatically if your ne
6. onboard calendar this command is used to update LED light system time Single LED Timing Set CMD LED SINGLE TIMING SET Table 6 15 Single LED Timing Set HEADO HEAD1 ADDRH ADDRL LEN CMD DATAO DATA1 DATA2 DATA3 004 00D 000 0x00 9 0x41 CTR MODE HOURON MINUTE ON SECOND_ON DATAS DATA5 Checksum HOUR OFF MINUTE OFF SECOND OFF The single LED timing would take effect when the CTR MODE 0x01 Timing Control Mode Group LED Timing Set CMD LED GROUP TIMING SET Table 6 16 Group LED Timing Set HEADO HEAD1 ADDRH ADDRL LEN CMD DATAO DATA DATA2 DATA3 DATA Checksum HOUR_OFF MINUTE_OFF SECOND_OFF DATAS DATAG The Group LED timing would take effect when the CTR_MODE 0x01 Timing Control Mode Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 24 A t Mm el 42236A MCU 02 2014 Appendix A Additional Information A 1 Lightweight Mesh Configuration Table A 1 lists the Lightweight Mesh Software Stack configuration used in this reference design and this configuration can be modified in src config config h Table A 1 Lightweight Mesh Options Option Value Description APP ADDR Node network address It should be 0 for the Gateway S 00001 to 0x0032 for Router 0x8001 to 0x8096 for End device APP CHANNEL 0x0D Radio transceiver channel Valid range for 2 4GHz r
7. receives a broadcast command it would transfer this command and responses TCP IP Server with success command 0x80 When Gateway receives a unicast command it would transfer the command and waiting for the response from LED light device based on the specific command 1 If this is a query command the LED light responses the specific information to Gateway and then the Gateway transfers this information to TCP IP Server 2 If this is a control configuration command the LED light responses the Gateway with success command 0x80 and then the Gateway responses the TCP IP Server with success command 0x80 If no response from LED light for a set time the Gateway responses TCP IP Server with timeout OxFF Figure 6 1 Gateway Command Handle Flow Diagram yes Transfer data to LED light and Send nor Send pb success CMD 0x80 success CMD 0x to Server 80 to Server yes yes i Got response gt NO NO Got response gt yes EE Lob no no uneoutOaF 1o yes RE Server Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 20 A t Mm el 42236A MCU 02 2014 6 2 6 2 1 6 2 2 The lightweight IP and lightweight Mesh share the same command set and data package structure The difference is that lightweight IP communication needs an extra data head and target address No
8. 0x0D if 0x20 CTR_MODE DIMO DIM1 DIM2 DIM3 e CTR_MODE Current device LED control Mode 0x00 LED light manual control through sending LED control command 0x01 Enable timing control 0x02 Autonomously controlled by on board light sensor e DIMx Channel x dimming value in percent Table 6 12 Single LED Control Response HEADO HEAD1 ADDRH ADDRL LEN CMD Checksum as GE a FOSTRE a o i 0D Oo 6 2 6 Group LED Control CMD LED GROUP CTRL Table 6 13 Group LED Control 0x04 OxOD 0x00 0x00 8 0x21 GROUP CTR MODE DIMO DIMI DIM2 DATAS Checksum e GROUP Target device group number e CTR MODE Current device LED control Mode 0x00 LED light manual control through sending LED control command 0x01 Enable group timing control 0x02 Autonomously controlled by on board light sensor e DIMx Channel x dimming value in percent Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 23 A t el 42236A MCU 02 2014 6 2 7 6 2 8 6 2 9 Time Synchronization CMD TIME SYNC Table 6 14 Time Synchronization HEADO HEAD1 ADDRH ADDRL LEN CMD DATAO DATA DATA2 DATA3 DATA4 0x04 0x0D 0x00 0x00 8 0x40 YEAR MONTH DAY HOUR MINUTE DATAS Checksum SECOND OOO The LED light integrates an
9. 4 Figure 5 4 Program the Gateway SAM ICE 000028010322 Device Progrmming GP ma Tool Device Interface Device signature Gee SAM KE aTsamame MAG oaase Read 33W Read p interface settings eae a Tool mf ermater Erase Chip Erase nom Device amformasion HMemarnes Dkommesiallught Gass ASF ef GREN Bits 1 rete Flash before programmene Lock bits LI Verify Flach after programming Seiat Reading device 0E To program the LED Commercial light the steps are 1 Connect JTAG ICE3 adapter to the Lightweight Mesh device JTAG interface 2 Power the JTAG ICE3 via the USB cable 3 Open Atmel Studio and select menu Tools gt Device Programming 4 Choose JTAG ICE3 for Tool ATmega256RFR2 for Device and JTAG for Interface and then click Apply button Click the Device signature Read button to check if the connection is correct 6 Select the Memories tab and then select the pre built image for the LED light device from in Flash section 7 Click Program If the pre built image is downloaded to the board message Verifying Flash OK appears Figure 5 5 Program the LED Light JTAGICE3 130200010075 Device Programming a es Tool Device Interface Device signature Target Voltage ATmega256RFR2 Ox1 EA802 32V fe Interface settings Device Tool information Erase Chip 7 Erase now Flash 255KB Device information Memories Fuses v Erase device bef
10. 4 Appendix A Additional Information rrrnrrrorrrrarerarernnnrarennnrrnnnennne 25 A 1 Lightweight Mesh Configuration rrrrnrrrrrnnrrnrnnnrenrnnnrrrnnnnernnnerennnnnrnnnnsnennnnnre 25 A 2 Application Communication Command Set cccccseececeececeeeeeeeeeeeeeesaeees 25 Appendix B REVISION HISTON iecscuerccccsrsncasouaraatpreatanaseneceedndaisepsianes 26 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 2 A t el 42236A MCU 02 2014 1 1 1 2 1 3 1 4 Overview The LED Commercial light based on lightweight Mesh stack protocol communicating is designed to passively receive data command from a Coordinator except the device request link command it means the communication beginner is always a Coordinator A device can be set as an End device or a Router when a device is set to a Router this device Router should route the data from a Coordinator or from an End device Router if the target address is not for itself A typical application scenario is shown in Figure 1 1 Figure 1 1 Typical Lightweight Mesh Network Application Scenario 3 me na i as EE Their amp at be anea e S O00 op eo Doi Jens Drin Coordinator Gateway kit The Coordinator which address is 0x0000 is in charge of e Periodically collect Devices information based on the device link list then report to PC server e Transfer PC server command to a devic
11. APPLICATION NOTE Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide Atmel 8 32 bit Microcontroller Description This application note describes the achievement of LED commercial light application function which includes light control information collection and link maintaining It enables the Atmel AVR wireless MCU and ARM MCU user to get start using Atmel proprietary lightweight mesh software stack and understand how to configure use and integrate the devices in their own design A getting started guide in Chapter 5 provides detailed setup and operation of preprogrammed firmware Features e Atmel ATSAM3X8E ARM Microcontroller AT86RF231 Transceiver e Atmel ATMEGA256RFR2 Microcontroller e Atmel proprietary Lightweight Mesh software stack V1 01 e Lightweight IP stack V1 4 0 e Light control information collection and link maintaining Figure 1 LED Commercial Light Kit and Gateway LED Light Adapter No Gateway The lightweight Mesh version is V1 01 Refer to Atmel AVR2130 Lightweight Mesh Developer Guide and Atmel AVR2131 Lightweight Mesh Getting Started Guide for detailed lightweight Mesh introduction For this reference design the hardware design files schematic BOM and PCB Gerber and software source code can be downloaded from Atmel website The provided hardware documentation can be used with not limitations to manufacture the reference hardware solution for the design
12. D 0x00 0x00 3 0x11 Request e Request 0x00 Request Device Status 0x01 Request Device Link Status Table 6 9 Device Status Query Response Request Device Status DATA DATA2 DATA3 _ DATAO HEADO HEAD1 ADDRH ADDRL LEN CMD DA AT p 0x04 0x0D 0x00 0x00 14 0x91 0x01 GROUP RESERVD CTR MODE DA A4 DATA _DA AG DA DAT AS DAT AY DATA10 DA ALARML ALARMH TEMPL TEMPH DIMO DIM1 DIM2 DIM3 e GROUP Current device group number e CTR MODE Current device LED control Mode 0x00 LED light manual control through sending LED control command 0x01 Timing control through sending timing setting and control command 0x02 Autonomously controlled by on board light sensor Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 22 A t Mm e L 42236A MCU 02 2014 e ALARM Alarm information report reserved in this application e TEMP Device temperature in 0 1K e DIMx Channel x dimming value in percent Table 6 10 Device Status Query Response Request Device Link Status DATA1 Checksum DATAO 0x00 Disconnected 0x01 Connected 6 2 5 Single LED Control CMD LED SINGLE CTRL Table 6 11 Signal LED Control ANC AD ADDR ADDR D DATAO DATA NVATA pupp NAT AZ 0x04
13. DENTAL DAMAGES INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS AND PROFITS BUSINESS INTERRUPTION OR LOSS OF INFORMATION ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice Atmel does not make any commitment to update the information contained herein Unless specifically provided otherwise Atmel products are not suitable for and shall not be used in automotive applications Atmel products are not intended authorized or warranted for use as components in applications intended to support or sustain life
14. PPLICATION NOTE 9 A t el 42236A MCU 02 2014 e tcp client connected It s the callback function invoked when a TCP connection is established It sends a string to TCP server after successful connection and set TCP client in receiving state by registering a callback function tcp_client_received in tcp recv e tcp err handler It s the callback function for TCP error handle It re initializes Gateway to TCP IP client if connection is aborted or connection reset occurs in lightweight IP e status callback It s the callback function for a status change in default network interface It initializes the Gateway as TCP IP client by calling tcp client init e rfDataQueryStartTimerHandler It is callback function for starting LED light information query It is triggered by function timers update through global timer table gs timers table e rfDataCollectionTimerHandler It is callback function for collecting LED light information after starting data query timer It is triggered by function timers update through global timer table gs timers tablef For more details about lightweight IP APIs refer to lightweight IP stack Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 10 A t el 42236A MCU 02 2014 3 3 Software Package Content The Gateway is developed based on ASF The directory structure of the software package integrates ASF structure and lightweight Mesh Software stack structu
15. WAY ADDR2 ETHERNET CONF GATEWAY ADDR3 netif add amp gs net if amp x ip addr amp x net mask amp x gateway NULL ethernetif init ethernet input Function ethernetif_init called by function tcp client init is responsible for the MAC address initialization and server address initialization The default server IP address is 192 168 1 58 and Port is 4008 as below Static Void Sale Void L p OLISI tne void struct ip addr apaddr IP4 ADDR amp 1paddr 192 168 1 58 7 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 6 Al t mMm el 42236A MCU 02 2014 struet Lop pcb pob p Cop newl gs Peb pcb if pcb NULL top err pob top err handler Lop bind p bs 465 Nel 15 10 Addr 0 tep connect pcb amp ipaddr 4008 tcp client connected Lightweight IP task handle LwIP App Task Hander is in charge of lightweight IP stack polling and lightweight IP stack timers updating through function ethernetif_input and timers_update Callback function tcp_client_received is responsible for receiving and handling TCP IP application layer data and function tcp_write is called for sending application layer data to TCP IP server Function tcp_client_connected is invoked when a TCP IP connection is established It sends a string to TCP IP server after successful connection and set TCP client in receiving state by registering a callback function tcp_client_rece
16. _serial h config h E hwipopts h gt stack H asf h For the Server IP address and Port settings refer to function tcp client init in src apps gateway LwIPApp c file as follows grali Void Slavic void Lop Client ni voLd IP4 ADDR amp 1paddr 192 168 1 58 tcp connect pcb amp lpaddr 4008 tcp client connected The default Server IP address is 192 168 1 58 Port is 4008 53 Program the Target Board Along with this document three elf files are provided Gateway CommecialLight_Gateway_ASF elf LED Commercial light CommercialLight elf and LED light adapter BuckE5 elf To program the Gateway SAM ICE adaptor mentioned in Chapter 2 is needed The steps are Connect SAM ICE to the SAM ICE adapter Connect SAM ICE adapter to the Gateway programming header J2 Power the Gateway via the USB cable Open Atmel Studio and select menu Tools gt Device Programming Choose SAM ICE for Tool ATSAM3X8E for Device and JTAG for Interface and then click Apply button Click the Device signature Read button to check if the connection is correct Select the Memories tab and then select the pre built image for the Gateway from in Flash section Click Program If the pre built image is downloaded to the board message Verifying Flash OK appears oY So SS YS Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 16 A t el 42236A MCU 02 201
17. adios is 11 26 NGS l i Sea Ox1A APP PAN ID 0x1234 Network identifier 0 65535 _APP_ENDPOINT 1 Application main data communication endpoint 0 16 NWK BUFFERS AMOUNT 3 Number of buffers reserved for stack operation A 2 Application Communication Command Set Table A 2 Command Set No OMD Value Property 1 CMD DEV LINK REQ 0x00 Unicast i Only for lightweight Mesh layer communication 2 CMD CMD QUERY REQ Ox01 Unicast Only for TCP IP layer communication 3 CMD LED GROUPING pod lune 7 4 CMD DEV STAT REQ 0x11 _ Unicast Oniy for lightweight Mesh layer communication 5 CMD LED SINGLE CTRL 0x20 Unicast 6 CMD LED GROUP CTRL 0x21 Broadcast _ 7 CMD_TIME_SYNC 0x40 Broadcast 8 CMD LED SINGLE TIMMING SET 0x41 Unicast 9 CMD LED GROUP TIMMING SET 0x42 Broadcast __ Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 25 A t el 42236A MCU 02 2014 Appendix B Revision History Doc Rev Date Comments 42236A 02 2014 Initial document release Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 26 A t el 42236A MCU 02 2014 Altmel Enabling Unlimited Possibilities Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan G K 1600 Technology Drive Unit 01 5 amp 16 19F Business Campus 16F Shin Osaki Kangyo Building San J
18. e e Device s request link command response and maintains device link list Coordinator is usually integrated into TCP IP to Lightweight Mesh Gateway There are two roles for Gateway TCP IP client for TCP IP communication and Coordinator for lightweight Mesh communication Device Lighting Kit The Device which could be End device or Router is deployed into LED commercial light for LED controlling and information report through lightweight communication Two responsibilities for the Device e Request device link e Executes control command and responses query command from Coordinator If the Device is configured as a Router it would route the data from a Coordinator or from an End device Router if the target address is not for itself LED Light Adapter LED light adapter which is made by ATxmega8E5 is the power supply of LED light In this application we don t plan to introduce the function of LED light adapter and how to achieve the function The elf file has been provided for its programming Refer to Section 5 3 Program the Target Board for the specific LED light adapter program operation The Whole System Topology The system usually includes four parts LED light Gateway TCP IP Server and User TCP IP Client The Gateway would periodically communicate with Server for LED light information uploading after connected with the Server The Server and User can control LED light and collect LED light information through communicating with Gate
19. e must have an exclusive MAC address and local IP address in a network MAC address definition The MAC address must be unique on the network define ETHERNET CONF ETHADDRO 0x00 define ETHERNET CONF ETHADDRI 0x04 define ETHERNET CONF ETHADDR2 0x25 define ETHERNET CONF ETHADDR3 Ox1C define ETHERNET CONF ETHADDR4 OxA0O define ETHERNET CONF ETHADDRS 0x02 WAN Address 192 168 1 50 The IP address being used define ETHERNET CONF IPADDRO 192 define ETHERNET CONF IPADDRI 168 define ETHERNET CONF IPADDR2 1 define ETHERNET CONF IPADDR3 102 WAN gateway 192 168 1 1 The gateway address being used define ETHERNET CONF GATEWAY ADDRO 192 define ETHERNET CONF GATEWAY ADORI 168 define ETHERNET CONF GATEWAY ADDR2 1 define ETHERNET CONF GATEWAY ADDR3 a The network mask being used define ETHERNET CONF NET MASKO 255 define ETHERNET CONF NET MASK1 255 define ETHERNET CONF NET MASK2 255 define ETHERNET CONF NET MASK3 0 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 15 A t Mm el 42236A MCU 02 2014 Figure 5 3 Gateway Lightweight IP Configuration al Solution CommecialLight Gateway ASF 1 project 4 Commeciallight Gateway ASF gt Ea Dependencies gt Ea Output Files sa Libraries lg sl 4 lg apps gt gateway b gt ast config conf board h conf clock h conf eth h conf spi master conf_uart
20. es whether the command should be transferred to LED light through lightweight Mesh or not For specific command definition refer to Section 6 2 Communication Command Set There are two timer handle functions rfDataQueryTimerHandler and rfDataCollectionTimerHandler for LED light information query rfDataQueryTimerHandler is to periodically start LED light information query and rfDataCollectionTimerHandler is to start a timer to collect selected LED light information Refer to Figure 3 3 for the application task running mechanism Figure 3 3 Gateway Application Task Flow Diagram lt Initialization p gt lt Light link list maintaining Response device link Net data come nb a yes request amp update device link list J yes no ae igbeeDevice Send request AG ed Hede no ad ul query timer query cmd to MERE ye timeout Server lt n Send the Zigbee control cmd Send device info query cmd based on 4 no a device link list Send end success info to Server 79 yes nd yes Finished Po Send SUCCESS 4 yes Got the info to Server response no no no no Send timeout Update the device info to Server YES ERE link l
21. est Device Status Query After the Gateway completely collects the device information in the list it would send the Request Command Query command to TCP IP Server 3 Request Time Sync Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 21 A t Mm el 42236A MCU 02 2014 Table 6 5 Request Command Query D DAIAU ADU ND ADDR ADDR 0x04 Ox0D 0x00 0x00 3 0x01 Request e Request 0 No command request 1 Request Device Status Query 2 Request Time Sync Note that this command only occurs between Gateway and TCP IP Server through lightweight IP 6 2 3 LED Light Grouping CMD_LED_GROUPING This command is to group the single LED light for LED light group control Table 6 6 LED Light Grouping HEADO HEAD1 ADDRH ADDRL LEN DATAO Checksum i 0x04 OxOD nm 3 0x04 GROUP e GROUP LED light new group number Table 6 7 LED Light Grouping Response ADU AD AV DIDI ADDR 0x84 GROUP 0x04 0x0D 3 6 2 4 Device Status Query CMD DEV STAT REQ The TCP IP Server should send Device Status Query command after received Request Device Information Query CMD CMD QUERY REQ the Gateway would response the connected device information according the attached data type Table 6 8 Device Status Query DO H ADDRH ADDRL LEN CMD 0x04 Ox0
22. ght Mesh Developer Guide The software block diagram lightweight Mesh software stack is given in Figure 3 1 Figure 3 1 The Lightweight Mesh Software Block Diagram Application Network Layer NVVK RF Physical Layer PHY Hardware Abstraction Level HAL System Services Application Services Currently the public release version of lightweight Mesh software stack works with AVR based MCUs but given its extreme portability and low resource requirements it can be run on almost any Atmel MCU In this application it s integrated into ATSAM3X8E MCU for Gateway and ATmega256RFR2 for the LED commercial light the version is v1 01 In order to improve the efficiency of Gateway information collection maximum Device quantity is limited the default is 200 50 for Router and 150 for End device So the Router address is from 0x0001 to 0x0032 and the End device is from 0x8001 to 0x8096 Lightweight Mesh application task includes two parts lightweight Mesh initialization SYS Init and lightweight Mesh task handle SYS TaskHandler Function LwMeshApp _Init is as below static void LwMeshApp Init void Config LwMesh 5SYS tnt NNK SetAddr APP ADDR NWK SetPanld APP PANID PHY S tlhannel APP CHANNEL PHY Sethxststie rrue NWK OpenEndpoint APP ENDPOINT rf rx handler nwk data req dstEndpoint 1 nwk data req sreEndpoint 2 nwk data req options 0 nyk data req coniirm FE tx finish handler
23. ifferent devices the random number generator is used to produce the random time for requesting device link Macro NET REQUEST LINK TIME WINDOW is used to limit the time window the default random time is from 0 to 32767 milliseconds Before using random number generator the predefined Macro PHY ENABLE RANDOM NUMBER GENERATOR must be enabled Because the Gateway is designed to periodically query device information so there is a timer insides the Device to monitor the unicast data from the Gateway If no data for NET LOST LINK TIMEOUT milliseconds the Device would enter no link state then the request data link function would be triggered Figure 4 1 describes the transfer of device link state Figure 4 1 Device Link Status Initialization Send Request Device Link command Send Request Device Link command Device is linked Device isn t linked Wait command from Gateway timeout Received unicast command from Gateway LED Light Management Led light management includes five functions in this application e LED self test There is a dedicated timer TestTimer and function TestTimerHander for LED self function test LED dimming value would be set from 0 to 100 then go back to 0 smoothly in the given time after pressing the onboard button e LED timing control The LED would be controlled by the preset timing value after enabling the timing settings through communicating e LED manual control The LED wo
24. ist Command transfer and report Light information query and collection va am am am am em am am am am am aml am am ww ow gt gt gt gt gt gt gt gt J Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 8 A t el 42236A MCU 02 2014 3 2 Main API Introduction 3 2 1 Lightweight Mesh APIs The main APIs used in this application are as follows e SYS Init It initializes lightweight Mesh HAL PHY NWK layer and system timer It is called from board_init e SYS_TaskHandler It is the core API of lightweight Mesh The PHY NWK and system timer task handlers are called in this API e LwMesh_App_Task_Handler It is the application layer task handler of lightweight Mesh also includes lightweight Mesh initialization and lightweight Mesh core stack running e rf rx handler The callback function registered by NWK NWK OpenEndpoint It is called when valid data was received from lightweight Mesh low level layer e NWK DataReaq It is called for lightweight Mesh data sending before calling this function make sure that the network is idle through calling NWK Busy e rf tx finish handler It is initialized in LwMeshApp_lnit It is called when the data sending is completed e appRfNetworkTimeoutTimerHandler It is a timer timeout task handler of application layer and is used to indicate the waiting response data timeout when the sending command is uni cast com
25. ived Function status callback is the callback function for a status change in default network interface It initializes the Gateway as TCP IP client by calling tcp_client_init Function tcp err handler is the callback function for TCP error handler It re initializes Gateway to TCP IP client if connection is aborted or connection reset occurs in lightweight IP Refer to Figure 3 2 for specific lightweight IP stack running mechanism Figure 3 2 Lightweight IP Task Flow Diagram lwip_ init v ethernet_configure_interface v gt ethernet task 4 Yes Yes No No ARP packet ip input No etharp arp input CP protocol Yes tcp_input Other protocol handler v tep client received tcp write v tcp output Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 7 A t el 42236A MCU 02 2014 3 1 3 Application Layer Task Gateway application task mainly includes three functions 1 TCP IP server command transfer and response TCP IP Server query command 2 LED light information periodic query collection and report 3 LED light link list maintaining TCP IP Server command transfer and query command is based on the lightweight IP task according to predefined command set application task decid
26. k and lightweight Mesh application task The LED commercial light application task is integrated into lightweight IP application task The content of main function is shown below int main void syscik Ina t y board init ledsInit Bring up the Ethernet interface amp initializes timer 0 channel 0 LwIP Init while 1 Check if any packets are available and process if they are ready That function also manages the lwIP timers LwIP App Task Hander lwMesh initialization Check if any packets are available and process if they are ready also manages the LwMesh task and timers LwMesh App Task handler Never reached return 0 Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 4 A t el 42236A MCU 02 2014 Function syscik init board init and ledslinit is respectively used to initialize MCU system clock target board configuration and network status indicator LED initialization Function LwIP Init LwIP App Task Hander and LwMesh App Task handler have been described in the code comment above 3 1 1 Lightweight Mesh Task Atmel lightweight Mesh is the easy to use proprietary low power wireless mesh network protocol from Atmel It is designed to work with all Atmel IEEE 802 15 4 transceivers and SoCs To find more detailed information about the lightweight Mesh architecture and application development process refer to Atmel AVR2130 Lightwei
27. kage Content rrrnnnnnnrnrnnnnrnrnnnrnnnnnnrnrnnnrenrnnnrnnnnsnennnnssnnnsnsnnnnnre 13 5 Getting Started Guide rrrnnnnnnnrnnnnnnnnennnrnnannvanennnnnnanrnnarnnanennsnnnanennn 14 5 1 Lightweight Mesh Parameters Configuration ccccccseeeeeeeeeeeeeeeeeeeeeeeens 14 5 2 Lightweight IP Parameters Configuration ccccccseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeas 15 5 3 Program the Target Board ee 16 5 4 Connecting to Ethernet ccccccecccccseeecceeseesceececceeseesseeseeseeesecsseseesseeeenas 18 6 Application Layer Communication Introduction rrrnnrrnnrrnrennnennnnr 20 6 1 Communication Method Lv4ss eserssms4ebdesspesneesmamindnetim dt 20 6 2 Communication Command Set rrrrnnnnrnrnnnrvnrnnnrnnnnnnrnvnnnrrnrnnnrnnnnnnrnrnnnernnnnnsen 21 6 2 1 Device Link Request CMD DEV LINK REQ erernnrrnronrnrnnnennnnen 21 6 2 2 Request Command Query CMD _CMD_QUERY_REQ 21 6 2 3 LED Light Grouping CMD LED GROUPING rrnernnnnnnnrnnnnnnnner 22 6 2 4 Device Status Query CMD DEV STAT REQ mmrrerrronrrrnnnennnnen 22 6 2 5 Single LED Control CMD LED SINGLE CTRL 0 ee 23 6 2 6 Group LED Control CMD LED GROUP CTRL rmrornernnnennannnnen 23 6 2 7 Time Synchronization CMD TIME SYNG rrrrnrnnnrnennnnnrrnrnnrennnnn 24 6 2 8 Single LED Timing Set CMD LED SINGLE TIMING SET 24 6 2 9 Group LED Timing Set CMD LED GROUP TIMING SET 2
28. mand which needs a response e appDataReceivedTimerHandler It is used to indicate through LED blinking that the system is receiving data through lightweight stack appDataTransmitedTimerHandler It is used to indicate through LED blinking that the system is sending data through lightweight stack For more details about other APIs in lightweight Mesh refer to the software package and documents inside The latest lightweight Mesh Software Stack package can be downloaded from http www atmel com tools LIGHTWEIGHT_MESH aspx 3 2 2 Lightweight IP APIs The main APIs of lightweight IP used in application are as follows e LwIP Init It initializes lightweight IP Ethernet interface related hardware and device link list e LwIP App Task Hander The lightweight IP Ethernet task handle it polls the Ethernet tasks periodically handles data transfer between lightweight IP and lightweight Mesh Device LED light data query and device link list maintaining e tcp client init It initializes the gateway as TCP IP client By default static IP is assigned to gateway and a port number is bound In this function it tries to connect to TCP IP server with the default parameters e tcp client received It s the callback function invoked whenever a data packet is received from lightweight IP For Gateway it stores data received from TCP IP server in a buffer Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M A
29. ore programming P V Read Lock bits Verify Flash after programming Program erify ea EEPROM 8KB Production file v Verify EEPROM after programming User Signatures 768bytes v Erase User Signatures before programming v Verify User Signatures after programming Reading device ID OK OK Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide Atmel APPLICATION NOTE 17 42236A MCU 02 2014 To program the LED light adapter the steps are Connect JTAG ICE3 adapter 50 mil 6 pin to LED light adapter PDI interface Power the JTAG ICE3 via the USB cable Open Atmel Studio and select menu Tools gt Device Programming Choose JTAG ICE3 for Tool ATXmega8E5 for Device and PDI for Interface and then click Apply button Click the Device signature Read button to check if the connection is correct Select the Memories tab and then select the pre built image for the LED light Adapter from in Flash section 7 Click Program If the pre built image is downloaded to the board message Verifying Flash OK appears 2 a eS a Figure 5 6 Program the LED Light Adapter r JTAGICE3 330200018671 Device Programming xs Tool Device Interface Device signature Target Voltage JTAGICE3 ATxmega8E5 0x1 E9341 32V 22 Interface settings Device Tool information Erase Chip
30. ose CA 95110 BEA Tower Millennium City 5 Parkring 4 1 6 4 Osaki Shinagawa ku USA 418 Kwun Tong Road D 85748 Garching b Munich Tokyo 141 0032 Tel 1 408 441 0311 Kwun Tong Kowloon GERMANY JAPAN Fax 1 408 487 2600 HONG KONG Tel 49 89 31970 0 Tel 81 3 6417 0300 www atmel com Tel 852 2245 6100 Fax 49 89 3194621 Fax 81 3 6417 0370 Fax 852 2722 1369 2014 Atmel Corporation All rights reserved Rev 42236A MCU 02 2014 Atmel Atmel logo and combinations thereof AVR Enabling Unlimited Possibilities and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries ARM and others are the registered trademark or trademarks of ARM Ltd Other terms and product names may be trademarks of others Disclaimer The information in this document is provided in connection with Atmel products No license express or implied by estoppel or otherwise to any intellectual property right is granted by this document or in connection with the sale of Atmel products EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT INDIRECT CONSEQUENTIAL PUNITIVE SPECIAL OR INCI
31. re For details of the structure of ASF refer to Atmel AVR4029 Atmel Software Framework Getting Started For the structure of lightweight Mesh refer to Atmel AVR2130 Lightweight Mesh Developer Guide The Gateway directory structure is shown as follows Figure 3 4 Gateway Directory Structure li sic 4 lg apps Lg gateway leds h LwIPApp c LwIPApp h LwMeshApp c LwMeshApp h main c FTTTTI otalnterface c C timer mgt sam c timer mgt sam h lg asf common t O boards t O services gt utils sam b gt components gt drivers gt utils lg thirdparty gt CMSIS lg lwip b lwip 1 4 0 gt lwip port 1 4 0 b gt config lg stack lg hal gt atsam3x e lg nwk gt inc gt src LG phy gt at86rf231 lg service gt inc gt SIE lg sys gt inc gt SIE E asf h i Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide M APPLICATION NOTE 11 A t el 42236A MCU 02 2014 4 4 1 4 2 Device Firmware Introduction In this application Device is in charge of LED commercial light management and communicating with Gateway through lightweight Mesh The lightweight Mesh stack has been described in Gateway Function Introduction section so in this section we would focus on Device link mechanism and LED light management from Device side Device Link Mechanism In order to decrease possibility of the communication confliction between d
32. te that the data length in the cell below is 8 bits Communication data pack definition between TCP IP Server and TCP IP Client Gateway is as below Table 6 1 TCP IP Data Package Definition rar me VEE KE EE KE VE 0x04 0x0D ADDRH L target Device suse LEN n 2 Checksum SUM HEADO DATA MOD 256 Communication data package definition between Gateway Coordinator and LED light End device Router is as below Table 6 2 Lightweight Mesh Data Package Definition EN LESE KD ee EEE KEENE LEN n 2 Checksum SUM LEN DATA MOD 256 Communication Command Set Device Link Request CMD DEV LINK REQ The initiator is LED light to notice the Gateway that a LED light device is online and request link After receives the request the Gateway would update device link list responses the LED light After LED light device received the response the LED light would stop sending this command until the LED light waiting device information query timeout Note that this command only occurs between Gateway and LED light device through lightweight Mesh Table 6 3 Device Link nie ERIE TER VEE 4 0x80 0 Table 6 4 Device Link Request Response a 4 ox00 O Request Command Query CMD_CMD_QUERY_REQ According to the attached data content the Gateway Request Command Query command includes three functions 1 No command request It is mainly for maintaining connection with TCP IP Server 2 Requ
33. twork supports this capability Otherwise you need to ask your network administrator for the appropriate IP settings A Obtain an IP address automatically Use the following IP address IP address 192 168 1 58 Subnet mask 255 255 255 Default gateway 197 168 1 1 Obtain DNS server address automatically Use the following DNS server addresses Preferred DNS server Alternate DNS server E Validate settings upon exit 2 Connect the Ethernet cable between the Gateway and the PC Power on the Gateway via the USB cable Successful Ethernet connection is indicated by LED D6 blink on the Gateway Open a third party Socket tools such as TCP UDP Socket debug tools Create a TCP server service and the listening Port is set to 4008 Starting listening and send command to the client after connected Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide Atmel APPLICATION NOTE 19 42236A MCU 02 2014 6 1 Application Layer Communication Introduction Communication Method In this application the communication includes two parts 1 TCP IP communication between TCP IP Server and TCP IP Client Gateway 2 Lightweight Mesh communication between Gateway Coordinator and LED commercial light End device Router From the communication property the command includes broadcast command and unicast command Refer to Appendix A 2 for command property When Gateway
34. uld be controlled through communication control command e LED autonomously control by light sensor The LED would be controlled by the onboard light sensor autonomously e Real time LED information collection The system would collect the LED information periodically Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 12 A t Mm el 42236A MCU 02 2014 4 3 Main API Introduction APP TaskHandler is in charge of lightweight Mesh initialization and application function initialization appDatalnd is used for lightweight Mesh receiving data and handling appNetworkStatusTimerHandler is responsible for lightweight Mesh network status indictor and device link state timeout timing userKeyTimerHandler is used to judge whether the onboard button has been pressed down it is designed for LED self test function appLinkingTimerHandler is called for Device link request appnetDatalndictorTimerHandler is used for receiving data indictor through LED display appCalendarReadTimerHandler is called to periodically update system time through reading calendar chip data appParameterUpdateTimerHandler is responsible for triggering LED parameters collection periodically 4 4 Software Package Content The LED light directory structure is as follows Figure 4 2 LED Light Directory Structure al Solution CommercialLight 1 project 4 Commerciallight Atmel Gad Dependencies
35. unning lightweight mesh stack Function NWK DataReq is responsible for sending lightweight mesh application layer data Make sure that the lightweight Mesh is idle NWK Busy is used to detect whether the lightweight Mesh is busy or not before sending application layer data Lightweight IP Task Lightweight IP is free third party software stack mainly for embedded operation platform Refer to lightweight IP website for more information Lightweight IP application task mainly includes two parts lightweight IP initialization LwIP Init and lightweight IP task handle LwIP App Task Hander Function LwIP Init is in charge of lightweight IP stack initialization Iwip init and Ethernet hardware interface initialization ethernet configure interface We use static local IP address in this application so the Ethernet hardware initialization includes IP address initialization subnet mask initialization default gateway address initialization and MAC address initialization See following code in function LwIP Init below Default ip addr IP4 ADDR amp x ip addr ETHERNET CONF IPADDRO ETHERNET CONF IPADDRI1 ETHERNET CONF IPADDR2 ETHERNET CONF IPADDR3 7 Default subnet mask IP4 ADDR amp x net mask ETHERNET CONF NET MASKO ETHERNET CONF NET MASK1 ETHERNET CONF NET MASK2 ETHERNET CONF NET MASK3 Default gateway addr IP4 ADDR amp x gateway ETHERNET CONF GATEWAY ADDRO ETHERNET CONF GATEWAY ADDRI ETHERNET CONF GATE
36. way but the User can t directly communicate with Gateway it needs data transfer through the Server after collected with the Server Refer to Figure 1 2 for the whole system topology Atmel AT06700 LED Commercial Lighting Kit and Gateway Software User s Guide APPLICATION NOTE 3 Al t mMm el 42236A MCU 02 2014 Figure 1 2 The Whole System Topology Lightweight Mesh Network LED light O O m 0x8000 O 0x0005 gt 6 L ad L 0x0000 O O 0x8001 0x0004 Server Gateway gt s Z TCP IP TCP IP gt a j r TCP IP S J N Gatewa TCPIIPZ ee S Gateway User 2 Development Tools To program or debug the preprogrammed firmware the following development tool chain is needed e Atmel Studio 6 Version 6 1 2514 beta or above e Atmel Software Framework Version 3 5 1 or above e Programming and debugging device Atmel JTAGICE3 SAM ICE JTAG e SAM ICE Adapter a minimized 1 27mm pitch 10 pin header adapter for Atmel SAM ICE For more details refer to Atmel AVR2033 SAM ICE Adapter Hardware User Manual e JTAGICE3 adapter 50 mil 6 pin 3 Gateway Firmware Introduction The Gateway is based on Atmel ATSAM3X8E microcontroller and Atmel AT86RF231 2 4GHz radio transceiver For gateway hardware design details refer to Atmel AT2200 ZigBee to Ethernet and Wi Fi Gateway with SAM3X Hardware User s Guide 3 1 Inside the Applications There are two tasks in Gateway firmware lightweight IP application tas

Download Pdf Manuals

image

Related Search

Related Contents

  MANUALE D`USO E MANUTENZIONE  Havis-Shields C-VS-1200-DUR User's Manual    Product Sheet - Projector Central  2015年定時株主総会招集通知  COBY electronic DVD-626 User's Manual  SRWF-506~508 user manual    Manual Orthopaedic Surgical Instruments  

Copyright © All rights reserved.
Failed to retrieve file