The src directory contains different applications that were presented at the ILSF (I Love Science Festival).
-
In
src\atmel_studio_projectan example of Arduino project ported to Atmel Studio can be found. Using Atmel Studio as an IDE offers to the user a higher flexibility and transparence over the code. The scriptavrdude_program_nano_every.batis an example on how to program an Arduino Nano Every board directly from the IDE. More informations on how to setup an external programmer in Atmel Studio can be found here. -
In
src\max3010_main_code_arduinothere is the Arduino project used to read data from the MAX301x PPG sensor, compute theHRandSpO2and send it through serial interface. It is the main code for thePPG Dashboardapplication and for3D PPG Printingapplication. -
In
src\ping_pong_tower_code_arduinothere is the Arduino project used to control the ping pong tower based on the heart rate value. -
In
src\python_3d_printingcan be found the Python application used to acquire and 3D print the PPG signal. -
In
src\python_dashboardandsrc\python_dashboard_2can be found the Python dashboard application.
- Firstly, one has to read the documentation of the ping pong tower to get a clear picture how it works, how the height measurement is done, what are the sensor output options (here, the analog ouput is used) and how to calibrate the height sensor. The documentation can be found in
docdirectory. - Go to the Arduino project and analyse the code, try to configure the configuration macros according to your needs. Also do not forget to set the
ANALOG_PINandPWM_CONTROL_PINaccording to the design.
-
Compile and load the code from
src\ping_pong_tower_code_arduino\ping_pong_main_code_arduinoto the Arduino. -
Perform the calibration as described in
doc\height sensor calibration. After calibration (do not power off the ping pong tower), disconnect the fan and connect it to the extension board. -
Connect the PWM pin and the sensor output to the Arduino. The ball should start rising and then it will float in the middle (approximately) of the tube.
-
If the ball is not stable or the height does not correspond to the HR value, you might need to create by yourself the following look-up tables. In this case a voltage divider was used, so the voltage values should be changed if the ping pong tower output is connected directly to the
ANALOG_PIN. For different ping pong towers, there should be created different look-up tables since the output analog voltage differs.
-
To create the voltage lookup table one can use the
src\ping_pong_tower_code_arduino\set_pwm_manuallyproject and which allows to set manually the ball at a specific height (the height can also be changed covering the fan with your hand). Read the sensor analog values and create thehr_lookup_tableandvoltage_lookup_tableaccording to your needs. -
To test that the newly created lookup tables, set the
SET_MANUAL_BEAT_AVGtoTRUE, compile and load the code. Then from a serial terminal send the desired HR value. The ball should be floating at the desired height according to the serial input value.
The fan control is done using a PI loop. An external PID library can be used by setting USE_PID_CONTROLLER to TRUE. The K constants has to be determined and are not the same as in the case of the implemented PI controller.
pingpongtower.mp4
- Install the requirements list from
src\python_3d_printing
cd src\python_3d_printing
pip install -r requirements.txt- Install
PrusaSclier. - Export your configuration bundle from
PrusaSlicerand save it tosrc\python_3d_printing\in. Modify the path in code:
- Compile and load the code from
src\max3010_main_code_arduino, where thePRINTING_APPis set toTRUE. - Connect the Arduino board. Check the serial COM and modify the file
src\python_3d_printing\serial.ini. - Create a new
API_KEYin OctoPrint (info here and assign to RaspberryPi the address10.0.0.1. Set the newAPI_KEYinsrc\python_3d_printing\python_interface.py
- In Spyder/PyCharm or other Python IDEs run
src\python_3d_printing\python_interface.py.
- The
src\python_3d_printing\outdirectory contains the image that was selected, thestlversion of the image and thegcodeoutput fromPrusaSlicer.
-
The response from the printer can be found in the console/terminal where the application was started. Refer to the HTTP status codes in order to find out what is going on. If the answer is
201the printer should start printing the PPG capture. While printing, othergcodefiles can be pushed in the queue but the files have to be manually selected for the printing (in theOctoPrintlocalhost). A [continous print plugin] (https://github.com/chennes/OctoPrint-Queue) can be further integrated. -
Output:
- Install the requirements list from
src\python_dashboard
cd src\python_dashboard
pip install -r requirements.txt- Compile and load the code from
src\max3010_main_code_arduino, where thePRINTING_APPis set toFALSE. - Connect the Arduino board. Check the serial COM and modify the file
src\python_dashboard\serial.ini. - In Spyder/PyCharm or other Python IDEs run
src\python_dashboard\project\ppg_dashboard.pyand close the console.
-
Open the command line and run the command
streamlit run ..\src\python_dashboard\project\ppg_dashboard.py. -
Open the local host URL.
dashboard.mp4
- If the current console in Spyder/PyCharm was not closed the serial port can not be opened.








