Difference between revisions of "QT Py"

From Land Boards Wiki
Jump to navigation Jump to search
 
(42 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Two Versions of the QT Py ==
+
[[File:tindie-mediums.png|link=https://www.tindie.com/products/27066/]]
  
* AdaFruit has SAMD21 and RP2040 versions of the QT Py
+
[[FILE:QTPy49_P18254-720px.jpg]]
** Same pinouts/form factors
 
* RP2040 vs SAM version
 
** RP2040 is faster (125 MHz vs 48 MHz)
 
** RP2040 has 2 cores vs 1
 
** RP2040 has more Flash
 
** RP2040 has more SRAM
 
** The RP2040 version is more expensive, but about the same cost if the SAM version is used with an external Flash
 
  
=== SAMD21 QT Py===
+
<video type="youtube">iI9lUsVSuF8</video>
  
[[File:QT_Py_4600-06.jpg]]
+
== Two Versions of the QT Py ==
 
 
<video type="youtube">0Qssr6B6MrU</video>
 
 
 
* [https://www.adafruit.com/product/4600 Adafruit QT Py SAMD21 Product Page]
 
** ATSAMD21E18 32-bit Cortex M0+ version
 
** 48 MHz, 32-bit processor
 
** 256KB Flash
 
** 32 KB RAM
 
* Native USB supported by every OS
 
** Can be used in Arduino or [https://circuitpython.org/ CircuitPython] as USB serial console, MIDI, Keyboard/Mouse HID, even a little disk drive for storing Python scripts.
 
* Built in RGB NeoPixel LED
 
* 11 GPIO pins:
 
** True analog output on one I/O pin
 
*** Can be used to play 10-bit quality audio clips in Arduino
 
**** CircuitPython does not have storage for audio clips
 
** 9 x 12-bit analog inputs (SDA/SCL do not have analog inputs)
 
** 1 x Optional AREF on A1
 
** 9 x PWM outputs (A0 is analog out, A1 is not PWM capable)
 
** Hardware I2C port with STEMMA QT plug-n-play connector
 
** Hardware UART
 
** Hardware SPI
 
** Hardware I2S
 
** 6 x Capacitive Touch with no additional components required
 
* 3.3V regulator with [https://www.diodes.com/assets/Datasheets/AP2112.pdf 600mA peak output] AP2112
 
* Optional SOIC-8 SPI Flash chip on bottom
 
** Can't use castellated pins if Flash on bottom is installed
 
** [https://www.adafruit.com/product/4763 GD25Q16]
 
** Access the SPI flash in Arduino on SPI1 and chip select pin 17
 
** In CircuitPython, a '[https://circuitpython.org/board/qtpy_m0_haxpress/ haxpress]' version of the runtime will need to be installed, so it knows to look for the larger filesystem
 
** There is more hardware support in the haxpress CircuitPython build because we can add more code to the internal flash instead of using it for a filesystem
 
* Reset switch for starting your project code over or entering bootloader mode
 
* USB Type C connector
 
 
 
=== RP2040 QT Py ===
 
 
 
[[file:QT Py RP2040.PNG]]
 
 
 
<video type="youtube">00t5y4nQlH8</video>
 
 
 
* [https://www.adafruit.com/product/4900 Adafruit QT Py RP2040 Product page]
 
* USB Type C connector
 
* RP2040 32-bit Cortex M0+ dual-core
 
* Runs at ~125 MHz
 
* 264 KB RAM
 
* 8 MB SPI FLASH chip for storing files and CircuitPython/MicroPython code storage. No EEPROM
 
* Can be used with MicroPython or CircuitPython
 
* Built-in RGB NeoPixel LED
 
* 13 GPIO pins (11 breakout pads and two QT pads):
 
** Four 12 bit ADCs (one more than Pico)
 
** Two I2C ports (one on the QT connector, one on the breakout pads)
 
** SPI and UART peripherals, in standard QT Py locations,
 
** PWM outputs on every IO pin - for servos, LEDs, etc
 
** There are 6 GPIO in consecutive order for PIO compatibility
 
* 3.3V logic and power 600 mA
 
* Both Reset button and Bootloader select buttons for quick restarts (no unplugging-replugging to relaunch code)
 
 
 
=== Links ===
 
 
 
* [https://circuitpython.org/board/qtpy_m0/ Adafruit QT Py page]
 
* [https://learn.adafruit.com/adafruit-qt-py Adafruit Learning System for QT Py]
 
 
 
== Pins ==
 
 
 
=== 3V ===
 
 
 
* Regulated output from the onboard regulator. You can draw 500mA
 
 
 
=== 5V ===
 
 
 
* 5v out from the USB port.
 
* Voltage input
 
** Requires external diode
 
*** Schottky, signal, power
 
*** Between external power source and this pin
 
*** Cannot power the USB port by supplying 5V to this pin
 
**** There is a protection diode that prevents the 5V from reaching the USB connector.
 
**** This is to protect host computer USB ports, etc.
 
 
 
=== A0 / D0 - Digital/analog GPIO pin 0  ===
 
 
 
* Digital I/O 0
 
* True analog output with 10 bit precision
 
* Does not have PWM
 
* Capacitive touch input.
 
 
 
=== A1 / D1 - Digital/analog GPIO pin 1 ===
 
 
 
* Digital I/O 1
 
* Capacitive touch input
 
* AREF pin.
 
 
 
=== A2 / D2 - Digital/analog GPIO pin 2  ===
 
 
 
* Digital I/O 2
 
* PWM
 
* Capacitive touch input.
 
 
 
=== A3 / D3 - Digital/analog GPIO pin 3 ===
 
 
 
* Digital I/O 3
 
* PWM output
 
* Capacitive touch input.
 
 
 
=== SDA / D4 ===
 
 
 
* Digital I/O 4
 
* I2C SDA pin
 
* PWM output
 
* No analog on this pin
 
* No pull up on this pin
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.
 
 
 
=== SCL / D5 ===
 
 
 
* Digital I/O 5
 
* I2C SCL
 
* No analog on this pin
 
* No pull up on this pin
 
* When using with I2C requires an external 2.2K-10K pullup to 3.3V.
 
 
 
=== TX / A6 / D6 ===
 
 
 
* Digital I/O 6
 
* Transmit (output) for Serial1
 
* Analog 6
 
* PWM output
 
* Capacitive touch input
 
 
 
=== RX / A7 / D7 ===
 
 
 
* Digital I/O 7
 
* Receive (input) for Serial1
 
* Analog 7
 
* PWM output
 
* Capacitive touch input
 
 
 
=== SCK / A8 / D8 ===
 
 
 
* Digital I/O 8
 
* SPI SCK pin
 
* Analog 8
 
* PWM output
 
 
 
=== MISO / A9 / D9 ===
 
 
 
* Digital I/O 8
 
* SPI MISO pin
 
* Analog 8
 
* PWM output
 
 
 
=== MOSI / A10 / D10 ===
 
 
 
* Digital I/O 10
 
* SPI MOSI pin
 
* Analog 10
 
* PWM output
 
 
 
=== NeoPixel ===
 
 
 
* Connected to digital pin 11 for signal
 
* Set pin 12 low for low power usage
 
* By default pin 12 is set high by Arduino/CircuitPython
 
* Code example
 
 
 
<pre>
 
import board
 
import neopixel
 
 
 
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
 
# fill((rVal, gVal, bVal))
 
# rVal, gVal, bVal = red/green/blue values (0-255)
 
pixels.fill((255, 0, 0))  # Note double parens
 
</pre>
 
 
 
== Programming ==
 
 
 
* C/C++ or CircuitPython
 
 
 
=== C/C++ ===
 
 
 
* [https://github.com/raspberrypi/pico-sdk RP2040 C/C++ SDK]
 
 
 
=== MicroPython ===
 
 
 
* [https://github.com/micropython/micropython/tree/master/ports/rp2 RP2040 MicroPython Repo]
 
 
 
=== CircuitPython ===
 
 
 
==== CircuitPython for SAMD ====
 
 
 
* Adafruit CircuitPython 7.3.0 on 2021-01-21
 
** [https://circuitpython.readthedocs.io/en/latest/README.html CircuitPython] is a derivative of MicroPython
 
** CircuitPython looks for a code file on the board to run
 
*** There are four options: code.txt, code.py, main.txt and main.py
 
*** CircuitPython looks for those files, in that order, and then runs the first one it finds
 
** [https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/Welcome_to_CircuitPython/QT_Py_blink.py QT_Py_blink.py]
 
** [https://circuitpython.org/board/qtpy_m0_haxpress/ QT Py Haxpress] used with 2MB Flash EEPROM
 
* [https://codewith.mu/ Mu code editor]
 
* Free memory
 
** Reports 17,776 bytes of free space
 
<pre>
 
import gc
 
gc.mem_free()
 
</pre>
 
 
 
===== Updating CircuitPython =====
 
 
 
* Save the contents of CIRCUITPY, just in case
 
* '''Double-click the reset button''' to show the BOOT drive
 
* Drag the update-bootloader .uf2 file to the BOOT drive
 
* Wait a few tens of seconds for the bootloader to update; the BOOT drive will reappear
 
* Check INFO_UF2.TXT to verify that the bootloader version has been updated. Then you will need to reload CircuitPython.
 
* [http://adafru.it/mpy-update Update mpy files]
 
 
 
==== Land Boards Python Code ====
 
 
 
* [https://learn.adafruit.com/circuitpython-essentials/circuitpython-i2c I2C scanner]
 
 
 
===== DIGIO-8 Drivers ======
 
 
 
* [https://github.com/land-boards/lb-boards/tree/master/Projects/QTPy/Land%20Boards/Land%20Boards%20QT%20Py%20Code GitHub Repo]
 
** [https://github.com/land-boards/lb-boards/blob/master/Projects/QTPy/Land%20Boards/Land%20Boards%20QT%20Py%20Code/I2CIO8.py I2CIO8.py Demo code] - Bounce an LED across MCP23008 card output pins
 
** [https://github.com/land-boards/lb-boards/blob/master/Projects/QTPy/Land%20Boards/Land%20Boards%20QT%20Py%20Code/I2CIO8_RW.py I2CIO8_RW.py] - Read jumpers, write back LEDs
 
 
 
==== Digital I/O Example ====
 
 
 
<pre>
 
import board
 
import digitalio
 
import time
 
 
 
led = digitalio.DigitalInOut(board.D13)
 
led.direction = digitalio.Direction.OUTPUT
 
 
 
while True:
 
    led.value = True
 
    time.sleep(0.1)
 
    led.value = False
 
    time.sleep(0.5)
 
</pre>
 
  
== Flash EEPROM 2 MB ==
+
* AdaFruit and Seeed Studio have SAMD21 and RP2040 versions of the QT Py (XIAO on Seeed Studio) with the same form factor
 +
** [[QT Py (SAMD based)]]
 +
** [[QT Py (RP2040 based)]]
 +
* [[QTPy49|QTPy49 Breakout card]]
  
[[File:QT_Py_4600-07.jpg]]
+
== RP2040 vs SAM version ==
  
== QT Py Breakout Board ==
+
* RP2040 is faster (125 MHz vs 48 MHz)
 +
* RP2040 has 2 cores vs 1
 +
* RP2040 has more Flash
 +
* RP2040 has more SRAM
 +
* The RP2040 version is more expensive, but about the same cost if the SAM version is used with an external Flash
 +
* [https://www.seeedstudio.com/blog/2020/01/09/samd21-arduino-boards-which-one-should-you-use/ SAMD21/RP2040 Arduino Boards – Which 32-bit Microcontrollers should you use?]
  
[[File:QT_Py_Breakout_P18212-720px.jpg]]
+
[[file:XIAO_SAM_vs_XIAO_RP2040.PNG]]
  
* Built onto [[GRID49]] card
+
== QTPy49 Breakout Card ==
* Socket for QT Py
 
* QT Py pins brought to header strips
 
* 3.3V power distribution on 2x8 header
 
  
=== Pins (CCW direction) ===
+
* [[QTPy49]]
  
* S12 = A0
+
[[file:QTPy49-P18253-720pxV.jpg]]
* R12 = A1
 
* Q12 = A2
 
* P12 = A3
 
* N12 = SDA
 
* M12 = SCL
 
* L12 = TX
 
* L1 = RX
 
* M1 = SCK
 
* N1 = MI
 
* P1 = MO
 
* Q1 = 3.3V
 
* R1 = GND
 
* S1 = 5V
 
* A6=B6=C6=D6=E6=F6=G6=H6 = GND
 
* A7=B7=C7=D7=E7=F7=G7=H7 = 3.3V
 

Latest revision as of 19:31, 24 July 2022

Tindie-mediums.png

QTPy49 P18254-720px.jpg

Two Versions of the QT Py

RP2040 vs SAM version

XIAO SAM vs XIAO RP2040.PNG

QTPy49 Breakout Card

QTPy49-P18253-720pxV.jpg