Hello Guest it is January 29, 2020, 02:16:13 PM

Author Topic: Steps/Inch on Lathe = 75,000; Seems a Tad High  (Read 6571 times)

0 Members and 1 Guest are viewing this topic.

Offline mc

*
  •  381 381
    • View Profile
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #10 on: September 02, 2014, 05:32:44 AM »
Ignore backlash until you get the units set correctly.
The Mach backlash setting will have no effect on an external motion controller anyway, as the backlash is handled internally by the controller.

Probably best if you have a read through this post I made last week over on the HSM forum - http://bbs.homeshopmachinist.net/threads/63822-Help-Choosing-Electronics-for-CNC-Lathe-Conversion?p=933822#post933822 as it covers the basic process of setting things up.

Something does seem a bit strange with your Z-axis steps. Any chance you could attach your kflop init file, or even just copy and paste your channel configuration settings from it?
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #11 on: September 02, 2014, 10:28:13 AM »
That's my thread! I have been looking for help all over the place. Thanks for the info on the Mach3 backlash tool not applying to external controllers. That's a major help.

Here is the init.c file:

#include "KMotionDef.h"

// Defines axis 0, 1 as simple step dir outputs
// enables them
// sets them as an xz coordinate system for GCode

int main()
{
   ch0->InputMode=NO_INPUT_MODE;
   ch0->OutputMode=STEP_DIR_MODE;
   ch0->Vel=100;
   ch0->Accel=1000;
   ch0->Jerk=10000;
   ch0->P=1;
   ch0->I=0;
   ch0->D=0;
   ch0->FFAccel=0;
   ch0->FFVel=0;
   ch0->MaxI=200;
   ch0->MaxErr=200;
   ch0->MaxOutput=200;
   ch0->DeadBandGain=1;
   ch0->DeadBandRange=0;
   ch0->InputChan0=0;
   ch0->InputChan1=1;
   ch0->OutputChan0=8;
   ch0->OutputChan1=1;
   ch0->MasterAxis=-1;
   ch0->LimitSwitchOptions=0x100;
   ch0->LimitSwitchNegBit=0;
   ch0->LimitSwitchPosBit=0;
   ch0->SoftLimitPos=1e+009;
   ch0->SoftLimitNeg=-1e+009;
   ch0->InputGain0=1;
   ch0->InputGain1=1;
   ch0->InputOffset0=0;
   ch0->InputOffset1=0;
   ch0->OutputGain=-1;
   ch0->OutputOffset=0;
   ch0->SlaveGain=1;
   ch0->BacklashMode=BACKLASH_OFF;
   ch0->BacklashAmount=0;
   ch0->BacklashRate=0;
   ch0->invDistPerCycle=1;
   ch0->Lead=0;
   ch0->MaxFollowingError=1000000000;
   ch0->StepperAmplitude=250;

   ch0->iir[0].B0=1;
   ch0->iir[0].B1=0;
   ch0->iir[0].B2=0;
   ch0->iir[0].A1=0;
   ch0->iir[0].A2=0;

   ch0->iir[1].B0=1;
   ch0->iir[1].B1=0;
   ch0->iir[1].B2=0;
   ch0->iir[1].A1=0;
   ch0->iir[1].A2=0;

   ch0->iir[2].B0=1;
   ch0->iir[2].B1=0;
   ch0->iir[2].B2=0;
   ch0->iir[2].A1=0;
   ch0->iir[2].A2=0;
    EnableAxisDest(0,0);

   ch1->InputMode=NO_INPUT_MODE;
   ch1->OutputMode=STEP_DIR_MODE;
   ch1->Vel=100;
   ch1->Accel=1000;
   ch1->Jerk=10000;
   ch1->P=1;
   ch1->I=0;
   ch1->D=0;
   ch1->FFAccel=0;
   ch1->FFVel=0;
   ch1->MaxI=200;
   ch1->MaxErr=200;
   ch1->MaxOutput=200;
   ch1->DeadBandGain=1;
   ch1->DeadBandRange=0;
   ch1->InputChan0=1;
   ch1->InputChan1=2;
   ch1->OutputChan0=9;
   ch1->OutputChan1=3;
   ch1->MasterAxis=-1;
   ch1->LimitSwitchOptions=0x100;
   ch1->LimitSwitchNegBit=0;
   ch1->LimitSwitchPosBit=0;
   ch1->SoftLimitPos=1e+009;
   ch1->SoftLimitNeg=-1e+009;
   ch1->InputGain0=1;
   ch1->InputGain1=1;
   ch1->InputOffset0=0;
   ch1->InputOffset1=0;
   ch1->OutputGain=-1;
   ch1->OutputOffset=0;
   ch1->SlaveGain=1;
   ch1->BacklashMode=BACKLASH_OFF;
   ch1->BacklashAmount=0;
   ch1->BacklashRate=0;
   ch1->invDistPerCycle=1;
   ch1->Lead=0;
   ch1->MaxFollowingError=1000000000;
   ch1->StepperAmplitude=250;

   ch1->iir[0].B0=1;
   ch1->iir[0].B1=0;
   ch1->iir[0].B2=0;
   ch1->iir[0].A1=0;
   ch1->iir[0].A2=0;

   ch1->iir[1].B0=1;
   ch1->iir[1].B1=0;
   ch1->iir[1].B2=0;
   ch1->iir[1].A1=0;
   ch1->iir[1].A2=0;

   ch1->iir[2].B0=1;
   ch1->iir[2].B1=0;
   ch1->iir[2].B2=0;
   ch1->iir[2].A1=0;
   ch1->iir[2].A2=0;
    EnableAxisDest(1,0);

   
   DefineCoordSystem(0,-1,1,-1);

    //return 0;
}

Offline mc

*
  •  381 381
    • View Profile
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #12 on: September 02, 2014, 11:32:31 AM »
Ha, I did wonder if there really had been a surge in lathe kflop mach users  :)

A couple things that stand out are the missing code to tell the kflop a kstep is attached, and your velocity, acceleration and jerk are low.
Try using the basic kstep example file supplied with kmotion, and editting it to suit, as it contains settings that are pretty good to start with, and the required code to implement all the kstep features.

Should be a case of just editting the DefineCoordMotion statement so only 2 axis are activated.
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #13 on: September 02, 2014, 12:40:30 PM »
Actually, that IS one of the files that came with KMotion, but I don't think it's Kstep-specific. I can root around and dig one out. I know it's in there.

I thought that when I wrote (0,-1,1,-1) I was calling 0 "x," deactivating y, and calling 1 "z". Wrong?

Offline mc

*
  •  381 381
    • View Profile
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #14 on: September 02, 2014, 01:07:19 PM »
That's correct, however the example files are set up for 3 or 4 axis, so you'll need to change it.
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #15 on: September 02, 2014, 01:57:24 PM »
I am looking at the "mot" files in Kmotion. It appears that they duplicate a lot of the stuff in the init.c file. Not sure why I need mot files AND an init.c file.

Offline mc

*
  •  381 381
    • View Profile
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #16 on: September 02, 2014, 02:09:44 PM »
You don't need or use the mot files. They're solely motor config files, which are only any use via the config&flash screen.All you use for most things are c files, which are what configure the motors for normal use.
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #17 on: September 02, 2014, 02:51:56 PM »
I got this to work in Mach3 and KmotionCNC, but the steps/inch setting seems to be wandering around now. I am working on that. The motors run much cooler now. I am researching jerk to find out the right setting. I have a physics degree, so I have some clue what acceleration per second is, but "jerk" is an engineering term, so I have never worked with it before. It sounds like a bad thing, but I assume it refers to softening the changes in motion, like reducing the pressure on a brake pedal?

Anyway, I will keep fooling with it. You have been a tremendous help. I had no idea the Kflop had to be told there was a Kstep, or that the mot files were not needed.

It's pretty cool, finally seeing something happen in KmotionCNC.

#include "KMotionDef.h"

// Defines axis 0, 1 as simple step dir TTL outputs for KSTEP
// enables them
// sets them as an xz coordinate system for GCode

int main()
{
   double T0, LastX=0, LastZ=0, Tau;
   
   KStepPresent=TRUE;      // enable KSTEP input multiplexing
   FPGA(KAN_TRIG_REG)=4;     // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP

   FPGA(STEP_PULSE_LENGTH_ADD) = 63 + 0x80;  // set polarity and pulse length to 4us
   
   ch0->InputMode=NO_INPUT_MODE;
   ch0->OutputMode=STEP_DIR_MODE;
   ch0->Vel=40000;
   ch0->Accel=200000;
   ch0->Jerk=4e+006;
   ch0->P=0;
   ch0->I=0.01;
   ch0->D=0;
   ch0->FFAccel=0;
   ch0->FFVel=0;
   ch0->MaxI=200;
   ch0->MaxErr=1e+006;
   ch0->MaxOutput=200;
   ch0->DeadBandGain=1;
   ch0->DeadBandRange=0;
   ch0->InputChan0=0;
   ch0->InputChan1=0;
   ch0->OutputChan0=8;
   ch0->OutputChan1=0;
   ch0->MasterAxis=-1;
   ch0->LimitSwitchOptions=0x0;
   ch0->SoftLimitPos=1e+030;
   ch0->SoftLimitNeg=-1e+030;
   ch0->InputGain0=1;
   ch0->InputGain1=1;
   ch0->InputOffset0=0;
   ch0->InputOffset1=0;
   ch0->OutputGain=1;
   ch0->OutputOffset=0;
   ch0->SlaveGain=1;
   ch0->BacklashMode=BACKLASH_OFF;
   ch0->BacklashAmount=0;
   ch0->BacklashRate=0;
   ch0->invDistPerCycle=1;
   ch0->Lead=0;
   ch0->MaxFollowingError=1000000000;
   ch0->StepperAmplitude=20;

   ch0->iir[0].B0=1;
   ch0->iir[0].B1=0;
   ch0->iir[0].B2=0;
   ch0->iir[0].A1=0;
   ch0->iir[0].A2=0;

   ch0->iir[1].B0=1;
   ch0->iir[1].B1=0;
   ch0->iir[1].B2=0;
   ch0->iir[1].A1=0;
   ch0->iir[1].A2=0;

   ch0->iir[2].B0=0.000769;
   ch0->iir[2].B1=0.001538;
   ch0->iir[2].B2=0.000769;
   ch0->iir[2].A1=1.92076;
   ch0->iir[2].A2=-0.923833;
    EnableAxisDest(0,0);

   ch1->InputMode=NO_INPUT_MODE;
   ch1->OutputMode=STEP_DIR_MODE;
   ch1->Vel=40000;
   ch1->Accel=200000;
   ch1->Jerk=4e+006;
   ch1->P=0;
   ch1->I=0.01;
   ch1->D=0;
   ch1->FFAccel=0;
   ch1->FFVel=0;
   ch1->MaxI=200;
   ch1->MaxErr=1e+006;
   ch1->MaxOutput=200;
   ch1->DeadBandGain=1;
   ch1->DeadBandRange=0;
   ch1->InputChan0=0;
   ch1->InputChan1=0;
   ch1->OutputChan0=9;
   ch1->OutputChan1=0;
   ch1->MasterAxis=-1;
   ch1->LimitSwitchOptions=0x0;
   ch1->SoftLimitPos=1e+030;
   ch1->SoftLimitNeg=-1e+030;
   ch1->InputGain0=1;
   ch1->InputGain1=1;
   ch1->InputOffset0=0;
   ch1->InputOffset1=0;
   ch1->OutputGain=1;
   ch1->OutputOffset=0;
   ch1->SlaveGain=1;
   ch1->BacklashMode=BACKLASH_OFF;
   ch1->BacklashAmount=0;
   ch1->BacklashRate=0;
   ch1->invDistPerCycle=1;
   ch1->Lead=0;
   ch1->MaxFollowingError=1000000000;
   ch1->StepperAmplitude=20;

   ch1->iir[0].B0=1;
   ch1->iir[0].B1=0;
   ch1->iir[0].B2=0;
   ch1->iir[0].A1=0;
   ch1->iir[0].A2=0;

   ch1->iir[1].B0=1;
   ch1->iir[1].B1=0;
   ch1->iir[1].B2=0;
   ch1->iir[1].A1=0;
   ch1->iir[1].A2=0;

   ch1->iir[2].B0=0.000769;
   ch1->iir[2].B1=0.001538;
   ch1->iir[2].B2=0.000769;
   ch1->iir[2].A1=1.92076;
   ch1->iir[2].A2=-0.923833;
    EnableAxisDest(1,0);

   

   DefineCoordSystem(0,-1,1,-1);
   
   SetBitDirection(45,1);  // set Enable Signal as Output
   SetBit(45);            // Enable the amplifiers
   
//  Add a small amount of Coordinated Motion Path smoothing if desired
//   Tau = 0.001;  // seconds for Low Pass Filter Time Constant
//   KLP = exp(-TIMEBASE/Tau);
   KLP=0; // force to 0 to disable
//   printf("Tau=%f KLP=%f\n",Tau,KLP);
   
   
   for (;;) // loop forever
   {
      WaitNextTimeSlice();
      
      // Service Amplifier disable after no activity for a while
      if (ch0->Dest != LastX || ch1->Dest != LastZ)
      {
         // we moved - enable KStep Amplifers
         SetBit(45);
         T0 = Time_sec();  // record the time and position of last motion
         LastX=ch0->Dest;
         LastZ=ch1->Dest;
      }
      else
      {
         if (Time_sec() > T0 + 10.0) ClearBit(45);
      }
   }

    return 0;
}

Offline mc

*
  •  381 381
    • View Profile
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #18 on: September 02, 2014, 06:39:22 PM »
Couple things if you're using that file as is.

Remove the bit that disables the amplifiers after being idle for a period, as it means position can be lost if the steppers happen to move when power is removed.
Also when running mach, I'd remove the SetBit(45) line, and instead set an enable in mach to Port 1 Pin 45, so the amps only get enabled when Mach does.

Jerk is a measurement of how quickly acceleration/deceleration is applied, and in KFlop is a measurement of counts/pulses per second per second per second (I bet you had to read that several times, as it took me a while to get my head around it!)
Without jerk, which is how Mach3 runs, on acceleration there is a sudden increase in the rate of pulses, which leads to a sudden change in force as something stationary suddenly has to accelerate. With jerk, the rate at which the acceleration is applied is controlled, so you get a smoother start to acceleration.
Think of it as when you press the accelerator in a car, if you suddenly stamp it to the floor, you start accelerating quickly and provided you've got enough horses under the bonnet, you get abrubtly forced back into the seat.
Now taking the same car, if you gradually press the accelerator to the floor, you ultimately get to the same acceleration rate, however you don't get as abrubtly forced back into the seat.

The trick is applying enough Jerk, so things accelerate smoothly and quick enough without causing jerky movement. It does essentially result in a very basic S-curve motion profile.
One thing to note, is while running KFlop with Mach, you have to ensure that the Mach settings aren't limited by the KFlop settings, as the KFlop max speed settings will over rule Mach settings. This can lead to a condition where actual movement is ever increasingly lagging behind Mach. I'm not sure what would happen if the lag becomes too big, but it's something to be aware of.

However none of that explains your step per unit issues.
I'd maybe try dropping the acceleration rate and speed rate down in Mach, incase you're loosing steps during the moves. Another way to check for this would be to set up a dial gauge against the carriage, zero the axis, then do a rapid away, then a slower feed return to the gauge. You're most likely to lose steps during the rapid, so doing a rapid in one direction followed by a slow return is more likely to show up lost steps.
Might also be worth checking that all your couplings are tight.

My next move after that would be visually check the motors are turning the correct number of turns for a requested move. i.e. mark the motor/coupling then command a move of 0.125" and check the motor does rotate one full turn. And if it does, check your screw is 8tpi.
Re: Steps/Inch on Lathe = 75,000; Seems a Tad High
« Reply #19 on: September 04, 2014, 05:39:29 PM »
I am getting back to this today. I got a call from Dolphin CAD/CAM about a discount, so I have been trying to get their demo to work with Alibre Design Personal, and it has sucked up a lot of time.

Regarding jerk, I have no idea what an acceptable figure is. I assume the notation used ("4e+006") means "4.00 x 10 to the sixth power," but I don't know what the units are or what levels make sense.

M x velocity is about 25"/min., and my z is about 138. The x acceleration is about 3.3"/second^2, and the z figure is about 32. Mach3 picked these figures. I don't know why it would ever need to move that fast on a mini-lathe in a garage. I can fool with it and see what happens.