Re: EMC on servo's



Khaweja,

You wrote:

> But my main question, which file contains the C code for input output for a
> specific card, and how do i change it. I mean i do not have money to buy a
> ServotoGo card, so i am building my own controller, and i need to PWM it .
> But i do not want to alter any of the original code of the EMC. Please can
> you give me any tips or clues for those problems?

The EMC motion controller in emc/src/emcmot/emcmot.c, calls a bunch of
functions prefixed with "ext", which stands for "external". These
include things like extEncoderReadAll(), extDacWrite(),
extLimitSwitchRead(), etc. These functions are prototyped (declared) in
emc/src/emcnml/extintf.h, and define the "External Interface" that
connects the generic EMC motion controller with specific boards.

The actual code that makes up these functions is board-specific. See
emc/src/emcmot/extstgmot.c as an example. These functions map the
external interface calls to the actual code for the Servo To Go board
functions, in emc/src/emcmot/stg.c.

You can create your own implementation of the external interface
functions, and write an interface wrapper for these, e.g.,

/* in myboard.c */
int myboardDacWrite(int axis, double volts)
{
  char out;

  /* purely hypothetical board with 8-bit DACs at 0x200, 0x201, ... */
  out = (int) (volts * 24);
  outb(out, 0x200 + axis);

  return 0;
}

/* in extmyboardmot.c */
int extDacWrite(int axis, double volts)
{
  return myboardDacWrite(axis, volts);
}

You could just implement extDacWrite() to directly do the outb(), etc.
but this prevents combining boards (STG for axes 0-3, your board for
axes 4 and 5, for example).

When you build a .o file for the actual controller, e.g., myboardmod.o,
you could use the stgmod.o target in emc/src/emcmot/Makefile as a
template and replace stg.o with myboard.o, extstgmot.o with
extmyboardmot.o and you'll get your new functions.

--Fred



Date Index | Thread Index | Back to archive index | Back to Mailing List Page

Problems or questions? Contact