Changes RSS

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

projects:tempdude [2009/12/31 18:19]
fishy Operations in this section are a lot simpler now. Scrapping old doc, will add new later.
projects:tempdude [2010/02/03 22:34] (current)
fishy
Line 21: Line 21:
   * based on "reference architecture" components   * based on "reference architecture" components
   * lightweight data storage; RRD or SQLite most probable.   * lightweight data storage; RRD or SQLite most probable.
- 
- 
 ===== System architecture ===== ===== System architecture =====
  
Line 37: Line 35:
  
 The software platform is to be based on the Microchip TCP/IP stack on the device. The first edition of the server-side software will be a simple TCP server written for GNU/Linux. The software platform is to be based on the Microchip TCP/IP stack on the device. The first edition of the server-side software will be a simple TCP server written for GNU/Linux.
 +
 +==== Firmware releases ====
 +
 +The firmware code is heavily limited by the fact that it is limited my Microchip's licensing. This means, you may
 +only "use, modify, copy and distribute" the Microchip code "when embedded on a Microchip microcontroller [...]".
 +My code however, you are free to use under a four-clause BSD license, as long as you filter the Microchip
 +code away :P
 +
 +Firmware version 1.0 is available! 
 +  * Want to hack, or add it to your own PIC-MINI-WEB?: {{:projects:tempdude-firmware-1.0.zip}}
 +  * A known bug exists: the destination port number is fixed at 13579. Config does work for IP but not port.
 +
 ==== System configuration operation ==== ==== System configuration operation ====
  
-The following are ideas on how the device should operate in regard to configuration. +The following considers how the device operates in regard to configuration. 
 Device-server communication is commented in a separate section.. Device-server communication is commented in a separate section..
- 
-If the device is unconfigured, it should use a MAC-address stored in program memory, and stop in an IP gleaning phase. Setting the IP-address of the device using an ARP directed PING should set the device ready for base configuration, where the device starts listening on a given TCP port (4919 decimal , 0x1337 hex). 
  
 === Hardware configuration process === === Hardware configuration process ===
Line 52: Line 60:
 === Normal boot === === Normal boot ===
  
-On a configured boot, the device will read its MAC address data from EEPROM. It will then attempt DHCP configuration of IP address. After DHCP configuration is complete, the device will start reading connected sensors, and sending data to the IP address and port configured in EEPROM using LEMP1documented separately. The device will also respond to ICMP PING.+On a normal boot, the device reads its MAC address data from EEPROM. It then attempts DHCP configuration of IP address. The device starts reading connected sensors, and sends data using LEMP1 (documented separately). The device will also respond to ICMP PING.
  
 === Configuration after normal boot === === Configuration after normal boot ===
 +
 +The configurable options in normal operation are the destination IP address and port number of LEMP1 operation. Device IP address is assigned over DHCP during boot.
 +
 +Device configuration is done using the UDPSet configuration tool, or a compatible tool.
 +  * Configuration is initiated from the device, by pressing Button 0.
 +  * When the button is pressed, LED0 is turned off, the device sends out an UDP packet using broadcast to port 13580 containing the byte-pattern '0xFE8001'. 
 +  * The device starts listening for a configuration packet sent to the device using UDP to port 13580. Packet contents are:
 +    * Config packet cookie, 0x4040
 +    * Server destination IP address as four bytes, highest octet fist, lowest octet last (e.g. the address 10.0.255.1 is sendt as 0x0A 0x00 0xFF 0x01)
 +    * Server destination port number, highest byte first ( e.g. 13579 is sendt as 0x350B)
 +    * The terminating byte 0x3B
 +  * Upon receiving a valid packet, the device sends an ACK package on the form '0x404006'.
 +  * The device applies the recieved parameters, and sends a final summary of used settings, replicating the config packet, but using '0x2020' as magic cookie, and '0x06' as terminating  byte. (e.g. a summary of server setting 10.0.255.1:13579 is acked as '0x20200A00FF01350B06').
 +  * If a config packet is not received after waiting for 30 seconds, the device times out, LED0 is turned on, and operation resumes.
  
 === Configuration tool === === Configuration tool ===
  
 +A configuration tool other than UDPSet may be written and used according to the previous description. The tool is to listen for UDP broadcast on port 13580. Configuration is to be sent after receiving Config REQ '0xFE8001'. Configuration is prepended by the sequence 0x4040, then the four IP quads as separate bytes, leftmost byte first, next the port number as two bytes, MSB first, and finally the terminating byte '0x3B'. The device will respond with a Config ACK on the form '0x404006', and an echo of the config, with lead-in replaced by 0x2020 and lead-out replaced with 0x06.
 +
 +UDPSet is a really simple Qt4 application, with a basic dialog GUI. This interface lets you enter the IP address and port number of your LEMP1 server that the device is to send data to. The 'Send config' button is inactive until the Config Req magic cookie is received. Upon receiving the
 +Config REQ the 'Send config' button is activated and the config may be sent.
 +
 +Note that the device times out waiting for config after 30 seconds.
 +
 +Download of UDPSet versions:
 +  * {{:projects:tempdude-udpset-0.2.tar.gz}}
 +==== LEMP1 ====
 +
 +Writeup of the LEMP1 protocol is still a todo. BUT, a software-based reference implementation exists
 +as tempsend.c, available here: {{:projects:tempsend.c.txt}}
 +
 +Compile tempsend using e.g.
 +
 +  gcc tempsend.c -o tempsend
 +
 +Command syntax for tempsend is:
 +<code>
 +  -s <ip of LEMP server>
 +  
 +  -p <portnumber of LEMP server>
 +  
 +  -i <node id>
 +      Node ID is five bytes, written as hexadecimal digits.
 +      Software Node ID _should_ start with 01, and the last
 +      byte should be a sensor index. i.e. 01 for a single sensor system.
 +      Example of valid Node ID string: 0100FF0201
 +   
 +  -v <value as float>
 +      The value is parsed from string to double, and should be
 +      within the range 155.0 to -55.0
 +</code> 
 +
 +To give an example command, let's send -14.5 degrees centigrade to a LEMP1 server
 +running at 10.0.3.4 port 13579 (default port) using 0x0102030401 as sensor id:
 +
 +  tempsend -s 10.0.3.4 -p 13579 -i 0102030401 -v -14.5
 +
 +A node about sensor ID's: ID's are typically locally significant to the LEMP server
 +you are reporting to, but the following guideline should be followed:
 +
 +  * The sensor ID is to be built up of
 +    * one byte manufacturer ID, using 0x01 for software agents.
 +    * Three bytes Node ID
 +    * One byte sensor index
 +  * The first byte should always be 0x01 for software sensors.
 +  * The next three bytes should be locally unique for each monitoring station
 +  * The last byte should be a sensor index for sensors attached to the monitoring station.
 +
 +So, having a monitoring station with five sensors, reporting using software agent, the sensor
 +ID's can be something like
 +
 +  0100FF0201
 +  0100FF0202
 +  0100FF0203
 +  0100FF0204
 +  0100FF0205
 +
 +where 00FF02 is the "unique" Node ID.
 ===== Development roadmap ===== ===== Development roadmap =====
  
Line 63: Line 146:
  
   * **done** Get hardware   * **done** Get hardware
-    * PIC-MINI-WEB http://www.sparkfun.com/commerce/product_info.php?products_id=7829 +    * **bought** PIC-MINI-WEB http://www.sparkfun.com/commerce/product_info.php?products_id=7829 
-    * PIC-PG1 http://www.sparkfun.com/commerce/product_info.php?products_id=9+    * **bought** PIC-PG1 http://www.sparkfun.com/commerce/product_info.php?products_id=9 
 +      * Did not need this one..
     * PIC-ICSP http://www.sparkfun.com/commerce/product_info.php?products_id=8108     * PIC-ICSP http://www.sparkfun.com/commerce/product_info.php?products_id=8108
-    * Microlab IDC2 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046 +      * Not compatible :( 
-    * DS18B20 tempsensor http://www.sparkfun.com/commerce/product_info.php?products_id=245+    * **borrowed** Microlab IDC2 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046 
 +    * **bought** PIC-ICD2 http://olimex.com/dev/pic-icd2.html 
 +    * **boughtx4** DS18B20 tempsensor http://www.sparkfun.com/commerce/product_info.php?products_id=245
  
   * **done** Get development software for the Microchip-side of development   * **done** Get development software for the Microchip-side of development
-    * Microchip MPLAB IDE http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002  +    * **v7.6** Microchip MPLAB IDE http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002  
-    * compilers from Microchip.+    * **MC18** compilers from Microchip.
  
-  * **done** Get fammiliar with hardware and development platform+  * **done** Get familiar with hardware and development platform
   * **done** Reprogram the device with stock program- and flash content   * **done** Reprogram the device with stock program- and flash content
-  * Remove unwanted components from program. Test programming of stripped code. +  * **done** Remove unwanted components from program. Test programming of stripped code. 
-  * Add DHCP client. Program device and verify DHCP operation. +  * **done** Implement reading of a single attached temperature sensor 
-  * Add simple TCP client, program and verify +  * **done** Implement proof-of-concept LEMP1 server 
-  * Verify that reload of stock software works +  * **done** Add simple LEMP1 implementation 
-  * Figure out how to read/write EEPROM, store and retrieve data on EEPROM +  * **done** Add DHCP client. Program device and verify DHCP operation. 
-  * Verify that reload of stock software works +  * **done** Implement reading of multiple sensors 
-  * Add TCP Server component that accepts connection, reads data and terminates+  * **done** Verify that reload of stock software works 
-  Implement 0x37 configuration +  * **done** Figure out how to read/write EEPROM, store and retrieve data on EEPROM 
-  * Implement IP Gleaning +  * **done** Verify that reload of stock software works 
-  * Implement IP Gleaning0x13 and 0x37 operation +  * Implement LEMP1 server with data storage
-  * Implement reset-on-switch +    WIP: Has proof of concept runningC-code dumping to file, perl-code dumping file to db 
-  * Implement 0x2342 operation +  * Design interface/connector-board 
-  * Implement simple TCP client app sending dummy data +  * Build and QA interface-board 
-  * Add heartbeat LED +  * Create encapsulation for the device.
-  * Implement reading of a single attached temperature sensor +
-  * Implement reading of multiple sensors +
- +
-===== Progress =====+