Measure: Difference between revisions
(s/w task list updated) |
|||
Line 207: | Line 207: | ||
11. Scale RMS, AVG and Pk Pk display values to correspond the voltage values. |
11. Scale RMS, AVG and Pk Pk display values to correspond the voltage values. |
||
12. Installation of NumPy and related dependancies on XO |
12. Installation of NumPy and related dependancies on XO OR convert code to use Numeric |
||
13. Journal Integration |
13. Journal Integration |
Revision as of 04:06, 25 July 2007
Introduction
Children learn by doing things. It is said "Give the child a hammer, and the world are his nails".
This activity is a tool that allows kids an expression of their curiosity. It is a tool that allows kids to explore and learn by doing, by connecting and observing span physical phenomena and real world events. Kids would learn by recording and observing the physical phenomena and by connecting their observations to a previously learned concept, or even better - learn the concept based on the experiments and observation.The basic functionality of this activity spans being able to measure DC and AC voltages by observing them on a oscilloscope like interface, logging data at a specified time interval and drawing the graph of logged data.
WARNING : Do not measure the mains voltage, it would destroy your XO
Elements of the Measure activity
- There is a 1050 X 800 pixels window in which one sees the waveform. There is a light Grey colored grid in the background.
- A slider for selecting different frequency ranges (top slider)
- A slider for selecting the sensitivity of the display - along the Y axis (bottom slider)
- A button to select AC measurement or DC measurement
- A button to switch Off/On the internal bias - Some microphones don't require an internal bias, most sensors do require a bias.
- A button to Stop/Start the waveform display
- Radio buttons to selectable data logging interval
- A button to Start / Stop the data logging and record it onto a file
- Draw graph of logged data from a previously recorded log file
A short video
<youtube>FE1ufEIXLVo</youtube>
--TODO shoot video again--
Learning activities
1. Record animal sounds , for example, sounds of birds and observe their waveforms. Which of these are high frequency sounds, which are the low frequency ones ? Adjust the frequency sliders accordingly.
2. Whistle into the mic and compare the loudness and frequency of whistles by observing the waveforms.
3. Turn the sensitivity slider up to the maximum and observe ambient noise - in a quiet room , near a noisy road
4. Measure the voltage of an AA size pencil cell. What settings do you use ? AC or DC ?
5. Measure resistance of water , other liquids
6. Log temperature using a temperature sensor at one hour intervals. When in the day is it the hottest ? The coldest ?
7. Some very interesting sensor ideas given by Arnans Roger , see - http://padthai.media.mit.edu:8080/cocoon/gogosite/documentation/makingSensors.xsp?lang=en
(Ideas 1 and 2 given by Erik Blankenship)
All ideas presented here are not necessarily supported by the current version of the measure activity.
TODO - add full pages of each activity including video
Downloading and running the activity on the XO
git-clone git://dev.laptop.org/projects/measure/
This would download all the relevant code in a folder 'measure'. Within this the folder Measure.activity is the activity for the XO and should be copied into the location /usr/share/activities on the XO. If you are using sugar-jhbuild emulation, then you should copy it to <sugar-jhbuild>/build/share/activities/ folder where <sugar-jhbuild> is the path of the sugar-jhbuild folder on your machine (PC). The other folder Measure_PC_version contains the basic set of python scripts for running the activity on your PC. Read the README file in the folder.
Activity has been found running well on build 515 and higher. Since it is a CPU intensive activity, it works best on B3 and B4 machines.
Ideas for the future / Possible developer level projects
1. A low cost (possibly $2) probe that would increase the range of voltage that can be applied to the input.
2. An ultrasonic distance measurement system that connects to the XO and allows the XO to log data. This has immense applications in water level monitoring in villages and also in robotics applications.
3. A general purpose hardware kit that interacts with the measure activity. Something on similar lines to http://www.create.ucsb.edu/~dano/CUI/
4. Sensors could be distributed along with the XO as peripherals. The advantage of this would be that the measure activity can be calibrated against the known specs of the sensors.
5. Being able to measure resistance
6. A low cost version of LEGO mindstorms system built around the XO. The XO has good hardware and software capabilities to achieve this.
7. RS232 or serial interface would allow a host of electronic devices to interact and communicate with the XO.
8. Build a sensor network using a sensor connected to each XO and utilize the mesh networking capability of the XO. This would give us a highly powerful, robust and reconfigurable sensor network.
9. Build medical applications using sensors and the XO.
10. Do some Fablab projects using the XO. See http://fab.cba.mit.edu/labs/vigyan/
11. Collaborative music creation over the mesh using the music software on the XOs and giving input from an array of different sensors.
12. Integrate sensor input into LOGO / Turtle activity
Note: This is more of a wish list and has not been written keeping a fine view of the h/w and s/w capabilities of the XO, only a general idea has been considered.
Hardware details
The Analog Devices AD1888 sound chip has the ability to sample DC voltages. Experimentally it has been found out that the range is fairly linear, however the range that it can sample is restricted to 0.3V - 1.9V , with all the internal gains turned to the minimum.
The XO hardware has been designed to facilitate measurement of DC voltages by the addition of an electronic switch that can be controlled via a setting on the Alsa mixer called 'Analog Input' . The high pass filter can also be turned on/off by a setting 'High Pass Filter' in Alsamixer. The ability to control V_REFOUT (bias voltage) is also available and is done by the control 'V_REFOUT' in alsamixer.
All the above settings are being handled in the activity by using an os.system("amixer <control name> <mute/unmute>")
? Maximum range of input that can be applied without destroying the hardware is not known
? Maximum range of AC signal
For software developers
Brief overview of the code
The code consists of the following 6 basic files
1. measure.py
2. audiograb.py
3. drawwaveform.py
4. config.py
5. buttons.py
6. loggingUI.py
measure.py is the main file which initiates all the classes and creates the main widget in which it adds all various other widgets. It also incorporates a gobject timeout which queues up the expose event after a time interval specified in config.py file.
audiograb.py is the file that takes care of grabbing input audio samples. It uses a gstreamer pipeline in which the handoff signal of the fakesink element is used to intercept the data in the pipeline. Data logging is done in this class since we can use the sampling rate as a time reference; i.e. we know the sampling rate and also the number of elements in each buffer that is intercepted from the pipeline. So each atomic time interval is (1/Fs * bufferSize). This is the time interval after which we get a handoff signal.
drawWaveform.py is the class that handles the waveform drawing part. It creates and uses a cairo context to draw the background, the grid and the waveform. It uses a combination of pango and cairo for displaying the text as it was found out that cairo is itself not good at rendering text. All drawing occurs in the expose function which is the gtk expose event handler. It does drawing from the real time samples or from a file. In real time, it can either draw time domain or display the frequency domain samples. self.integer_buffer is one buffer that is obtained from audiograb.py and self.main_bufers is the buffer that accumulates all these buffers. The self.main_buffers is sampled at varying intervals of time, depending upon the frequency range selected, to form self.buffers which is the buffer that is scaled and drawn. self.main_buffers is sampled at a larger interval (set by self.spacing) for lower frequencies and at a shorter interval for higher frequencies. An example calculation is as follows. If we form 1 self.buffers by taking all consecutive elements, we would be sampling at 48khz. I have found that to draw a reasonable representation of a sine wave, one needs at least 8 -12 points. Hence the largest frequency that can be represented accurately is given by 48/12 = 4Khz, or less.Text is updated after every self.update_text expose events.
config.py contains all global variables.
buttons.py contains the buttons and the two sliders that one sees below the graph drawing area. The frequency slider changes values in discrete intervals of ten.
loggingUI.py contains the logging UI options that one sees to the right to the graph drawing area.
Signals and timeouts used in the software
The handoff signal in audiograb.py is emitted whenever a new buffer is available. The signal handler is on_buffer which adds a gobject timeout. On timeout, _new_buffer is called which emits a custom signal new-buffer. The signal handler for this custom signal is _new_buffer in drawWaveform. Within _new_buffer, the new buffer is read and saved /stored. The expose event is queued in the main measure.py which causes the expose function to be called.
Tutorials you might need
You would probably need some knowledge of the following to develop on some or all of the aspects. A higher number of stars in front of each point represents a higher level of proficiency required for this project.
1. gobject - ** - http://www.sicem.biz/personal/lgs/docs/gobject-python/gobject-tutorial.html
4. gstreamer - * - http://pygstdocs.berlios.de/pygst-tutorial/index.html
5. cairo - *** - http://www.tortall.net/mu/wiki/PyGTKCairoTutorial
6. pango - * -
7. sugar and activity bundling - ** - http://wiki.laptop.org/go/Sugar_Activity_Tutorial
Software task list
1. Check all settings of Alsamixer at startup and shutdown of activity. Make kernel patch.
2. Find appropriate smoothing algorithm
3. Include header in log file , also include all relevant information - scale, interval etc.
4. Explore a scrolled window for graph of logged data
5. Set spacing interval when drawing from file
6. Explore pylab/matplotlib as an alternate rendering option or maybe just for the plot from log part
7. Calculate and display Fourier transform, add a button in UI
8. Work on optimizing the display, esp the background display method (explain)
9. Incorporate sharing wherein shared waveform would be drawn with a separate color. Basically self.buffers list is required to be shared
10. Calculate scale on different ranges and display it along other details in "Show Details"
11. Scale RMS, AVG and Pk Pk display values to correspond the voltage values.
12. Installation of NumPy and related dependancies on XO OR convert code to use Numeric
13. Journal Integration
14. Fix bug #2390
For content developers
I have yet to work on a to-do task list for the content. However, I wish to develop a complete page around each of the points (and more) enumerated in the Learning activities section mentioned above. Ideally I would want a short illustrative video on each page.
Some Links
1. List of activities on the XO - http://wiki.laptop.org/go/Activities
2. OLPC official website - http://laptop.org
Contact
Best to use the discussion page
Alternatively -
Email: arjun@laptop.org
IRC: arjs on #freenode usually in #olpc , #sugar and #olpc-content
WARNING : Do not measure the mains voltage, it would destroy your XO
--Arjs 11:50, 23 July 2007 (EDT)