Hello Guest it is March 28, 2024, 06:04:04 AM

Author Topic: Macro Syntax Error  (Read 3793 times)

0 Members and 1 Guest are viewing this topic.

Offline rufan

*
  •  38 38
    • View Profile
Macro Syntax Error
« on: June 07, 2013, 11:45:38 AM »
I have add the following command to my macro, but then get a Syntax Error on the "Then"
For me everything looks normal, don't understand why.
Do someone have any idea.

While IsActive(OEMTRIG1) = False Then
   DoSpinStop()
Wend

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macro Syntax Error
« Reply #1 on: June 07, 2013, 01:33:17 PM »
Well hello rufan - welcome to the forum.

There is so much wrong in that little snippet of code.

1) While syntax does not include the "then" keyword. "then" is part of the "if" statement.
2) Do not compare to false (or true) - it's bad form - in this case, use "not" instead.
3) even with these corrections, your loop will make constant calls to doSpinStop() whilst OEMTRIG1 is false. This is a BAD thing to do and will end in tears.

Perhaps you can describe what you'd like to achieve.

Offline rufan

*
  •  38 38
    • View Profile
Re: Macro Syntax Error
« Reply #2 on: June 07, 2013, 01:47:44 PM »
I am not a programmer, I learn by trail and error and of course from you guys
I have copied this command from the Macro Programmers Reference Manual and modify it.

Page 79:
While IsActive(OEMTRIG10) = False Then
Sleep 10
Wend

What I want to achieve is:
I need to get the spindle aligned.
A spindle friction brake is active, then the spindle turns very slow until OEMTRIG1 and Index Pulse is active then the spindle needs to stop.
It's a DC motor running for this procedure at 100RPM

Thank you.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macro Syntax Error
« Reply #3 on: June 08, 2013, 03:04:24 AM »
I think we'll just have to assume the author of that manual had some sort of brain fart - because that code on page 79 is complete bollocks  ;D

It's not entirely clear what you have connected to what - i.e. what is OEMTRIG1 connected to and what does it signify has occurred when it goes active? Also what signal is "Index Pulse" connected to?

anyway - whatever - waiting for OEMTRIG1 and "Index pulse" to both be active before you then stop the spindle will look something like this...

while not (isActive(OEMTRIG1) and isActive(whatever signal you have "Index pulse" connected to))
  sleep 10
wend
DoSpinStop()

Offline rufan

*
  •  38 38
    • View Profile
Re: Macro Syntax Error
« Reply #4 on: June 08, 2013, 07:17:09 AM »
Let me explain

I have a Dual  Slotted Opto Switch with a space of +/- 5mm from each other.
A disk with a 6mm gap is installed on the spindle axis.
1 output connected to Spindle Index
2 output connected to OEM Trig #1

The spindle will turn at slow speed(100) when the gap in the disk line up with the opto switches the spindle must stop turning.
A friction brake is already triggered, so when spindle stops turning it will stop immediately.
Then I can move onto the next process of changing tools.

SetSpinSpeed(100)
ActivateSignal(OUTPUT9)      'Active Friction Brake
DoSpinCW()            'Turn spindle at 100rpm

While (isActive(OEMTRIG1) And isActive(OEMLED826))
  sleep 10
Wend
DoSpinStop()            'Stop spindle
deActivateSignal(OUTPUT9)           'Deactivate Friction Brake

I will try this later

Thank for helping.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Macro Syntax Error
« Reply #5 on: June 08, 2013, 11:15:03 AM »
OK - not sure I can see from your description why you need TWO signals but whatever.

BTW you don't read a LED's status with the isActive function - that will fail, You'd use getOEMLED. However, personally I wouldn't read the LED at all when you can read the signal directly. i.e. isActive(INDEX)