Page 1 of 1

Switch Alarm

Posted: Wed Feb 27, 2019 5:07 pm
by CNC_Machines
Greetings,

I am using the KFlop to run our automated factory equipment. I would like to use a hardware switch connected to the KFlop to signal to communicate with an application running on the PC. An example would be, we are making a dashboard for the engineering team to watch status of all the equipment. When an operator turns the switch I need some way to detect that in order to notify the dashboard.

The only way I am aware of to communicate from the KFlop to the PC is by writing a text file. Is there any other way? Can the KFlop start an executable on the PC? Could it write to a SQL server? I know an M code under "execute PC" will do something similar. Can I do the same thing from a C program running on the KFlop?

Thanks,

Scott

Re: Switch Alarm

Posted: Wed Feb 27, 2019 6:10 pm
by TomKerekes
Hi Scott,

I believe your systems are running KMotionCNC? In this case when the input changes you might have KFLOP request KMotionCNC to perform an MCode Action that would in turn execute a PC program or batch file that would update some data somewhere for your dashboard. Below is the PC Command code to do this.

#define PC_COMM_MCODE 14 // Persist+1 is which MCode to execute

HTH

Re: Switch Alarm

Posted: Wed Feb 27, 2019 6:35 pm
by CNC_Machines
Thanks Tom! Exactly what I was asking for. Trying to understand the comment "// Persist+1 is which MCode to execute". Lets say that KMotion CNC has "Execute PC" with a batch file connected to M100. Would to run that batch file from a C program I would simply insert the line of code:

#define PC_COMM_MCODE 99 // Persist+1 is which MCode to execute

99 is one less than the M code of 100 that I am wanting to run?

Re: Switch Alarm

Posted: Wed Feb 27, 2019 8:40 pm
by TomKerekes
Hi Scott,

No. See KFLOPtoPCCmdExamples.c

You would code:
DoPCInt(PC_COMM_MCODE,100);

To invoke the M100 Action.