Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: dah79 on January 22, 2016, 09:39:48 AM

Title: Adding external push buttons
Post by: dah79 on January 22, 2016, 09:39:48 AM
Hello. 

I am looking at retrofitting an outdated mill using a MachMotion controller.  I would like to be able to use the spare inputs on their Apollo III controller to connect external push buttons or possibly a joystick used for jogging remotely.  I have no experience with Mach4, so am looking for a way how to do this...or if it is easily done.

I have read many posts here and I am pretty sure that it is possible, just need some direction as to the easiest way.  If possible, I would like to have 4 buttons for Continuous jog of X/Y + & - and then have 2 more buttons for Incremental jog of Z.

I know there are other options for jogging using the software, keyboard or MPG, but I am looking for a remote option.

Thank you
Title: Re: Adding external push buttons
Post by: ger21 on January 22, 2016, 10:00:22 AM
From what I've read here, the Machmotion people probably know more about Mach4 than anyone outside of Artsoft. Have you asked them?
Title: Re: Adding external push buttons
Post by: dah79 on January 22, 2016, 10:10:12 AM
Yes, I have asked them and was told that they weren't sure.  Looking at 'Brains', it looks like it could be done there??
Title: Re: Adding external push buttons
Post by: dude1 on January 22, 2016, 08:50:53 PM
you can do it with a script just find Daz and ask him
Title: Re: Adding external push buttons
Post by: dah79 on January 23, 2016, 08:51:16 AM
Looks like possibly using an OEMtrigger would work as well, can anyone verify?

Title: Re: Adding external push buttons
Post by: Steve Stallings on January 23, 2016, 10:21:10 AM
OEMtriggers are called Signal Scripts in Mach4.

See section 3.2.4 of the Mach4 Scripting Manual.

See:  http://www.pmdx.com/Downloads_Mach4/Mach4_Documentation/Mach4%20Scripting%20Manual.pdf (http://www.pmdx.com/Downloads_Mach4/Mach4_Documentation/Mach4%20Scripting%20Manual.pdf)

or: http://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Scripting%20Manual.pdf (http://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Scripting%20Manual.pdf)

This section of the manual gives an example of a physical Cycle Start button implementation.

Title: Re: Adding external push buttons
Post by: Pedio on January 23, 2016, 10:21:40 AM
I added a manual pause button and go button to mine. There was a good post on this issue. You should be able to find it with a little looking on this forum.

That was before they got the shuttlePro plug in working. Now life is nirvana for me! Just remember the wheeles in the middle of the shuttle pro use the current jog increment as a basis for their movement. You also may have to play with the jog rate and Jog rate % to get it really working.

It was worth every penny!
Title: Re: Adding external push buttons
Post by: DazTheGas on January 24, 2016, 06:53:26 AM
As steve says the signal scripts are the way to make anything work you can think of within mach4

if you go into the screen editor and look at the startup script there are a few examples there.

For example if you were wanting to use your extra inputs you have left as jogging then you would need a signal for each axis you wanted to jog, so for xyz that would be 3 inputs altogether + any other buttons like jog mode.

Code: [Select]
[mc.ISIG_INPUT10] = function (state) -- assign input 10 to X++
    if (state == 1) then   
       mc.mcJogVelocityStart(inst,0,1);
    else
       mc.mcJogVelocityStop(inst,0);
    end

end,

Although the code above is straight forward you would have to add in extra stuff to your code to check if you are in 'cont' mode or 'inc' mode, because this signal is in a constant loop mach4 will also need a condition for this signal in the case you were using the keyboard jog or external control otherwise the mcJogVelocityStop or mcJogIncStop etc would overide other devices with jogging support rendering them useless.

DazTheGas
Title: Re: Adding external push buttons
Post by: dunnitagain on January 24, 2016, 06:41:02 PM
   I'm watching this also , I have a control panel with 33 Push buttons id like to incorporate into my Retrofit.
I spoke with Machmotion and they wouldn't help me either .  I don't have the codeing knowledge to use the examples to write my own scripts.
Title: Re: Adding external push buttons
Post by: dah79 on January 24, 2016, 08:09:08 PM
Thanks for the replies.  I too do not have the programming knowledge at the moment as I am just looking into Mach.  From what I have read, though, it looks like 'Brains' would be a simpler programming method IF it would work.  I come from a PLC programming background and it is easier to understand.

So, if there is anyone out there that can answer this, I am still interested.
Title: Re: Adding external push buttons
Post by: dude1 on January 24, 2016, 08:11:12 PM
have a look in the scripting manual , what daz posted above can be change to input what ever, call what ever one after the other in a table. just play and post back when you need help.

I think the manual is a bit out you will have to check with Daz on this one
Title: Re: Adding external push buttons
Post by: dude1 on January 24, 2016, 08:12:22 PM
Brains is a M3 thing M4 use's a different method 
Title: Re: Adding external push buttons
Post by: dah79 on January 24, 2016, 08:21:36 PM
Quote
Brains is a M3 thing M4 use's a different method

Oh, I did not realize that.  Guess I need to do more research on scripts...or maybe Machmotion needs to if they want to make a sale as this seems to be fairly common thing.
Title: Re: Adding external push buttons
Post by: dude1 on January 25, 2016, 03:26:01 AM
Machmotion are using M4 (look up there youtube channel) they will be waiting for it to get more stable, if you ask for a M3 controller they will help then
Title: Re: Adding external push buttons
Post by: dah79 on January 25, 2016, 12:37:23 PM
Found another possible solution to this.  This has been done using Mach3, but since it is a keyboard emulator, I am wondering why it wouldn't work with Mach4.

https://www.youtube.com/watch?v=KvhJj1yzqks (https://www.youtube.com/watch?v=KvhJj1yzqks)

http://www.ultimarc.com/ipac1.html (http://www.ultimarc.com/ipac1.html)
Title: Re: Adding external push buttons
Post by: dude1 on January 25, 2016, 01:46:40 PM
you can do the same thing with a pokeys what is good to go with M3 and M4 have a look at the 57cnc or the 57 E or U
Title: Re: Adding external push buttons
Post by: fozzyber on January 25, 2016, 03:10:10 PM
hows does the 56u work with mach4, I have tried to get it to work but have had no luck.
Title: Re: Adding external push buttons
Post by: dude1 on January 25, 2016, 03:56:07 PM
dont know I only have a 57cnc what is so hard to get going that all you have to do is plug it in, it is just as easy in M3 plug it in and that's about all.

you can use the pokeys boards as IO only

you would have to ask the pokeys boy about the 56u
Title: Re: Adding external push buttons
Post by: dunnitagain on January 25, 2016, 09:26:42 PM
    If its as simple as adding a Pokeys , I can do that ! Is it as responsive as the scripting ? I would like the easiest solution for my application , because I plan to use Mach 4 to revive several old , large
pieces of machinery ( I mean Real Large ) . That are in great shape , and very viable , but have dead controls .
Title: Re: Adding external push buttons
Post by: dah79 on January 25, 2016, 10:15:49 PM
Keep the replies coming.  Looking at Pokeys on the web, it looks like they are pretty much plug and play for keyboard emulation.  I did notice that the the 56U is no longer available and has been replaced with the 57U.

I just downloaded my demo of Mach4 today, so I have a LOT of learning to do, but would really like to get this figured out without scripting and other programming if possible.

Thanks,
Dave
Title: Re: Adding external push buttons
Post by: dude1 on January 25, 2016, 11:14:17 PM
in M4 you still have to map the controls sort of you can get the pokeys to do some of it, it's not that easy to do ( it crashes a lot so i gave up), as M3 is, that was plug and set steps vell and acc and that all I did with the 57CNC , I have there new one I am not sure if it's been released yet.

hossmachine use's a pokeys with M4 he has for quite sometime, look him up on youtube he has a control panel
Title: Re: Adding external push buttons
Post by: dah79 on April 04, 2016, 03:18:24 PM
Have gotten my Pokeys 57U and have been trying to configure using Mach4 in Demo mode as I don't have my controller yet.  Am having a lot of issues with Mach crashing when hitting 'OK' or 'APPLY'.  Has anyone successfully got the Pokeys 57U to work with Mach4?  I am trying to use it to connect external remote jogging operations.
Title: Re: Adding external push buttons
Post by: cncman172 on April 06, 2016, 02:44:30 PM
dah79,

I have a Pokeys 56U, which is listed as a 57U when you upgrade the firmware.  The latest plugin for MACH4 is 7.29.0.2914.  The plugin in getting better but still has numerous issues.  If all you have are dedicated switches and an MPG you will be able to get this to work.  I have several segments works for example a matrix keyboard, I can get keys on the keyboard to perform functions like Feedhold and that works perfect.  I can also get the LCD display to update if I write to the global registers under the Pokey plugin.  I have been able to output to LEDs which are in a matrix configuration from Mach4, which works fine as well.  The challenge is if you are using Matrix keyboard you can't access these and assign these inside the pokeys plugin, but if you use dedicated input pins or output pins that stuff seems to work.  One issue is enabling and disabling the MPG, that is not available by default in the plugin, they do have something called a deadman switch option which is for the MPGs that have a button you hold in while using the MPG.  My MPG does not have that style switch so getting it to work correctly has been a challenge.  I have hard coded that switch in the plugin saying always ON, and been able to jog a given axis with the MPG.  You have to use code inside of MACH4 in the PLC script and Signal Scripts and Screen Load scripts to get this stuff to work.  Unfortunately, there is no detailed step by step instructions available or video where someone setup a pokeys pendant.  I am trying to get this done, since moving over to MACH4 from MACH3 will not happen if I can't get the pendant stuff to work.  I opened tickets with Polabs of many issues they responded and said they would investigate and then never responded again.  The learning curve in MACH4 is pretty steep, there are a hand full of experts that have their machines working and they have been coding LUA to make things work. DazTheGas has posted many videos and honestly you will learn a great deal about how MACH4 works by watching his videos.  He does not have a Pokeys device as I asked him questions since he is an amazing resource who has shared far more about MACH4 and how to do things than the writers.  The manuals for MACH4 are very thin, nothing in comparison to MACH3 which have very detailed manuals.  rumor has it that Newfangled solutions was having them written professionally but MACH4 has been out more than a year now and nothing.  As I get the basics figured out I will post some instructions.

Russ
 
Title: Re: Adding external push buttons
Post by: dah79 on April 06, 2016, 04:39:42 PM
Thank you Russ!  I will be in touch for sure.  I have gotten several buttons/switches working through the Pokeys without doing anything but configuring them (once I figured out how).  Have had lots of issues with Mach crashing while configuring, not sure why. I have been trying to 'practice' with the Mach Demo software, don't know if that is why.
What I can't figure out yet is how to use a pot for the feed override.  Any ideas?
I have purchased a MachMotion retrofit kit, in fact I just finished unloading it.  Nice looking stuff! 
MM said I would need some custom programming to get pot to work.  I am just trying to wrap my head around all of this Mach stuff as I am more versed in the Linuxcnc systems.
Need to open up all this stuff and see what I got and then continue reading more.
Thanks again!
Dave
Title: Re: Adding external push buttons
Post by: smurph on April 06, 2016, 11:30:42 PM
A pot would most likely have to be hooked to an analog input on some hardware.  Not sure if pokeys does this or not.  Most devices will export the analog input as a register.  Depending on the analog input's resolution.  One might expect a 0 to 1023 value in the register from a 10 bit analog input.  You would then need to apply a ratio to that to make the values fall within the range of say the feed rate override settings.  So the task then becomes:

1. read the analog register.
2. convert to a proper value.
3. call the API function to set the value.

This is done in the screen's PLC script with the Mach API and LUA scripting.

Steve
Title: Re: Adding external push buttons
Post by: dah79 on April 07, 2016, 06:36:59 AM
Thank you Steve.  My Pokeys does have analog inputs.  I can see a range from 0-3.3volts using their diagnostics.  I will see if I can figure out how to do the rest.
Dave
Title: Re: Adding external push buttons
Post by: Chaoticone on April 07, 2016, 11:31:46 AM
The Analog inputs via modbus video at http://www.machsupport.com/videos/ may prove to be helpful. The video is for Mach3 and modbus but it will show you basically what you will need to do in your PLC script.

I hope to get a chance to make a video on this soon. I know it doesn't help now but it is planned. 
Title: Re: Adding external push buttons
Post by: cncman172 on April 07, 2016, 07:19:35 PM
Dave,
Look under global registers in Mach4.  The pokey plugin has several global registers amount them the analog reading.  You can check this is real time so moving the pop and checking the analog register.  If they follow you can built a series of if cases to control feed rate or spindle.

Russ
Title: Re: Adding external push buttons
Post by: dah79 on April 08, 2016, 02:14:54 PM
Hey Russ,
I was able to create a screen dro and tie the Pokeys register to it, so I can see a value change on the screen.  The first issue is there must be a scaling problem as the range is 0-1 and in Pokeys it is 0-3.3.
I have no idea now what to do with this, but at least I know that Mach can see it.
Title: Re: Adding external push buttons
Post by: cncman172 on April 08, 2016, 02:45:21 PM
Dave,
Can you post the code you used?  With maybe a couple of screenshots.  The voltage in my view does not really matter, since POKEYS is converting this to number.  When you say the range is 0-1 does this mean 0, .1, .2, .3 ..... 1  Or just binary "0" or "1".  If you are actually getting a range of values then you have something workable.  I have not played with the analog inputs in my POKEYS, but I have played with most everything else.

Russ
Title: Re: Adding external push buttons
Post by: dah79 on April 08, 2016, 03:10:58 PM
Russ,

I will get some screenshots for you, but may not be until tonight.  There was no code involved.  Keep in mind I know nothing about Mach, so I just stumbled on this.  I copied a DRO that was already on the screen and modified it's properties and just chose my Pokeyes input (41) for the input register (don't recall if that is the correct terminology in the properties).  I added a few more decimal places, but other than that I didn't do anything.

The range that shows on my new DRO is 0.00000-1.00000.  Seems to be very accurate as mid range on the pot read 0.50000.  I was excited to see that much happen and I really don't care what the scale is as long as it is linear.  I want to be able to control the slider for the FRO, which the default range is 0-250.

Dave

Title: Re: Adding external push buttons
Post by: cncman172 on April 08, 2016, 04:52:10 PM
Dave,
You could simply change the range from 0-999 for the slider control.  That would give 1000 steps which is probably more than you need.  The other option is just take the reading and multiple by four.  If the plan is to use an analog pot to perform feed rate override or spindle over ride you will need to add some LUA code in the PLC script.  You would do thing like this if the pot is in the middle and it reads .5 then feed would remain the same.  If the reading with higher than .5 same .6 you would issue a command to increase the feed rate, or if it was lower say .4 you would issue the command to reduce the feed rate.  The same situation if this was the spindle.  The number of steps you choose really depends on how well the analog pot works and how much range is really necessary.  Most commercial machines using something like 50-200% for spindle and 0-200% for feed rate.

Russ
Title: Re: Adding external push buttons
Post by: dah79 on April 08, 2016, 05:56:56 PM
Russ,

Here is a screen shot of my Pokeys config and Mach4 config for the "new" DRO and the existing FRO slider (which I didn't change).  Ideally what I would like is to have a selector switch at my remote button station that would enable/disable my remote buttons.  While they are enabled, I would like my remote FRO pot to adjust the screen slider (or at least it's function).  I may be asking too much, especially for someone who knows nothing of programming.

Looking for any help I can get and appreciating every bit of it!
Title: Re: Adding external push buttons
Post by: cncman172 on April 09, 2016, 08:31:02 AM
Dave,

The first step now that you have that slider and the range from 0% to 250% is to see how much the voltage value changes over that range.  Then we can use a little math to normalize this so it matches the slide proportionally.  Then the next step will be to link that to some LUA code to perform the function you want.

Russ
Title: Re: Adding external push buttons
Post by: DazTheGas on April 10, 2016, 03:09:07 AM
dah79 - You will need a function within your plc that will take the value from the register which not sure is min 0 to max 3.3v this will need to be converted to a range between 0 - 250 then the dro and fro populated with the result.
Also you will need this the other way round so when you change the fro on screen it will change the register (which it cannot as due to the pot corrected will overide)
so this is where your selector switch would come in and dissable the onscreen slider whilst the pot is being used.

DazTheGas
Title: Re: Adding external push buttons
Post by: dah79 on April 10, 2016, 06:13:29 AM
Thank you.  I will look into how to do this.
Dave
Title: Re: Adding external push buttons
Post by: dah79 on April 11, 2016, 09:12:07 AM
Looking into this further, I am obviously missing something.

I have created a slider with a name, RemoteFROPot.  I have set the range from 0-200, and there is nothing in the Code.  If I set the Code to FRO, it follows the override like expected, but I want it to follow my remote pot.

The DRO that I created is called Remotedro, and it is tied to Register Pokeys_35528/Analog Input41.  When I adjust the remote pot, the DRO value changes from 0.0000-1.0000.

How do I set the Code in my slider to see the Pokeys_35528/Analog Input41?