This document will take you through the steps to get your module ready to program.
To start with, you'll need to download the Thonny IDE. This is what you will use to program and debug the module.
-
Download the most recent firmware from the MicroPython website.
-
Holding down the white button labeled 'BOOTSEL' on the Raspberry Pi Pico, connect the module to your computer via the USB cable.
-
Open your file manager and drag and drop the downloaded .uf2 onto the new drive named 'RPI-RP2'.
-
The Pico will automatically eject once the process is completed.
-
Disconnect the Pico from the USB cable.
-
Reconnect, this time without holding down the button on the back.
-
Open up Thonny if not already open, and go to the bottom right where you can select the interpreter.
-
Click to select interpreter and choose 'MicroPython (Raspberry Pi Pico)'.
-
Click Tools -> Manage Packages to open the package manager.
-
Type 'ssd1306' into the search box and click 'Search on PyPi'
-
Click the result named 'micropython-ssd1306'.
-
Click 'Install'.
-
You will see that a folder has been created inside the Pico named 'lib', which contains the new file 'ssd1306.py'.
Use the exact same process as for the ssd1306 library to install the europi library:
-
Type 'europi' into the search box and click 'Search on PyPi'
-
Click the result named 'micropython-europi'.
-
Click 'Install'.
-
You will now see the new file 'europi.py' alongside the 'ssd1306.py' inside the 'lib' folder.
Now that you have installed the europi.py and ssd1306 libraries, you are ready to take the next step with the module.
- Option 1: Start writing your own program from scratch
- Option 2: Use someone else's program from the contrib folder
- Option 3: Calibrate the module for higher accuracy
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 *'
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.
- 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.
- Once you have chosen a program, click the '.py' file with the same name as the explanatory '.md' file to open it in GitHub.
- Click the pencil icon to 'Edit this file' in the top right
4. Highlight the entire contents of the file
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'
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.
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.
- 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 thecalibrate.py
file from either thelib
directory on your Pico, or from the firmware directory in the repository. - 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.
- Turn on the rack power supply, and the screen will display 'Calibration Mode'. If it doesn't, try troubleshooting.
- 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.
- 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.
- 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.
- Once you have connected the analogue input to CV output 1, press button 1
- Wait for each voltage up to 10V to complete. The module will tell you once it has completed.
- 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.