1. Parport
Parport est un pilote pour le port parallèle traditionnel des PC. Le port dispose d’un total de 17 broches physiques. Le port parallèle originel a divisé ces broches en trois groupes: données, contrôles et états. Le groupe “données” consiste en 8 broches de sortie, le groupe “contrôles” consiste en 4 broches et le groupe “états” consiste en 5 broches d’entrée.
Au début des années 1990, le port parallèle bidirectionnel est arrivé, ce qui a permis à l’utilisateur d’ajuster le groupe des données comme étant des sorties ou comme étant des entrées. Le pilote de HAL supporte le port bidirectionnel et permet à l’utilisateur de configurer le groupe des données en entrées ou en sorties. Si il est configuré en sorties, un port fournit un total de 12 sorties et 5 entrées. Si il est configuré en entrées, il fournit 4 sorties et 13 entrées.
Dans certains ports parallèles, les broches du groupe contrôle sont des collecteurs ouverts, ils peuvent aussi être mis à l'état bas par une porte extérieure. Sur une carte avec les broches de contrôle en collecteurs ouverts, le mode “x” de HAL permet un usage plus flexible avec 8 sorties dédiées, 5 entrées dédiées et 4 broches en collecteurs ouverts. Dans d’autres ports parallèles, les broches du groupe contrôles sont en push-pull et ne peuvent pas être utilisées comme des entrées.footnote:[HAL ne peut pas déterminer automatiquement si les broches en mode bidirectionnel “x” sont effectivement en collecteurs ouverts (OC). Si elles n’y sont pas, elles ne peuvent pas être utilisées comme des entrées. Essayer de les passer à l'état BAS par une source extérieure peut détériorer le matériel.
Pour déterminer si votre port a des broches de contrôle en “collecteur ouvert”, charger hal_parport en mode “x”, positionner les broches de contrôle à une valeur HAUTE. HAL doit lire des pins à l'état VRAI. Ensuite, insérer une résistance de 470Ω entre une des broches de contrôle et GND du port parallèle. Si la tension de cette broche de contrôle est maintenant proche de 0V et que HAL la lit comme une pin FAUSSE, alors vous avez un port OC. Si la tension résultante est loin de 0V ou que HAL ne la lit pas comme étant FAUSSE, votre port ne ne peut pas être utilisé en mode “x”.
Le matériel extérieur qui pilote les broches de contrôle devrait également utiliser des portes en collecteur ouvert (ex: 74LS05…). Généralement, une pin de HAL -out devrait être VRAIE quand la pin physique est utilisée comme une entrée.
Sur certaines machines, les paramètres du BIOS peuvent affecter la possibilité d’utiliser le mode “x”. Le mode “SPP” est le mode qui fonctionne le plus fréquemment. ]
Aucune autre combinaison n’est supportée. Un port ne peut plus être modifié pour passer d’entrées en sorties dès que le pilote est installé. La figure [fig:Parport-block-diag] montre deux diagrammes, un montre le pilote quand le groupe de données est configuré en sorties et le second le montre configuré en entrées.
Le pilote parport peut contrôler au maximum 8 ports (définis par MAX_PORTS dans le fichier hal_parport.c). Les ports sont numérotés à partir de zéro.
1.1. Installation
loadrt hal_parport cfg="<config-string>"
La chaine config-string représente l’adresse hexadécimale du port, suivie optionnellement par une direction, le tout répété pour chaque port. Les directions sont “in”, “out”, ou “x”, elles déterminent la direction des broches physiques 2 à 9 et s’il y a lieu de créer des pins d’entrée de HAL pour les broches de contrôle physiques. Si la direction n’est pas précisée, le groupe données sera par défault en sortie. Par exemple:
loadrt hal_parport cfg="0x278 0x378 in 0x20A0 out"
Cet exemple installe les pilotes pour un port 0x0278, avec les broches 2 à 9 en sorties (par défaut, puisque ni “ in ”, ni “out” n’est spécifié), un port 0x0378, avec les broches 2 à 9 en entrées et un port 0x20A0, avec les broches 2 à 9 explicitement spécifiées en sorties. Notez que vous devez connaître l’adresse de base des ports parallèles pour configurer correctement les pilotes. Pour les ports sur bus ISA, ce n’est généralement pas un problème, étant donné que les ports sont presque toujours à une adresse “bien connue”, comme 0x278 ou 0x378 qui sont typiquement configurées dans le BIOS. Les adresses des cartes sur bus PCI sont habituellement trouvées avec “lspci -v” dans une ligne “I/O ports”, ou dans un message du kernel après l’exécution de “sudo modprobe -a parport_pc`”. Il n'y a pas d'adresse par défaut, si `<config-string> ne contient pas au moins une adresse, un message d’erreur s’affichera.
1.2. Pins
-
(bit) ``parport.<portnum>.pin-<pinnum>-out — Pilote une pin de sortie physique.
-
(bit) ``parport.<portnum>.pin-<pinnum>-in — Suit une pin d’entrée physique.
-
(bit) ``parport.<portnum>.pin-<pinnum>-in-not — Suit une pin d’entrée physique, mais inversée.
Pour chaque pin, <portnum> est le numéro du port et <pinnum> est le numéro de la broche physique du connecteur DB-25.
Pour chaque broche de sortie physique, le pilote crée une simple pin de HAL, par exemple parport.0.pin-14-out . Les pins 2 jusqu'à 9 font partie du groupe données, elles sont des pins de sortie si le port est défini comme un port de sorties (par défaut en sortie). Les broches 1, 14, 16 et 17 sont des sorties dans tous les modes. Ces pins de HAL contrôlent l'état des pins physiques correspondantes.
Pour chaque pin d’entrée physique, le pilote crée deux pins de HAL, par exemple parport.0.pin-12-in et parport.0.pin-12-in-not . Les pins 10, 11, 12, 13 et 15 sont toujours des sorties. Les pins 2 jusqu'à 9 sont des pins d’entrée seulement si le port est défini comme un port d’entrées. Une pin de HAL -in est VRAIE si la pin physique est haute et FAUSSE si la pin physique est basse. Une pin de HAL -in-not est inversée, elle est FAUSSE si la pin physique est haute. En connectant un signal à l’une ou à l’autre, l’utilisateur peut décider de la logique de l’entrée. En mode “x”, les pins 1, 14, 16 et 17 sont également des pins d’entrée.
1.3. Paramètres
-
(bit) ``parport.<portnum>.pin-<pinnum>-out-invert — Inverse une pin de sortie.
-
`(bit) ``parport.<portnum>.pin-<pinnum>-out-reset ` (seulement les pins 2..9) — VRAIE si cette pin doit être réinitialisée quand la fonction de réinitialisation est exécutée.
-
(U32) parport.<portnum>.reset-time — Le temps (en nanosecondes) entre le moment ou la broche est écrite et le moment ou elle est réititialisée par les fonctions de réinitialisation de HAL.
Le paramètre -invert détermine si une pin de sortie est active haute ou active basse. Si -invert est FAUX, mettre la pin HAL -out VRAIE placera la pin physique à l'état haut et mettre la pin HAL FAUSSE placera la pin physique à l'état bas. Si -invert est VRAI, mettre la pin HAL -out VRAIE va mettre la pin physique à l'état bas.
Si -reset est VRAI, la fonction de réinitialisation va passer la pin à la valeur de -out-invert. Ceci peut être utilisé en conjonction avec “stepgen doublefreq” pour produire un pas par période.
1.4. Fonctions
-
(funct) ``parport.<portnum>.read — Lit les pins physiques du port <portnum> et met à jour les pins de HAL` -in` et` -in-not`.
-
(funct) ``parport.read-all — Lit les pins physiques de tous les ports et met à jour les pins de HAL -in et -in-not.
-
(funct) ``parport.<portnum>.write — Lit les pins de HAL -out du port <portnum> et met à jour les pins de sortie physiques correspondantes.
-
(funct) ``parport.write-all — Lit les pins de HAL -out de tous les ports et met à jour toutes les pins de sortie physiques.
-
(funct) ``parport.<portnum>.reset — Attends que le délai de mise à jour soit écoulé depuis le dernière écriture, remet à jour les pins aux valeurs indiquées par -out-invert et les paramètres de -out-invert. La réinitialisation doit être plus tard dans le même thread que l'écriture.
Les différentes fonctions sont prévues pour les situations où un port doit être mis à jour dans un thread très rapide, mais d’autres ports peuvent être mis à jour dans un thread plus lent pour gagner du temps CPU. Ce n’est probablement pas une bonne idée d’utiliser en même temps, les fonctions -all et une fonction individuelle.
1.5. Problèmes courants
Si le chargement du module le message suivant:
insmod: error inserting '/home/jepler/emc2/rtlib/hal_parport.ko':
s’assurer que le noyau du kernel standard, parport_pc, n’est pas
chargé
[In the emc packages for Ubuntu, the file
/etc/modprobe.d/emc2
generally prevents parport_pc from being automatically loaded.
]
et qu’aucun périphérique dans le système ne revendique les ports
concernés.
SI le module est chargé mais ne semble pas fonctionner, l’adresse du port est incorrecte ou le module probe_parport est requis.
2. probe_parport
Dans les PC récents, le port parallèle peut exiger une configuration plug and play (PNP) avant d'être utilisable. Le module probe_parport effectue la configuration de tous les ports PNP présents et devrait être chargé avant hal_parport . Sur les machines sans ports PNP, il peut être chargé mais n’a aucun effet.
2.1. Installation
loadrt probe_parport
Si le kernel Linux affiche un message similaire à:
parport: PnPBIOS parport detected.
Quand le module parport_pc est chargé, avec la commande: sudo modprobe -a parport_pc; sudo rmmod parport_pc, l’utilisation de ce module sera probablement nécessaire.
.
Les modules commerciaux ci-dessous pouront êtres traduits en français sur demande.
The commercial modules below could be translated into French on request.
.
3. AX5214H
The Axiom Measurement & Control AX5214H is a 48 channel digital I/O
board. It plugs into an ISA bus, and resembles a pair of 8255
chips.
[In fact it may be a pair of 8255 chips, but I’m not
sure. If/when
someone starts a driver for an 8255 they should look at the ax5214
code, much of the work is already done.
]
3.1. Installing
loadrt hal_ax5214h cfg="<config-string>"
The config string consists of a hex port address, followed by an 8 character string of “I” and “O” which sets groups of pins as inputs and outputs. The first two character set the direction of the first two 8 bit blocks of pins (0-7 and 8-15). The next two set blocks of 4 pins (16-19 and 20-23). The pattern then repeats, two more blocks of 8 bits (24-31 and 32-39) and two blocks of 4 bits (40-43 and 44-47). If more than one board is installed, the data for the second board follows the first. As an example, the string "0x220 IIIOIIOO 0x300 OIOOIOIO" installs drivers for two boards. The first board is at address 0x220, and has 36 inputs (0-19 and 24-39) and 12 outputs (20-23 and 40-47). The second board is at address 0x300, and has 20 inputs (8-15, 24-31, and 40-43) and 28 outputs (0-7. 16-23, 32-39, and 44-47). Up to 8 boards may be used in one system.
3.2. Pins
-
(bit`) ax5214.<boardnum>.out-<pinnum> `-- Drives a physical output pin.
-
(bit) ax5214.<boardnum>.in-<pinnum> — Tracks a physical input pin.
-
(bit) ax5214.<boardnum>.in-<pinnum>-not — Tracks a physical input pin, inverted.
For each pin, <boardnum> is the board number (starts at zero), and <pinnum> is the I/O channel number (0 to 47).
Note that the driver assumes active LOW signals. This is so that modules such as OPTO-22 will work correctly (TRUE means output ON, or input energized). If the signals are being used directly without buffering or isolation the inversion needs to be accounted for. The in- HAL pin is TRUE if the physical pin is low (OPTO-22 module energized), and FALSE if the physical pin is high (OPTO-22 module off). The in-<pinnum>-not HAL pin is inverted — it is FALSE if the physical pin is low (OPTO-22 module energized). By connecting a signal to one or the other, the user can determine the state of the input.
3.3. Parameters
-
(bit) ax5214.<boardnum>.out-<pinnum>-invert — Inverts an output pin.
The -invert parameter determines whether an output pin is active high or active low. If -invert is FALSE, setting the HAL out- pin TRUE drives the physical pin low, turning ON an attached OPTO-22 module, and FALSE drives it high, turning OFF the OPTO-22 module. If -invert is TRUE, then setting the HAL out- pin TRUE will drive the physical pin high and turn the module OFF.
3.4. Functions
-
(funct) ``ax5214.<boardnum>.read — Reads all digital inputs on one board.
-
`(funct) ``ax5214.<boardnum>.write `-- Writes all digital outputs on one board.
4. Servo-To-Go
The Servo-To-Go is one of the first PC motion control cards
[a
motion control card usually is a board containing devices to control
one or more axes (the control devices are usually DAC’s to set an
analog voltage, encoder counting chips for feedback, etc.)
]
supported by EMC. It is an ISA card and it exists in different
flavours (all supported by this driver). The board includes up to 8
channels of quadrature encoder input, 8 channels of analog input and
output, 32 bits digital I/O, an interval timer with interrupt and a
watchdog.
4.1. Installing:
loadrt hal_stg [base=<address>] [num_chan=<nr>] [dio="<dio-string>"] [model=<model>]
The base address field is optional; if it’s not provided the driver
attempts to autodetect the board. The num_chan field is used to specify
the number of channels available on the card, if not used the 8 axis
version is assumed. The digital inputs/outputs configuration is
determined by a config string passed to insmod when loading the module.
The format consists of a four character string that sets the direction
of each group of pins. Each character of the direction string is either
"I" or "O". The first character sets the direction of port A (Port A -
DIO.0-7), the next sets port B (Port B - DIO.8-15), the next sets port
C (Port C - DIO.16-23), and the fourth sets port D (Port D -
DIO.24-31). The model field can be used in case the driver doesn’t
autodetect the right card version
[hint: after starting up the
driver, dmesg can be consulted for
messages relevant to the driver (e.g. autodetected version number and
base address)
]
. For example:
loadrt hal_stg base=0x300 num_chan=4 dio="IOIO"
This example installs the stg driver for a card found at the base address of 0x300, 4 channels of encoder feedback, DAC’s and ADC’s, along with 32 bits of I/O configured like this: the first 8 (Port A) configured as Input, the next 8 (Port B) configured as Output, the next 8 (Port C) configured as Input, and the last 8 (Port D) configured as Output
loadrt hal_stg
This example installs the driver and attempts to autodetect the board address and board model, it installs 8 axes by default along with a standard I/O setup: Port A & B configured as Input, Port C & D configured as Output.
4.2. Pins
-
(s32`) stg.<channel>.counts `-- Tracks the counted encoder ticks.
-
(float) stg.<channel>.position — Outputs a converted position.
-
(float`) stg.<channel>.dac-value `-- Drives the voltage for the corresponding DAC.
-
(float) stg.<channel>.adc-value — Tracks the measured voltage from the corresponding ADC.
-
(bit) ``stg.in-<pinnum> — Tracks a physical input pin.
-
(bit) ``stg.in-<pinnum>-not — Tracks a physical input pin, but inverted.
-
(bit) ``stg.out-<pinnum> — Drives a physical output pin
For each pin, <channel> is the axis number, and <pinnum> is the
logic pin number of the STG
[if IIOO is defined, there
are 16 input pins (in-00 .. in-15) and 16
output pins (out-00 .. out-15), and they correspond to PORTs ABCD
(in-00 is PORTA.0, out-15 is PORTD.7)
]
.
The in- HAL pin is TRUE if the physical pin is high, and FALSE if the physical pin is low. The in-<pinnum>-not HAL pin is inverted — it is FALSE if the physical pin is high. By connecting a signal to one or the other, the user can determine the state of the input.
4.3. Parameters
-
(float) ``stg.<channel>.position-scale — The number of counts / user unit (to convert from counts to units).
-
(float`) stg.<channel>.dac-offset `-- Sets the offset for the corresponding DAC.
-
(float) stg.<channel>.dac-gain — Sets the gain of the corresponding DAC.
-
(float) stg.<channel>.adc-offset — Sets the offset of the corresponding ADC.
-
(float) stg.<channel>.adc-gain — Sets the gain of the corresponding ADC.
-
(bit) stg.out-<pinnum>-invert — Inverts an output pin.
The -invert parameter determines whether an output pin is active high or active low. If -invert is FALSE, setting the HAL out- pin TRUE drives the physical pin high, and FALSE drives it low. If -invert is TRUE, then setting the HAL out- pin TRUE will drive the physical pin low.
4.4. Functions
-
(funct) ``stg.capture-position — Reads the encoder counters from the axis <channel>.
-
`(funct) ``stg.write-dacs `-- Writes the voltages to the DACs.
-
(funct) ``stg.read-adcs — Reads the voltages from the ADCs.
-
(funct) ``stg.di-read — Reads physical in- pins of all ports and updates all HAL in- and in-<pinnum>-not pins.
-
(funct) ``stg.do-write — Reads all HAL out- pins and updates all physical output pins.
5. Mesa Electronics m5i20 “Anything I/O Card”
The Mesa Electronics m5i20 card consists of an FPGA that can be loaded
with a wide variety of configurations, and has 72 pins that leave the
PC. The assignment of the pins depends on the FPGA configuration.
Currently there is a HAL driver for the “4 axis host based motion
control” configuration, and this FPGA configurations is also provided
with EMC2. It provides 8 encoder counters, 4 PWM outputs (normally used
as DACs) and up to 48 digital I/O channels, 32 inputs and 16
outputs.
[Ideally the encoders, “DACs”, and digital I/O would
comply with the
canonical interfaces defined earlier, but they don’t. Fixing that is on
the things-to-do list.
]
Installing:
loadrt hal_m5i20 [loadFpga=1|0] [dacRate=<rate>]
If loadFpga is 1 (the default) the driver will load the FPGA configuration on startup. If it is 0, the driver assumes the configuration is already loaded. dacRate sets the carrier frequency for the PWM outputs, in Hz. The default is 32000, for 32KHz PWM. Valid values are from 1 to 32226. The driver prints some useful debugging message to the kernel log, which can be viewed with dmesg.
Up to 4 boards may be used in one system.
5.1. Pins
In the following pins, parameters, and functions, <board> is the board ID. According to the naming conventions the first board should always have an ID of zero, however this driver uses the PCI board ID, so it may be non-zero even if there is only one board.
-
(s32`) m5i20.<board>.enc-<channel>-count `-- Encoder position, in counts.
-
(float`) m5i20.<board>.enc-<channel>-position `-- Encoder position, in user units.
-
(bit) ``m5i20.<board>.enc-<channel>-index — Current status of index pulse input?
-
(bit)` m5i20.<board>.enc-<channel>-index-enable -- when true , and an index pulse appears on the encoder input, reset counter to zero and clear `index-enable.
-
(bit) ``m5i20.<board>.enc-<channel>-reset — When true, counter is forced to zero.
-
(bit) ``m5i20.<board>.dac-<channel>-enable — Enables DAC if true. DAC outputs zero volts if false?
-
(float) ``m5i20.<board>.dac-<channel>-value — Analog output value for PWM “DAC” (in user units, see -scale and -offset)
-
(bit) ``m5i20.<board>.in-<channel> — State of digital input pin, see canonical digital input.
-
(bit) ``m5i20.<board>.in-<channel>-not — Inverted state of digital input pin, see canonical digital input.
-
(bit) ``m5i20.<board>.out-<channel> — Value to be written to digital output, see canonical digital output.
-
(bit) ``m5i20.<board>.estop-in — Dedicated estop input, more details needed.
-
(bit) ``m5i20.<board>.estop-in-not — Inverted state of dedicated estop input.
-
(bit) ``m5i20.<board>.watchdog-reset — Bidirectional, - Set TRUE to reset watchdog once, is automatically cleared. If bit value 16 is set in watchdog-control then this value is not used, and the hardware watchdog is cleared every time the dac-write function is executed.
5.2. Parameters
-
(float) ``m5i20.<board>.enc-<channel>-scale — The number of counts / user unit (to convert from counts to units).
-
(float`) m5i20.<board>.dac-<channel>-offset `-- Sets the DAC offset.
-
(float`) m5i20.<board>.dac-<channel>-gain `-- Sets the DAC gain (scaling).
-
(bit`) m5i20.<board>.dac-<channel>-interlaced ` — Sets the DAC to interlaced mode. Use this mode if you are filtering the PWM to generate an anaolg voltage.
[With normal 10 bit PWM, 50% duty cycle would be 512 cycles on and 512 cycles off = ca 30 kHz with 33 MHz reference counter. With fully interleaved PWM this would be 1 cycle on, 1 cycle off for 1024 cycles (16.66 MHz if the PWM reference counter runs at 33 MHz) = much easier to filter. The 5I20 configuration interlace is somewhat between non and fully interlaced (to make it easy to filter but not have as many transistions as fully interleaved). ]
-
(bit`) m5i20.<board>.out-<channel>-invert `-- Inverts a digital output, see canonical digital output.
-
(u32) m5i20.<board>.watchdog-control — Configures the watchdog. The value may be a bitwise OR of the following values:
[width="90%", options="header"] |======================================== |Bit # | Value | Meaning |0 | 1 | Watchdog is enabled |1 | 2 | Watchdog is automatically reset by DAC writes (the HAL `dac-write` function) |======================================== Typically, the useful values are 0 (watchdog disabled) or 3 (watchdog enabled, cleared by `dac-write`). - `(``u32``) m5i20.<board>.led-view` -- Maps some of the I/O to onboard LEDs. See table below.
5.3. Functions
-
(funct) ``m5i20.<board>.encoder-read — Reads all encoder counters.
-
(funct)` m5i20.<board>.digital-in-read `-- Reads digital inputs.
-
`(funct) ``m5i20.<board>.dac-write `-- Writes the voltages (PWM duty cycles) to the “DACs”.
-
(funct)` m5i20.<board>.digital-out-write `-- Writes digital outputs.
-
(funct) ``m5i20.<board>.misc-update — Writes watchdog timer configuration to hardware. Resets watchdog timer. Updates E-stop pin (more info needed). Updates onboard LEDs.
5.4. Connector pinout
The Hostmot-4 FPGA configuration has the following pinout. There are three 50-pin ribbon cable connectors on the card: P2, P3, and P4. There are also 8 status LEDs.
5.4.1. Connector P2
m5i20 card connector P2 | Function/HAL-pin |
---|---|
1 |
enc-01 A input |
3 |
enc-01 B input |
5 |
enc-00 A input |
7 |
enc-00 B input |
9 |
enc-01 index input |
11 |
enc-00 index input |
13 |
dac-01 output |
15 |
dac-00 output |
17 |
DIR output for dac-01 |
19 |
DIR output for dac-00 |
21 |
dac-01-enable output |
23 |
dac-00-enable output |
25 |
enc-03 B input |
27 |
enc-03 A input |
29 |
enc-02 B input |
31 |
enc-02 A input |
33 |
enc-03 index input |
35 |
enc-02 index input |
37 |
dac-03 output |
39 |
dac-02 output |
41 |
DIR output for dac-03 |
43 |
DIR output for dac-02 |
45 |
dac-03-enable output |
47 |
dac-02-enable output |
49 |
Power +5 V (or +3.3V ?) |
all even pins |
Ground |
5.4.2. Connector P3
Encoder counters 4 - 7 work simultaneously with in-00 to in-11.
If you are using in-00 to in-11 as general purpose IO then reading enc-<4-7> will produce some random junk number.
m5i20 card connector P3 | Function/HAL-pin | Secondary Function/HAL-pin |
---|---|---|
1 |
in-00 |
enc-04 A input |
3 |
in-01 |
enc-04 B input |
5 |
in-02 |
enc-04 index input |
7 |
in-03 |
enc-05 A input |
9 |
in-04 |
enc-05 B input |
11 |
in-05 |
enc-05 index input |
13 |
in-06 |
enc-06 A input |
15 |
in-07 |
enc-06 B input |
17 |
in-08 |
enc-06 index input |
19 |
in-09 |
enc-07 A input |
21 |
in-10 |
enc-07 B input |
23 |
in-11 |
enc-07 index input |
25 |
in-12 |
|
27 |
in-13 |
|
29 |
in-14 |
|
31 |
in-15 |
|
33 |
out-00 |
|
35 |
out-01 |
|
37 |
out-02 |
|
39 |
out-03 |
|
41 |
out-04 |
|
43 |
out-05 |
|
45 |
out-06 |
|
47 |
out-07 |
|
49 |
Power +5 V (or +3.3V ?) |
|
all even pins |
Ground |
5.4.3. Connector P4
The index mask masks the index input of the encoder so that the
encoder index can be combined with a mechanical switch or opto detector
to clear or latch the encoder counter only when the mask input bit is
in proper state (selected by mask polarity bit) and encoder index
occurs. This is useful for homing. The behaviour of these pins is
controlled by the Counter Control Register (CCR), however there is
currently no function in the driver to change the CCR. See
REGMAP4
[emc2/src/hal/drivers/m5i20/REGMAP4E
]
for a description of the CCR.
m5i20 card connector P4 | Function/HAL-pin | Secondary Function/HAL-pin |
---|---|---|
1 |
in-16 |
enc-00 index mask |
3 |
in-17 |
enc-01 index mask |
5 |
in-18 |
enc-02 index mask |
7 |
in-19 |
enc-03 index mask |
9 |
in-20 |
|
11 |
in-21 |
|
13 |
in-22 |
|
15 |
in-23 |
|
17 |
in-24 |
enc-04 index mask |
19 |
in-25 |
enc-05 index mask |
21 |
in-26 |
enc-06 index mask |
23 |
in-27 |
enc-07 index mask |
25 |
in-28 |
|
27 |
in-29 |
|
29 |
in-30 |
|
31 |
in-31 |
|
33 |
out-08 |
|
35 |
out-09 |
|
37 |
out-10 |
|
39 |
out-11 |
|
41 |
out-12 |
|
43 |
out-13 |
|
45 |
out-14 |
|
47 |
out-15 |
|
49 |
Power +5 V (or +3.3V ?) |
|
all even pins |
Ground |
5.4.4. LEDs
The status LEDs will monitor one motion channel set by the` m5i20.<board>.led-view parameter. A call to `m5i20.<board>.misc-update is required to update the viewed channel.
LED name | Output |
---|---|
LED0 |
IRQLatch ? |
LED1 |
enc-<channel> A |
LED2 |
enc-<channel> B |
LED3 |
enc-<channel> index |
LED4 |
dac-<channel> DIR |
LED5 |
dac-<channel> |
LED6 |
dac-<channel>-enable |
LED7 |
watchdog timeout ? |
6. Vital Systems Motenc-100 and Motenc-LITE
The Vital Systems Motenc-100 and Motenc-LITE are 8- and 4-channel
servo control boards. The Motenc-100 provides 8 quadrature encoder
counters, 8 analog inputs, 8 analog outputs, 64 (68?) digital inputs,
and 32 digital outputs. The Motenc-LITE has only 4 encoder counters, 32
digital inputs and 16 digital outputs, but it still has 8 analog inputs
and 8 analog outputs. The driver automatically identifies the installed
board and exports the appropriate HAL objects.
[Ideally the
encoders, DACs, ADCs, and digital I/O would comply with
the canonical interfaces defined earlier, but they don’t. Fixing that
is on the things-to-do list.
]
Installing:
loadrt hal_motenc
During loading (or attempted loading) the driver prints some usefull debugging message to the kernel log, which can be viewed with dmesg.
Up to 4 boards may be used in one system.
6.1. Pins
In the following pins, parameters, and functions, <board> is the board ID. According to the naming conventions the first board should always have an ID of zero. However this driver sets the ID based on a pair of jumpers on the baord, so it may be non-zero even if there is only one board.
-
(s32`) motenc.<board>.enc-<channel>-count `-- Encoder position, in counts.
-
(float`) motenc.<board>.enc-<channel>-position `-- Encoder position, in user units.
-
(bit) ``motenc.<board>.enc-<channel>-index — Current status of index pulse input.
-
(bit) ``motenc.<board>.enc-<channel>-idx-latch — Driver sets this pin true when it latches an index pulse (enabled by latch-index). Cleared by clearing` latch-index`.
-
(bit) ``motenc.<board>.enc-<channel>-latch-index — If this pin is true, the driver will reset the counter on the next index pulse.
-
(bit) ``motenc.<board>.enc-<channel>-reset-count — If this pin is true, the counter will immediately be reset to zero, and the pin will be cleared.
-
(float) ``motenc.<board>.dac-<channel>-value — Analog output value for DAC (in user units, see -gain and -offset)
-
(float) ``motenc.<board>.adc-<channel>-value — Analog input value read by ADC (in user units, see -gain and -offset)
-
(bit) ``motenc.<board>.in-<channel> — State of digital input pin, see canonical digital input.
-
(bit) ``motenc.<board>.in-<channel>-not — Inverted state of digital input pin, see canonical digital input.
-
(bit) ``motenc.<board>.out-<channel> — Value to be written to digital output, seen canonical digital output.
-
(bit) ``motenc.<board>.estop-in — Dedicated estop input, more details needed.
-
(bit) ``motenc.<board>.estop-in-not — Inverted state of dedicated estop input.
-
(bit) ``motenc.<board>.watchdog-reset — Bidirectional, - Set TRUE to reset watchdog once, is automatically cleared.
6.2. Parameters
-
(float) ``motenc.<board>.enc-<channel>-scale — The number of counts / user unit (to convert from counts to units).
-
(float`) motenc.<board>.dac-<channel>-offset `-- Sets the DAC offset.
-
(float`) motenc.<board>.dac-<channel>-gain `-- Sets the DAC gain (scaling).
-
(float`) motenc.<board>.adc-<channel>-offset `-- Sets the ADC offset.
-
(float`) motenc.<board>.adc-<channel>-gain `-- Sets the ADC gain (scaling).
-
(bit`) motenc.<board>.out-<channel>-invert `-- Inverts a digital output, see canonical digital output.
-
(u32) motenc.<board>.watchdog-control — Configures the watchdog. The value may be a bitwise OR of the following values:
[width="90%", options="header"] |======================================== |Bit # | Value | Meaning |0 | 1 | Timeout is 16ms if set, 8ms if unset |2 | 4 | Watchdog is enabled |4 | 16 | Watchdog is automatically reset by DAC writes (the HAL `dac-write` function) |======================================== Typically, the useful values are 0 (watchdog disabled) or 20 (8ms watchdog enabled, cleared by `dac-write`). - `(``u32``) motenc.<board>.led-view` -- Maps some of the I/O to onboard LEDs?
6.3. Functions
-
(funct) ``motenc.<board>.encoder-read — Reads all encoder counters.
-
`(funct) ``motenc.<board>.adc-read `-- Reads the analog-to-digital converters.
-
(funct)` motenc.<board>.digital-in-read `-- Reads digital inputs.
-
`(funct) ``motenc.<board>.dac-write `-- Writes the voltages to the DACs.
-
(funct)` motenc.<board>.digital-out-write `-- Writes digital outputs.
-
(funct) ``motenc.<board>.misc-update — Updates misc stuff.
7. Pico Systems PPMC (Parallel Port Motion Control)
Pico Systems has a family of boards for doing servo, stepper, and pwm control. The boards connect to the PC through a parallel port working in EPP mode. Although most users connect one board to a parallel port, in theory any mix of up to 8 or 16 boards can be used on a single parport. One driver serves all types of boards. The final mix of I/O depends on the connected board(s). The driver doesn’t distinguish between boards, it simply numbers I/O channels (encoders, etc) starting from 0 on the first card.
Installing:
loadrt hal_ppmc port_addr=<addr1>[,<addr2>[,<addr3>...]]
The port_addr parameter tells the driver what parallel port(s) to check. By default, <addr1> is 0x0378, and <addr2> and following are not used. The driver searches the entire address space of the enhanced parallel port(s) at port_addr , looking for any board(s) in the PPMC family. It then exports HAL pins for whatever it finds. During loading (or attempted loading) the driver prints some usefull debugging message to the kernel log, which can be viewed with dmesg.
Up to 3 parport busses may be used, and each bus may have up to 8 devices on it.
7.1. Pins
In the following pins, parameters, and functions, <board> is the board ID. According to the naming conventions the first board should always have an ID of zero. However this driver sets the ID based on a pair of jumpers on the baord, so it may be non-zero even if there is only one board.
-
(s32`) ppmc.<port>.encoder.<channel>.count `-- Encoder position, in counts.
-
(s32`) ppmc.<port>.encoder.<channel>.delta `-- Change in counts since last read.
-
(float`) ppmc.<port>.encoder.<channel>.position `-- Encoder position, in user units.
-
(bit) ``ppmc.<port>.encoder.<channel>.index — Something to do with index pulse.
[Index handling does not comply with the canonical encoder interface, and should be changed. ]
-
(bit) ``ppmc.<port>.pwm.<channel>.enable — Enables a PWM generator.
-
(float) ``ppmc.<port>.pwm.<channel>.value — Value which determines the duty cycle of the PWM waveforms. The value is divided by pwm.<channel>.scale , and if the result is 0.6 the duty cycle will be 60%, and so on. Negative values result in the duty cycle being based on the absolute value, and the direction pin is set to indicate negative.
-
(bit) ``ppmc.<port>.stepgen.<channel>.enable — Enables a step pulse generator.
-
(float) ``ppmc.<port>.stepgen.<channel>.velocity — Value which determines the step frequency. The value is multiplied by stepgen.<channel>.scale , and the result is the frequency in steps per second. Negative values result in the frequency being based on the absolute value, and the direction pin is set to indicate negative.
-
(bit) ``ppmc.<port>.in-<channel> — State of digital input pin, see canonical digital input.
-
(bit) ``ppmc.<port>.in.<channel>.not — Inverted state of digital input pin, see canonical digital input.
-
(bit) ``ppmc.<port>.out-<channel> — Value to be written to digital output, seen canonical digital output.
7.2. Parameters
-
(float) ``ppmc.<port>.enc.<channel>.scale — The number of counts / user unit (to convert from counts to units).
-
(float) ``ppmc.<port>.pwm.<channel-range>.freq — The PWM carrier frequency, in Hz. Applies to a group of four consecutive PWM generators, as indicated by <channel-range>. Minimum is 153Hz, maximum is 500KHz.
-
(float) ppmc.<port>.pwm.<channel>.scale `-- Scaling for PWM generator. If `scale is X, then the duty cycle will be 100% when the value pin is X (or -X).
-
(float`) ppmc.<port>.pwm.<channel>.max-dc `-- Maximum duty cycle, from 0.0 to 1.0.
-
(float`) ppmc.<port>.pwm.<channel>.min-dc `-- Minimum duty cycle, from 0.0 to 1.0.
-
(float`) ppmc.<port>.pwm.<channel>.duty-cycle `-- Actual duty cycle (used mostly for troubleshooting.)
-
(bit`) ppmc.<port>.pwm.<channel>.bootstrap ` — If true, the PWM generator will generate a short sequence of pulses of both polarities when it is enabled, to charge the bootstrap capacators used on some MOSFET gate drivers.
-
(u32) ppmc.<port>.stepgen.<channel-range>.setup-time ` -- Sets minimum time between direction change and step pulse, in units of 100nS. Applies to a group fof four consecutive PWM generators, as indicated by `<channel-range>.
-
(u32) ppmc.<port>.stepgen.<channel-range>.pulse-width ` -- Sets width of step pulses, in units of 100nS. Applies to a group fof four consecutive PWM generators, as indicated by `<channel-range>.
-
(u32) ppmc.<port>.stepgen.<channel-range>.pulse-space-min ` -- Sets minimum time between pulses, in units of 100nS. The maximum step rate is 1/( 100nS * ( pulse-width` +` pulse-space-min` )). Applies to a group fof four consecutive PWM generators, as indicated by <channel-range>.
-
(float) ppmc.<port>.stepgen.<channel>.scale ` -- Scaling for step pulse generator. The step frequency in Hz is the absolute value of `velocity * scale.
-
(float) ppmc.<port>.stepgen.<channel>.max-vel `-- The maximum value for `velocity. Commands greater than max-vel will be clamped. Also applies to negative values. (The absolute value is clamped.)
-
(float`) ppmc.<port>.stepgen.<channel>.frequency `-- Actual step pulse frequency in Hz (used mostly for troubleshooting.)
-
(bit`) ppmc.<port>.out.<channel>.invert `-- Inverts a digital output, see canonical digital output.
7.3. Functions
-
(funct) ``ppmc.<port>.read — Reads all inputs (digital inputs and encoder counters) on one port.
-
`(funct) ``ppmc.<port>.write `-- Writes all outputs (digital outputs, stepgens, PWMs) on one port.
8. Pluto-P: generalities
The Pluto-P is an inexpensive ($60) FPGA board featuring the ACEX1K chip from Altera.
8.1. Requirements
-
A Pluto-P board
-
An EPP-compatible parallel port, configured for EPP mode in the system BIOS
8.2. Connectors
-
The Pluto-P board is shipped with the left connector presoldered, with the key in the indicated position. The other connectors are unpopulated. There does not seem to be a standard 12-pin IDC connector, but some of the pins of a 16P connector can hang off the board next to QA3/QZ3.
-
The bottom and right connectors are on the same .1" grid, but the left connector is not. If OUT2…OUT9 are not required, a single IDC connector can span the bottom connector and the bottom two rows of the right connector.
8.3. Physical Pins
-
Read the ACEX1K datasheet for information about input and output voltage thresholds. The pins are all configured in "LVTTL/LVCMOS" mode and are generally compatible with 5V TTL logic.
-
Before configuration and after properly exiting emc2, all Pluto-P pins are tristated with weak pull-ups (20kΩ min, 50kΩ max). If the watchdog timer is enabled (the default), these pins are also tristated after an interruption of communication between emc2 and the board. The watchdog timer takes approximately 6.5ms to activate. However, software bugs in the pluto_servo firmware or emc2 can leave the Pluto-P pins in an undefined state.
-
In pwm+dir mode, by default dir is HIGH for negative values and LOW for positive values. To select HIGH for positive values and LOW for negative values, set the corresponding dout-NN-invert parameter TRUE to invert the signal.
-
The index input is triggered on the rising edge. Initial testing has shown that the QZx inputs are particularly noise sensitive, due to being polled every 25ns. Digital filtering has been added to filter pulses shorter than 175ns (seven polling times). Additional external filtering on all input pins, such as a Schmitt buffer or inverter, RC filter, or differential receiver (if applicable) is recommended.
-
The IN1…IN7 pins have 22-ohm series resistors to their associated FPGA pins. No other pins have any sort of protection for out-of-spec voltages or currents. It is up to the integrator to add appropriate isolation and protection. Traditional parallel port optoisolator boards do not work with pluto_servo due to the bidirectional nature of the EPP protocol.
8.4. LED
-
When the device is unprogrammed, the LED glows faintly. When the device is programmed, the LED glows according to the duty cycle of PWM0 (LED = UP0 xor DOWN0) or STEPGEN0 (LED = STEP0 xor DIR0).
8.5. Power
-
A small amount of current may be drawn from VCC. The available current depends on the unregulated DC input to the board. Alternately, regulated +3.3VDC may be supplied to the FPGA through these VCC pins. The required current is not yet known, but is probably around 50mA plus I/O current.
-
The regulator on the Pluto-P board is a low-dropout type. Supplying 5V at the power jack will allow the regulator to work properly.
8.6. PC interface
-
At present, only a single pluto_servo or pluto_step board is supported. At present there is no provision for multiple boards on one parallel port (because all boards reside at the same EPP address) but supporting one board per parallel port should be possible.
8.7. Rebuilding the FPGA firmware
The src/hal/drivers/pluto_servo_firmware/ and src/hal/drivers/pluto_step_firmware/` ` subdirectories contain the Verilog source code plus additional files used by Quartus for the FPGA firmwares. Altera’s Quartus II software is required to rebuild the FPGA firmware. To rebuild the firmware from the .hdl and other source files, open the .qpf file and press CTRL-L. Then, recompile emc2.
Like the HAL hardware driver, the FPGA firmware is licensed under the terms of the GNU General Public License.
The gratis version of Quartus II runs only on Microsoft Windows, although there is apparently a paid version that runs on Linux.
8.8. For more information
The Pluto-P board may be ordered from http://www.knjn.com/ShopBoards_Parallel.html (US based, international shipping is available). Some additional information about it is available from http://www.fpga4fun.com/board_pluto-P.html and from the developer’s blog.
9. pluto-servo: Hardware PWM and quadrature counting
The pluto_servo system is suitable for control of a 4-axis CNC mill with servo motors, a 3-axis mill with PWM spindle control, a lathe with spindle encoder, etc. The large number of inputs allows a full set of limit switches.
This driver features:
-
4 quadrature channels with 40MHz sample rate. The counters operate in "4x" mode. The maximum useful quadrature rate is 8191 counts per emc2 servo cycle, or about 8MHz for EMC2’s default 1ms servo rate.
-
4 PWM channels, "up/down" or "pwm+dir" style. 4095 duty cycles from -100% to +100%, including 0%. The PWM period is approximately 19.5kHz (40MHz / 2047). A PDM-like mode is also available.
-
18 digital outputs: 10 dedicated, 8 shared with PWM functions. (Example: A lathe with unidirectional PWM spindle control may use 13 total digital outputs)
-
20 digital inputs: 8 dedicated, 12 shared with Quadrature functions. (Example: A lathe with index pulse only on the spindle may use 13 total digital inputs)
-
EPP communication with the PC. The EPP communication typically takes around 100uS on machines tested so far, enabling servo rates above 1kHz.
9.1. Pinout
- UPx
-
The "up" (up/down mode) or “pwm” (pwm+direction mode) signal from PWM generator X. May be used as a digital output if the corresponding PWM channel is unused, or the output on the channel is always negative. The corresponding digital output invert may be set to TRUE to make UPx active low rather than active high.
- DNx
-
The "down" (up/down mode) or “direction” (pwm+direction mode) signal from PWM generator X. May be used as a digital output if the corresponding PWM channel is unused, or the output on the channel is never negative. The corresponding digital ouput invert may be set to TRUE to make DNx active low rather than active high.
- QAx, QBx
-
The A and B signals for Quadrature counter X. May be used as a digital input if the corresponding quadrature channel is unused.
- QZx
-
The Z (index) signal for quadrature counter X. May be used as a digital input if the index feature of the corresponding quadrature channel is unused.
- INx
-
Dedicated digital input #x
- OUTx
-
Dedicated digital output #x
- GND
-
Ground
- VCC
-
+3.3V regulated DC
Primary function | Alternate Function | Behavior if both functions used |
---|---|---|
UP0 |
PWM0 |
When pwm-0-pwmdir is TRUE, this pin is the PWM output |
OUT10 |
XOR’d with UP0 or PWM0 |
|
UP1 |
PWM1 |
When pwm-1-pwmdir is TRUE, this pin is the PWM output |
OUT12 |
XOR’d with UP1 or PWM1 |
|
UP2 |
PWM2 |
When pwm-2-pwmdir is TRUE, this pin is the PWM output |
OUT14 |
XOR’d with UP2 or PWM2 |
|
UP3 |
PWM3 |
When pwm-3-pwmdir is TRUE, this pin is the PWM output |
OUT16 |
XOR’d with UP3 or PWM3 |
|
DN0 |
DIR0 |
When pwm-0-pwmdir is TRUE, this pin is the DIR output |
OUT11 |
XOR’d with DN0 or DIR0 |
|
DN1 |
DIR1 |
When pwm-1-pwmdir is TRUE, this pin is the DIR output |
OUT13 |
XOR’d with DN1 or DIR1 |
|
DN2 |
DIR2 |
When pwm-2-pwmdir is TRUE, this pin is the DIR output |
OUT15 |
XOR’d with DN2 or DIR2 |
|
DN3 |
DIR3 |
When pwm-3-pwmdir is TRUE, this pin is the DIR output |
OUT17 |
XOR’d with DN3 or DIR3 |
|
QZ0 |
IN8 |
Read same value |
QZ1 |
IN9 |
Read same value |
QZ2 |
IN10 |
Read same value |
QZ3 |
IN11 |
Read same value |
QA0 |
IN12 |
Read same value |
QA1 |
IN13 |
Read same value |
QA2 |
IN14 |
Read same value |
QA3 |
IN15 |
Read same value |
QB0 |
IN16 |
Read same value |
QB1 |
IN17 |
Read same value |
QB2 |
IN18 |
Read same value |
QB3 |
IN19 |
Read same value |
9.2. Input latching and output updating
-
PWM duty cycles for each channel are updated at different times.
-
Digital outputs OUT0 through OUT9 are all updated at the same time. Digital outputs OUT10 through OUT17 are updated at the same time as the pwm function they are shared with.
-
Digital inputs IN0 through IN19 are all latched at the same time.
-
Quadrature positions for each channel are latched at different times.
9.3. HAL Functions, Pins and Parameters
A list of all loadrt arguments, HAL function names, pin names and parameter names is in the manual page, pluto_servo.9.
9.4. Compatible driver hardware
A schematic for a 2A, 2-axis PWM servo amplifier board is available (http://emergent.unpy.net/projects/01148303608). The L298 H-Bridge (L298 H-bridge) is inexpensive and can easily be used for motors up to 4A (one motor per L298) or up to 2A (two motors per L298) with the supply voltage up to 46V. However, the L298 does not have built-in current limiting, a problem for motors with high stall currents. For higher currents and voltages, some users have reported success with International Rectifier’s integrated high-side/low-side drivers. (http://www.cnczone.com/forums/showthread.php?t=25929)
10. Pluto-step: 300kHz Hardware Step Generator
Pluto-step is suitable for control of a 3- or 4-axis CNC mill with stepper motors. The large number of inputs allows for a full set of limit switches.
The board features:
-
4 “step+direction” channels with 312.5kHz maximum step rate, programmable step length, space, and direction change times
-
14 dedicated digital outputs
-
16 dedicated digital inputs
-
EPP communuication with the PC
10.1. Pinout
- STEPx
-
The “step” (clock) output of stepgen channel x
- DIRx
-
The “direction” output of stepgen channel x
- INx
-
Dedicated digital input #x
- OUTx
-
Dedicated digital output #x
- GND
-
Ground
- VCC
-
+3.3V regulated DC
While the “extended main connector” has a superset of signals usually found on a Step & Direction DB25 connector—4 step generators, 9 inputs, and 6 general-purpose outputs—the layout on this header is different than the layout of a standard 26-pin ribbon cable to DB25 connector.
10.2. Input latching and output updating
-
Step frequencies for each channel are updated at different times.
-
Digital outputs are all updated at the same time.
-
Digital inputs are all latched at the same time.
-
Feedback positions for each channel are latched at different times.
10.3. Step Waveform Timings
The firmware and driver enforce step length, space, and direction change times. Timings are rounded up to the next multiple of 1.6μs, with a maximum of 49.6μs. The timings are the same as for the software stepgen component, except that “dirhold” and “dirsetup” have been merged into a single parameter “dirtime” which should be the maximum of the two, and that the same step timings are always applied to all channels.
10.4. HAL Functions, Pins and Parameters
A list of all loadrt arguments, HAL function names, pin names and parameter names is in the manual page, pluto_step.9.