Dear Tom, we are using a KFlop and a KStep to control a linear stage with 2 Optical Limit Switch (3.3V trigger signal, connected to Pin 34 and 35). Below is our code.
//Z axis-channel 13, 34-35
ch1->InputMode=NO_INPUT_MODE;
ch1->OutputMode=STEP_DIR_MODE;
ch1->Vel=4000;
ch1->Accel=40000;
ch1->Jerk=400000;
ch1->P=0;
ch1->I=0.01;
ch1->D=0;
ch1->FFAccel=0;
ch1->FFVel=0;
ch1->MaxI=200;
ch1->MaxErr=1e+06;
ch1->MaxOutput=200;
ch1->DeadBandGain=1;
ch1->DeadBandRange=0;
ch1->InputChan0=1;
ch1->InputChan1=0;
ch1->OutputChan0=13;
ch1->OutputChan1=0;
ch1->MasterAxis=-1;
ch1->LimitSwitchOptions=0x113;
ch1->LimitSwitchNegBit=35;
ch1->LimitSwitchPosBit=34;
ch1->SoftLimitPos=1e+09;
ch1->SoftLimitNeg=-1e+09;
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.92081;
ch1->iir[2].A2=-0.923885;
SetBitDirection(34,0);
SetBitDirection(35,0);
The strange thing is when we move the axis for a certain distance, the axis will be disabled quite often during movement even if the optical limit switch is not physically triggered (blocked) at all. This only happens when we connect two optical switches to pin 34 and 35 and set ch1->LimitSwitchOptions to 0x113. If setting ch1->LimitSwitchOptions to 0x112, only one optical switch is functional and it works perfectly.
Is it possible that the two pins interfere with each other? Thanks.
Limit switch issue
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Limit switch issue
You possibly have noise on the wiring. How is it wired? Those pins need to be driven high and low.
Since you have a KStep it would be better to use the 24V Opto-isolated inputs available on KStep.
Since you have a KStep it would be better to use the 24V Opto-isolated inputs available on KStep.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Limit switch issue
Thanks, Tom.
The signal wire of the limit switch is directly connected to KFLop IO34 and IO35.
The tricky thing is if I keep the two optical limit switches connected to IO34 and IO35 and set LimitSwitchOptions to 0x112 //means just use the positive one. It works perfectly.
Once I change LimitSwitchOptions to 0x113 //, both the negative and positive sensors are enabled. The axis will often be stopped and disabled during movement even without triggering the optical switch.
The signal wire of the limit switch is directly connected to KFLop IO34 and IO35.
The tricky thing is if I keep the two optical limit switches connected to IO34 and IO35 and set LimitSwitchOptions to 0x112 //means just use the positive one. It works perfectly.
Once I change LimitSwitchOptions to 0x113 //, both the negative and positive sensors are enabled. The axis will often be stopped and disabled during movement even without triggering the optical switch.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Limit switch issue
That doesn't explain how it is wired.The signal wire of the limit switch is directly connected to KFLop IO34 and IO35.
IO34 and IO35 are high impedance 3.3V LVTTL Inputs. You can not just connect them to a switch. When the switch is open the input will be floating and its voltage will be indeterminate. You might get lucky and sometimes work.The tricky thing is if I keep the two optical limit switches connected to IO34 and IO35 and set LimitSwitchOptions to 0x112 //means just use the positive one. It works perfectly.
IO26 - IO33 have 150 Ohm pull down resistors. These will be guaranteed to be low when disconnected (switch open). So you could use a switch to connect them to 3.3V.
As I said it would be better to use the opto-isolated inputs. Long limit switch wiring running all over the system can pick up noise which will not be isolated from the high speed digital circuits.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Limit switch issue
Thanks, Tom. I changed IO 34 and IO 35 to IO 32 and IO 33, which are connected to the signal pin of a 3.3V optical limit switch. This solved my issue.