Hello Guest it is March 28, 2024, 04:08:58 PM

Author Topic: Is this basic script possible, please help.  (Read 5186 times)

0 Members and 2 Guests are viewing this topic.

Offline btu44

*
  •  28 28
    • View Profile
Is this basic script possible, please help.
« on: June 04, 2012, 02:12:34 PM »
Hello,

I'm wanting to setup an automatic pulley number detection system for my CNC mill controlled by Mach3.
I have the detection hardware pretty much figured out but writing the Mach3 script is over my head.

Here is my attempt to create a flow chart of events.

                  Press Cycle Start button
               Check port 2 pin 13 for low
   yes                                        no
set OEMcode 56 to 1        set OEMcode 56 to 2
                OEM code 1000 (cycle start)
                Ignore port 2 pin 13

Hope this makes sence and some one maybe able to help me out.

Thank you,
Barry
« Last Edit: June 04, 2012, 02:21:04 PM by btu44 »

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Is this basic script possible, please help.
« Reply #1 on: June 04, 2012, 02:18:35 PM »
What do you want to happen if the signal is seen or if its not?
Are you just wanting a message to pop up saying which pulley its in?
Are you wanting to change the pulley Number in Mach?
Are you wanting both?
Are you wanting something else?

Hood

Offline btu44

*
  •  28 28
    • View Profile
Re: Is this basic script possible, please help.
« Reply #2 on: June 04, 2012, 02:22:14 PM »
Sorry Hood, I hit the Post button before finishing

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Is this basic script possible, please help.
« Reply #3 on: June 04, 2012, 02:26:52 PM »
No problem. :)

So what you want is code in your start button so that when you press it it will look to see the state of the input and whatever that is write to the pulley DRO and then start the programme?

The other option is have it continually monitored and it would change the pulley number whenevr the signal was changed. Two ways that could be done, brain or macropump.

Let me know which you wish and I should be able to help.
Hood

Offline btu44

*
  •  28 28
    • View Profile
Re: Is this basic script possible, please help.
« Reply #4 on: June 04, 2012, 02:38:36 PM »
So what you want is code in your start button so that when you press it it will look to see the state of the input and whatever that is write to the pulley DRO and then start the programme?

Yes, exactly

The other option is have it continually monitored and it would change the pulley number whenevr the signal was changed. Two ways that could be done, brain or macropump.

How I am detecting the pulley # is with a IR xmit/rec module detecting a white painted V belt. The module is positioned to see the belt only in pulley position 1.
I'm thinking that with the belt spinning and vibrating a false signal is possible. Would this change the pulley DRO during cycle run?

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Is this basic script possible, please help.
« Reply #5 on: June 04, 2012, 02:48:19 PM »
Ok option one may be the best then as you say the belt may not get detected properly when spinning.
Ok first thing you will have to do is open your screenset in one of the screen designers (Screen4 or MachScreen) and change the Start button (on all pages) to a VB button. I use Screen4 so not sure how its done in MachScreen but imagine it would be the same. What you do is double click the start button and a box will pop up and you just choose the VB button option, close then save screenset. May be an idea to use Save As option and choose a name for it, especially if its the standard screen you use as if you dont then there is a chance it will get overwritten if you upgrade Mach versions in the future.
Ok once you have done that you will need to load the screen in Mach (from View menu) if you have chosen to rename the screen.

Next is go to Operator menu then Edit Button Script. You should see the Start button flashing, click on it and the editor will open, in the editor paste the script below then choose File and save and thats you almost done. The only other thing to do is go into ports and pins and set up input 2 to pin 13 port 2. If you already use that input use another and change the script to the input number you have set.
Hood


If IsActive (Input2) Then
SetOemDRO(56,1)
Sleep 500
Else
SetOemDRO(56,2)
Sleep 500
End If
DoOemButton (1000)

Offline btu44

*
  •  28 28
    • View Profile
Re: Is this basic script possible, please help.
« Reply #6 on: June 04, 2012, 03:30:03 PM »
This looks great ;D ;D ;D

I've worked with MachScreen a fair amount and can do all you described.

The script you wrote sure looks alot diffrent than my attempt. You sure saved me alot of time.
Is the 'Sleep 500' in seconds or milliseconds? If I re-run this script before 'Sleep 500' times out, will it 'wake up'?

Thanks so much,
Barry

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Is this basic script possible, please help.
« Reply #7 on: June 04, 2012, 03:35:31 PM »
Sleep is mS, so that is  1/2 a second, likely you could make it a lot shorter as it is just to allow time for the DRO to update before the M3 or whatever would be called. As that will be after the cycle start has been "pressed" by the macro then likely you wouldnt even need the sleeps.
Hood

Offline btu44

*
  •  28 28
    • View Profile
Re: Is this basic script possible, please help.
« Reply #8 on: June 07, 2012, 11:20:12 AM »
OK the hardware part of this project is almost done, hopefully be testing today.

But I do have another question. In System Hotkeys I have Trigger #1 assigned OEM Code 1000.

Can I assign this script to an external button?

I did a search and didn't find this answered already.

Thanks,
Barry

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Is this basic script possible, please help.
« Reply #9 on: June 07, 2012, 11:36:12 AM »
I use the MachMad  plugin that Scott made to do that, its a kind of a round about way to do it but it does work well.

Hood