User Tools

Site Tools


wio:wiopi-en

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wio:wiopi-en [2021/01/19 08:16] – [I2C Slaves] rjversluiswio:wiopi-en [2023/10/29 10:20] (current) rjversluis
Line 1: Line 1:
-====== WIOpi ====== 
 [[:english|{{ :hardware.png}}]][[:english|{{ :rocrail-logo-35.png}}]] [[:english|{{ :hardware.png}}]][[:english|{{ :rocrail-logo-35.png}}]]
-  * [[:wio:overview-en|WIO Overview]] [[:arduino:wio-setup-en|WIO Setup]] | [[:arduino:wioctrl-en|WIO Control]] | [[:arduino:amp-en|User Bitmaps]] | [[:arduino:wio-en|WIO Firmware]] | [[:arduino:wio-cam-en|WIO CAM]] | [[:arduino:wio-mobile-en|WIO Mobile]] | [[:arduino:wio-cable-en|Cable]] | [[:wio:wio-ledscript-en|LEDScript]] | **[[:wio:wiopi-en|WIOpi]]** +====== WIOpi ====== 
-    * [[:wio:wiopi-01-en|WIOpi-01]]+[[:wio:overview-en|{{ :wio:wiologo.png}}]] 
 +**[[:wio:overview-en|WIO Overview]]** 
 +  * [[:arduino:wio-setup-en|WIO Setup]] | [[:arduino:wioctrl-en|WIO Control]] | [[:arduino:amp-en|User Bitmaps]] | [[:arduino:wio-en|WIO Firmware]] | [[:arduino:wio-mobile-en|WIO Mobile]] | [[:arduino:wio-cable-en|Cable]] | [[:wio:wio-ledscript-en|LEDScript]] | **[[:wio:wiopi-en|WIOpi]]** 
 +    * [[:wio:wiopi-01-en|WIOpi-01 PCB]] 
 +    * [[:wio:wiopico-en|SIOpico]] //I2C Slave I/O for WIOpi//
     * [[:rocnet:headless-cam-en|Headless Raspberry Pi Setup]]     * [[:rocnet:headless-cam-en|Headless Raspberry Pi Setup]]
 +    * [[:rpi:interfaces-en|I2C Speed]]
 +    * [[:wiopi:zero-server-en|Zero Rocrail Server]]
  \\  \\
  
-|  Work In Progress  | 
 {{:wio:zero.jpg?0x120}} {{:wio:zero.jpg?0x120}}
  \\  \\
 +|  Before mounting the header on the Zero, check this [[:wio:wiopi-01-en|WIOpi-01]]  |
  
 +
 +<html><!--
 + \\
 +=====PiOS Versions=====
 +^ Version ^ Remark ^ Date ^
 +| PiOS 11 'Bullseye' | OK |
 +| PiOS 12 'Bookworm' | I2C brings only I/O Error (5) | Oct. 2023 |
 +--></html>
 +
 +
 + \\
 =====Introduction===== =====Introduction=====
-WIOpi is a program targeted for the Raspberry Pi and its GPIO.\\+WIOpi is a program targeted for the Raspberry Pi and its GPIO. (Model 1, 2, 3, 4 and ZeroW.)\\
 The hardware requirements and support are the same as for __**[[:rocnet:rocnetnode-en|RocNetNode]]**__.\\ The hardware requirements and support are the same as for __**[[:rocnet:rocnetnode-en|RocNetNode]]**__.\\
 By running the WIOpi program on the Raspberry Pi, it will behave and process like a WIO on ESP base.\\ By running the WIOpi program on the Raspberry Pi, it will behave and process like a WIO on ESP base.\\
Line 17: Line 33:
 ^ WIOpi runs in context of user **pi**. ^\\ ^ 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.// \\ //The user **pi** is default in the groups **gpio**, **i2c** and **spi**, so no need to run WIOpi in super user context.// \\
 +**Note**: Type mobile should run in root context to be able to run a high performance motor thread.\\
 <code> <code>
 $ groups $ groups
Line 42: Line 59:
  
  \\  \\
 +
 +=====Supported Boards=====
 +  * Raspberry ZeroW 1 and 2
 +  * Raspberry Pi 1, 2 and 3
 +
 +//The Raspberry Pi 4 is not supported.//\\ 
 + \\
 +
 =====Install===== =====Install=====
 Activate I2C, SPI and UART in the raspi-conf utility.\\ Activate I2C, SPI and UART in the raspi-conf utility.\\
Line 59: Line 84:
  
  
 +====Swap Size====
 +The default swap size of 100MB ist for a Zero with 512MB memory not enough.\\
 +<code bash>
 +sudo nano /etc/dphys-swapfile
 +</code>
 +Change the swap size to 1024:
 +<code bash>
 +CONF_SWAPSIZE=1024
 +</code>
 +Restart the service:
 +<code bash>
 +sudo /etc/init.d/dphys-swapfile stop
 +sudo /etc/init.d/dphys-swapfile start
 +</code>
  \\  \\
 =====Command Line Options===== =====Command Line Options=====
 ^ Option ^ Description ^ ^ Option ^ Description ^
 +| -info | set trace level info |
 | -t <filename> | trace filename | | -t <filename> | trace filename |
 | -server <ip> | Rocrail server IP or DNS name | | -server <ip> | Rocrail server IP or DNS name |
 | -id <1...255> | WIOpi Node ID | | -id <1...255> | WIOpi Node ID |
 +| -softpwm | Use software PWM for servos to enable play sound. |
  
  
Line 72: Line 113:
 The Pinout and mapping is printed in the console after startup.\\ The Pinout and mapping is printed in the console after startup.\\
 It depends on the configuration found in the wiopi.ini.\\ It depends on the configuration found in the wiopi.ini.\\
-See for Raspberry Pi Pinout information: https://de.pinout.xyz \\+See for Raspberry Pi Pinout information: https://pinout.xyz \\ 
 +More detailed info: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html \\ 
 +Or issue in a terminal the pinout command.\\
  
  \\  \\
Line 79: Line 122:
   * __**[[:rocnet:pi01can-en|Pi01CAN]]**__   * __**[[:rocnet:pi01can-en|Pi01CAN]]**__
   * __**[[:gca_pi02-en|Pi02]]**__ (max. 4 = 128 I/O)   * __**[[:gca_pi02-en|Pi02]]**__ (max. 4 = 128 I/O)
-  * __**[[:gca-pi03-en|Pi03]]**__ (max. 64 Servo)+  * __**[[:gca-pi03-en|Pi03]]**__ (max. 128 Servos - address 1-128) ((The WIOpi only saves servo positions in case of a shutdown.))
   * __**[[:gca-pi06-en|Pi06]]**__ (Power & Patch)   * __**[[:gca-pi06-en|Pi06]]**__ (Power & Patch)
   * __**[[:gca-pi08-en|Pi08]]**__ (max. 8 = 128 LED. Output address < = 128)   * __**[[:gca-pi08-en|Pi08]]**__ (max. 8 = 128 LED. Output address < = 128)
Line 88: Line 131:
   * __**[[:arduino:wio-en#sensors|BMx280]]**__ (max. 2 Environment)   * __**[[:arduino:wio-en#sensors|BMx280]]**__ (max. 2 Environment)
   * __**[[:gca214-en|GCA214]]**__ RailCom reader on Pi01 (PiOS 32bit only because of the none standard baudrate of 250000.)   * __**[[:gca214-en|GCA214]]**__ RailCom reader on Pi01 (PiOS 32bit only because of the none standard baudrate of 250000.)
-  * __**[[:arduino:wio-en#sound|Play sound]]**__ with "omxplayer" (Without prefix forward slash) +  * __**[[:arduino:wio-en#sound|Play sound]]**__ with "mplayer" (Without prefix forward slash) 
-  * Mobile soft PWM for controlling a DC Motor (Power MOSFET and bistable direction relay)+  * Mobile soft PWM for controlling a DC MotorMOSFET or H-Bridge. ((//WIOpi must be started with sudo to generate a good quality PWM.//)
   * WS2801 RGB LEDs over SPI (Output address > 128)   * WS2801 RGB LEDs over SPI (Output address > 128)
     * LEDScript support in case Port Type is set to Macro.      * LEDScript support in case Port Type is set to Macro. 
-  * 2 Servos on the hardware PWM pins (phys. 32 & 33). ((//Note: WIOpi must be started with sudo to be able to use the PWM outputs.//)) +  * 2 Servos on the hardware PWM pins (phys. 32 & 33 - address 129 and 130). ((//WIOpi must be started with sudo to be able to use the PWM outputs.//)) 
-  * Analog inputs: PCF8591 and ADS1115+  * Analog inputs: PCF8591 
 + 
 +**Note:** //The WIOpi only saves servo positions in case of a shutdown.//\\ 
 + 
 + \\ 
 +=====Onboard Servos===== 
 +The two onboard servos have address 129 and 130.\\ 
 +Mobile functions 1 and 2 are mapped to those onboard servo addresses.\\ 
 +**Note:** //The WIOpi only saves servo positions in case of a shutdown.//\\
  
  
Line 102: Line 153:
 dtoverlay=pwm-2chan,pin=12,func=2,pin2=13,func2=4 dtoverlay=pwm-2chan,pin=12,func=2,pin2=13,func2=4
 </code> </code>
-The filter is quit simple: (Example is for just one channel.)+The filter is quit simple: (Example is for just one channel, and not tested.)
 <code> <code>
                   1µ                   1µ
Line 141: Line 192:
  
  \\  \\
-=====Signals on Pi02/Pi08===== +=====Signals on Pi02/Pi08/WS2801 ===== 
-__**[[:rocnet:rocnetnode-led-en#signal_support|Signals Support]]**__ is also available on the Pi02, with address offset 129.\\+__**[[:rocnet:rocnetnode-led-en#signal_support|Signals Support]]**__ is also available on the Pi02, in case no Pi08 is connected.\\
  
 **Pi08**: 1...128 \\ **Pi08**: 1...128 \\
-**Pi02**: 129...256 (mapped on 1...128) \\ +**Pi02**: 1...128 \\ 
-**WS2801** \\+**WS2801**: 129...256 (mapped on 1...128) \\ 
 + 
 + \\ 
 +===== ID12LA RFID Reader ===== 
 +The default serial device is ''/dev/ttyS0'', and can be changed in the wiopi.ini:\\ 
 +<code> 
 +serialdev="/dev/ttyAMA0" 
 +</code> 
 +|< >| 
 +^ Raspberry pi Model ^ PiOS 10 ^ PiOS 11 ^ 
 +| Zero 1 | /dev/ttyAMA0 | 
 +| Rpi 1 | /dev/ttyAMA0 | 
 +| Zero 2 | /dev/ttyS0 | /dev/ttyAMA0 | 
 +| Rpi 2...4 | /dev/ttyS0 | 
 + 
 +**Note:** //Seems to be PiOS version dependent; Check the system.//\\
  
  \\  \\
Line 155: Line 221:
 |  4 Wire  ||| |  4 Wire  |||
 ^ Function ^ Header ^ GPIO ^ ^ Function ^ Header ^ GPIO ^
-| IN1 (Coil 1) |   |   |+| IN1 (Coil 1) |  27  |   |
 | GND |  9  |  -  | | GND |  9  |  -  |
-| IN2 (Coil 2) |  11  |  17  | +| IN2 (Coil 2) |  29  |   | 
-| IN3 (Coil 3) |  13  |  27  | +| IN3 (Coil 3) |  31  |   | 
-| IN4 (Coil 4) |  15  |  22  | +| IN4 (Coil 4) |  35  |  19  | 
-| HALL (Calibrate) |  21  |   |+| HALL (Calibrate) |  37  |  26  |
  \\  \\
  
Line 167: Line 233:
 |  3 Wire  ||| |  3 Wire  |||
 ^ Function ^ Header ^ GPIO ^ Example TB6600 ^ ^ Function ^ Header ^ GPIO ^ Example TB6600 ^
-| STEP(Clock) |   |   | CLK+ |+| STEP(Clock) |  27  |   | CLK+ |
 | GND |  9  |  -  | EN-, DIR-, CLK- | | GND |  9  |  -  | EN-, DIR-, CLK- |
-| DIR |  11  |  17  | DIR+ | +| DIR |  29  |   | DIR+ | 
-| ENABLE |  13  |  27  | EN+ | +| ENABLE |  31  |   | EN+ | 
-| HALL (Calibrate) |  21  |  13  |+| HALL (Calibrate) |  37  |  26  |
 {{ :wio:qsh4218-35-10-027.jpg?400}}\\ {{ :wio:qsh4218-35-10-027.jpg?400}}\\
  
Line 178: Line 244:
 =====WS2801===== =====WS2801=====
 |< >| |< >|
-^ WS2801 ^ Header ^ Function ^ +^ WS2801 ^ Header ^ I/O1 ^Function ^ 
-| DI | 19 MOSI | Digital In | +| DI | 19 MOSI |  6  | Digital In | 
-| CI | 23 SCLK | Clock In | +| CI | 23 SCLK |  8  | Clock In | 
-| GND | 25 GND | Ground |+| GND | 25 GND |  2  | Ground |
  
 ====Output settings for LEDScript==== ====Output settings for LEDScript====
-Address > 128.\\+Address > 128 or count, ON Parameter, is set to zero.\\
 Options Color, Type Macro.\\ Options Color, Type Macro.\\
  
Line 191: Line 257:
   * [[https://pinout.xyz|Pinout]]   * [[https://pinout.xyz|Pinout]]
   * [[https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/README.md|RaspberryPi Mechanical Drawings]]   * [[https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/README.md|RaspberryPi Mechanical Drawings]]
 +
 +====Files====
 +  * https://gitlab.com/rocrail/wio/-/tree/master/hardware/WIOpi
 +
 +
  
 <code> <code>
Line 245: Line 316:
 http://<zero-name>:8081 http://<zero-name>:8081
 </code> </code>
 +
 +====Mobile====
 +Function 8 can be used to activate and deactivate the CAM.\\
  
  
  \\  \\
 =====I2C Slaves===== =====I2C Slaves=====
-WIOpi supports up to 4 Arduino Slaves.\\+WIOpi supports up to 4 I2C Slaves.\\
 The reserved I2C device addresses are 0x7C, 0x7D, 0x7E and 0x7F.\\ The reserved I2C device addresses are 0x7C, 0x7D, 0x7E and 0x7F.\\
-The WIOnano can be used as skeleton:\\ 
-  * https://gitlab.com/rocrail/wio/-/blob/master/WIOnano/WIOnano.ino 
  
 To address a pin on a slave, the following parameters are involved: To address a pin on a slave, the following parameters are involved:
Line 285: Line 357:
  
  \\  \\
 +
 +
 +=====CAN Slaves=====
 +The [[https://www.fischl.de/usbtin/|USBtin]] CAN adapter can be used to include [[:can-gca2-en|CANGC2]] and [[:can-gc6-en|CANGC6]] modules.\\
 +The CANGC modules must be programmed as follows:
 +  * Long events (deselect Short events)
 +  * The Node Nr. must be set equal to the module its CAN ID
 +  * The Event Nr. must be set equal to the corresponding port number (1...16)
 +  * SoD 4711
 +:!: //The programming must be done by the RCAN library in Rocrail; It is not possible to program CANGCx over WIOpi. The same USBtin can be used for this purpose.//\\
 + \\
 +====Setup examples====
 +{{:wio:cangc2-setup-wiopi-slave.jpg?600}}\\
 +{{:wio:cangc6-setup-wiopi-slave.jpg?600}}\\
 +====Rocrail Addressing====
 +^ Object ^ Node ID ^ Address ^ Port ^
 +| Sensor | WIOpi Node ID | Event Nr. + (Node Nr. * 256) | - |
 +| Output/Servo | WIOpi Node ID | Event Nr. | Node Nr. |
 +
 +
 +
 +
 +
 + \\
 +
 =====User Pin Definitions===== =====User Pin Definitions=====
 To remap pins for Pi01, Stepper and Mobile, the following child nodes in the ''wiopi.ini'' can be used:\\ To remap pins for Pi01, Stepper and Mobile, the following child nodes in the ''wiopi.ini'' can be used:\\
Line 294: Line 391:
 </wiopoi> </wiopoi>
 </code> </code>
 +The **nr** attribute resembles the connector number, __not__ the GPIO.\\ 
  
 +^ Name(fn) ^ Description ^ Remark ^
 +| LED1 | Pi01 LED1 output |
 +| LED2 | Pi01 LED2 output |
 +| Button | Pi01 Button input |
 +| IN1 | Stepper IN1 output | 3W Clock |
 +| IN2 | Stepper IN2 output | 3W Dir |
 +| IN3 | Stepper IN3 output | 3W Enable |
 +| IN4 | Stepper IN4 output |
 +| CAL | Stepper calibration input |
 +| PWM | Mobile PWM output |
 +| FWD | Mobile forwards relay pulse output |
 +| REV | Mobile reverse relay pulse output |
 +| LIGHTS1 | Mobile lights Cab 1 output |
 +| LIGHTS2 | Mobile lights Cab 2 output |
  
 + \\
 +
 +=====Auto Server Connect=====
 +WIOpi use the __**[[:networking-en|R2RNet]]**__ service to detect the Rocrail server in the LAN.\\
 +This service must be __**[[:networking-en#setup|activated in the server settings]]**__.\\
 +\\
 +If Auto Server Connect doesn't work (f.e. the router doesn't support UDP Multicast) the Rocrail Server IP or Name can be added to the wiopi.ini:\\
 +<code xml>
 +<wiopi server="insert the server ip here" nid="99" nodename="WIOpi">
 +</code>
 +WIOpi should be stopped before editing this file:
 +<code>
 +sudo killall wiopi
 +</code>
 + \\
 +\\
 +
 +=====Info Level=====
 +You can edit the startwiopi.sh with sudo nano startwiopi.sh \\
 +Add -info behind ./wiopi for information:
 +<code>
 +#!/bin/sh
 +cd /home/pi/WIOpi
 +sudo ./wiopi -info
 +</code>
 +This should only be done for testing because of cpu utilization
 +=====Mobile Dual Motor=====
 +Locomotives with dual motors require dual H-Bridge support.\\
 +Set the "dualmotor" option to "true" in the wiopi.ini to enable this.\\
 +The second H-Bridge connects to the I/O2 connector on pin 4, 5 and 6.\\
 +The __**[[:gca-wiodrive-en|WIO-Drive]]**__, without ESP, can be used as second H-Bridge. Mount only those parts needed for controlling the H-Bridge. Do not place the rectifier, but wire it.\\
 +|< >|
 +^ I/O2 ^ H-Bridge ^ Rpi Conn ^ WIODrive ^
 +|  2  |  GND  |  25  | IBB1-3 |
 +|  4  |  IN2  |  29  | IBB1-2 |
 +|  5  |  IN1  |  31  | IBB1-1 |
 +|  6  |  ENA  |  35  | ESC1-3 |
  
  
wio/wiopi-en.1611040596.txt.gz · Last modified: 2021/01/19 08:16 by rjversluis