An advantage of the Linux-based embedded systems is its impressing ability to accept hardware additions. We have both the possibilities of a typical personal computer (PC) and the possibilities of microcontrollers (but lacking real-time characteristics, take this into account).
This session is devoted to play with commercial additions to our elected embeded system, These additions could be transferred to other embedded systems of the same nature.
To get the maximum, we will try to get visually appealing applications.
Growing hardware: «shields»
In the programming session, we played with simple hardware and gave some highlights about RPi conectivity. Now, we want to go beyond.
In the Raspberry Pi ecosystem, an add-on hardware in named «shield». There are thousands of commercial «shields» for any pourpose.
Find your bellowed cape. Explain to your classmates its characteristics and price.
Piface 2 digital shield
A popular solution to simplify the connection of digital input/output is the use of the PiFace 2 digital.
Take a look to the official web page of this product. Find in Internet projects using this board an comment with your classmates.
Lets install it on your RPi board … Hey, you must shutdown completely your board. Plug-out the power cord.
Ha, ha, ha!!! Welcome to real world of embedded development!!! (Raspbian stretch!).
Testing the Piface
Well, never start programming if you are not sure that «the thing» is working properly. You can follow the instructions available in http://www.piface.org.uk/guides/Install_PiFace_Software/piface_digital_emulator/
Or, better now, take a look to the repositories …
Find a kind of green «croissant» in to-left corner of the desktop and run it. If it does not appear, then write in a terminale «piface-digital-emulator».
This is an emulator of the board. Try to test if it works, you should see lighting LEDs or clashing relays.
PROBLEMS?: Well, find de reason. This is real world.
(NOTE: This year (Raspbian strech), the reason is different, so lets circumvent the issue in a different way.
Do you remember «wiring pi»? Check the «examples» directory, check for «Piface» examples, buiild it and test.
The «tank of liquids»
Now it is time to connect real things to the Piface. For example a real digital level sensor or a «real» pump.
A «real» level sensor
Please, follow these connections:
– Sensor «tank empty»: Digital input 0, 1=yes/0=no
– Sensor «tank full»: Digital input 1, 1=yes/0=no
– Actuator «pump»: Digital output 0, 1=active/0=inactive
Then check that they work using the emulator.
Review the contents of the programming session. You can use «wiring» with Piface. Great!!
You should work in the host machine, not directly on the RPi.
Team «level»: Develop a module level.cpp/level.h to deal with level sensors. Build a test application.
Team «pump»: Develop a module pump.cpp/pump.h to deal with pump actuator. Build a test application.
Growing visual: use Qt
Well, lets return to Qt a get some more visual. We don’t have to much time, but …
The flow should be:
- Use a button to configure all sensors and actuators functions.
- User a timer for running: read sensor, compute action, write actuators, update visuals