This is an old revision of the document!
Table of Contents
WIOpi
- WIO Overview | WIO Setup | WIO Control | User Bitmaps | WIO Firmware | WIO CAM | WIO Mobile | Cable | LEDScript | WIOpi
Work In Progress |
Introduction
WIOpi is a program targeted for the Raspberry Pi and its GPIO.
The hardware requirements and support are the same as for RocNetNode.
By running the WIOpi program on the Raspberry Pi, it will behave and process like a WIO on ESP base.
WIOpi runs in context of user pi. |
---|
The user pi is default in the groups gpio, i2c and spi, so no need to run WIOpi in super user context.
$ groups pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
The following files and directories are extracted:
. ├── cam │ └── cam.py ├── reboot.sh ├── scripts │ └── Disco00.led ├── startwiopi.sh ├── update.sh └── wiopi
The commands to start and stop the cam.py Python script can be specified in the wiopi.ini.
Defauls are:
<var name="startcam" vt="string" defval="nohup python3 cam/cam.py &"/> <var name="stopcam" vt="string" defval="killall python3"/>
Install
cd mkdir WIOpi cd WIOpi wget https://wiki.rocrail.net/rocrail-snapshot/WIOpi-ARMHF.tar.gz tar xf WIOpi-ARMHF.tar.gz rm WIOpi-ARMHF.tar.gz
Add a crontab task:
@reboot /home/pi/WIOpi/startwiopi.sh
The ARMHF build runs also under PiOS 64bit. (ARM64)
--------------------------------------------------- WW WW IIII OOOOOO WW WW II OO OO .. WW WW WW II OO OO ppppp ii WWWWWWWW II OO OO pp pp ii WW WW IIII OOOOOO ppppp ii pp pp --------------------------------------------------- TM and Copyright 2002-2020 Robert Jan Versluis. All Rights Reserved. r.j.versluis @ rocrail.net https://wiki.rocrail.net --------------------------------------------------- WIOpi 2.1.1021 [Dec 10 2020 07:52:42] --------------------------------------------------- 20201211.153950.005 w9999I main OI2C 0094 I2C device found at 0x20 fh=4 20201211.153950.005 w9999I main OI2C 0094 I2C device found at 0x21 fh=6 20201211.153950.010 w9999I main OI2C 0094 I2C device found at 0x3C fh=7 20201211.153950.012 w9999I main OI2C 0094 I2C device found at 0x40 fh=9 20201211.153950.017 w9999I main OI2C 0094 I2C device found at 0x60 fh=10 20201211.153950.021 w9999I main OIO 0098 init MCP23017 device 0x20 I/O map=0xF0F0 ppoobbiippoobbii 20201211.153950.022 w9999I main OIO 0098 init MCP23017 device 0x21 I/O map=0xFFFF iiiiiiiiiiiiiiii 20201211.153950.023 w9999I main OServo 0091 init PCA9685 device 0x40 prescale=101 20201211.153950.034 w9999I main OLED 0076 init PCA9622 device 0x60 20201211.153950.035 w9999I main ODisplay 0337 init SSD1306 device 0x3C geometry=1 20201211.153950.038 w9999I main ODisplay 0189 clear display[0] 20201211.153950.105 w9999I main OWIOpi 0638 Up and running 99:WIOpi-99 20201211.153950.712 w9999I wiocon OWIOpi 0320 send server [mbp2020:8051] WIO handshake... 20201211.153950.936 w9999I wiostat OWIOpi 0466 SSID "Keltenbahn" RSSI=-52 dBm 20201211.153951.105 w9999I doRFID OID12 0085 init ID12 device /dev/ttyS0
Pinout
The Pinout and mapping is printed in the console after startup.
It depends on the configuration found in the wiopi.ini.
See for Raspberry Pi Pinout information: https://de.pinout.xyz
-P-I-N-O-U-T--------------------- | Name | Log | Phys | +-------------------------------+ | I2C SDA | 08 | 03 | | I2C SCL | 09 | 05 | | Pi01 TxD | 15 | 08 | | Pi01 RxD | 16 | 10 | | Pi01 LED1 | 02 | 13 | | Pi01 LED2 | 07 | 07 | | Pi01 Button | 03 | 15 | | Pixel CI | 29 | 40 | | Pixel DI | 28 | 38 | | Servo 0 | 26 | 32 | | Servo 1 | 23 | 33 | | MCP2515 MOSI | 12 | 19 | | MCP2515 MISO | 13 | 21 | | MCP2515 SCLK | 14 | 23 | | MCP2515 INT | 06 | 22 | | MCP2515 CSO | 10 | 24 | | Stepper IN1 | 30 | 27 | | Stepper IN2 | 21 | 29 | | Stepper IN3 | 22 | 31 | | Stepper IN4 | 25 | 37 | | Stepper CAL | 11 | 26 | | S88 PS | 31 | 28 | | S88 RESET | 27 | 36 | | S88 CLOCK | 28 | 38 | | S88 DATA | 29 | 40 | ---------------------------------
Supported Hardware
- Pi02 (max. 4 = 128 I/O)
- Pi03 (max. 4 = 64 Servo)
- Pi06 (Power & Patch)
- Pi08 (max. 8 = 128 LED. Output address < = 128)
- ID12 RFID reader on Pi01
- SSD1306 / SH1106 OLED (max. 2, restricted by the I2C addressing of the SSD1306 / SH1106)
Note: The SH1106 seems incompatible with the Pi01, I2C Driver, so it must be connected directly to the I2C pins. - HT16K33 (max. 2 Clock)
- BMx280 (max. 2 Environment)
- GCA214 RailCom reader on Pi01 (PiOS 32bit only because of the none standard baudrate of 250000.)
- Play sound with "omxplayer" (Without prefix forward slash)
- Mobile soft PWM for controlling a DC Motor (Power MOSFET and bistable direction relay)
- WS2801 RGB LEDs over SPI (Output address > 128)
- LEDScript support in case Port Type is set to Macro.
- 2 Servos on the hardware PWM pins (phys. 32 & 33). 1)
- Analog inputs: PCF8591 and ADS1115
Sound
The Servo outputs, PWM0 and PWM1, can also be used for audio:
dtoverlay=pwm-2chan,pin=12,func=2,pin2=13,func2=4
The filter is quit simple: (Example is for just one channel.)
1µ || | Servo0 -+---+----|| |----+ | | || | | /| +-+ | | / | |1| --- +---+ | |5| --- 33n | | | |0| | | | | +-+ | +---+ | | | | \ | GND -+---+------------+ \|
Pi01
LED functions
Both LEDs will flash fast on a show command to identify itself.
Another show command will stop this flashing.
LED1 (green) | Description |
---|---|
Off | WIOpi does not run, or no GPIO access granted. |
Slow flash | Normal function. |
Fast flash | No Rocrail server connection. |
LED2 (red) | Description |
---|---|
Off | Idle communication. |
Flash | Packet received. |
Pushbutton
In case both LEDs are flashing to identify itself, it will stop this mode.
Otherwise it sends a query response to the Server.
Signals on Pi02/Pi08
Signals Support is also available on the Pi02, with address offset 129.
Pi08: 1…128
Pi02: 129…256 (mapped on 1…128)
WS2801
Stepper Control
See for turntable setup: WIO Stepper
4 Wire | ||
Function | Header | GPIO |
---|---|---|
IN1 (Coil 1) | 7 | 4 |
GND | 9 | - |
IN2 (Coil 2) | 11 | 17 |
IN3 (Coil 3) | 13 | 27 |
IN4 (Coil 4) | 15 | 22 |
HALL (Calibrate) | 21 | 9 |
3 Wire | |||
Function | Header | GPIO | Example TB6600 |
---|---|---|---|
STEP(Clock) | 7 | 4 | CLK+ |
GND | 9 | - | EN-, DIR-, CLK- |
DIR | 11 | 17 | DIR+ |
ENABLE | 13 | 27 | EN+ |
HALL (Calibrate) | 21 | 13 |
WS2801
WS2801 | Header | Function |
---|---|---|
DI | 19 MOSI | Digital In |
CI | 23 SCLK | Clock In |
GND | 25 GND | Ground |
Output settings for LEDScript
Address > 128.
Options Color, Type Macro.
WIOpi-01
The Rpi-Zero header mounted on the bottom side. (without factory header) The Rpi-1/4 header mounted on the top side. (factory default) Short header on the Rpi-1; No native servo support. -------------------- | Rpi0 bottom hdr | -------------------- | | -- Zero set top | | | | ---------------------------------------- | WIOpi-01 | ---------------------------------------- | | || | | || -- Pi2++ piggy bag || | | || ---------------------------------------- | Rpi1/4 top hdr | ---------------------------------------- WIOpi-01 connectors: (pins) ============================== 1 x DC Power supply 2 1 x Pixx RJ12 2 x I2C 4 1 x WS2801 4 1 x Stepper 5 2 x Servo 3 1 x UART 4 1 x Lights 3 1 x Motor 2 2 or 4 x I/O (optional) 10 WIOpi-01 components: ============================== 2 x LED 1 x Button 1 x H-Bridge 2 x I2C I/O Extender (optional) 1 x I2C buffer for Pixx RJ12
CAM
The CAM can be used parallel with WIOpi as documented here:
top - 11:54:34 up 26 min, 2 users, load average: 1.53, 1.27, 0.85 Tasks: 77 total, 1 running, 76 sleeping, 0 stopped, 0 zombie %Cpu(s): 7.2 us, 15.4 sy, 0.0 ni, 71.9 id, 0.0 wa, 0.0 hi, 5.5 si, 0.0 st MiB Mem : 368.4 total, 222.4 free, 73.5 used, 72.5 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 244.2 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 527 root 20 0 0 0 0 I 8.1 0.0 0:00.48 kworker/u2:2-brcmf_wq/mmc1:0001:1 435 pi 20 0 120260 20208 8232 S 7.8 5.4 1:56.07 python3 301 pi 20 0 9944 2528 2072 S 7.5 0.7 2:00.87 wiopi 526 root 20 0 0 0 0 I 2.9 0.0 0:00.61 kworker/0:1-events 521 pi 20 0 10280 2972 2516 R 1.3 0.8 0:01.73 top
Link to stream:
http://<zero-name>:8081
I2C Slaves
WIOpi supports up to 4 Arduino Slaves.
The reserved I2C device addresses are 0x7C, 0x7D, 0x7E and 0x7F.
The WIOnano can be used as skeleton:
To address a pin on a slave, the following parameters are involved:
- Node ID: The ID of the WIOpi
- Address: Pin number
- Port: Slave I2C ID
Supported Rocrail objects:
- Digital output
Monitor trace DOUT(0x0A) on Pin 5(data[0]) off(data[1]):
opc=0x0A dlc=5 data=05 00 00 00 7C 00 00 00
Ten times a second, the slaves are polled for their input pin state. (If any defined.)
20210105.083513.532 w9999I main OWire 0187 I2C device found at 0x7C 20210105.083513.542 w9999I main ODisplay 0392 init SSD1306 device 0x3C geometry=3 ... 20210105.083513.886 w9999I doManage OManager 0101 read reg array slave 0x7C rc=2: opc=0x99 11 66
- Note 1: The Arduino Nano cannot handle error free I2C speeds above the default 100kHz.