Switch Alarm

Moderators: TomKerekes, dynomotion

Post Reply
CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Switch Alarm

Post by CNC_Machines » Wed Feb 27, 2019 5:07 pm

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

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

Re: Switch Alarm

Post by TomKerekes » Wed Feb 27, 2019 6:10 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

CNC_Machines
Posts: 60
Joined: Fri Apr 27, 2018 10:43 pm

Re: Switch Alarm

Post by CNC_Machines » Wed Feb 27, 2019 6:35 pm

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?

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

Re: Switch Alarm

Post by TomKerekes » Wed Feb 27, 2019 8:40 pm

Hi Scott,

No. See KFLOPtoPCCmdExamples.c

You would code:
DoPCInt(PC_COMM_MCODE,100);

To invoke the M100 Action.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply