TOC PREV NEXT INDEX

Handbook - Servo To Go


Servo To Go Integration

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.


The .ini file

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.

Stg files

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

  • Model 1
  • produces stg.o (4 axes)
  • with -DSTG_8_AXES produces stg8.o (8 axes)

./src/emcmot/stg2.c

./src/emcmot/stg2.h

  • For Model 2
  • 4 axis default (use -DSTG_8_AXES for 8 axes, 4 or 8 are currently your only choices).
./src/emcmot/stg_v2_axis8.c
  • same as above but does not have FIND_STG_BASE_ADDRESS variable and associated code.
  • May be obsolete since there are some typos in comments that are corrected in stg2.c
./src/emcmot/stgdiag.c
  • diagnostics program
  • a stand-alone console (command line) program to test card functions
  • note that a similar program is available on the Servo To Go web site.
./src/emcmot/extstgmot.c
  • dispatcher/wrapper
  • implements functions described in extintf.h by calling functions in stg.c or stg2.c
./plat/nonrealtime/bin/stg2diag
  • executable from stgdiag.c
  • Model 2
  • Use from command line.
./plat/nonrealtime/bin/stg2mot
  • non-real-time
  • from stg2.o
  • Model 2
  • 4 axes.
./plat/nonrealtime/bin/stgdiag
  • executable from stgdiag.c
  • Model 1
  • Use from command line.
./plat/nonrealtime/bin/stgmot
  • non-realtime
  • from stg.o
  • Model 1
  • 4 axes.
./plat/nonrealtime/lib/stg.o
  • from stg.c
  • intermediate file
./plat/nonrealtime/lib/stg2.o
  • from stg2.c
  • intermediate file
./plat/nonrealtime/lib/stg8.o
  • from stg.c with STG_8_AXES flag
  • Model 1.
./plat/nonrealtime/lib/stgdiag.o
  • intermediate file
  • used to make the executable in the bin directory.
./plat/realtime/lib/stg.o
  • from stg.c
  • intermediate file
./plat/realtime/lib/stg2.o
  • from stg2.c
  • intermediate file
./plat/realtime/lib/stg2mod.o
  • from stg2.o
  • Model 2
  • 4 axes
./plat/realtime/lib/stg8.o
  • from stg.c with -DSTG_8_AXES
  • Model 1
  • 8 axes
./plat/realtime/lib/stg8mod.o
  • installable kernel module
  • from stg8.o
  • Model 1
  • 8 axis
./plat/realtime/lib/stg_v2_8axis_mod.o
  • from stg2.o (not stg_v2_8axis.o)
  • same as stg2mod.o (no, I don't know why)
./plat/realtime/lib/stgmod.o
  • from stg.o
  • Model 1
  • 4 axis

 

Options in extstgmot.c

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.

What is the difference between Model 1 and 2?

The Model 2 has:

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.

stgdiag

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.

lstg

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 

This page is maintained by Don McLane. email me
TOC PREV NEXT INDEX