Manipulating GPIO

From AllStarLink Wiki
Revision as of 02:55, 11 January 2022 by KB8JNM (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are 2 types of GPIO as they currently exist in the software. I/O's from a URI/sound fob or equivelant AND I/O's from a hardware driven Parallel Port (usb converted parallel ports can not be bit-banged for control)

URIs/USB Sound Fobs (CM108, CM119)

The GPIO (general-purpose I/O) pins on a URI (or similar USB device) may be individually used as either input or output pins. Currently the URI (because of the CM108-AH chip) only supports 2 usable GPIO pins (GPIO 1 and GPIO 4), plus one pin (labeled GPIO2, but is actually the 'HOOK' signal on the CM-108AH chip) that may be used only for input. The old version of the URI and some other devices that use the original CM-108A chip, have full access to the GPIO 2 signal also.

The upside to the CM-108AH is that if you are monitoring an external contact closure, the GPIO2 (HOOK) input is internally pulled-up and de-bounced, so its perfect for such applications.

Chan_usbradio and chan_simpleusb supports configuration of the GPIO pins in the following manner (from within the section of usbradio.conf that is for the desired device):

gpio1 = in ; in, out0 or out1
gpio4 = out0 ; in, out0 or out1


Printer Port / Parallel Port

Support for configuration of pins 2-9 (output) and pins 10-13 and 15 (inputs) on a Parallel/Printer Port

First, there must be a description in rpt.conf of the address of the port. Standard ports are 378, 278 and 3bc /LPT1, LPT2 and LPT3 respectively.

Described in the file as

iobase=0x378 - iobase=0x278 - iobase=0x3bc / LPT1, LPT2 and LPT3 respectively.

If you might imagine you may use a Doug Hall RBI-1 interface, then begin populating Parallel Port pins starting after pp3 (pin5) as the first 3 would be used for that device and is unchangeable.

Pins 2-9 (output) and pins 10-13 and 15 (inputs)

pp2 = out1 ; out0 (or ptt inside of USBRadio/SimpleUSB)
pp10 = in  (or cor / ctcss inside of USBRadio/SimpleUSB)

Inside of SimpleUSB/USBRadio

When you configure an input pin (10,11,12,13 or 15), you can either designate it as

'cor' (RX input signal) or 'ctcss' (use as the 'ctcss tone valid') input.

If you choose 'cor' or 'ctcss', you also need to set the associated 'carrierfrom' or 'ctcssfrom' to either 'pp' (use the

associated input pin non-inverted) or 'ppinvert' (use the associated input pin inverted).

When you configure an output pin (2-9) as 'ptt' makes the pin the PTT signal on it, either non-inverted or inverted,

depending on the 'invertptt=' setting.

Example:

pp6=ptt

pp7=ctcss

pp11=cor

invertptt=0

carrierfrom=ppinvert (could also be ctcss or ctcssinvert or pp)


Notes:

Pins 18-25 are ground, and all other pins are to be treated as no connection.

PP output pins are 0v/NC/float when not active. When active/true, they switch to ground. So, test with one probe on pin and one on digital/frame ground. Pins never show a voltage.

The condition of the input pins are made available via channel variables (e.g. RPT_URI_GPIO1,

RPT_URI_GPIO4, RPT_PP12, etc.) used by the Event Management Subsystem.

Usage

The output pins may be manipulated via the 'cop,61' (or 'cop,62') command (directly or through a DTMF

command) as follows:

61 - Send Message to USB to control GPIO pins (cop,61,GPIO1=0[,PP4=1].....)
62 - Same as above, without generating the 'complete' telemetry.

Use 0 or 1 to set the specified output to 0 or 1, or a number greater then 1 to specify how

many milliseconds minus 1 to invert its current state. For example, to pulse the bit for 500ms you

would use the value '501'(currently, specified time only significant in increments of 50ms). The

use of specifying a value of N+1 to indicate N milliseconds was done so that if, in the future,

the granulatity increases down to the millisecond level, a value of 1 ms could be specified.

For example, if you wanted to have a DTMF function (in this example *1234) that turned GPIO 1

on, you would specify the following in the [functions] section of the rpt.conf file:

1234 = cop,61,GPIO1=1 ; Turn on GPIO 1


A simple example command structure for using all 8 PP pins for output switches:

98910=cop,61,pp1=0 ;pport pin 1 off

98911=cop,61,pp1=1 ;pport pin 1 on

98920=cop,61,pp2=0 ;pport pin 2 off

98921=cop,61,pp2=1 ;pport pin 2 on

98930=cop,61,pp3=0 ;pport pin 3 off

98931=cop,61,pp3=1 ;pport pin 3 on

98940=cop,61,pp4=0 ;pport pin 4 off

98941=cop,61,pp4=1 ;pport pin 4 on

98950=cop,61,pp5=0 ;pport pin 5 off

98951=cop,61,pp5=1 ;pport pin 5 on

98960=cop,61,pp6=0 ;pport pin 6 off

98961=cop,61,pp6=1 ;pport pin 6 on

98970=cop,61,pp7=0 ;pport pin 7 off

98971=cop,61,pp7=1 ;pport pin 7 on

98980=cop,61,pp8=0 ;pport pin 8 off

98981=cop,61,pp8=1 ;pport pin 8 on


Using a easier to remember structure as you think of it as - 989 (for pp switch cmd) + 1-8 (pp pin#) + 1/0 (on/off). Change to suite needs



This page still needs minor revisions.