For machines that use servo motors, one option is to use the servo motor interface card from Servo To Go, Inc. It has been used in several installations, and the driver code is included with the EMC distribution. Here we attempt to document matters relating to this card. The organization is FAQ-like at this point, addressing specific questions or aspects of using the Servo To Go card.
Here is a .ini file that is known to work. You'll probably have to change some settings for your system, but this is a good place to start.
There are a large number of files associated with the Servo To Go card. Below we will try to gather them up in one place and describe each. Unfortunately, by the time you read this, it is likely to be out of date.
./src/emcmot/stg.c ./src/emcmot/stg.h |
|
./src/emcmot/stg2.c ./src/emcmot/stg2.h |
|
./src/emcmot/stg_v2_axis8.c |
|
./src/emcmot/stgdiag.c |
|
./src/emcmot/extstgmot.c |
|
./plat/nonrealtime/bin/stg2diag |
|
./plat/nonrealtime/bin/stg2mot |
|
./plat/nonrealtime/bin/stgdiag |
|
./plat/nonrealtime/bin/stgmot |
|
./plat/nonrealtime/lib/stg.o |
|
./plat/nonrealtime/lib/stg2.o |
|
./plat/nonrealtime/lib/stg8.o |
|
./plat/nonrealtime/lib/stgdiag.o |
|
./plat/realtime/lib/stg.o |
|
./plat/realtime/lib/stg2.o |
|
./plat/realtime/lib/stg2mod.o |
|
./plat/realtime/lib/stg8.o |
|
./plat/realtime/lib/stg8mod.o |
|
./plat/realtime/lib/stg_v2_8axis_mod.o |
|
./plat/realtime/lib/stgmod.o |
|
Your system may require changes to extstgmot.c. After making any changes you will need to recompile. Here are some of the options from the source code.
/* Uncomment any of the following declarations to inhibit the use of home switches or index pulses when homing, or to ignore limit switches if you don't have them. */ /* Uncomment NO_HOME_SWITCH if you want homing sequence to ignore the home switch, and only use the index pulse for homing. This has the effect of making the home switches always appear tripped. */ /* #define NO_HOME_SWITCH */ /* Uncomment NO_INDEX_PULSE if you want homing sequence to ignore the index pulse, and only use the home switch for homing. This has the effect of making the index pulse always appear present. */ /* #define NO_INDEX_PULSE */ /* Uncomment NO_LIMIT_SWITCH if you don't have limit switches. This has the effect of making the positive and negative travel limit switches never appear tripped. */ /* #define NO_LIMIT_SWITCH */
Where's the driver?
Or sometimes the question is "is there a Servo To Go driver for Linux in there? If so where is it?". EMC's modular design is quite elegant, although it makes this particular question hard to answer. Are stg.c (for Model 1) and stg2.c (for Model 2) the drivers? No, these are modules which customize the driver for the Servo To Go card when they are linked in. They implement functions that the driver uses.
Can I point to the drivers? Yes, there's stgmod.o and stg2mod.o (and some variants) for RT-Linux. They are installable kernel modules. Communication with the driver is typically by a shared memory area (the other option is to use a fifo). The driver commands are listed in emcmot.h.
The Model 2 has:
- index pulse circuit redesigned.
- external latch input
- more flexible watchdog timer
- more options for using spare timer
Reading encoders and writing to DACs happen to be unchanged between the Model 1 and 2. So if that is all you are doing, then it will work even if you use the wrong driver. However if you are using other functions on the board (digital I/O or ADCs) then you will need the correct driver.
Included in the EMC distribution is a diagnostics program to help verify the Servo To Go hardware. The source code for the program is typically located in:
/usr/local/emc/src/emcmot/stgdiag.c
There are two versions of the executable (depending on whether it is linked with stg.c or stg2.c). stgdiag is for the Model 1 card and stg2diag is for the Model 2. The executables are usually located in:
/usr/local/emc/plat/nonrealtime/bin/
To run the program, either navagate to the above directory, or have it on your path. The syntax is (using the Model 2 version as the example):
stg2diag [ dio | dac | limit | home | index <axis> | latch <axis>][ base_address ]
first set of options:
none | position for x, y, and z continuously updated, control-C to quit |
dio |
digital I/O, displays state of ports A, B and D |
dac | digital to analog converter, prompts for axis, then prompts for voltage |
limit | displays limit switches continuously, new line at each change, control-C to stop |
home | displays home switches continuously, new line at each change, control-C to stop |
index <axis> |
continously display state of index pulse for given axis, control-C to stop |
latch <axis> | continously display state of index pulse latch, control-C to stop |
Default base address is 0x200 unless the base address is specified in the final argument.
There is another program available to help debug and verify the Servo To Go hardware functionality. It is available from the Servo To Go website in the Download Area. Like stgdiag, it is a console application. However lstg is more general, and has slightly more functions. Here is an example of its use:
[root@mclinux don]# lstg Servo To Go Demo Enter the letter corresponding to the desired command. You don't need to follow it with a carriage return. If the letter isn't a valid command, the list of commands will be repeated. To exit from a demo, type any character. Base Address = 200 Board Model = Model 2 ServoToGo: [carriage return] Commands: o - Digital output demo, toggle bit i - Digital input demo D - DAC demo for chan 3, ramp d - DAC demo, set voltage r - Some random motion on chan 0 a - ADC demo A - ADC autozero ON n - ADC noise demo N - ADC autozero OFF e - Encoder demo E - Zero Encoders x - Index pulse demo X - Index latch demo l - External Latch Test y - IRR test, continually reset index latch 1..8 - Set default Axis q - Quit ServoToGo:q