Sorry Jef....
Seems that you already do the change....
just I don't have clue how to recompile this...
may that helps if I say that I use (active) linux near a week now. So 
all that stuff is new for me.
some more help?


Jeff Epler pravi:
> Slavko Kocjancic wanted a custom step type for his homemade stepper
> driver.  This adds a (single) customizable step waveform.  These
> waveforms have the same limitations as the existing ones: up to 5 output
> phases, and up to 10 steps per cycle
> ---
> Slavko, can you let me know whether this patch meets your needs? I ran
> the following then looked at the waveforms in halscope and saw something
> that looked like what I expected:
>
>     loadrt stepgen step_type=15 user_step_type=0,1,2,3,4,5,6,7 ctrl_type=v
>     loadrt threads period1=32000 fp1=0 name2=slow period2=960000
>     addf stepgen.make-pulses thread1
>     addf stepgen.capture-position slow
>     addf stepgen.update-freq slow
>     setp stepgen.0.enable 1
>     setp stepgen.0.position-scale 1000
>     setp steggen.0.velocity .5
>     start
>
> Thanks,
> Jeff
>
>  docs/man/man9/stepgen.9      |    9 ++++--
>  src/hal/components/stepgen.c |   53 
> ++++++++++++++++++++++++++++++++++--------
>  2 files changed, 49 insertions(+), 13 deletions(-)
>
> diff --git a/docs/man/man9/stepgen.9 b/docs/man/man9/stepgen.9
> index 2d1c32c..2afe528 100644
> --- a/docs/man/man9/stepgen.9
> +++ b/docs/man/man9/stepgen.9
> @@ -8,7 +8,7 @@
>  .SH NAME
>  stepgen \- software step pulse generation
>  .SH SYNOPSIS
> -\fBloadrt stepgen step_type=\fItype0\fR[,\fItype1\fR...] 
> [\fBctrl_type=\fItype0\fR[,\fItype1\fR...]]
> +\fBloadrt stepgen step_type=\fItype0\fR[,\fItype1\fR...] 
> [\fBctrl_type=\fItype0\fR[,\fItype1\fR...]] [\fBuser_step_type=#,#\fR...]
>  
>  .SH DESCRIPTION
>  \fBstepgen\fR is used to control stepper motors.  The maximum
> @@ -31,7 +31,7 @@ velocity mode replaces the former component \fBfreqgen\fR.)
>  motors/channels actually loaded depends on the number of \fItype\fR values
>  given.  The value of each \fItype\fR determines the outputs for that channel.
>  Position or velocity mode can be individually selected for each channel.
> -Both control modes support the same 15 possible step types.
> +Both control modes support the same 16 possible step types.
>  .P
>  By far the most common step type is '0', standard step and direction.  Others
>  include up/down, quadrature, and a wide variety of three, four, and five 
> phase
> @@ -67,7 +67,10 @@ Five pins, phases A through E.  Five steps per full cycle. 
>  See HAL reference ma
>  .TP
>  types 13 and 14: five phase, half step
>  Five pins, phases A through E.  Ten steps per full cycle.  See HAL reference 
> manual for the patterns.
> -
> +.TP
> +type 15: user-specified
> +This uses the waveform specified by the \fBuser_step_type\fR module 
> parameter,
> +which may have up to 10 steps and 5 phases.
>  .SH FUNCTIONS
>  .TP 
>  \fBstepgen.make-pulses \fR(no floating-point)
> diff --git a/src/hal/components/stepgen.c b/src/hal/components/stepgen.c
> index 9dafce1..f8be19b 100644
> --- a/src/hal/components/stepgen.c
> +++ b/src/hal/components/stepgen.c
> @@ -314,6 +314,8 @@ int step_type[MAX_CHAN] = { -1, -1, -1, -1, -1, -1, -1, 
> -1 };
>  RTAPI_MP_ARRAY_INT(step_type,MAX_CHAN,"stepping types for up to 8 channels");
>  const char *ctrl_type[MAX_CHAN];
>  RTAPI_MP_ARRAY_STRING(ctrl_type,MAX_CHAN,"control type (pos or vel) for up 
> to 8 channels");
> +int user_step_type[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
> +RTAPI_MP_ARRAY_INT(user_step_type, 10, "lookup table for user-defined step 
> type");
>  
>  /***********************************************************************
>  *                STRUCTURES AND GLOBAL VARIABLES                       *
> @@ -373,7 +375,7 @@ static stepgen_t *stepgen_array;
>  
>  /* lookup tables for stepping types 2 and higher - phase A is the LSB */
>  
> -static const unsigned char master_lut[][10] = {
> +static unsigned char master_lut[][10] = {
>      {1, 3, 2, 0, 0, 0, 0, 0, 0, 0},  /* type 2: Quadrature */
>      {1, 2, 4, 0, 0, 0, 0, 0, 0, 0},  /* type 3: Three Wire */
>      {1, 3, 2, 6, 4, 5, 0, 0, 0, 0},  /* type 4: Three Wire Half Step */
> @@ -386,16 +388,17 @@ static const unsigned char master_lut[][10] = {
>      {1, 2, 4, 8, 16, 0, 0, 0, 0, 0}, /* 11: Five Wire Unipolar */
>      {3, 6, 12, 24, 17, 0, 0, 0, 0, 0},       /* 12: Five Wire Wave */
>      {1, 3, 2, 6, 4, 12, 8, 24, 16, 17},      /* 13: Five Wire Uni Half */
> -    {3, 7, 6, 14, 12, 28, 24, 25, 17, 19}    /* 14: Five Wire Wave Half */
> +    {3, 7, 6, 14, 12, 28, 24, 25, 17, 19},   /* 14: Five Wire Wave Half */
> +    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* 15: User-defined */
>  };
>  
> -static const unsigned char cycle_len_lut[] =
> -    { 4, 3, 6, 4, 4, 4, 4, 8, 8, 5, 5, 10, 10 };
> +static unsigned char cycle_len_lut[] =
> +    { 4, 3, 6, 4, 4, 4, 4, 8, 8, 5, 5, 10, 10, 0 };
>  
> -static const unsigned char num_phases_lut[] =
> -    { 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, };
> +static unsigned char num_phases_lut[] =
> +    { 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 0, };
>  
> -#define MAX_STEP_TYPE 14
> +#define MAX_STEP_TYPE 15
>  
>  #define STEP_PIN     0       /* output phase used for STEP signal */
>  #define DIR_PIN              1       /* output phase used for DIR signal */
> @@ -429,7 +432,7 @@ static void make_pulses(void *arg, long period);
>  static void update_freq(void *arg, long period);
>  static void update_pos(void *arg, long period);
>  static CONTROL parse_ctrl_type(const char *ctrl);
> -
> +static int setup_user_step_type(void);
>  
>  /***********************************************************************
>  *                       INIT AND EXIT CODE                             *
> @@ -439,11 +442,16 @@ int rtapi_app_main(void)
>  {
>      int n, retval;
>  
> +    retval = setup_user_step_type();
> +    if(retval < 0) {
> +         return retval;
> +    }
> +
>      for (n = 0; n < MAX_CHAN && step_type[n] != -1 ; n++) {
>       if ((step_type[n] > MAX_STEP_TYPE) || (step_type[n] < 0)) {
>           rtapi_print_msg(RTAPI_MSG_ERR,
> -                         "STEPGEN: ERROR: bad stepping type '%i', axis %i\n",
> -                         step_type[n], n);
> +                         "STEPGEN: ERROR: bad stepping type '%i', axis %i 
> (must be 0..%d)\n",
> +                         step_type[n], n, MAX_STEP_TYPE);
>           return -1;
>       }
>       if(parse_ctrl_type(ctrl_type[n]) == INVALID) {
> @@ -1194,3 +1202,28 @@ static CONTROL parse_ctrl_type(const char *ctrl)
>      if(*ctrl == 'v' || *ctrl == 'V') return VELOCITY;
>      return INVALID;
>  }
> +
> +static int setup_user_step_type(void) {
> +    int used_phases = 0;
> +    int i = 0;
> +    for(i=0; i<10 && user_step_type[i] != -1; i++) {
> +        master_lut[13][i] = user_step_type[i];
> +     used_phases |= user_step_type[i];
> +    }
> +    cycle_len_lut[13] = i;
> +    if(used_phases & ~0x1f) {
> +         rtapi_print_msg(RTAPI_MSG_ERR, "STEPGEN: ERROR: "
> +                         "bad user step type uses more than 5 phases");
> +         return -EINVAL; // more than 5 phases is not allowed
> +    }
> +    
> +    if(used_phases & 0x10) num_phases_lut[13] = 5; // find-first-set-bit 
> would be handy here
> +    else if(used_phases & 0x8) num_phases_lut[13] = 4;
> +    else if(used_phases & 0x4) num_phases_lut[13] = 3;
> +    else if(used_phases & 0x2) num_phases_lut[13] = 2;
> +    else if(used_phases & 0x1) num_phases_lut[13] = 1;
> +
> +    rtapi_print_msg(RTAPI_MSG_ERR, "User step type has %d phases and %d 
> steps per cycle\n", used_phases, i);
> +    return 0;
> +}
> +
>   


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to