Machsupport Forum

Third party software and hardware support forums. => PoKeys => Topic started by: JORATORCA on October 30, 2016, 11:14:39 AM

Title: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on October 30, 2016, 11:14:39 AM
Hello everyone,
I am developing a device to manually control my CNC router through a PoKeys57CNC programmed with PoBlocks. This device can generate pulses through its internal pulse generator to operate autonomously without being connected to a PC. I can move the axes with several MPG, enter coordinates, or enter a distance to travel for each axis. This works very well. The problem occurs when the pulse generator has Mach3 takes control and the program generated with PoBlocks is not aware that Mach3 took control. I need to be able to say PoKeys57CNC program, which is Mach3 which has control. For this I thinking about two systems:
1. Capture Charge Pump signal generated by Mach3: I can not do this by setting some of the I / O PoKeys57CNC as input to detect the pulse of 12.5 kHz. I do not know if it is possible.
2. Through macropump: I set PoKeys57CNC plugin for Mach3 communicates through UserDRO range 1100 to 1127 (see attached image). It works well, for example, pressing the button that activates the active Mist UserDRO 1100. With other events that occur during operation of Mach3 I can activate and deactivate other UserDRO. The problem is that I do not get any events that tells me that Mach3 is working (properly). I have tried to detect through the VB-script when the Alt + F4 keys (closed session) are pressed, so that, before closing the session Mach3 the macropump change the status of the selected UserDRO, but neither I succeeded.
I thank you in advance for your help.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on November 14, 2016, 02:06:00 AM
Nobody can help me? I can not advance in my project if I can not send to the Pokeys57CNC any signal from Mach3 to inform that the program is active and that (this is the tricky part) tells you when Mach3 is going to close. Thank you for your help.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on November 29, 2016, 10:00:13 AM
Charge pump signal should work?  

I am working in a custom screen set so I cant remember if the Mach3 1024.set has an LED for the charge pump, I believe it does, if not you can just create one.  Use that LED and a shared data slot to send the signal to the Poblocks program.

The trick is to create a brain that watches the LED status.  An active LED in Mach3 will output a 1, inactive will be a 0.  This 1 and 0 can be sent to a DRO (has to be a custom DRO and the DRO needs to be a Mach3 to Pokeys shared ouput slot 21-27.

So when the charge pump LED is active it will send a 1 to the DRO and a 0 when it is inactive.  The DRO value can then be sent from Mach3 to Pokeys.  In your Pokeys program you can use this on/off signal for whatever you need.  Its a work around but it does work.  It would be nice if PoBlocks could read the logic state of Mach3 LED's.
 
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: eurohoppel on November 29, 2016, 04:21:25 PM
Hello,
 just an example ;)
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on November 29, 2016, 04:56:27 PM
Yep, just like eurohoppel posted.

You will have to give the DRO a number that can utilize the shared slots in Poblocks. (Mach to Poblocks not Poblocks to Mach). 

So if your starting your shared slots on DRO 1100 and you want to send this on/off signal from Mach3 to the Poblocks application you will used a DRO numbered between 1121 - 1127.

Again, its kind of a work around but it does yield a result.  I use this same method for two LED status signals.

Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on November 30, 2016, 03:44:21 PM
Thank you very much for your help. I tried the brain example that you gave me but I can not make it work with the charge pump. To verify that there is good communication with PoKeys57CNC I modified the brain as I attached it. I've been able to enable and disable an output on the PoKeys57CNC by pressing Flood Toogle, so I deduce that the communication is set. I do not know if the problem is that I have some bad settings in Mach3 where the chargepump is not activated.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on November 30, 2016, 04:41:06 PM
Another method would be to jumper an output pin (Mach plugin selected output) say, "Pin 45 charge pump" on the 57cnc board to another pin setup as an input on the poblocks side.  You have to remember than if a pin is being used on the Poblocks side that you don't configure it on the pokeys plugin for Mach3.

So in essence, set up pin 45 (dedicated charge pump pin on the 57cnc board) with a jumper wire to any other open i/o pin on the board.  In Poblocks setup that pin as an input for you logic level needs.

When the charge pump is active it will send an output signal that can be read by the input side of the poblocks app.

I have not tested this method with the charge pump but have with a standard output from Mach to an input on the poblocks side.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on November 30, 2016, 06:00:42 PM
I already tried to use the Pokeys57CNC charge pump signal output on pin 45. This output generates a signal of 5Khz when the pulse engine is active, but it is independent of whether Mach3 is active or not. That is to say, whether the pulse generator is the Mach3 or if it is the pulse engine of the PoKeys57CNC, I get the 5 kHz signal on the pin 45.
What I need is to be able to tell PoKeys57CNC in some unequivocal way that Mach3 is in control.
The solution with the brain seems appropriate, but I do not understand why I do not get the signal of the charge pump of Mach3. Do you know any way to check if Mach3 is generating the charge pump signal?
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 01, 2016, 10:51:50 AM
Correct me if I am wrong but doesn't the Pokeys Mach3 plugin override any pulse engine generators setup in Poblocks?  If so then the Poblocks pulse engines would become inactive when Mach3 is running.

Another method would be to just use the E stop led in the brain vs the charge pump.  Mach3 starts up in E-stop active mode and the signals can be used as described above in a brain to poblocks setup.

But again.  On my end when I setup a poblocks utilizing a pulse engine block configuration it works as long as Mach3 is not running.  When Mach is active the poblock pulse engine is ignored.

 

 
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 01, 2016, 02:14:03 PM
That was what I expected. Your reflection has made me try again.

What I have discovered is that if I enable the charge pump in the Pokeys57CNC using the PoKeys software, when I move the motors manually with the MPG without connection to the PC, the 5 kHz pulse is generated by the pin 45. So far everything is fine.

If I connect Mach3 and in the plugin I do not have the "enable safety charge pump" box checked, the / Mach3 plugin modifies the configuration I made with the PoKeys software and the charge pump stops working. In the same way, if I activate the "enable safety charge pump" box of the plugin from Mach3, I always get the signal of 5khz when Mach3 is connected, even if the motors do not move! So it does not help me at all.

I can not use the signal from Estop. When connecting Mach3 would have a "signal" connection, since when starting Mach3 always starts with the Estop enabled and would be worth as a message for PoKeys57CNC: "Mach3 has come into operation, let it take control."

But the problem is to inform PoKeys57CNC when Mach3 stops working. I have clear how to activate a communication signal from Mach3 to PoKeys57CNC through macropump or a brain. But how do I send another signal to PoKeys57CNC when I press the button to close the application from the PC?

In other words. In macropump, how do I check if the red cross button was pressed to close the application? And how do I command through the macropump Mach3 shutdown ?. If I can control this, I will be able to program the disconnection of an OEM LED and then allow Mach3 to close.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 01, 2016, 03:01:51 PM
I may not fully understand your goals, but after reading through this thread again I think I have a grasp on what you want to do.  When Mach3 is active it should have control over machine movement.  When Mach3 is not active or the computer is not running you want a poblocks configuration to allow machine movement via MPG or other manual control method???

You don't need a brain, macro pump or vb script, though you could probably accomplish the task with one or more of these tools.

The simplest way I can think of is to:

1) activate "Enable safety charge pump (pin 45) and keep "Enable in emergency (reset)" unchecked in the Pokeys plugin for Mach3.

2) Jumper pin 45 and 43 on the Analog inputs connector on the 57CNC.

3) Load the attached Poblock to the 57cnc board via the Poblocks application.  or merge the poblock configuration that is attached into your current custom poblocks build.  This is one method for telling a poblocks configuration that Mach3 is active.

4) For testing purposes only: wire an led from pin 13 on the Encoders connector on the 57cnc board to a ground pin next to pin 13.  If your using pin 43 and/or pin 13 in the plugin for Mach3 you will have to disable them to allow the poblock program to have access to these i/o's.

When Mach 3 is active (running and out of estop) the LED on between pin 13 and GND will light.  When in active estop or you close Mach3 the led will go off.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 01, 2016, 03:25:04 PM
Just another note:

Mach3 and Poblocks can communicate via pins as long as they are configured correctly on each side.  If a Poblocks application uses pin 1 for example them Mach3 plugin can not use pin 1 for anything.  The same goes in reverse.  This method allows you to have an output from Poblocks (say pin 1) communicate to Mach3 on an input pin (say pin 2).  You configure the output pin 1 in Poblocks and configure the input pin 2 in the Plugin for Mach.

Shared pins can be used by both but the Mach3 to Poblocks is limited in number of pins (21-27) and if you want to only communicate simple logic level stuff you have to create an LED, DRO and brain as mentioned earlier.


Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 01, 2016, 06:19:24 PM
Thank you turboedges.
I have managed to make it work perfectly. Now I understand how it is done.

The truth is that if you do not tell it difficult to find documentation on these incompatibilities when setting pins from Poblocks and the Mach3 plugin on PoKeys devices.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 02, 2016, 01:46:59 AM
Bufff. It did not work for me! :'( :'( By integrating this solution into PoBloks, I have discovered that output 13 is set to 1 even when the pulse engine is activated by manually moving the axes with the MPG.

I have to look for a solution that shows me only what I need: that Mach3 is active.

I still think that the solution is to permanently check through the macropump if the button of the red cross of closing of the Mach3 application has been pressed. Any ideas?
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 02, 2016, 09:32:56 AM
If your willing to share your poblocks .xml I might be able to assist.  I understand if you are not willing.  I am sure there is some other poblocks configuration that can solve for this.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 02, 2016, 01:01:04 PM
I enclose a reduced version with only two modes of operation, automatic and MPG.

As in the AUTO mode the pulse engine of PoKeys57CNC is disabled, it is Mach3 which causes the 5kHz signal of the charge pump to be output from the pin 45. In this AUTO mode, if I close Mach3 the 5 kHz signal disappears.

The problem is that, if this Mach3 is closed, I select the MPG mode, the 5 kHz signal appears. What I need is to generate a signal that prevents me from selecting any other mode, other than AUTO, if and only if Mach3 is active.

How I am able to send a signal (a 1 for example) to PoKeys57CNC from Mach3 when I start it, the only thing I do not know is to be able to put that signal to 0 when I close Mach3. I think that if I am able to detect by code (macropump) that I pressed the button to close Mach3, I will be able to detect its shutdown and act accordingly within my code.

I hope you have understood me. I do not express myself very well in English.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 02, 2016, 03:52:38 PM
I have noticed that  the plugin for Mach3 seems to leave a pin i/o state in its last know status when closing. 

So if the i/o pin that the poblocks app is looking at is high (say Mach3 active) when closing Mach3 the signal will stay high until Mach3 is restarted.  Obviously this isnt what you want.  Your goal would be to have the signal go low when closing Mach. 

Charge pump seems to be the only signal that turn on and off when mach3 is active.  But as you may have notice in the .xml when mach3 is inactive the change pump pin still floats and needs to be pulled down.  The GT block was just a quick way to demonstrate the concept.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 06, 2016, 02:39:45 PM
I'm still mulling over the matter. I have thought that PoKeys57CNC may be periodically checking if there is a Mach3 response. To do this it launches through a shared output (for example through UserDRO (1100)) that will receive Mach3 when it is active.

If Mach3 receives this input, a script (macropump) responds to PoKeys57CNC (for example through the shared output UserDRO (1124)). With this simple code check the operation of Mach3:
If GetUserDRO(1100) = 1 Then   'If I receive a 1 of PoKeys57CNC...
   SetUserDRO(1124, 1)              'Return shipping 1 to Mach3...
   activateSignal(OUTPUT7)         'and activates output 7 to display on the Mach3 diagnostic screen
Else
   SetUserDRO(1124, 0)
   DeactivateSignal(OUTPUT7)
End If

I have some problems that I can not solve:

1. The maximum frequency with which the check is refreshed is 200 ms (time it takes to run the macropump). It's slow, but it might be.
2. The output signal I get in PoKeys57CNC is a square wave of approximately 1.5 Hz and I need to convert it to a logic signal (1 if I have the square wave present and 0 when it disappears). I would like to do it through PoBlocks but I do not see the way to do it.
3. If when I disconnect Mach3 the shared output UserDRO (1124) is at 0, I get a persistent 0 Volts signal at PoKeys57CNC, but if I stayed at 1, I get a high signal. I do not know how to solve it either.

I attached the xml of PoBlocks so that you can understand it better.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 06, 2016, 02:51:33 PM
Have you tried this:

1) Open, Pokeys application (should be Pokeys Configuration v4.2.13)
2) To to: Peripherals> Failsafe Settings.
3) Set any pin to the desired failsafe setting.

This will allow the pokeys device to revert to a specific logic value when Mach3 is closed.


I will see if anything comes to mind when taking a look at the .xml you attached
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 06, 2016, 02:52:19 PM
Make sure you click "send to device" after setting your default failsafe settings.
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 06, 2016, 03:07:50 PM
It works!!!

What does the Fail Safe function actually do? I would like to understand how it works.

Whenever I close Mach3 output 43 remains at 0. Now only need to convert the square wave I receive from Mach3 by 1 to the output of PoKeys57CNC. I would like to do it with the logical blocks of PoBlocks and without having to use more pins (I am running out). Is it possible?
Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: turboedgs on December 06, 2016, 03:25:44 PM
Re: the failsafe.  It will set any pin to a user defined state (high or low) when communication with Mach is lost. 

What you were experiencing was the charge pump going into failsafe setting when Mach was terminated.  I think the default of the Pokeys system is a high level.  By switching the default to low the pulse engine signal will go low when Mach is terminated.



Title: Re: HOW TO DETECT THAT IS RUNNING MACH3 IN POKEYS57CNC
Post by: JORATORCA on December 06, 2016, 06:14:25 PM
I see the LED I have on output 43 blinking and I measured it with the oscilloscope and it actually receives a pulse every 100 ms (the time I have set in the failsafe) that sets it to 0, but immediately after it is set to 1.

I put a sneak on the LCD to tell me in what state was the "shared output 24". I have noticed that this happens when it stays at 1. If left at 0 the output 43 stays at 0 all the time. :'( :'(