Difference between revisions of "Activities/Turtle Art/Using Turtle Art Sensors"

From Sugar Labs
Jump to navigation Jump to search
Line 415: Line 415:
  
  
The diode is still required. The original cat's whisker diode was made with galena crystals. [[http://en.wikipedia.org/wiki/Cat%27s-whisker_detector]]
+
The diode is still required. The original cat's whisker diode was made with galena crystals. [[http://en.wikipedia.org/wiki/Cat%27s-whisker_detector]] Other materials are iron pyrite ("fool's gold", iron disulfide), silicon, molybdenite (MoS2), and silicon carbide (carborundum, SiC). It is also possible to use a rusty razor blade (iron oxide).
  
 
==Links==
 
==Links==

Revision as of 01:02, 4 December 2010

CAUTION. APPLYING EXTERNAL POWER SOURCES TO THE XO LAPTOP'S MICROPHONE INPUT CAN CAUSE PERMANENT DAMAGE. BE SURE YOU READ AND UNDERSTAND THE FOLLOWING BEFORE CONNECTING POWER SOURCES TO YOUR LAPTOP. DO NOT CONNECT TO HAZARDOUS VOLTAGES

Specifications

The OLPC XO can measure external inputs with its microphone jack.

Measure tut 1 24.jpg

Standard 3.5mm 2-pin switched mono microphone jack; selectable 2V DC bias; selectable sensor-input mode (DC or AC coupled); selectable +20dB boost.

If using a stereo plug it is the tip (usually the red wire) plus the earth.

The XO1 is protected at the input by a 5V zener diode. The allowable input is -0.5V to 5V. Inputs outside this range will cause excessive current and damage. Even a single 1.5V battery can cause damage if connected reverse polarity.

The XO1.5 is protected by a resistor,(1/16W 470 ohm SMD0402) and a pair of diodes to ground and to +3.3V which should protect -6V to +9V continuously, and up to higher voltages for shorter periods of time. Similar protection is planned for the XO1.75.

For the XO1, the addition of a 150k ohm series resistor would (I expect, no guarantee) give a reduced sensitivity in voltage mode (0-4V) but allow inputs to +- 100V without damage. Input impedance in resistance, volume and pitch modes is much lower but a 1k ohm series resistor should still allow inputs to +-12V.

If applying an external voltage to the XO1, it is highly recommended that test leads be made up with a microphone plug and an inbuilt series resistor.

Audio 680 ohm.jpg

680 ohm series resistor on a 3.5mm audio plug

Test leads with a zener diode and series resistor would expand the safe range for the XO1.5 and XO1.75.

Damage can also be caused by applying voltages between the grounds of any of the external sockets.

Voltage Mode

XO1

Measurement range is DC 0.4V to 1.85V. Voltages less than 0.4V report as 0.4V, voltages greater than 1.85V report as 1.85V. Accuracy is around 3% of full scale. Impedance 140k ohms to a 0.6V bias.

Voltage sensor.jpg

XO1.5

0.17V - 3.0V, impedance 15k ohms to a 1.7V bias. (Still buggy, use a sound, volume or pitch block first to set up the electronics.)

Resistance Mode

XO1

Measurement range is 750 ohms to 14k ohms, resistances less than 700 ohms report as 700 ohms, greater than 14k ohms report as 14k ohms. Accuracy is around 5% with respect to the full scale voltage measured across the resistor, this translates to round 50 ohms at bottom scale and 2k ohms at top scale. (A series protection resistor of around 700 ohms would give a measurement range of 0 - 13k ohms and protection against +-8V inputs.)

XO1.5

2k ohms to open circuit. (Still buggy, use a sound, volume or pitch block first to set up the electronics.)

Pitch Mode

Pitch Mode is set up for the internal microphone but can also be accessed through the microphone jack, 2V DC bias is on, AC coupled, +20dB boost is on. The frequency of the strongest component is reported in Hz. The resolution is +-8Hz

Sound Mode

Raw data ranging +-32000 XO1, +-10,000 XO1.5. Set up is AC coupled, Bias on, Boost on. Sensitivity is 2uV per unit or 16mV full scale, so sine wave clipping sets in at round 10mV RMS on the XO1. For the XO1.5, sensitivity is approximately 8uV per unit.

With the inbuilt microphone, normal speech is approximately +-1000 XO1 and +-200 XO1.5.

Volume Mode

Ranging 0 to 32000 XO1, 0 to 10,000 XO1.5, set up is for microphone, AC coupled, Bias on, Boost on. Volume is the rectified average of Sound, ie. volume=average(abs(sound))

Graphing the output

Ta oscilloscope.jpg

Source file as doc File:Oscillo.doc

Measuring Temperature

(For instructions on using the LM35 sensor, see http://wiki.laptop.org/go/Making_XO_sensors/Making_a_Temperature_Sensor and http://www.reducativa.com/xo/man-sis-sensoresdetemperatura.pdf - in Spanish)

Ntc thermistor.jpg

Connect the TDC05C247 thermistor, Specifications:

  • NTC (Negative Temperature Coefficient) Thermistor
  • Operating temperature range: -20 Celsius ~ +125 Celsius
  • Maximum power rating: 500mW
  • Nominal resistance at 25 Celsius 4.7k ohms

Left, the resistance was plotted against temperature and the curve of best fit calculated. Right the blocks convert from resistance to temperature C.

Ntc thermistor calibration.jpg Python function thermistor.jpg

Teaching ideas:

  • measure resistance and temperature with a thermometer
  • construct your own calibration function
  • exponential decay
  • diurnal temperature
  • heat of reaction, weak acid and base

24 hours temperature

The following Turtle Art project captures and graphs 24 hours temperature. You may need to set your time zone and disable power management in 'My Settings'.

Temp24hrs.jpg

File:Oscillo daily temp.doc ta project as doc (rename to .ta outside of Sugar or copy contents to a ta project)


Logged temperature.jpg

Measuring Soil Moisture

Two probes into the soil measured in resistance mode. Only a few cm of wire are required to bring soil within the resistance range of the XO1, 700 ohms to 14k ohms (XO1.5, 2k ohms to open circuit).

Measuring Water Salinity

Place two copper wires into a glass of water. Experiment with your water and wire diameter, I was able to get a measurement of 5k ohms with 12cm of wire in tank water.

Conductivity rainwater.jpg

Use the graphing software shown previously but set the turtle y to resistance/50 to scale to the screen size, each 100 on the vertical scale corresponds then to 5000 ohms.

Conductivity rainwater graph.jpg

The graph shows first an unconnected circuit (14k ohms) then the circuit is connected. Note how the resistance slowly rises. The terminals are reversed mid screen, the sudden dip and gradual rise are more pronounced. Why is this? Electrolysis products (microscopic bubbles of hydrogen and oxygen for pure water) build up near the electrodes.

Conductivity salt water.jpg

Small amounts of salt are added to tank water, bringing the resistance down from 5k ohms to 2k ohms. Salt added on two occasions

Generating Electricity from a Changing Magnetic Field

Requires a refrigerator magnet, often given away free with advertising on it.

Wrap 50 turns of insulated wire onto a nail and connect the two ends to a phono plug as shown (if it is a stereo plug, probably the red wire and the copper shield). Connect the phono plug to the microphone input. Graph the Sound or Volume block. This is better with the XO1 than the XO1.5 because it is more sensitive.

Copper wire on nail.jpg.JPG Fridge magnet.jpg

  • Wipe the sharp end rapidly over the back of the fridge magnet, try both directions.
  • Try a different number of turns of wire
  • Try moving the nail more slowly, what happens?
  • What is happening?
  • Why does it work better on one axis of the magnet? (hint rub 2 magnets together)
  • Graph pitch. Explain the result.

Carbon Microphone

Microphone diagram.jpg

Required:

  • charcoal
  • aluminium foil
  • plastic lid
  • wire
  • rubber band

Carbon microphone materials.jpg

Crush the charcoal to a fine powder. Make a hole in the centre of the lid. Strip a small amount of insulation from the wire, pass the wire through the hole. Then place a piece of foil against the wire. Fill the lid with crushed charcoal. Place foil over the charcoal and secure with a rubber band. Connect a wire to this foil. Try to get the foil under tension.

Complete microphone.jpg

Experiment with the fineness of the crushed charcoal and the tension in the foil. The more squashed the charcoal is, the lower the resistance. With the XO1, aim for a resistance of around 3k ohms and for the XO1, definitely 700 ohms < resistance < 14k ohms. (XO1.5 2kohms<resistance<open circuit).

Graph the resistance, pressing on the foil changes the resistance. You have built a pressure sensor. It can also sense air pressure. You have built a microphone. Change to Sound sensing. On my first try I was able to sense clapping.

Lemon battery

See http://en.wikipedia.org/wiki/Lemon_battery

Lemon battery.jpg

With a copper wire and galvanised nail, the measured voltage is 0.93V, comfortably within the measurement range of the XO1 laptop. The laptop produced negligible loading on the open circuit voltage on the XO1. With copper wire and an ungalvanised nail the voltage was 0.49V.

The internal resistance of the lemon battery is around 10k ohms, the input impedance of the XO1.5 of 15k ohms introduces considerable error.

Experiment with different materials. Try lemon cells in series.

Door bell / Burglar alarm

Visitors touch the two wires together to ring your door bell. Alternatively, arrange two wires to touch as your door opens.

Here are the Turtle blocks:

Doorbell.jpg

The Python Code Block Pythoncodeblock.jpg is used to sound an alarm in your loudspeakers.

You need to type the following into Pippy and save to the Journal. Type it exactly as shown, the indents on the last 3 lines are important, for the characters '-l 1' the first is an 'el' and the second a 'one'.

Doorbell python.jpg

Then in Turtle Art, load the Pippy code TAPippyButton.svg into the Python Code Block Pythoncodeblock.jpg , then run your program.

Two-tone alarm

Use the following Turtle blocks and Pippy code for a warbling alarm

Warbling alarm TA.jpg

2tone python.jpg

How it works: the 1000 and 1100 blocks are input x in the Python code. The -f option in speaker-test is the frequency, {0} gets replaced by x which in turn is replaced by 1000 or 1100 so speaker-test is sent either -f 1000 or -f 1100 giving frequencies of 1000 Hz or 1100 Hz.

Measuring AC Amps

An inexpensive current transformer can be built to measure AC amps.

50 turns of insulated copper wire are wrapped on a soft iron bar. Threaded shaft, nuts and another bar complete the magnetic circuit.

Current transformer1.jpg

Assembled, with optional red heat shrink. The current in the black wire is measured. The 50 turns of fine wire connect to the XO1 in Volume Mode. The maximum is about 15 amps AC before clipping of the AC waveform occurs.

Current transformer2.jpg

To change sensitivity, vary the number of turns.

Current transformer sensitivity.jpg

Volume measured on XO1, 50 turns of wire.

Measuring power

DO NOT CONNECT TO MAINS POWER. DO NOT WORK NEAR EXPOSED ELECTRICAL CONNECTIONS.

Power = AC Volts x AC Amps x Power Factor

In mains circuits, the voltage is usually known. Typically, power factor is 0.8 or 1.0 depending on the electrical load.

lesson ideas (Spanish)

Importing Logged Data into other Activities

Saving logged data to the clipboard

Logged data can be pushed onto the heap, then when logging is finished, the contents of the heap can be placed onto the clipboard for use in other Activities.

Copy the following code into Pippy (from V104 this is included with the samples)

def myblock(lc, x):
    from gtk import Clipboard
    from tautils import data_to_string
    Clipboard().set_text(data_to_string(lc.heap))
    return

Save to the journal, then in Turtle Art, load the Pippy code TAPippyButton.svg into the Python Code Block Pythoncodeblock.jpg. When the Python Code Block is executed, the contents of the heap are placed on the clipboard.

Example, import temperatures into Gnumeric spreadsheet

For example, temperatures are logged and then copied to the clipboard. This builds on measuring with a thermistor and the XO1 previously. First load the Pippy code TAPippyButton.svg. The temperature is measured and pushed to the heap, then a 5 second delay. This repeats 20 times. Then the contents of the heap are copied to the clipboard.

Temp to clip.jpg

TurtleArt can be run in Gnome on the XO. The data is then pasted to a Gnumeric spreadsheet. The data is converted text to columns (the Data menu), the leading '[' and trailing ']' are manually deleted, the data is graphed. (Unfortunately, on the XO, the Data, text to columns dialog boxes are off screen, alt f alt f shift tab shift tab shift tab allow conversion of comma separated data.)

Sensor imported gnumeric.JPG

Temperature data imported into Gnumeric spreadsheet

Saving logged data to the Journal

The following code File:Saveheaptojournal.doc (from V104 this is included with the samples) in the Python Code Block will save the heap as a text file named 'heap' in the Journal. The file 'heap' can then be opened with Write or Edit.

def myblock(lc, x):
    from tautils import get_path, data_to_file
    from sugar.activity import activity
    from gettext import gettext as _
    import os.path
    from sugar.datastore import datastore
    from sugar import profile
    # Save the heap to a file (JSON-encoded)
    heap_file = os.path.join(get_path(activity, 'instance'), 'heap.txt')
    data_to_file(lc.heap, heap_file)
    # Create a datastore object
    dsobject = datastore.create()
    # Write any metadata (specifically set the title of the file
    #                     and specify that this is a plain text file).
    dsobject.metadata['title'] = _('heap')
    dsobject.metadata['icon-color'] = profile.get_color().to_string()
    dsobject.metadata['mime_type'] = 'text/plain'
    dsobject.set_file_path(heap_file)
    datastore.write(dsobject)
    dsobject.destroy()
    return

Logging at regular intervals

The following takes readings at regular intervals, in this case 10 seconds and pushes the result to the heap. For example, use for daily temperature, light, power, noise. Taking readings hourly, quarter hourly etc.

Timed logging.jpg

Acceleration on an inclined plane

Ballonplane.jpg


The XO laptop can be used to do experiments on motion, rolling a ball down a ramp. The XO1.5 is faster and better suited for this. Inexpensive sensor switches can be made of aluminium foil. The switches are 5cm wide to provide an 'on' time which is long enough to measure.


Acceleration setup.jpg Foil sensor switch.jpg


The logging rate can be increased (Turtle Blocks104) by patching one of the Turtle Art files, talogo.py in directory home/olpc/Activities/TurtleArt.activity/TurtleArt changing self.max_samples from 1500 to 150, This reduces the repeat loop from 12mS to 4mS but there is around 50mS jitter. Datalogging can be done without patching the file, using wide switches and shallow ramps keeps the events within the capability of the XO laptop.


Shown below is a triggerable oscilloscope with calibrated timebase. Action 1 clears the screen and draws the scale, the program waits in action 2 until triggered by the first switch. The graphing then starts, time() in seconds is multiplied by 500 to set the horizontal position so 500 screen units or 5 squares equals one second.


Triggerableoscilloscope.jpg

File:Singleshottriggerableoscilloscope.doc TurtleArt project as doc


Switches were placed at 20cm, 60cm, 100cm, 140cm, and 180cm along a ramp of length 180cm and height 25cm.

The oscilloscope data is shown below, each square is approximately 200mS


Accel oscilloscope.jpg


The match between theory and experiment is shown below. Note, the mathematics for a rolling ball is not simple, the potential energy is converted into translational kinetic energy, Kt and rotational kinetic energy, Kr.

Mgh = Kt + Kr = 1/2 Mv^2 + 1/2 Iw^2

For a solid sphere, Kt/Kr =5/2 (see Work and energy in rolling motion or Wikipedia)


Acceleration.jpg

File:Acceleration.ods

A simpler experiment is to accelerate a ball down a curved ramp, measure the horizontal exit velocity with two switches and predict the landing position as shown below. The ramp is preferably curved so that the ball is not bouncing when it hits the switches.

Falling ball.jpg Parabola fall.JPG Parabola timing.jpg

h = 1/2 g t^2
t=sqrt(2h/g)
horizontal distance = vt = v x sqrt(2h/g)

In this case, switch spacing is 0.5m, h=0.6m, time 1.9 squares @200mS per square, g=9.8 and the horizontal distance was 0.4m

distance = v x sqrt(2h/g)
= 0.5/0.38 x sqrt (2x 0.6/9.8)
= 0.46m  (measured 0.4m)

Light dependant resistor (LDR)

The ORP12 is a 'classic' cadmium sulphide photocell. Tests were done on a LDR that is 'similar to Philips ORP12'

Ldr.jpg

http://www.jaycar.com.au/productView.asp?ID=RD3480

XOandPcell.jpg

For this cell, the calibration was Lux = 3 * 10^8 * (R^ -1.5034)

Ldr calibration.jpg

For the XO1 (700 ohms -14k ohms) the range is 170 Lux to 15000 Lux (brighter home artificial light to outdoor overcast).

For the XO1.5 (2k ohms - open circuit) the range is 2 Lux to 4000 Lux (dim home artificial lighting to indoor daylight).

24hrlux blocks.jpg 24hrlux.jpg

Turtle Art project as doc File:Turtle Art lux.doc

Photovoltaic panel

IT IS RECOMMENDED THAT A SERIES PROTECTION RESISTOR BE BUILT INTO THE PHONO PLUG AND LEADS IF USING AN EXTERNAL VOLTAGE

Shown is the solar cell from the D.LIGHT S250 [[1]]

It has a 6V solar cell, the outer connection is -ve and the inner +ve

Photovoltaic.jpg

A voltage divider is needed to bring it into the range of the XO1 0.4V to 1.85V (XO1.5 0.17 to 3.0V). With the values shown below, the sensitivity is reduced by

1k/(1k +2.7k) = 1/3.7

giving a maximum of 6.8V XO1 or 11.1V XO1.5

PV voltagedivider.jpg

RC time constant

IT IS RECOMMENDED THAT A SERIES PROTECTION RESISTOR BE BUILT INTO THE PHONO PLUG AND LEADS IF USING AN EXTERNAL VOLTAGE

Rc cct.jpg

The theoretical time constant for a parallel resistor/capacitor is

T = RC

T in seconds, R in ohms and C in farads

Ta oscilloscope rc.jpg

Turtle Art project as doc File:Oscillo with trigger 1rc.doc

The plot below was drawn by Turtle Art (black lines and annotations were added later). C was 4uF, the load provided by the XO is in the order of 100k ohms. In the two plots, Rx was 100k ohms and open circuit. The calculated resistance of the XO1 is

R = T/C
= 0.32/(4x10^-6) = 80k

and the parallel resistance of 100k and the XO1 is estimated as

R = T/C
= 0.14 /(4x10^-6) = 35k

Rc-time.jpg


This Turtle Art project File:Turtle Art Activityrcpushstack.doc (as doc, rename from .doc to .ta in Windows or Linux or open as doc and paste into a Turtle Art session) graphs and also writes the time/voltage values to the screen.

RCprint values.jpg

This project will also copy the time/voltage values to the clipboard if the Pippy sample code copy_from_heap.py is copied to the Journal TAPippyButton.svg and then loaded from the Journal into the Python Code Block Pythoncodeblock.jpg(click on the code block). Shown below, the time/voltage values are pasted into a Write session.

RC data to clip.jpg

The XO as an audio amplifier

Turtle Art is not required. The following command in Terminal Terminal ico.jpegpasses data from the microphone socket to the speaker. You may need to disable power management.

 arecord | aplay

You might want to adjust the settings after reading arecord --help and aplay --help

For example, amplify the output of a crystal radio [[2]]

XO crystalradio.jpg Xtalradioschematic.jpg

This worked better on the XO1.5, presumably because of its higher processing speed. The headphones are omitted. A 0.1uF capacitor is connected between the radio output and the XO input to isolate the detector diode from the XO's DC bias. Theory predicts that a resistor to ground would be necessary at the radio output but practice indicates otherwise.

You can construct most of the crystal radio from common materials

Inductor.jpg

The tuned circuit inductor, 75 turns of insulated wire on a toilet paper core.

Capacitor.jpg

The tuned circuit capacitor, two sheets of aluminium foil approximately 10cm x 10cm sitting loosely and separated by cling wrap gave a resonant frequency of approximately 1MHz with the above inductor.


The 0.1uF capacitor can be made in the same way, the tuning capacitor is estimated at 100pF (10^-10 F) when sitting loose. The coupling capacitor needed is of the order of 0.1uF (10^-7 F). Tightly rolling the layers reduces the plate separation and a workable coupling capacitor was made by tightly rolling only 10cm x 10cm plates.


The diode is still required. The original cat's whisker diode was made with galena crystals. [[3]] Other materials are iron pyrite ("fool's gold", iron disulfide), silicon, molybdenite (MoS2), and silicon carbide (carborundum, SiC). It is also possible to use a rusty razor blade (iron oxide).

Links