Hello Guest it is March 28, 2024, 02:30:14 PM

Author Topic: Mach3 and a tube bender  (Read 48979 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach3 and a tube bender
« Reply #40 on: February 16, 2009, 04:33:00 PM »
Fer Mayrl,

Essentially, you are suggesting I add an OEM button and an OEMled.  The OEMbutton will turn on an OEMled.  Once the aforementioned OEMled is on, then the loop will start?  How do I make a button trigger an LED to turn on?

Using my existing interface, I added OEMbutton(233), which turns on Output 4.  Next to the button I have OEMLed(77), which turns on when Output4 is energized.  When I load my screen in Mach3, the LED does not turn on if I click the button.  I can get OEMLed(830) on but hitting one of my limit switches.  Any idea why I can't get an OEMbutton to turn on a corresponding OEMled?
« Last Edit: February 16, 2009, 04:50:45 PM by supahonkey »
Re: Mach3 and a tube bender
« Reply #41 on: February 16, 2009, 04:58:37 PM »
Here is my "new" code.  I believe I have added the correct stuff.  I can get the LED(830) to turn on when I close the limit switch.  It's weird why my OEMButton and OEMLed for Output 4 won't work.  I still can't get the program to respond to anything.  Here is the code:

'Goto angle
'Macropump.m1s

DesiredAnglePos = GetUserDRO(2000) 'angle entry dro on your screen
CurrentAngPos= GetOEMDRO(29) 'encoder1 DRO from your die

If GetOEMLED(164) Or GetOEMLED(165) Or GetOEMLED(830) Then 'if the CW or CCW or the Limit switch is open, led is on

   If GetOEMLED(164) And GetOEMLED(830) Then 'if the spindle CW led and the limit switch is on.
      If CurrentAngPos <= DesiredAnglePos Then
      ActivateSignal(OUTPUT2) 'coil A cw
      Else
      DeActivateSignal(OUTPUT2)
      End If   
   End If

   If GetOEMLED(165) And GetOEMLED(830) Then 'if the spindle CCW led and the Limit switch is on.
      If CurrentAngPos >= DesiredAnglePos Then
      ActivateSignal(OUTPUT3) 'coil B ccw
      Else
      DeActivateSignal(OUTPUT3)
      End If   
   End If
   
End If   

Re: Mach3 and a tube bender
« Reply #42 on: February 16, 2009, 05:00:58 PM »
Well,
you have to add an OEMbutton, if using screen3 you can add the following macro to it: assuming the oem led is number 1200

If GetOEMLED(1200) then
SetUserLED(1200,0)
else
SetUserLED(1200,1)
end if

This will toggle led 1200 on and off

if you are using screen4 then add the button on the screen, then go to mach and click edit button script in the operator menu, you can add the script there and click save...
Re: Mach3 and a tube bender
« Reply #43 on: February 17, 2009, 09:04:57 PM »
Ah, it seems like everything I do never works at first.  I can only get fer mayrl's simple script to work.  Scott - I cannot get your script to do anything.  It throws no syntax errors, it just does nothing.  I tried adding fer mayrl's suggestion to Scott's original code: (Bold reflects the new stuff)

'Goto angle
'Macropump.m1s

DesiredAnglePos = GetUserDRO(2000) 'angle entry dro on your screen
CurrentAngPos= GetOEMDRO(29) 'encoder1 DRO from your die

If GetOEMLED(164) Or GetOEMLED(165) Or GetOEMLED(1200) Then 'if the CW or CCW led is on

   If GetOEMLED(164) And GetOEMLED(1200) Then 'if the spindle CW led and the limit switch is on.
      If CurrentAngPos <= DesiredAnglePos Then
      ActivateSignal(OUTPUT2) 'coil A cw
      Else
      DeActivateSignal(OUTPUT2)
      End If   
   End If

   If GetOEMLED(165) And GetOEMLED(1200) Then 'if the spindle CCW led and the Limit switch is on.
      If CurrentAngPos >= DesiredAnglePos Then
      ActivateSignal(OUTPUT3) 'coil B ccw
      Else
      DeActivateSignal(OUTPUT3)
      End If   
   End If
   
End If   

I still get no response, even if I press the button to light OEMLED1200.  The OemLED1200 does light up, I just get nothing. 

I am having one hell of a time getting Mach to actually save VB scripts when I edit the buttons.  I can only get it to retain code by saving it as the hiddenscript.  If I give the button a new name, such as CW, I can close the editor, click View > Save Current View, go back to the button editor, click the button, and there is absolutely no code present.  I googled the problem and everyone's suggestion was to click "Save Current View." 

Re: Mach3 and a tube bender
« Reply #44 on: February 17, 2009, 09:31:12 PM »
Please correct me if I am wrong, but I would assume something as simple as the following code would work:

If GetOEMLED(1200) Then 'If OEMLED1200 is active
ActivateSignal(OUTPUT2) 'Activate Output2
Else
DeActivateSignal(Output2) 'Deactivate Output2
End If

I have a button that turns on OEMLED1200.  When I hit this button, the LED turns green.  Based on the above code, I would expect for Ouput2 to go high.  Unfortunately I read nothing with the multimeter.  And yes, Output2 is configured.  If I check ActiveLow for Output 2, my relay becomes energized.
« Last Edit: February 17, 2009, 09:43:44 PM by supahonkey »

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Mach3 and a tube bender
« Reply #45 on: February 17, 2009, 10:35:58 PM »
no what controlled my code was the direction you wanted to turn your rotary device.

I.e. if you put a "M3" in your MDI or Gcode it would rotate positive, until the encoder reached the desired position.
if you put a "M4" in your MDI or Gcode it would rotate negative, until the encoder reached the desired position.

when you post a M3 the oemLED164 will turn on
when you post a M4 the oemLED165 will turn on

Scott
« Last Edit: February 17, 2009, 10:38:09 PM by poppabear »
fun times

vmax549

*
Re: Mach3 and a tube bender
« Reply #46 on: February 17, 2009, 10:41:33 PM »
(;-) YOU need to brush up on your VB.

If GetOEMLED(1200) Then   THis is a conditional statement BUT you did not specify your condition for activation

If GetOEMLED(1200) =(1)  Then    would indicate IF the led value =1 then do something
If GetOEMLED(1200) <>(0) Then   would indicate that IF the led doesnot equal 0 then do something

Just a thought, (;-) TP
Re: Mach3 and a tube bender
« Reply #47 on: February 18, 2009, 12:08:12 AM »
I think the condition is implicit to be a 1 when no argument is used.

Scott... wouldnt a Brain be simpler to implement than this?
its late now and my head is closed for business right now...

Ill give it a try tomorrow.

Regards
Fernando

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Mach3 and a tube bender
« Reply #48 on: February 18, 2009, 09:06:55 AM »
just a few things:

  it is GetUserLED(1200), the GetOEMLED range is for the OEM leds in VB.

Fernando, you can do it the way you did as well, it is another option.

if you put a User LED 1200 and a User LED 1201 on your screen for testing, then put this code in your macro pump, (check it twice to make sure it is running after you do).

'macropump.m1s

If GetUserLed(1200) Then
SetUserLed(1201, 1)
Else
SetUserLed(1201,0)
End If

the GetUserLED(1200) will evaluate to a "1" if it is on, and a "0" if it is off.
so you can open up your VB scripter window OR, put an On/Off button to control UseLED1200
in eighter case when you toggle the state of 1200, to ON, you will see 1201 turn on, and vice versa.

MacroPump:  Yes Superhonkey it is a pain in the butt, but always go back and check to see if the Cheack to enable the macropump did indeed stay checked.

Brains: Yes it could be done in Brains as well, although the logic would be more complex than he is ready for. He noted that he is new, so coding is sometimes more
human readable than "ladder logic" is. IMHO.

Scott

fun times
Re: Mach3 and a tube bender
« Reply #49 on: February 18, 2009, 09:17:45 AM »
Scott,

I finally got the ActivateSignal and DeActivateSignal commands working as a Macropump.  I have two limit switches.  I made a macropump with two if statements:

'Macropump.m1s

If GetOEMLed(833) Then
ActivateSignal(Output3)
Else
DeactivateSignal(Output3)
End If 
 
If GetOEMLED(830) Then
ActivateSignal(Output2)
Else
DeactivateSignal(Output2)
End If

If I close the switches, their respective Outputs energize.  If I have my own screen loaded, the Macropump doesn't work.  If the default 1024.set screen is loaded, the Macropump works.  Why is that happening?  I bet I could Scott's script to work if I could overcome this issue.
« Last Edit: February 18, 2009, 10:20:57 AM by supahonkey »