KFlop digital IO pins are swapped?

Moderators: TomKerekes, dynomotion

Post Reply
xuphoenix
Posts: 14
Joined: Sun Apr 19, 2020 3:32 am

KFlop digital IO pins are swapped?

Post by xuphoenix » Mon Feb 20, 2023 4:53 am

I physically connected a limit switch (positive end) signal pin to IO0 (see the attached picture), but in the program, I have to configure LimitSwitchPosBit as 1, as shown below:
ch1->LimitSwitchOptions=0x112;
ch1->LimitSwitchPosBit=1;
SetBitDirection(1,0);
It works. But somehow, IO0 and IO1 are high and low at the same time based on the digital I/O screen, and they look like IO0 and IO1 are interconnected internally.

If I configure LimitSwitchPosBit as 0, the same as the physical pin connection. I cannot move ch1's axis toward the positive limit switch even if it's not triggered at all.
ch1->LimitSwitchOptions=0x112;
ch1->LimitSwitchPosBit=0;
SetBitDirection(0,0);
Is my KFlop broken?
Attachments
1.PNG

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: KFlop digital IO pins are swapped?

Post by TomKerekes » Mon Feb 20, 2023 8:41 pm

If an input is left floating and open it state is indeterminate. It may follow a nearby signal based on parasitic resistance and capacitance. So just ignore its state (or drive it high or low).

It may be the signal has noise (glitch spikes). In that case the limit will always trigger. It may be the glitches are not introduced into the nearby inputs.

Here is a program to watch for a glitch:

Code: Select all

include "KMotionDef.h"

// Simple check for Glitch on Input Pin

main()
{
	while (!ReadBit(0)) ;  // tight loop while input is low
	printf("Input was high!!\n");
}
You can reduce noise by using shielded cables, or by adding a 0.1uF Capacitor to GND near KFLOP, or by using opto isolated 24V signals as with our Konnect Option.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply