![Atmel STK511 Скачать руководство пользователя страница 28](http://html.mh-extra.com/html/atmel/stk511/stk511_user-manual_3003507028.webp)
STK511 Transmitter Board
STK511 User Guide
5-5
4842B–AVR–10/09
5.2
Software Description
5.2.1
Overview
There are two sample programs included on the accompanying CD that demonstrate the transmitter's
functional capabilities. One called STK511 TX UpDown, increments and decrements a counter and
transmits the count value. The other, called STK511 TX Sensor, utilizes the integral CdS photocell as a
light-intensity sensor and sends an 8 bit digital value corresponding to the voltage measured across the
light sensor.
Button functionality specific to each program is included in the descriptions that follow.
1.
STK511 TX UpDown senses right/left button presses and increments/decrements (respectively) a
counter in the ATtiny13. The count value is transmitted to the companion receiver upon button
release. With the receiver mated through the STK511 to the STK500, the count value is displayed (in
hexadecimal format) on the 8 LEDs of the STK500. When not transmitting the results of an incre-
ment/decrement command, the transmitter is in a low-current-consumption sleep mode.
2.
STK511 TX Sensor demonstrates the capabilities of the A/D converter in the ATtiny13, using the
CdS photocell as a light-intensity sensor. The resistance of the photocell’s output (which is inversely
proportional to the amount of light incident on the sensor) is converted to an input voltage signal to
the A/D converter. The resulting A/D conversion quantization is binned into one of eight value-
ranges, which is transmitted to the companion receiver mated to the STK511. The relative intensity
of the detected light is displayed in bar graph form on the 8 LEDs of the STK500 -- from right to left,
more lighted LED indicate higher light levels incident on the photocell. The two buttons on the trans-
mitter initiate periodic RF transmission of the binned A/D data, as well as determine the transmit
interval. Pressing the right button sets the transmit interval at 0.25 seconds; the left, at 8 seconds.
Sensor readings are sent for approximately 30 seconds, after which the transmitter enters a low-cur-
rent-consumption sleep mode. Periodic transmissions resume when either button is pressed.
5.2.2
Sample Software
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; routine: Main
; calls: Setup, Snooze
; called by:
; function: main pgm
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Main:
RCALL
Snooze
; Sleep
CPI
WDTcounter,0x00; TP - Check for 30 sec timeout here
BRNE
KeepAlive
; TP - If not 30 sec loop but keep sleeping in
between TX
LDI
R16,0x50
; TP - If 30 sec passed turn off the WD Timer
OUT
WDTCR,R16
LDI
R16,0x00
; TP - Sleep until button press starts WD Timer
OUT
WDTCR,R16