next up previous contents index
Next: 7. Servo To Go Up: 6. Hardware Previous: 6.3.1 Some Ini File   Contents   Index

6.4 Tuning freqmod

When If you have stepper motors and a stepper motor controller that requires phase stepping, then freqmod.o is a solution. Phase stepping requires the computer to output the motor phase signals directly, the stepper driver is just an amplifier.

This procedure version 1.0 John Sheahan 11 September 2001, Developed with linux kernel2.2.18 / rtlinux-rtl3.0-6 / :emc-2.07. Setup of linux/emc is covered elsewhere and must be done first

Setup The assumption is that your stepper motors are running on the bench. Put a marker on the shaft so that rotation is clear. I used wood scraps. Connect the stepper controller to the chosen parallel port, wire up the steppers. Don't power up the steppers yet.

As I'm a shell dinosaur I'll describe things that way. Adjust suitably for GUI operation.

to test the base setup:

# get to the relevant directory

/usr/local/emc

# become root

su -

# run the simulation. Note, the motors will not turn and are not needed, yet.

./sim.run

# hit F1 to get from ESTOP state to ESTOP RESET

# hit F2 to get to ON state

# try the arrow keys and pageup pagedown to jog the motors

# hit F4 to get to AUTO state

# click file -> open

# click cds.ngc

# click open

# view ->  backplot

# click run

wait and watch the windows scroll.

This was intended to test the base install and introduce a little functionality. Next step is to make the software run with YOUR motors. Choose a name for your setup. I'll use table as I'm building a routing table. Substitute _yourname_ for table in the rest.

# copy the sim files as we now know they work :)

# copy the runfile. If you do this with a gui, ensure the file is executable after

cp -p sim.run table.run

# copy the variables

cp sim.var table.var

# copy the tool file

cp sim.tbl table.tbl

# copy the nml file

cp sim.nml table.nml

Now we need to change the references in the new files. With your favorite editor, in table.run, change the line

INIFILE=sim.ini

to read

INIFILE=table.ini

The nml and tbl files should be ok for now. The real work comes in the ini file. tuning the .ini file with your favorite editor initial requirements You need to have this information to hand:

what units you want to operate the machine in, inches or mm

the leadscrew pitch [each axis]

the number of steps per revolution [each axis]

the maximum velocity each axis can run at.

this is getting harder, might be limited by the computer, the steppers, stepper driver, or fear.

the maximum acceleration for each axis

you might calculate this or just experiment Now edit table.ini Adjust the sections as described here. I'm mostly only going to discuss what needs to be changed.

[EMC] 
MACHINE = Stepper Stand

set the name string to whatever you want.

NML_FILE = table.nml 
DEBUG = 0x7FFFFFFF

bring it down to 0x3 or 0x0 as soon as things are making sense

RS274NGC_STARTUP_CODE=G20

set this to G20 to accept inches, or G21 for the rest of the world. This is the default unit for GCODE commands

[DISPLAY] is ok as is.  
[TASK] is ok as is.  
[RS274NGC] 
PARAMETER_FILE = table.var 
[EMCMOT] 
PLAT = realtime 
EMCMOT = freqmod.o 
STEPPING_TYPE = 1 
; 0= drn,clock ; 1 == phase step ; 2 == table driven, see emcmot.c 
; only works with freqmod.o 
PERIOD = 0.000050

this one is tricky, its the interrupt time for the timer ISR in seconds. If you make it too fast (small number), your computer will lock solid. 50us works for a 150MHz computer. If your cpu is faster, shrink this time accordingly. It should be as small as practical, and should divide cleanly into CYCLE_TIME. The smaller this is the faster and smoother your steppers can be controlled.

[TRAJ] 
LINEAR_UNITS = 1.0

1.0 is good if you are going to use metric for the rest of the numbers in this section. If you prefer inches, set to 0.03937007874016

CYCLE_TIME = 0.010

controls the rate trajectory will be computed.

DEFAULT_VELOCITY = 0.03 
MAX_VELOCITY = 2.60

this needs to be bigger than any of the axis limits. Don't make it too small, as the Z axis will behave very strangely!

DEFAULT_ACCELERATION = 1.5 
MAX_ACCELERATION = 2.0

choose this to keep your motors tracking.

[AXIS_0] note, all the axis have the same format, described once.
UNITS = 1.0

as above [TRAJ]linear_units

MAX_VELOCITY = 1.2

an appropriate limit for this axis and your motors.

P = 10.000

gain constant. this may need tuning later, see various comments on PID tuning in other documents. 10 worked for me.

I = 0.0 
D = 0.0 
FF0 = 0.0

I got too much endpoint error unless this was 0.

FF1 = 0.0 
FF2 = 0.0 
BACKLASH = 0.000

tweak this later to match your measured mechanical performance

DEADBAND = 0.010

set this to just over half what your single step resolution is, ie a little more than 1/INPUT_SCALE

CYCLE_TIME = 0.0010000 
INPUT_SCALE = 133.333333333 0

I have 200 step/rev stepper motors and a 1.5mm/turn leadscrew (cheap!) so I get 200/1.5 = 133.3 steps/mm. Offset is zero.

OUTPUT_SCALE = 133.333333333 0.000000000

set this the same as INPUT_SCALE

MIN_LIMIT = -100.0

this is the travel limit from home of your axis

MAX_LIMIT = 100.0

the travel limit in the positive direction

MIN_OUTPUT = -100 
MAX_OUTPUT = 100 
FERROR = 4.000 
MIN_FERROR = 1.000 
HOMING_VEL = 0.1 
HOME_OFFSET = 0.0 
ENABLE_POLARITY = 0 
MIN_LIMIT_SWITCH_POLARITY = 0

these polarity settings set the way your limit switches are wired. If the system will not come out of RESET state, change to 1

MAX_LIMIT_SWITCH_POLARITY = 0 
HOME_SWITCH_POLARITY = 0 
HOMING_POLARITY = 1 
JOGGING_POLARITY = 1 
FAULT_POLARITY = 1 
[EMCIO] 
EMCIO = bridgeportio

this is probably silly, and will require a second parallel port in your computer. consider a different setting here. Advice please.

TOOL_TABLE = table.tbl 
ESTOP_SENSE_POLARITY = 0

to let it start.

LUBE_SENSE_POLARITY = 0 
[EMCSERVER] 
; EMCSERVER = emcsvr

comment it out, not using it currently

now test it now all that typing is done, lets make the motors spin! Here is a suggested test procedure. Power up the stepper drivers (preferably with the steppers not mechanically connected to anything, as that may make expensive noises

execute ./table.run.

hit F1. (with the cursor in the nice blue window) state should change from ESTOP to ESTOP_RESET. If not, you probably have ESTOP_SENSE_POLARITY backwards, swap 1 and 0.

alternatively you only have one parallel port and would be better off with EMCIO = minimillio

hit F2. State should now become ON. If not, one of your SWITCH_POLARITY settings is probably reversed. You can use scripts/IO_Show.tcl to check this, if the upper right hand column is red, you need a 0 in the POLARITY setting.

try jogging the axis by hitting the cursor arrow keys, and pageup / pagedown. The motors should move a tad. now try a bigger move at full speed.Lets use some gcode.

hit F5, state should change to MDI for manual entry.

type g0x0 <return>

this should move the X axis 1 mm (or 1 inch if that's the RS274NGC_STARTUP_CODE default chosen).

type g0x10y10z5 <return>

all three motors should move off to x=10 y=10 z=5 checks, please everyone add more.

if the motors rattle backwards and forwards a step, your deadzone is too small. click on the axis to fix, click settings->calibration, edit deadband, click ok.

if the final displayed value is too different to the final requested value, your deadband is too big. Or you may have too high FF coefficients.

if your motors emit funny noises when stopped or moving, your gain (p) is too high.

if your motor gets there very slowly, your P gain is too low.

if you get 'following' errors, your P gain is too low, or your output_scale is wrong. calibration check

type g0x0y0z0 <return>

this gets things back to zero. Arrange the motor position and shaft marker so you can see them.

now lets ask for a 1-motor-revolution move. I have 1.5mm pitch leadscrews, so:

type g01x1.5y1.5z1.5f10 <return>

I just asked to move to 1.5mm on all three axis, at 10mm/minute. Adjust for your leadscrew pitch.

the motors should turn exactly 1 revolution. If not, the following is possible:

you miscalculated or mistyped the distance.

the motor body moved

the shaft marker moved (it got me!)

the input_scale setting is wrong on that axis now switch to auto mode (F4 or the mouse) and file->open the skeleton file. click run and watch it all whir. then its probably time to connect up more mechanics and test some more.

John Sheahan


next up previous contents index
Next: 7. Servo To Go Up: 6. Hardware Previous: 6.3.1 Some Ini File   Contents   Index
root 2003-05-26