Repository navigation
Releases
Releases · perc-sw/analog_shield_micropython
Analog Shield MicroPython v0.1.0-rc.1
First release candidate of analog_shield.py, a one-file MicroPython library for the
Analog Shield (Rev C) on a Phyduino Pico, written for the Department of Physics
"Introduction to Electronics" course. It gives names to the shield's LEDs, rotary encoder
and push switch, potentiometer, and LMT84 temperature sensor, with the voltage at each
stage of the amplifier. Download analog_shield.py, or the smaller, compiled
analog_shield.mpy, from the files below and copy it to the board, or install it with
mpremote mip install github:perc-sw/analog_shield_micropython.
analog_shield.py: one-file library for the Analog Shield (Rev C) on a Phyduino Pico, on top of thephyduino.pybuilt into the Phyduino Pico firmware.green_ledandred_led(D6, D5), which light when their pin is low:on(),off(),toggle(),value().encoder(): the rotary encoder on D3/D4, counted by pin interrupts, withposition()(one per click),steps(),set_position(), and the push switch on D2 withpressed()andon_press()(debounced, run withmicropython.schedule()).temperature(): the LMT84 through the TLV2472 amplifier, with each stage of the chain in volts:raw_sensor_volts()(A1),sensor_volts(),amplifier_volts(),output_volts()(A3 or A0, chosen withset_output_pin()to match JP2), plustemperature_from_volts(),amplifier_gain(),amplifier_offset_volts()andset_supply_volts()for the +5V rail. Allows for the Phyduino Pico's 100 kOhm pulldown on A3 (R49), so A3 and A0 give the same temperature.pot_volts(): the potentiometer on A5.version(): the library version, as in__version__.
package.json, sompremote mip install github:perc-sw/analog_shield_micropythoninstalls it. Each GitHub release also hasanalog_shield.pyand a compiledanalog_shield.mpyattached, with their SHA-256.- 6 examples in two sets,
examples/arduino/analog_shield/(setup()andloop(), witharduino.py) andexamples/phyduino/analog_shield/(plain MicroPython, withphyduino.py):blink_leds,encoder_counter,encoder_led_brightness,read_pot,temperatureandamplifier_chain. - 2 more examples:
demo(the temperature on A3 once a second, with the green LED lit while it runs) andplotter(all the shield's readings aslabel:valuepairs for a serial plotter, with the knob switching between A0 and A3). - Host tests (pytest) with a fake
machinemodule, againstphyduino.pyfrom phyduino_pico_micropython v0.1.0-rc.1. - Documentation site (
docs/) with a Doxygen API reference generated from the docstrings, published to GitHub Pages.
Known issues
- A5 reads at most 2.048 V, so with JP3 (VIO) on 3.3 V the last third or so of the potentiometer's turn reads full scale.
- After
mcu.pwm("D6")oranalogWrite(6, ...),green_ledno longer changes the LED: the pin stays on PWM (the same forred_ledand D5). Callmcu.pin("D6", "out")to free it. - The J2 sensor connector (A4) has no functions; read it with
mcu.analog_volts("A4").