Hello Guest it is April 20, 2024, 01:37:04 AM

Author Topic: Macropump code trouble  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.

Macropump code trouble
« on: June 07, 2015, 02:55:36 AM »
Hi,
Having trouble getting a macropump to run

It seems like there is somethng wrong with the code/syntax in the if/then statements. With this removed, the pump runs and I can see the Macro calls counting in the message bar.

Code: [Select]
i=i+1
 
 message" Macro Running #"&i
 
 a=GetUserLed(2000)   
 
 If a = 0 Then
   i=0
   DoOemButton (1024)
   While IsMoving()
   Wend
   DoOemButton (1023)
   While IsMoving()
   Wend
   DoOemButton (1022)
   While IsMoving()
   
   DoOemButton (1026)
   While IsMoving()
   Wend
   
   DoOEMButton(133)
   DoOEMButton(134)
   DoOEMButton(135)

End If 
   

What am i doing wrong?

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Macropump code trouble
« Reply #1 on: June 07, 2015, 03:42:06 PM »
You seem to be missing a Wend see below

DoOemButton (1022)
   While IsMoving()
    Wend

Hood

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macropump code trouble
« Reply #2 on: June 07, 2015, 09:45:31 PM »
I am not sure WHAT you are doing but code like that will bring the macropump down to a crawl and be VERY unpredictable.

(;-) TP
Re: Macropump code trouble
« Reply #3 on: June 08, 2015, 12:36:13 AM »
Thanks Hood. Sometimes you can stare at a piece of code and not see a simple error!

It's a script to home my axis which is called from a brain. The script is much cleaner than that now, the counts and other variable sets were just a test to confirm the script was running as if there is an error in the code the whole script gets ignored. I wanted to do the whole thing as a brain so I could have a timer set so that the button needs to be held for 2 seconds. Using the refall in a brain does not home my dual screw axis as I like, so to align it for square I had to go with the brain / macro pump way.
Why do you think it will be slow and unpredictable? If the condition at the beginning is not met, it just exits and runs again when it's called. If I've asked for a refall (led 2000 is active), there is nothing else going on with the machine, and nothing else in the pump that needs to be done, so it's ok if the pump timer pauses whilst the code runs.

If there is abetted way to do this please tell me.
It's working pretty good now.