Presentation is loading. Please wait.

Presentation is loading. Please wait.

Environment Temperature Monitor

Similar presentations


Presentation on theme: "Environment Temperature Monitor"— Presentation transcript:

1 Environment Temperature Monitor
Embedded Systems Programming Environment Temperature Monitor (Support for multiple sensors with auto-detect omitted and faulty sensors) Requirements analysis Selecting sensors, inputs and outputs I/O ports and interfacing Configuration of internal modules

2 Case study - Requirements analysis
Functional requirements of the Environment Temperature Monitor: Detect temperature value from several temperature sensors. Detect humidity from one humidity sensor. Support flexible addition / removal of optional temperature sensors, to support a wide range of deployment scenarios. Sample all sensors periodically (once per 10 seconds). At a slower rate (100 seconds), generate statistics for each sensor (Minimum, Mean, Maximum values over the most-recent 10 samples). Send the statistics, for each sensor, to a central collection node, using a wireless network. Detect omitted sensors, and faults (short circuited or open circuited sensor devices and connection cables to sensors). A signal LED should blink briefly to indicate sample events. A signal LED should blink briefly to indicate ‘generate statistics and send data’ events. Separate LED signals should be used to indicate whether the unit is connected or not connected to the rest of the system (via the wireless network). Since one of these signals will always be in use, these also serve as a power on / functioning indication. Richard Anthony

3 Case study - Requirements analysis
Non-functional requirements: Use very low levels of power. Be compact and suitable for deployment into homes, office environments or other workplaces. Be moderately robust, and resistant to light shocks. Be flexible in deployment in terms of the connection and disconnection of the optional temperature sensors. Automatically detect when an optional sensor is {connected and working, omitted or open circuit, short circuit} Use wireless communication to facilitate ease of deployment and flexibility of deployment. 3 Richard Anthony

4 Case study - Selecting sensors, inputs and outputs
Sensors, and I/O devices for the Environment Temperature Monitor: A single combined digital humidity and temperature sensor is used. This sensor requires the I2C bus (compatible with Atmel’s TWI bus) and thus needs to be connected to the SCL and SDA pins. Up to 8 analogue temperature sensors (LM35) are used. Each requires a single analogue input pin Several low-intensity LEDs are adequate for the signal LEDs. Each requires a single digital output pin ZigBee radio module. Requires USART (Rx and Tx pins). Also requires three handshaking signals: 2 digital outputs and 1 digital input. 4 Richard Anthony

5 Case study - I/O ports and interfacing (1)
Interfacing sensors and I/O devices to specific ports (for ATmega32A), ordered in terms of most specific requirements first. Allocate devices that need specific ports or functionality first: The ZigBee module’s serial interface is connected to Port D bits 0 and 1 which provide the USART Rx and Tx functions respectively. The combined digital humidity and temperature sensor is connected to the Atmel’s TWI bus (SCL pin Port C bit 0 and SDA pin Port C bit 1). The analogue temperature sensors are connected to the Analogue-to-Digital converter, Port A bits 0-7. The ZigBee module’s handshaking signals are connected to Port D bits 4, 5 and 6. The signal LEDs are connected to Port B bits 0, 1 and 2. 5 Richard Anthony

6 I2C Humidity and Temperature sensor
Case study - I/O ports and interfacing ATmega32A Richard Anthony ATmega32A Temperature sensors ZigBee Comms Signal LEDs ZigBee module handshaking I2C Humidity and Temperature sensor 6

7 Case study - I/O ports and interfacing – ATmega1281 Equivalent
Temperature sensors ATmega1281 Case study - I/O ports and interfacing – ATmega1281 Equivalent Richard Anthony ZigBee Comms ZigBee module handshaking I2C Humidity and Temperature sensor Signal LEDs

8 Case study - I/O ports and interfacing – ATmega2560 Equivalent
Temperature sensors ZigBee comms Richard Anthony ZigBee module handshaking I2C Humidity and Temperature sensor Signal LEDs

9 Humidity and Temperature module
Circuit / connections Data (to Atmel µC) GND (0V) 5V Clock signal (from Atmel µC) Sensors 1 HYT 221 Digital Humidity and Temperature module HYT 221 Humidity and Temperature module +5V logic supply SDA VDD SCL GND GND (0V) ATmega32A Data Clock I2C / TWI The Atmel’s internal pull-up resistors must be turned on for SCL and SDA (Port C bits 0,1) Richard Anthony

10 Sensors 2 LM35 precision analogue temperature sensor
Output examples 50mV = 5ºC 210mV = 21ºC 560mV = 56ºC LM35 Temperature sensor +5V logic supply VDD Output GND GND (0V) 270K Ohm pull-down resistor ATmega32A The 270KΩ pull-down resistor was chosen specifically so as to be too large to affect the output of the LM35 (when present), yet allows enough current to flow to hold the Atmel’s pin within 10mV of GND when the LM35 is omitted. Richard Anthony

11 Flow chart (1) Main Start Configure Timer1 (10 second clock)
Configure TWI / I2C bus interface Configure USART (for ZigBee wireless communications) Configure ADC Transmit Data flag == true ? Yes No Transmit aggregated data over ZigBee wireless network SampleClock = 0 Timer1 ISR Start (10-second clock interval) Request sample from digital Humidity and Temperature sensor (triggers TWI ISR when sample ready for reading) Start ADC conversion (read each of the analogue temperature sensors in sequence) Stop ++ SampleClock SampleClock %= 10 11 Richard Anthony

12 Temperature = sensor reading
Flow chart (3) ADC ISR (analogue temperature sensors) Temperature = 0 (signal open circuit / omitted – pull down resistor ensures a reading below the Low threshold) Start (conversion complete) sensor reading < Low threshold ? Yes No Stop Temperature = 100 (signal short circuit) sensor reading > High threshold Temperature = sensor reading (actual sensed temperature range is 2ºC to 80ºC, values outside this range are used to indicate faults or omitted sensors) SampleClock >= 9 ? TransmitData flag = true 12 Richard Anthony

13 Timing diagram 1 10-second clock and sensor sampling
seconds Timer1 (10-second clock) Initiate Analogue sensor sampling Analogue sensor sampling active Initiate Digital Humidity / Temperature Sensor sampling 13 Digital Humidity / Temperature Sensor sampling active Richard Anthony

14 TransmitData flag is set once all 8 ADC channels have been sampled
Timing diagram Analogue sensor sampling 10 seconds Timer ISR starts ADC sampling sequence Timer1 (10-second clock) ADC start conversion (0) (1) (2) (3) … (6) (7) (channel) TransmitData flag is set once all 8 ADC channels have been sampled ADC conversion complete ISR (0) (1) (2) (3) … (6) (7) (channel) ADC clock divider chosen such that total ADC sample time is longer than the digital sensor sampling activity. Thus implies that ALL sampling is complete at this point in time. TransmitData flag Richard Anthony

15 Timer ISR starts Digital sensor sampling sequence
Timing diagram Digital sensor sampling 10 seconds Timer ISR starts Digital sensor sampling sequence Timer1 (10-second clock) Digital sensor data requested (H) (T) via TWI bus (H = humidity, T = Temperature) ADC timing configured to ensure it takes longer than the digital sensor sampling. ALL sampling is complete before the TransmitData flag is set. Digital sensor data available (H) (T) on TWI bus (H = humidity, T = Temperature) TransmitData flag Richard Anthony

16 Timer ISR starts Analogue and Digital sensor sampling sequence
Timing diagram Data management 10 seconds Timer ISR starts Analogue and Digital sensor sampling sequence Timer1 (10-second clock) Sensor sampling active The TransmitData flag is only set on completion of every TENTH sampling activity (i.e. once per 100 seconds) TransmitData flag Compute statistics and reset TransmitData flag Send data to sink node over ZigBee wireless network Richard Anthony

17 Case study - Configuration of internal modules (outline details) ADC
The ADC is configured to sample the 8 analogue input channels in sequence The ISR routine for one conversion re-configures the ADC to convert the next channel in the sequence. External pull-down resistors are used such that unused channels give a near-zero reading, which is used to automatically detect that a particular sensor is omitted. Timers Timer 1 is used to provide a 10-second periodic clock pulse which is used as the basis for all sensor-sampling activity. USART The USART is configured to provide a serial connection (9600 baud) to the ZigBee wireless module. Two-Wire Interface (TWI) The TWI is configured to request data from the combined digital Humidity and Temperature sensor. Richard Anthony


Download ppt "Environment Temperature Monitor"

Similar presentations


Ads by Google