Difference: SolutionsToTheExercises (15 vs. 16)

Revision 162017-11-30 - uli

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Solutions to the exercises

Line: 41 to 41
  https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/QtLED.tar.gz
Added:
>
>
One way to develop the course in the future is the replacement of the C programming language by Python. Many Python modules are available for the Raspberry Pi and its sensors but in a course like ours it would be interesting to look behind the facade of prefabricated modules and try to write those ourselves to be able to understand what is going one behind the scene. This will allow us to create Python modules also for those devices which do not have a Python module written by somebody else yet.

Here is an attempt to write the LED exercises in Python:

https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/ledPython

 
  • Solutions to the exercises on switches

    These exercises have also been skipped because of lack of time but I attach the solution codes nevertheless such that you can have a look at them and/or use them in a future course

https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/switches.tar.gz

Line: 60 to 66
 
  • Solutions to exercise 6: The DHT11 temperature and humidity sensor

    The code contains an example of how to write a shared library. You can collect all libraries for your course in a common directory (.g. /opt/ucc/lib) as you do for all corresponding include files (/opt/ucc/include). Then you make the directory of libraries globally known to the system by putting a file ucc.conf into /etc/ld.so.conf. ucc.conf simply contains the text /opt/ucc/lib. Finally you run the command sudo ldconf and /opt/ucc/lib will be added to the search path of shared libraries on the system.

https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/dht11.tar.gz
Added:
>
>
Again I tried to also write a Python module. dht11Example.py and dht11Class.py are the files you may want to have a look at

https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/dht11Python.tar.gz

 
  • Solutions to the exercises on light measurement

    Again the exercises have not been proposed during the course. They use the photo resistor available in the sensor kit but need a high value capacitor in addition. In these exercise the analogue value of resistance is not measured through an ADC but uses a capacitor which is charged over the resistance in the photo resistor. By measuring the time the capacitor needs to be charge to a level that switches the state of a gpio pin from low to high, the resistance and thus the light intensity can be measured.
    Again the solutions are available here:
https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/photoResistor.tar.gz

  • Solutions to exercise 12: Reading the BMP180 temperature and barometric pressure sensor

    The manufacturer of the device provides an access library to the device which takes care of converting the raw data read from the sensor device into humanly readable values. The library must be adapted to the I2C access method used be the micro-controller to which the device is connected (in our case the Raspberry Pi). The solutions show how this is done, how to extract the documentation from the source code using the doxygen tool and how to use the library in your own programs.
Line: 67 to 77
 
  • Solutions to exercise 10: a 2 line LCD Display

    Very often embedded systems do not have a keyboard, mouse and screen attached to them but they must live with more rudimentary (and much cheaper) input/output devices. Such a device is the 2-line display we have in our sensor collection. It is highly recommendable to write a shared library for the device because it can be used in many applications (see the nameDisplay, VoltMeter and MeteoStation we had at the Open Day).

    The solutions show how this is done, how the library is tested and how to include in-code documentation in doxygen format.
https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/hd44780.tar.gz
Added:
>
>
Also for the hzd44780 I tried to write a Python class. This one even contains code to create your own characters by specifying the corresponding dot matrix. Have a look at helloWorld.py, which prints Hello World! in English and Привет Мир! (Hello World in Russian")

https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/lcdPython.tar.gz

 
  • Solutions to exercise 8: Digital to Analogue conversion

    Many devices are controlled through analogue signal levels. A nice example of a device creating these signal levels is the MicroChip mcp4725, a 12 bit I2C based DAC. The solutions show examples of how to set a level and how to create wave forms.
    https://iotworkshop.africa/pub/Embedded_Systems/SolutionsToTheExercises/mcp4725.tar.gz
    The frequency of the wave form is limited by the I2C access speed (normally 100 kBit/s). The chip is capable of going up to 3.4 MBits/s. When measuring the time needed for a single I2C transfer I get 500 us for a "write" to the DAC. With 100 samples in the signal I therefore get a maximum frequency of
    1/50*10e-3 = 200 Hz.

    The I2C interface in the BCM2835 CPU chip on the Raspberry Pi can go up to almost 1.7 Mbps. I therefore need a library which allows me to control the corresponding register, which I found in the bcm2835 library
    which however is much lower level than pigpio or wiringPi and therefore more difficult to understand and use.
    The library code is attached to this page.
    The Makefile for the library has been re-written to create a shared instead of a static library as done by the original code. When using this library instead of pigpio and setting the clock divider for the I2C bus to the highest speed possible I get an increase in frequency by a factor of 10 (60us per I2C transfer instead of 520 us) resulting in a max. frequencies of 2 KHz for a full 100 sample signal. Again the code is attached.

    Here are some screen shots taken from the Hantek 6022BE oscilloscope equipped with far from perfect software. This software is however able to read out some wave forms and display them.
sineWave.png sawtooth.png
triangularWave.png rectangularWave.png
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback