1 / 18

Light Sense Lab.

Light Sense Lab. Read data from light(photo diode) sensor, display using oscilloscope. ZigbeX Photo Diode. ZigbeX Photo Diode. Photo diode CDS named CDS is connected to INT0 & ADC0 on Atmega 128(8bit CPU) CDS inputs resistance value varying on light strength Output to ADC0

tmann
Download Presentation

Light Sense Lab.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Light Sense Lab. Read data from light(photo diode) sensor, display using oscilloscope.

  2. ZigbeX Photo Diode

  3. ZigbeXPhoto Diode • Photo diode CDS • named CDS is connected to INT0 &ADC0 on Atmega 128(8bit CPU) • CDS inputs resistance value varying on light strength • Output to ADC0 • Light Sensor Component • Photo component

  4. Photo component • ADCC component • Photo component needs to uses upper level component ADCC.

  5. Read Light strength • Ex. // upper level comp event ADC.dataReady(uint16_t data) { //data -> measured data … } // upper level comp. xxx_function() { call ADC.getData() … } Photo component

  6. Using Oscilloscope

  7. Oscilloscope Lab • Oscilloscope program • Oscilloscope program delivers data from mote to PC via “com” port • Oscilloscope Location • c:\Programfiles\UCB\cygwin\opt\tinyos‐1.x\contrib\zigbex\ Osilloscope • Oscilloscope.nc,OscilloscopeM.nc, &OscopeMsg.h .

  8. Oscilloscope.nc • Oscilloscope.nc • Osilloscope components • UART Comm – connecting to PC • DemoSensorC- Get the light data • TimerC &LedsC configuration Oscilloscope { } implementation { components Main, OscilloscopeM, TimerC, LedsC, DemoSensorC as Sensor, UARTComm as Comm; Main.StdControl ‐> OscilloscopeM; Main.StdControl ‐> TimerC; OscilloscopeM.Timer ‐> TimerC.Timer[unique("Timer")]; OscilloscopeM.Leds ‐> LedsC; OscilloscopeM.ADC ‐> Sensor; … }

  9. Serial Comm. • UARTComm component • UARTComm provides ReceiveMsg interface and SendMsg interface.

  10. OscilloscopeM.nc • OscilloscopeM.nc (1) includes OscopeMsg; module OscilloscopeM { provides interface StdControl; uses {     … // interfaces } } implementation {    … // variables command result_t StdControl.init() {      … // initialization return SUCCESS; }

  11. OscilloscopeM.nc • OscilloscopeM.nc (2) command result_t StdControl.start() { call SensorControl.start(); call Timer.start(TIMER_REPEAT, 125); call CommControl.start(); return SUCCESS; } command result_t StdControl.stop() {     … return SUCCESS; } event result_t Timer.fired() { return call ADC.getData(); }

  12. OscilloscopeM.nc • OscilloscopeM.nc (3) async event result_t ADC.dataReady (uint16_t data) { struct OscopeMsg *pack; atomic { pack = (struct OscopeMsg *) msg[currentMsg].data; pack‐>data[packetReadingNumber++] = data; readingNumber++; dbg(DBG_USR1, "data_event\n"); if (packetReadingNumber == BUFFER_SIZE) { post dataTask(); } } if (data > 0x0300) call Leds.redOn(); else call Leds.redOff(); return SUCCESS; }

  13. OscilloscopeM.nc • OscilloscopeM.nc (4) task void dataTask(){ struct OscopeMsg *pack; atomic { pack = (struct OscopeMsg *)msg[currentMsg].data; packetReadingNumber = 0; pack‐>lastSampleNumber = readingNumber; } pack‐>channel = 1; pack‐>sourceMoteID = TOS_LOCAL_ADDRESS; if (call DataMsg.send(TOS_UART_ADDR, sizeof(struct OscopeMsg), &msg[currentMsg])) { atomic { currentMsg ^= 0x1; } call Leds.yellowToggle(); } } event result_t DataMsg.sendDone (TOS_MsgPtr sent, result_t success) { return SUCCESS; }

  14. Oscilloscope Lab.

  15. Oscilloscope lab. 1 • Starts cygwin. Move to folder as follows • make zigbex cd /opt/tinyos‐1.x/contrib/zigbex cd Oscilloscope

  16. Oscilloscope lab. 2 • ZigbeX Download • Run AVR studio at Windows • Tolol->auto connect-> browse main.hex located at • c:\Programfiles\UCB\cygwin\opt\tinyos‐1.x\contrib\zigbex\Oscilloscope\ build\ zigbex

  17. Oscilloscope lab. 3 • Java application • When it is configured correctly, • Move to/opt/tinyos‐1.x/tools/javain Cygwin • Type as follows export MOTECOM=serial@COM1:57600 cd /opt/tinyos‐1.x/tools/java java net.tinyos.oscope.oscilloscope

  18. Oscilloscope result • Result

More Related