Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: rrc1962 on October 17, 2010, 08:02:18 PM

Title: Is this possible?
Post by: rrc1962 on October 17, 2010, 08:02:18 PM
Is it possible to change a pin assignment via VB?  for instance, change the probe input for pin 11 to pin 12 using a VB script.

Thanks
Title: Re: Is this possible?
Post by: BR549 on October 17, 2010, 10:23:35 PM
Not directly that I know of.  What would be the purpose? It could be done indirectly.

(;-) TP
Title: Re: Is this possible?
Post by: HimyKabibble on October 17, 2010, 10:47:20 PM
No, there is no way to do that.

Regards,
Ray L.
Title: Re: Is this possible?
Post by: Tweakie.CNC on October 18, 2010, 03:19:56 AM
I have to disagree with Ray (in a nice way) because there is the probability that "everything is possible".

With regard to the question - the Probe input is Input 22 and it's pin assignment is stored in the .xml. It would not be too difficult to create a VB routine to modify the .xml (change the pin assignment) but it may need a restart for the change to take effect.

Tweakie.
Title: Re: Is this possible?
Post by: rrc1962 on October 18, 2010, 09:34:47 AM
I have 2 inputs for 2 probes that do different things based on some conditional logic.  My initial thought was to just switch the pin assignment for the probe function.  I could write a probe macro and instead of using G31, just use "G01 Z-1" and in the While isMoving loop, look for a low input.  In other words, if condition 1 is met, check input 1 for low.  If condition 2 is met, check input 2.  When the input goes low, stop motion and exit while loop.

How would I check an input from a VB script?

Thanks
Title: Re: Is this possible?
Post by: HimyKabibble on October 18, 2010, 09:58:04 AM
I have 2 inputs for 2 probes that do different things based on some conditional logic.  My initial thought was to just switch the pin assignment for the probe function.  I could write a probe macro and instead of using G31, just use "G01 Z-1" and in the While isMoving loop, look for a low input.  In other words, if condition 1 is met, check input 1 for low.  If condition 2 is met, check input 2.  When the input goes low, stop motion and exit while loop.

How would I check an input from a VB script?

Thanks

Get ready to break a lot of probes.  You have NO guarantee your VB code will be running nearly often enough to sense when the probe makes contact with any reliability at all.

Regards,
Ray L.
Title: Re: Is this possible?
Post by: Tweakie.CNC on October 18, 2010, 10:54:14 AM
Quote
How would I check an input from a VB script?

I think you may have gone full circle here because the best way must be to use the G31. (If GetOemLED (825) = True Then.......).

Tweakie.
Title: Re: Is this possible?
Post by: BR549 on October 18, 2010, 11:15:04 AM

2 ways to do what you need.

1. wire ALL probes in series on one set of pins. Then which ever one trips the input THAT is the active probe. Very simple logic.

2. Use a mach output signal to drive a flip flop relay to reverse the probe input between 2 probes. Call it from VB monitor the flip flop to see which is     active.  More complicated logic.

Title: Re: Is this possible?
Post by: LarryL on October 18, 2010, 11:41:04 AM
Hey Tweakie,

Got a question for you!  Is it possible to assign a hotkey value to an external switch?

Larry
Title: Re: Is this possible?
Post by: Tweakie.CNC on October 18, 2010, 12:00:33 PM
Not quite sure of the question there Larry.

Do you want the hotkey to operate an external relay or something ? or do you want an external switch / button to have the same function as a hotkey ?

Tweakie.
Title: Re: Is this possible?
Post by: LarryL on October 18, 2010, 12:09:57 PM
Hi Tweakie,

I am thinking about using an external switch, a magnetic sensor switch, to control a takeup roller on my CNC Quilter with a value assigned to it to trigger the hotkey combination that would activate the roller motor.

Larry 
Title: Re: Is this possible?
Post by: rrc1962 on October 18, 2010, 01:46:52 PM

2 ways to do what you need.

1. wire ALL probes in series on one set of pins. Then which ever one trips the input THAT is the active probe. Very simple logic.

2. Use a mach output signal to drive a flip flop relay to reverse the probe input between 2 probes. Call it from VB monitor the flip flop to see which is     active.  More complicated logic.



I thought of #1 but the problem was that is if probe 2 is needed and probe 1 contacts first, there is no way to deal with that.

#2 has promise.  I'm using a gecko G540 drive which has two outputs and I'm using them both.  Right now I have a three position switch on the machine that selects the probe.  In Mach I also have a switch (so to speak) that selects the probe because each probe has different logic associated with it.  So first you have to select the probe on the machine, then you have to select the same probe in Mach.  

The probe won't change during the program run cycle.  Ideally I want to have buttons on the mach screen to select probe 1 or 2, then have a macro at the beginning of the program set things up to read from the correct probe.  A Mach controlled relay in place of the switch on the machine would work.

One other idea would be to use a double pole switch on the machine and use one input to mach.  If that input were low, call it probe 1.  If the input were high, call it probe 2.  This method would eliminate the on-screen switches in Mach and instead just check the "probe state" input and set things up based on that.  I'd rather have a button on the mach screen over a mechanical switch on the machine, but ultimately, I just want one switch.  Sounds like it may be easier to put it on the machine and read it's state from Mach.  Could have an LED on screen to indicate switch position.  This way I can still use G31 to probe, which has never let me down.  I think I've talked my self into giving this a shot.  
Title: Re: Is this possible?
Post by: BR549 on October 18, 2010, 03:54:51 PM
OK you have my curiousity up. WHY would you need 2 probes so close together as they would get confused as to which one tripped???

(;-) TP
Title: Re: Is this possible?
Post by: rrc1962 on October 18, 2010, 06:53:14 PM
There are some initial positioning and offset differences depending on which probe is used.  A macro that runs at the beginning of the program sets all that up.  

basically what I did was use a DPDT switch on the machine.  One pole switches the two probe inputs and the other switches to ground when probe 1 is selected.  That runs back to the controller where mach sees it as an input (Input 1).  When my macro runs, it checks the state of input 1 and sets things up accordingly.  It works very well.

My only concern is that I have an LED on screen for the two probes.  Probe 1 is active when input 1 is active, so I have OEMLED 821 lit (true) when probe 1 is active.  Basically, probe 2 is active when OEMLED 821 is false so no LED is really needed for probe 2, but for cool factor I wanted to add one.  I added a userLED, then wrote a macropump that just sets it's state opposite that of OEMLED 821.

This works great, but I'm concerned about this piece of code running all the time and using valuable resources.  It's just a simple if then else like this....

If getOEMLED(821) = False Then
   setUserLED(1102, 1)
else
   setUserLED(1102, 0)
end if
Title: Re: Is this possible?
Post by: BR549 on October 18, 2010, 07:16:46 PM
Put in into a brain and mach will never know it is there(;-)
Title: Re: Is this possible?
Post by: rrc1962 on October 18, 2010, 07:35:01 PM
But then I'd have to learn all about brains. :)
Title: Re: Is this possible?
Post by: rrc1962 on October 18, 2010, 08:27:14 PM
Figured it out.  Brain works much better.  Thanks for that tip.