This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lab9 [2016/01/05 16:45] dan.tudose [Voltage] |
lab9 [2018/01/25 19:00] (current) narcisa_ana.vasile [Voltage] |
||
---|---|---|---|
Line 10: | Line 10: | ||
$ cd tests/ | $ cd tests/ | ||
$ make NODE=3 -j10 | $ make NODE=3 -j10 | ||
- | $ make udp-client.avr-zigduino.u AVRDUDE_PORT=/ | + | $ make udp-client.sparrow.u AVRDUDE_PORT=/ |
- | $ make udp-server.avr-zigduino.u login AVRDUDE_PORT=/ | + | $ make udp-server.sparrow.u login AVRDUDE_PORT=/ |
</ | </ | ||
Line 32: | Line 32: | ||
===== Shell ===== | ===== Shell ===== | ||
- | The shell is a very powerful feature of Contiki. Within this OS lies a fully-featured command shell. The shell in the avr-zigduino | + | The shell is a very powerful feature of Contiki. Within this OS lies a fully-featured command shell. The shell in the sparrow |
==== Building ==== | ==== Building ==== | ||
Line 85: | Line 85: | ||
==== blink & kill ==== | ==== blink & kill ==== | ||
- | Try "blink 100 &" to start blinking the LED's for 100 times. Notice the '&' | + | Try "blink 100 &" to start blinking the LED's for 100 times. Notice the '&' |
Then type "kill blink" when you're done admiring your blinking lights. | Then type "kill blink" when you're done admiring your blinking lights. | ||
Line 114: | Line 114: | ||
Individual Sensors | Individual Sensors | ||
- | Contiki defines macros to provide a standard interface to sensors. Each sensor gets its own module under platform/avr-zigduino/dev e.g. temperature-sensor.c. This module is responsible for interfacing with the hardware to collect the actual sensor value. Each sensor module produces one value each time it's requested. | + | Contiki defines macros to provide a standard interface to sensors. Each sensor gets its own module under platform/sparrow/dev e.g. temperature-sensor.c. This module is responsible for interfacing with the hardware to collect the actual sensor value. Each sensor module produces one value each time it's requested. |
==== Message Builder ==== | ==== Message Builder ==== | ||
Line 134: | Line 134: | ||
==== Node Images: rpl-collect ==== | ==== Node Images: rpl-collect ==== | ||
- | Build the rpl-collect example. This brings together all the client-side components, and creates two firmware images. One for the senders, and one for the sink. Note that the avr-zidguino | + | Build the rpl-collect example. This brings together all the client-side components, and creates two firmware images. One for the senders, and one for the sink. Note that the sparrow |
==== Building ==== | ==== Building ==== | ||
Line 142: | Line 142: | ||
< | < | ||
$ cd examples/ | $ cd examples/ | ||
- | $ make TARGET=avr-zigduino | + | $ make TARGET=sparrow |
$ make PERIOD=15 NODE=3 -j10 | $ make PERIOD=15 NODE=3 -j10 | ||
- | $ make udp-sender.avr-zigduino.u AVRDUDE_PORT=/ | + | $ make udp-sender.sparrow.u AVRDUDE_PORT=/ |
- | $ make udp-sink.avr-zigduino.u AVRDUDE_PORT=/ | + | $ make udp-sink.sparrow.u AVRDUDE_PORT=/ |
$ make login AVRDUDE_PORT=/ | $ make login AVRDUDE_PORT=/ | ||
</ | </ | ||
Line 159: | Line 159: | ||
==== Host PC: collect-view ==== | ==== Host PC: collect-view ==== | ||
- | Now you'll want to watch your data coming through, which is what the collect-view java app does for us. Note that I made a few modifications for Zigduino, so be sure to build a fresh copy. When running it, send in the device where the sink node is connected. | + | Now you'll want to watch your data coming through, which is what the collect-view java app does for us. Note that I made a few modifications for Sparrow, so be sure to build a fresh copy. When running it, send in the device where the sink node is connected. |
< | < | ||
$ cd tools/ | $ cd tools/ | ||
Line 172: | Line 172: | ||
==== Button ==== | ==== Button ==== | ||
- | Contiki designates one button to be the ' | + | Contiki designates one button to be the ' |
{{ :: | {{ :: | ||
==== Temperature ==== | ==== Temperature ==== | ||
- | The Atmega128RFA1 has an internal temperature sensor, so the avr-zigduino | + | The Atmega128RFA1 has an internal temperature sensor, so the sparrow |
{{ :: | {{ :: | ||
Line 183: | Line 183: | ||
==== Voltage ==== | ==== Voltage ==== | ||
- | It's interesting to know how the battery is doing. While there is a " | + | It's interesting to know how the battery is doing. While there is a " |
What we do instead is hook up the battery voltage to analog pin A1, and read that. The chip uses an internal reference voltage of 1.6, so we first have to divide down the battery voltage into a measurable range. I am using a voltage divider circuit with a 1M and 470k resistors, so when the ADC pin reads 1.6V, there is actually 5.0V coming in through the battery. Here is a simple schematic to explain: | What we do instead is hook up the battery voltage to analog pin A1, and read that. The chip uses an internal reference voltage of 1.6, so we first have to divide down the battery voltage into a measurable range. I am using a voltage divider circuit with a 1M and 470k resistors, so when the ADC pin reads 1.6V, there is actually 5.0V coming in through the battery. Here is a simple schematic to explain: | ||
Line 202: | Line 202: | ||
Values 0-7 are added by the sink after it receives the message from the sender, before it sends it up to the java app. DATA_LEN refers to the final length of the data which the sink is printing for the java app. | Values 0-7 are added by the sink after it receives the message from the sender, before it sends it up to the java app. DATA_LEN refers to the final length of the data which the sink is printing for the java app. | ||
- | < | + | < |
- | | + | public static final int DATA_LEN = 0; |
+ | public static final int TIMESTAMP1 = 1; | ||
+ | public static final int TIMESTAMP2 = 2; | ||
+ | public static final int TIMESYNCTIMESTAMP = 3; | ||
+ | public static final int NODE_ID = 4; | ||
+ | public static final int SEQNO = 5; | ||
+ | public static final int HOPS = 6; | ||
+ | public static final int LATENCY = 7; | ||
</ | </ | ||
==== Sender Header ==== | ==== Sender Header ==== | ||
Line 209: | Line 216: | ||
Values 8-19 are added by the sender to give information about the sender node and its position on the network. " | Values 8-19 are added by the sender to give information about the sender node and its position on the network. " | ||
- | < | + | < |
- | public static final int DATA_LEN2 = 8; public static final int CLOCK = 9; public static final int TIMESYNCHTIME = 10; public static final int TIME_CPU = 11; public static final int TIME_LPM = 12; public static final int TIME_TRANSMIT = 13; public static final int TIME_LISTEN = 14; public static final int BEST_NEIGHBOR = 15; public static final int BEST_NEIGHBOR_ETX = 16; public static final int RTMETRIC = 17; public static final int NUM_NEIGHBORS = 18; public static final int BEACON_INTERVAL = 19; | + | public static final int DATA_LEN2 = 8; |
+ | public static final int CLOCK = 9; | ||
+ | public static final int TIMESYNCHTIME = 10; | ||
+ | public static final int TIME_CPU = 11; | ||
+ | public static final int TIME_LPM = 12; | ||
+ | public static final int TIME_TRANSMIT = 13; | ||
+ | public static final int TIME_LISTEN = 14; | ||
+ | public static final int BEST_NEIGHBOR = 15; | ||
+ | public static final int BEST_NEIGHBOR_ETX = 16; | ||
+ | public static final int RTMETRIC = 17; | ||
+ | public static final int NUM_NEIGHBORS = 18; | ||
+ | public static final int BEACON_INTERVAL = 19; | ||
</ | </ | ||
==== Sensor Message ==== | ==== Sensor Message ==== | ||
Line 216: | Line 234: | ||
Values 20-26 are the actual sensor values measured by the sensor modules and collected by the message builder. | Values 20-26 are the actual sensor values measured by the sensor modules and collected by the message builder. | ||
- | < | + | < |
- | | + | public static final int BATTERY_VOLTAGE = 20; |
+ | public static final int BATTERY_INDICATOR = 21; | ||
+ | public static final int LIGHT1 = 22; | ||
+ | public static final int LIGHT2 = 23; | ||
+ | public static final int TEMPERATURE = 24; | ||
+ | public static final int HUMIDITY = 25; | ||
+ | public static final int RSSI = 26; | ||
</ | </ | ||
==== Interpretation ==== | ==== Interpretation ==== | ||
Line 223: | Line 247: | ||
And some more clues on how to interpret these from SensorData.java | And some more clues on how to interpret these from SensorData.java | ||
- | < | + | < |
- | | + | this.nodeTime = ((values[TIMESTAMP1] << 16) + values[TIMESTAMP2]) * 1000L; |
+ | |||
+ | public static String mapNodeID(int nodeID) { | ||
+ | return "" | ||
+ | } | ||
+ | |||
+ | public double getTemperature() { | ||
+ | return -39.6 + 0.01 * values[TEMPERATURE]; | ||
+ | } | ||
+ | |||
+ | public double getBatteryVoltage() { | ||
+ | return values[BATTERY_VOLTAGE] * 2 * 2.5 / 4096.0; | ||
+ | } | ||
+ | |||
+ | public double getRadioIntensity() { | ||
+ | return values[RSSI]; | ||
+ | } | ||
+ | |||
+ | public double getLatency() { | ||
+ | return values[LATENCY] / 32678.0; | ||
+ | } | ||
+ | |||
+ | public double getHumidity() { | ||
+ | double v = -4.0 + 405.0 * values[HUMIDITY] / 10000.0; | ||
+ | if(v > 100) { | ||
+ | | ||
+ | | ||
+ | return v; | ||
+ | } | ||
+ | |||
+ | public double getLight1() { | ||
+ | return 10.0 * values[LIGHT1] / 7.0; | ||
+ | } | ||
+ | |||
+ | public double getLight2() { | ||
+ | return 46.0 * values[LIGHT2] / 10.0; | ||
+ | } | ||
</ | </ |