PiPicoMite02

From Land Boards Wiki
Jump to navigation Jump to search

Tindie-mediums.png

PiPicoMite-02 P18268 720px.jpg

Card Versions

  • There are three versions of this card
    • PiPicoMite01
      • Has 16-bit port I/O expander
      • 120x70mm with (4) 6-32 mounting holes
    • PiPicoMite02 (this version)
      • Has 32-bit port I/O expander(s)
      • 95x95mm with (4) 6-32 mounting holes
    • PiPicoMite03
      • 99.5x69.5mm - Fits into extruded Aluminum Enclosure
      • Fully functional, reduced cost

Features

  • Raspberry Pi Pico
    • All Pico pins brought to headers
    • Pico pin marking on rear
  • VGA
    • 640x480 monochrome resolution
    • 320x240 colour resolution
    • 1:2:1 - R:G:B - 16 colours
  • PS/2 Keyboard
    • 5V to keyboard with voltage translator
    • Does not require a keyboard that runs at 3.3V
  • SD Card
  • Stereo audio
  • 32-bit GPIO
    • (2) MCP23017 Datasheet - Rev D
    • MCP23017... LOST TWO INPUTS
      • MCP23017 now a 14/16-bit expander, with two of the pins (GPA7 and GPB7) losing their input capabilities
      • The chips look the same, are called the same, and act mostly the same — if you don’t download the latest version of the datasheet (Revision D), you’d never know that there’s been a change* 16-bit General Purpose I/O (GPIO)
    • I2C1 (I2C2 from MMBASIC)
    • DB-37 Female connector
    • Jumper selectable terminators
  • I2C0 connector
    • With Interrupt line
  • Power options
    • 5V power input
      • USB Micro on Pico card
      • USB B
      • 0.1" pitch header
    • 3.3V output header
  • 95mmx95mm outline ODAS standard
  • (4) 6-32 Mounting holes

BASIC Interpreter

The PicoMiteVGA boots straight into the MMBasic prompt. At which point you can enter, edit and save the program, test BASIC commands and run the program.

MMBasic is a Microsoft BASIC compatible implementation of the BASIC language, originally written by Geoff Graham and enhanced and ported to the Pico by Peter Mather, who also designed the original PicoMite on which this design is based. It is full featured with floating point, 64-bit integers and string variables, long variable names, arrays of floats, integers or strings with multiple dimensions, extensive string handling and user defined subroutines and functions. Typically it will execute a program up to 100,000 lines per second. Embedded compiled C programs can be used for even higher performance.

Using MMBasic you can use communications protocols such as I2C or SPI to get data from a variety of sensors. You can save data to an SD card, measure voltages, detect digital inputs and drive output pins to turn on lights, relays, etc.

The emphasis with MMBasic is on ease of use and development. The development cycle is very fast with the ability to instantly switch from edit to run. Errors are listed in plain English and when an error does occur a single keystroke will invoke the built in editor with the cursor positioned on the line that caused the error.

MMBASIC Credits

Peter Mather led the project, ported the MMBasic interpreter to the Raspberry Pi Pico and wrote the hardware device drivers. Geoff Graham wrote the MMBasic interpreter and the manual. Mick Ames wrote the PIO compiler and its corresponding documentation. The VGA driver code was derived from work by Miroslav Nemecek.

Raspberry Pi Pico Pinout (Reference)

PiPico Pins.PNG

Pin Marking on Rear

PiPicoMite02 REAR 3D.png

Schematic

Connectors

PicoMite02 Rev1 CAD.PNG

J1 - I2C (RTC, etc.)

PiPicoMite02 J1 I2C.PNG

  1. INT (GP3)
  2. SCL (GP1)
  3. SDA (GP0)
  4. VCC
  5. GND

Can use Real Time Clocks using the PCF8563, DS1307, DS3231 or DS3232 chips means that the time is always accurately known.

J2, J3 Pico Connectors

PiPicoMite02 J2-3.PNG

Pico Function Mapping

GP FUNCTION PICO PIN GP FUNCTION PICO PIN
GP0 I2C0_SDA (J1-I2C) 1 GP16 VGA_HSYNC 21
GP1 I2C0_SCL (J1-I2C) 2 GP17 VGA_VSYNC 22
GP2 I2C1_INT (MCP23017 if J4 in) 4 GP18 VGA_BLU 24
GP3 I2C0_INT (J1-I2C) 5 GP19 VGA_GRN_LO 25
GP4 SPARE 6 GP20 VGA_GRN_HI 26
GP5 SPARE 7 GP21 VGA_RED 27
GP6 AUDIO-L 9 GP22 SPARE 29
GP7 AUDIO-R 10 RUN RUN/RESET* 30
GP8 PS2_CLK 11 GP26 SPARE 31
GP9 PS2_DATA 12 GP27 SPARE 32
GP10 SD_SCK 14 GP28 SPARE 34
GP11 SD_MOSI 15 ADC ADCREF 35
GP12 SD_MISO 16 VEN3 3.3V ENABLE 37
GP13 SD_SLVSEL 17 3.3V POWER_3.3V 36
GP14 I2C1_SDA (2xMCP23017) 19 VSYS PS2_5V 39
GP15 I2C1_SCL (2xMCP23017) 20

J4- MCP23017s - I2C Interrupt 2

PiPicoMite02 J4 I2C-Interrupt.PNG

  • Install jumper to connect INTA interrupts from MCP23017s to GP2 on Pico
  • No Pull-up

J5 - I2C2 Terminators

PiPicoMite02 J5 I2CTerms.PNG

  • Install shunts to terminate SDA, SCL signals
  • Commands
SETPIN GP14, GP15, I2C2
I2C2 OPEN 400, 100
I2C2 WRITE &H20, OC, LEN, B0[, B1...]
I2C2 READ &H20, OX, LEN, BUFF()
  • &H20 - I2C Address 0x20
  • OC: 0=terminate after, 1=chain next
  • len - Length of buffer (normally 1 for receive)
  • B0,B1... Bytes to send
  • BUFF() - receive buffer

J6 - 3.3V Power Out

PiPicoMite02 J6 3p3V.PNG

J7 - 5V Input

PiPicoMite02 J7 5V.PNG

  • Useful for external 5V

J8 - Audio

OPTION AUDIO GP6, GP7
PLAY WAV "file.wav"

PiPicoMite02 J8 Audio.PNG

J9 - VGA

The VGA output is 640 x 480 pixels in monochrome mode or 320 x 240 pixels in colour mode with 16 colours (1 bit for red, 2 bits for green and 1 bit for blue). The VGA output is generated using the second CPU on the RP2040 processor plus one PIO channel so it does not affect the BASIC interpreter which runs at full speed on the first CPU. A handfull of components (resistors and a couple of diodes) is all that is required to connect the VGA monitor.

From within your BASIC program you can turn pixels on/off and draw lines, boxes and circles in any colour. Text can be positioned anywhere on the screen and displayed in any colour in a variety of fonts.

The built-in editor within MMBasic works perfectly with the VGA monitor and PS2 keyboard to allow programs to be edited (with colour coded text) and saved to an SD card.

PiPicoMite02 J9 VGA.PNG

J10 - USB B Power Connectors

PiPicoMite01 J10 5V-Power.PNG

  • Full size USB B connector
  • No USB signal connections, just used for power

J11 - PS/2 Keyboard

The PS2 keyboard connects to the Raspberry Pi Pico via a level shifter and works as a normal keyboard with the function keys and arrow keys fully operational. It can be configured for the standard US layout used in the USA, Australia and New Zealand or specialised layouts used in the United Kingdom, Germany, France and Spain.

PiPicoMite01 J11 Keyboard.PNG

P1 - 32-bit GPIO


DC37 F.jpg

PiPicoMite02 P1 GPIO.PNG

SetPin GP14, GP15, I2C2
I2C2 OPEN 400, 100
I2C2 WRITE &H20, 0, 2, &H00, &H00
I2C2 WRITE &H20, 0, 2, &H01, &H00
I2C2 WRITE &H21, 0, 2, &H00, &H00
I2C2 WRITE &H21, 0, 2, &H01, &H00

PiPicoMite02 DB37 to DB37RIBBON Pins

P1 Chip Port Bit DB37RIBBON P1 Chip Port Bit DB37RIBBON
1 GND 37 20 GND 36
2 0 B 7 35 21 0 A 0 34
3 0 B 6 33 22 0 A 1 32
4 0 B 5 31 23 0 A 2 30
5 0 B 4 29 24 0 A 3 28
6 0 B 3 27 25 0 A 4 26
7 0 B 2 25 26 0 A 5 24
8 0 B 1 23 27 0 A 6 22
9 0 B 0 21 28 0 A 7 20
10 N/C 19 29 1 B 7 18
11 1 A 0 17 30 1 B 6 16
12 1 A 1 15 31 1 B 5 14
13 1 A 2 13 32 1 B 4 12
14 1 A 3 11 33 1 B 3 10
15 1 A 4 9 34 1 B 2 8
16 1 A 5 7 35 1 B 1 6
17 1 A 6 5 36 1 B 0 4
18 1 A 7 3 37 +3.3V 2
19 +3.3V 1

SD1 - SD Card

The PicoMiteVGA firmware reserves eight program storage "slots" in the Raspberry Pi Pico flash memory. Programs can be saved and retreived from these without the need for any additional storage.

For more storage SD cards can be connected with full support for these built into MMBasic including the ability to open files for reading, writing or random access and loading and saving programs. SD cards connect directly to the Raspberry Pi Pico and the firmware will work with cards up to 32GB formatted in FAT16 or FAT32. The files created can be read and written on personal computers running Windows, Linux or the Mac operating system.

OPTION SDCARD GP13, GP10, GP11, GP12

PiPicoMite01 J1 SD Card.PNG

Configuration Options

> OPTION LIST
OPTION COLOURCODE ON
OPTION KEYBOARD US
OPTION SDCARD GP13, GP10, GP11, GP12
OPTION AUDIO GP6,GP7, ON PWM CHANNEL 3
option system i2c gp0, gp1

PicoMiteVGA Software

Download MMBASIC

  • Tested with "VGA only" versions
  • TheBackshed forum - support
  • If the Pico does not already have MMBASIC installed
  • Hold button on Pico while plugging in USB Micro to PC
  • Drive will open
  • Drop VGA uf2 onto Drive
  • System will reboot
> print mm.ver
 5.070502
  • Run TeraTerm
    • Connect to Serial

Configure MMBASIC

  • Setups
    • Can copy-paste a line at a time into TeraTerm
    • First two will reboot card
OPTION SDCARD GP13, GP10, GP11, GP12
OPTION AUDIO GP6, GP7
OPTION COLOURCODE ON
OPTION POWER PWM

  • Remove USB power
  • Install SD card
  • Apply USB power

PicoMite Source code

On-Board 32-bit Port Expanders Example Code

Example code that uses the (2) MCP23017 Port Expanders on the card

GPIO32-01.bas

  • GPIO32-01.bas
    • Test the (2) MCP23017 parts on the PiPicoMite02 card
    • Light all of the output pins one at a time
    • Alternate patterns then bounce a LED

GPIO32_Bits.bas

Land Boards Card Test Code

External MCP23017 I2C Demo Code

  • Test external I2C I/O connector
  • External PROTO16-I2C card
  • External PIO16-01.BAS - GitHub repo
  • Set all 16 GPIO pins as outputs
  • Write alternate patterns, bounce a 1 across the outputs
SetPin GP14, GP15, I2C2
I2C2 OPEN 400, 100
I2C2 WRITE &H20, 0, 2, &H00, &H00
I2C2 WRITE &H20, 0, 2, &H01, &H00
I2C2 WRITE &H20, 0, 2, &H14, &H55
I2C2 WRITE &H20, 0, 2, &H15, &HAA
Pause 1000
I2C2 WRITE &H20, 0, 2, &H14, &HAA
I2C2 WRITE &H20, 0, 2, &H15, &H55
I2C2 CLOSE

MCP23008 Demo Code

CircuitPython on PiPicoMite0x Cards

  • Reduced parts count for CircuitPython

PiPicoMite02 CPBuild P18348-720px.jpg

  • The PiPicoMite0x cards can run CircuitPython with some limitations
  • Card features for CircuitPython application
    • SD support
    • (2) MCP23017, 16-bit port expanders for 32-bits of Digital I/O
      • DB-37
    • 5V input
    • External I2C on J1
    • (2) 1x20 headers breakout all Pico pins
  • CircuitPython does not have built-in support for
    • VGA
    • PS/2
    • Audio

CircuitPython Digital I/O

  • PiPicoMite02_Digio32.py - Library
    • Control the (2) MCP23017 parts on the PiPicoMite02
    • Provides Arduino-like functions
# digitalWrite(bit,value)
#    bit = 0-31
#    value = 0, 1
# digitalRead(bit)
#    bit = 0-31
#    returns 0, 1
# pinMode(bit,value)
#    bit = 0-31
#    value = INPUT, OUTPUT, INPUT_PULLUP
# pinMode(bit,value)

CircuitPython SD Card

# CS = GP13
# SCK = GP10
# MOSI = GP11
# MISO = GP12

spi = busio.SPI(board.GP10, MOSI=board.GP11, MISO=board.GP12)
cs = board.GP13

sdcard = sdcardio.SDCard(spi, cs)
  • Make directories
>>> os.mkdir('/sd/CircuitPython/')
>>> os.mkdir('/sd/CircuitPython/SD_Card')
  • Add code to path
>>> import sys
>>> sys.path
['', '/', '.frozen', '/lib']
>>> sys.path.append("/sd")
>>> sys.path
['', '/', '.frozen', '/lib', '/sd']
>>> os.listdir('/sd/CircuitPython/SD_Card')
[]

Factory Test Procedure

  • Test assembled cards using this procedure
  • MMBASIC is already set up on the card

Equipment

  • Unit Under Test (UUT)
  • VGA monitor
  • Stereo amplified speakers
  • PS/2 keyboard
  • MMBASIC SD card with contents
  • Raspberry Pi Pico with MMBASIC installed
  • PC running TeraTerm
  • If optional port expander is installed

Test SD card interface

  • Type
files

  • Returns
A:/
   <DIR>  basic
   <DIR>  bmps
   <DIR>  demos
   <DIR>  games
   <DIR>  jpegs
   <DIR>  lbcards
   <DIR>  OnBoard
   <DIR>  performance
   <DIR>  wave
9 directories, 0 files

Test Sound

  • Type
chdir "/wave"
play wav "sample4.wav"

  • Sound should come out of speakers
  • Stop with
play stop

Test Keyboard

  • Type on keyboard
  • Verify keys show up on VGA

Test VGA

  • Type
chdir "/demos"
load "Colours.bas"
run

  • Verify 16 distinct colors on VGA
  • Type
mode 1

Test GPIO (optional (2) MCP23017 are installed)

> chdir "/lbcards/GPIO32"
>load "GPIO32-01.bas"
>run
Looping through LEDs
Hit a key to stop
  • LEDs will blink
  • Any key will stop the program
flash save 3

PiPicoMite02 P1 to LED-32 wiring

  • PiPicoMite02 P1 is a female connector
  • Use DB37RIBBON to convert to right angle header pins
  • LED-32 has a 40-pin right angle header pins
  • Cable has (2) of 2x10 Dupont housings at each end
  • Wiring
P1 Chip Port Bit DB37RIB LED LED-32 pin Color P1 Chip Port Bit DB37RIB LED LED-32 pin Color
1 GND 1 39 BLK 20 GND 2 40 BLK
2 0 B 7 3 D15 35 WHT 21 0 A 0 4 D31 36 BRN
3 0 B 6 5 D14 33 GRY 22 0 A 1 6 D30 34 ORA
4 0 B 5 7 D13 31 VIO 23 0 A 2 8 D29 32 YEL
5 0 B 4 9 D12 29 BLU 24 0 A 3 10 D28 30 GRN
6 0 B 3 11 D11 27 GRN 25 0 A 4 12 D27 28 BLU
7 0 B 2 13 D10 25 YEL 26 0 A 5 14 D26 26 VIO
8 0 B 1 15 D9 23 ORA 27 0 A 6 16 D25 24 GRY
9 0 B 0 17 D8 21 BRN 28 0 A 7 18 D24 22 WHT
10 N/C 19 29 1 B 7 20 D23 20 WHT
11 1 A 0 21 D0 5 BRN 30 1 B 6 22 D22 18 GRY
12 1 A 1 23 D1 7 ORA 31 1 B 5 24 D21 16 VIO
13 1 A 2 25 D2 9 YEL 32 1 B 4 26 D20 14 BLU
14 1 A 3 27 D3 11 GRN 33 1 B 3 28 D19 12 GRN
15 1 A 4 29 D4 13 BLU 34 1 B 2 30 D18 10 YEL
16 1 A 5 31 D5 15 VIO 35 1 B 1 32 D17 8 ORA
17 1 A 6 33 D6 17 GRY 36 1 B 0 34 D16 6 BRN
18 1 A 7 35 D7 19 WHT 37 +3.3V 36 D15
19 +3.3V 37

Test 5V in

  • Connect USB B to 5V (or PC)
  • Remove USB Micro cable
  • Card should continue to run

Test I2C header (RTC)

PiPicoMite02 J1 I2C.PNG

  1. J1 I2C0SCL wired to RTC SCL
  2. J1 I2C0SDA wired to RTC SDA
  3. J1 VCC wired to RTC VCC
  4. J1 GND wired to RTC GND

RTC PartsSide.PNG

  • If RTC is not configured, type
option system i2c gp0, gp1
rtc settime YYYY, MM, DD, HH, MM, SS

  • Check time
rtc gettime
print time$

  • Verify RTC time works

Combined Copy/Paste

  • Above tests can be copy/pasted
files

chdir "/wave"
play wav "sample4.wav"

play stop

chdir "/demos"
load "Colours.bas"

mode 1

option system i2c gp0, gp1
rtc gettime
print time$

SPI port expanders

  • Experimental - Untested

MCP23017.PNG

It seems to me that the GP2-GP5 lines could be used for SPI since they are on SPI0. The other SPI bus connects to the SD card socket using SPI1 so there should be no conflict with the port use. I’m not sure about software implementation/support in the MMBASIC since I’ve not tried it.

PiPicoMite02 SPI connections.PNG

Looks like the SPI connections would be:

  • GP2/SPI0-SCK MCP23S17 Pin 12, Pico Pin 4
  • GP3/SPI0-MOSI MCP23S17 Pin 13, Pico Pin 5
  • GP4/SPI0-MISO MCP23S17 Pin 14, Pico Pin 6
  • GP5/SPI0-CS MCP23S17 Pin 11, Pico Pin 7

Mechanicals

PicoMite02 Rev1 Mechs.PNG

Issues

Rev 1

  • No issues

Assembly Sheet