586,617 active members*
2,392 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Dynomotion/Kflop/Kanalog > Kanalog Differential Encoder Setup - First Time
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2014
    Posts
    23

    Question Kanalog Differential Encoder Setup - First Time

    I have a 2K PPR differential encoder. I have a Kanalog board. I have a KFLOP. Currently I have the 2 boards mounted and powered. I am receiving the AB channels from the encoder fine. 1 Rev = 8000 counts. But, I need to know if the Z index is coming in. I understood to connect the AB channels to the first diff encoder input. Pins A0+, A0-, B0+, B0-. No issue. I also understood to connect the Z index to the first of the second diff bank on JP2. A4+, A4-. I have this done. I am using this as my X axis on Channel 0. All that said, how do I attach the Z index to channel 0. Is there a C program I need. Code for the Init.c.?

    I simple explanation is all I need with details. I know how encoders work. I will be using this as a DAC servo. I want homing to the index marker after home switch operation. +-10V to the drive. Easy stuff.

  2. #2
    Join Date
    May 2006
    Posts
    4047

    Re: Kanalog Differential Encoder Setup - First Time

    Hi Don,

    JP2 A0 comes into KFLOP as IO36 but will be difficult to see on the Digital IO Screen. A Home C Program is required to basically move until the Limit is detected and then the Index Pulse Is detected and then to Stop.

    There is an example function in SimpleHomeIndexFunction.c It can be called in a similar manner as the SimpleHome3Axis.c example.

    Let us know if this isn't clear.

    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Aug 2014
    Posts
    23

    Re: Kanalog Differential Encoder Setup - First Time

    Okay. I got the SnapAmp installed. Here is what I have set up.

    I have the encoder wired to the first diff encoder AB and then the Z to pin 68. I can see the encoder counts in diagnostics. But, I get no count in axis. I ran the AutoPhaseFind.c program. Motor rotates fine 2 rev forward, and 2 back. Here is what I have in the AutoPhase:

    #include "KMotionDef.h"

    // Drive a 3 Phase motor that has a Z index by
    // 3 phase driving the coils (like a stepping motor)
    // two revs each direction (two z pulses)
    // monitor how many counts/cycle and counts/rev
    // (including direction)and also determine the commutation
    // offset by recording the phase angle at the index
    // (which will be where zero is set) and offsetting by 1/4 of a cycle
    //
    // Set the following parameters according to your situation
    // See the report generated on the Console Screen

    #define PWM_CHAN 8 // which pair of PWM channels used
    #define ENCODER_CHAN 4 // which encoder we are connected to
    #define ENCODER_GAIN 1 // Set to -1 if desired to reverse axis direction
    #define AMPLITUDE 10 // Set how hard to drive the coils pwm counts
    #define Z_BIT_NUMBER 68 // What bit the Z index is connected to
    #define CLAMP_VOLTAGE 85 // volts - set a few volts higher than your supply
    #define AXIS_CHAN 4 // Axis channel to be used and configured
    #define Ncycles 4 // don't change this

    void main()
    {
    float mid,A=AMPLITUDE; // set coil current amplitude
    int k=0,i,dk=1,WhichSnap,WhichClamp,WhichClampEnable,i gnore=300,kpos[Ncycles],zmark,m=0;
    double cnts_per_cycle,p0[Ncycles];
    CHAN *ch = &chan[AXIS_CHAN];

    if (PWM_CHAN < 12)
    WhichSnap=SNAP0;
    else
    WhichSnap=SNAP1;

    if (PWM_CHAN==8 || PWM_CHAN==12)
    {
    WhichClamp=SNAP_SUPPLY_CLAMP0;
    WhichClampEnable=SNAP_SUPPLY_CLAMP_ENA0;
    }
    else
    {
    WhichClamp=SNAP_SUPPLY_CLAMP1;
    WhichClampEnable=SNAP_SUPPLY_CLAMP_ENA1;
    }


    WriteSnapAmp(WhichSnap+WhichClamp ,SNAP_CONVERT_VOLTS_TO_ADC(CLAMP_VOLTAGE));
    WriteSnapAmp(WhichSnap+WhichClampEnable,1);
    WriteSnapAmp(WhichSnap+SNAP_PEAK_CUR_LIMIT0,10); // current limit
    WriteSnapAmp(WhichSnap+SNAP_PEAK_CUR_LIMIT1,10); // current limit

    Delay_sec(1); // wait for any fault to clear

    // rotate until we find the index mark

    ch->Enable=FALSE;
    ch->OutputChan0=PWM_CHAN;
    ch->InputMode=ENCODER_MODE;
    ch->InputChan0=ENCODER_CHAN;
    ch->OutputMode=BRUSHLESS_3PH_MODE;
    ch->InputGain0=ENCODER_GAIN;

    for (;
    {
    Delay_sec(0.001); // wait a millisecond
    k+= dk;

    Write3PH(ch,A, k/1000.0); // move the pole

    zmark = ReadBit(Z_BIT_NUMBER);

    if (!zmark && ignore>0) ignore--;

    if (ignore==0 && zmark) // check for index mark
    {
    p0[m]=ch->Position; // save position
    kpos[m]=k; // save phase angle

    if (++m == Ncycles)
    {
    ch->Position=0; // set current position to Zero
    break;
    }

    if (m==2) dk = -dk;
    ignore=300;
    }
    }

    Write3PH(ch,0,0); // turn off the coil


    // ch4->CommutationOffset = 3*8000/2.0/12.0 * 1.02;

    printf("\nREPORT\n------\n");
    for (i=0; i<Ncycles; i++)
    printf("%d Position = %6.0f PhaseAngle = %f\n",i,p0[i],kpos[i]/1000.0);

    printf("Counts per rev = %6.0f\n",p0[1]-p0[0]);
    cnts_per_cycle = (p0[1]-p0[0])/(kpos[1]-kpos[0])*1000.0;
    printf("Counts per cycle = %6.0f\n",cnts_per_cycle);

    // round to 10
    if (cnts_per_cycle>0)
    cnts_per_cycle = ((int)(cnts_per_cycle/10.0 + 0.5))*10.0;
    else
    cnts_per_cycle = ((int)(cnts_per_cycle/10.0 - 0.5))*10.0;

    printf("Counts per cycle (rounded)= %6.0f\n",cnts_per_cycle);

    ch->invDistPerCycle = 1.0/cnts_per_cycle;
    printf("invDistPerCycle (rounded)= %15.12f\n",ch->invDistPerCycle);

    mid = (kpos[2]+kpos[1])/2000.0;
    mid = mid - (int)mid;
    ch->CommutationOffset = mid*cnts_per_cycle + 0.25*fast_fabs(cnts_per_cycle);
    printf("Commutation offset = %6.0f\n",ch->CommutationOffset);
    printf("Input Gain Specified = %6.3f\n",ch->InputGain0);

    Here is the report:

    REPORT
    ------
    0 Position = 0 PhaseAngle = 4.246000
    1 Position = 0 PhaseAngle = 8.246000
    2 Position = 0 PhaseAngle = 4.007000
    3 Position = 0 PhaseAngle = 0.007000
    Counts per rev = 0
    Counts per cycle = 0
    Counts per cycle (rounded)= 0
    invDistPerCycle (rounded)= 17976931348623459339141845703125000000000000000000 000000000000000000000000000000000000000000000000
    000Commutation offset = 0
    Input Gain Specified = 1.000


    Obviously wrong. I know it is because the encoder counts are not reaching. But since I can see them flip in digitalI/O for the snap ticking the check marks.... I assume that the encoder is fine. I tried the encoder first with Kanalog. Counts fine.

    What have I done wrong, right, or otherwise.

    I only have the SnapAmp and the KFLOP connected.

  4. #4
    Join Date
    Aug 2014
    Posts
    23

    Re: Kanalog Differential Encoder Setup - First Time

    Okay. I figured out the encoder channel was set to 4 and not 8. I have the motor servoing now. But I cannot get more than say 250 rpms. Smooth movement but slow. I check the pwm output % and it maxs to 17.4%. Set vel to 40000000. Still maxs at that value. Am I missing something? Otherwise very nice.

    And super easy to work with.

    Just need more speed captain.

  5. #5
    Join Date
    May 2006
    Posts
    4047

    Re: Kanalog Differential Encoder Setup - First Time

    Hi Don,

    Post your settings and a Plots from the Step Response Screen and we should be able to help.

    Also post the results from the AutoPhaseFind Report. The results from the Auto Phase Find should be merged into a C program similar to HomeBrushlessSnap4.c and used on power up to set the commutation and begin servoing.

    There is a MaxOutput setting that limits the max servo output to the SnapAmp pwm drive. The max allowed PWM value is 230. So set the MaxOutput to 230 to allow the maximum voltage to the motor.

    HTH
    Regards
    TK
    http://dynomotion.com

  6. #6
    Join Date
    Aug 2014
    Posts
    23

    Re: Kanalog Differential Encoder Setup - First Time

    Okay. I am working to install the Kanalog. MY drive has an offset input. Is there a parameter in KFLOP that will set this analog offset before the signal is sent? or should I use the drive to create the offset?

  7. #7
    Join Date
    May 2006
    Posts
    4047

    Re: Kanalog Differential Encoder Setup - First Time

    Hi Don,

    KFLOP has an OutputOffset parameter but this won't occur until after the axis is configured, so it may be better to do it in the drive. Usually a small offset doesn't matter if the drives are disabled until the servo is enabled. The servo will naturally output whatever is required to hold position.

    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. differential quadrature encoder
    By howanc7 in forum Servo Motors / Drives
    Replies: 9
    Last Post: 01-14-2014, 12:00 AM
  2. Wiring differential encoder
    By scrambled in forum CNC Machine Related Electronics
    Replies: 25
    Last Post: 09-06-2009, 07:56 PM
  3. Differential encoder e5 with the g320x
    By dgalaxy in forum Gecko Drives
    Replies: 2
    Last Post: 08-28-2009, 09:53 PM
  4. modify MPG to differential encoder
    By Karl_T in forum CNC Machine Related Electronics
    Replies: 7
    Last Post: 05-23-2009, 06:05 PM
  5. Differential Encoder Signals
    By eloid in forum DIY CNC Router Table Machines
    Replies: 8
    Last Post: 01-30-2008, 03:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •