Skip to content

Latest commit

 

History

History
111 lines (73 loc) · 6.94 KB

programming_instructions.md

File metadata and controls

111 lines (73 loc) · 6.94 KB

Setting up and programming the EuroPi

This document will take you through the steps to get your module ready to program.

Setting Up

Downloading Thonny

To start with, you'll need to download the Thonny IDE. This is what you will use to program and debug the module.

Thonny

Installing the firmware

  1. Download the most recent firmware from the MicroPython website.

  2. Holding down the white button labeled 'BOOTSEL' on the Raspberry Pi Pico, connect the module to your computer via the USB cable.

    _DSC2400

  3. Open your file manager and drag and drop the downloaded .uf2 onto the new drive named 'RPI-RP2'.

  4. The Pico will automatically eject once the process is completed.

Installing the OLED library

  1. Disconnect the Pico from the USB cable.

  2. Reconnect, this time without holding down the button on the back.

    _DSC2401

  3. Open up Thonny if not already open, and go to the bottom right where you can select the interpreter.

  4. Click to select interpreter and choose 'MicroPython (Raspberry Pi Pico)'.

    Interpreter Select

  5. Click Tools -> Manage Packages to open the package manager.

  6. Type 'ssd1306' into the search box and click 'Search on PyPi'

  7. Click the result named 'micropython-ssd1306'.

    ssd1306 library

  8. Click 'Install'.

  9. You will see that a folder has been created inside the Pico named 'lib', which contains the new file 'ssd1306.py'.

    ssd1306 inside lib

Installing the EuroPi library

Use the exact same process as for the ssd1306 library to install the europi library:

  1. Type 'europi' into the search box and click 'Search on PyPi'

  2. Click the result named 'micropython-europi'.

    image

  3. Click 'Install'.

  4. You will now see the new file 'europi.py' alongside the 'ssd1306.py' inside the 'lib' folder.

Next Steps

Now that you have installed the europi.py and ssd1306 libraries, you are ready to take the next step with the module.

Write your own program from scratch

To program the module, just create a new Python file, and then press Ctrl-Shift-S to save as to the Raspberry Pi Pico, and name it 'main.py'.
Do not save files to the 'lib' folder, as this is just for libraries to be imported rather than programs that you will write.
Now import the entire europi library by simply adding the line 'from europi import *'

From europi import

Now you have access to the inputs and outputs using easy methods, which you can read about more in the README.md of the software folder.

Copy someone else's program to run on your module

  1. Open the contrib folder and decide which program you would like to run. Each program will have an identically named '.md' file describing how to use it.
  2. Once you have chosen a program, click the '.py' file with the same name as the explanatory '.md' file to open it in GitHub.
  3. Click the pencil icon to 'Edit this file' in the top right

image
4. Highlight the entire contents of the file

image
5. Press Ctrl-C to copy the contents of the file 6. Open Thonny, make sure your module is connected, and then press Ctrl-N to create a new blank file 7. Press Ctrl-V in the file to paste the contents of the file you copied 8. Press Ctrl-S to save the file, then choose 'Raspberry Pi Pico'

image
9. Name the file 'main.py', being careful to include the '.py' so the module knows it is a Python file. If you do not name it 'main.py', the module will not know to automatically run your program whenever it is connected to power.

image

Calibrate the module

To use the module for accurately reading and outputting voltages, you need to complete a calibration process. This will allow your specific module to account for any differences in components, such as resistor tolerances.
If you do not wish to calibrate the module and don't mind your voltages being slightly inaccurate, simply skip to the programming step and your module will use default values.

  1. To begin, you need to copy the calibrate.py file and name it /main.py in the root directory, as we did in Option 2 above. You can obtain the calibrate.py file from either the lib directory on your Pico, or from the firmware directory in the repository.
  2. Make sure your module is connected to rack power for the calibration process. It doesn't matter if it connected to USB as well, however if it is it will give an extra warning to turn on rack power which you need to skip using button 1.
  3. Turn on the rack power supply, and the screen will display 'Calibration Mode'. If it doesn't, try troubleshooting.
  4. There are 2 options for calibration:
  • Low Accuracy: Only a single 10V supply is required
  • High Accuracy: A variable supply is required to produce voltages from 0-10V
    Press button 1 to choose Low Accuracy mode, or button 2 to choose High Accuracy mode.
  1. Connect your voltage source to the analogue input, and input each voltage displayed on the screen. To take a reading (once your voltage is connected), press button 1.
  2. Once all the required voltages have been input, you now need to disconnect the analogue input from your voltage source, and instead connect it to CV output 1.
  3. Once you have connected the analogue input to CV output 1, press button 1
  4. Wait for each voltage up to 10V to complete. The module will tell you once it has completed.
  5. The calibration process is now complete! You now need to rename or delete the 'calibrate.py' program, however DO NOT delete the new file created called 'calibration_values.py'. This file is where the calibration values are stored, and if you delete it you will have to complete the calibration again.