Hello Guest it is March 29, 2024, 09:27:21 AM

Author Topic: How can i activate a signal until a LED turns on?  (Read 8310 times)

0 Members and 1 Guest are viewing this topic.

How can i activate a signal until a LED turns on?
« on: September 13, 2010, 12:51:16 PM »
Hey :)

my problem:
i want to activate and deactivate a Signal (Output1, power socket). It should be activated if the macro starts. And should be deactivated if the X-reference LED turns on or rather the inductive proximity switch gets activated (this switch is the X-ref).

I tried it with loops and if-clauses, but the Signal stays activated, even the X-ref LED in Mach3 turns on. Equal how long.

Here is my if-clause: (GetLED=true means, that the LED and the switch isn't activated)
Code: [Select]
ActivateSignal(OUTPUT1)

startif:

If GetLED(7)=true Then
   Sleep(50)
   GoTo startif
Else
   DeactivateSignal(OUTPUT1)
End If

I hope that you can help me. Maybe there is some code, thats works better as if-clauses to realize that what i want.
Best regards, Jan

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How can i activate a signal until a LED turns on?
« Reply #1 on: September 14, 2010, 03:57:34 AM »
Hi Jank - welcome.

Can you explain what it is you actually want the machine to do? i.e. you want to turn a signal ON to do what and you want to turn it off when WHAT happens. Don't worry about code at the moment - let's just get a clear idea of the overall picture.
Re: How can i activate a signal until a LED turns on?
« Reply #2 on: September 14, 2010, 04:31:24 AM »
Hi stirling,

i want to turn the signal (output1) on at the start. The signal is a power socket on the CNC-Control and there is a normal motor plugged in. This is working fine already.
On the machine, there is a switch, wich is declared as the X-Reference in Mach3. And the switch works fine, also. If it's activated, the LED in Mach3 turns on, and if the switch is deactivated, the LED turns off.

The scenario:
The Motor starts and moves. Anytime the switch will be activated when the chain has moved a bit. Then the motor should stop.

This is what i want, but i don't get it. I hope i explained it understandably.

I hope you can help me :)
Thanks a lot, Jan

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How can i activate a signal until a LED turns on?
« Reply #3 on: September 14, 2010, 06:30:57 AM »
Hi Jan

i want to turn the signal (output1) on at the start.
Can you explain a bit more? i.e. the start of what? - when you first start Mach3? - when you start a gcode program?, when you press an on-screen button?

On the machine, there is a switch, wich is declared as the X-Reference in Mach3.
Not sure I understand this - This LED is activated when the X axis is homed and you havn't mentioned anything about homing.

Can you describe what all this is for? That way I can see the way to do what you want

Cheers

Ian
Re: How can i activate a signal until a LED turns on?
« Reply #4 on: September 14, 2010, 08:17:18 AM »
Hi Ian,
at first, thanks for your help! :)

i want to turn the signal (output1) on at the start.
Can you explain a bit more? i.e. the start of what? - when you first start Mach3? - when you start a gcode program?, when you press an on-screen button?
For the beginning, only if the macro starts. I don't know anything about on-screen buttons yet. But if i can start a macro with an on-screen button, this can be a choice in the future when the main part works.

On the machine, there is a switch, wich is declared as the X-Reference in Mach3.
Not sure I understand this - This LED is activated when the X axis is homed and you havn't mentioned anything about homing.
Sorry, thats really confusing. The X-Reference isn't used as an real reference point. I only need it, because i don't have any other sensor to use. And the Motor at the X-axis don't need any reference, because it is moving continiously in one way (to turn the workparts on its own axis).

Can you describe what all this is for? That way I can see the way to do what you want
There is a chain with extended bolts on both sides. The chain moves in an curcuit. The motor on Output1 is to powering the chain and only have to move in one way. On the top bolts are workparts. The bolts on the bottom side of the chain are to activate/deactivate the inductive proximity switch.
The chain has to stop if the switch detects one of the bottom bolts. Then other axis work and painting the workparts. This will be an extra routine.
When this routine has finished, the motor on Output1 should start again. And stop again if the switch detects the next bolt. And again and again.

Was this description better? I hope so,
best regards, jan

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How can i activate a signal until a LED turns on?
« Reply #5 on: September 14, 2010, 10:23:22 AM »
Hi Jan - Ok I think I understand a little of what you're trying to do. You need to try using OEM triggers - I'm guessing you're trying to do this with the macropump but that is NOT the correct way to do this for various reasons.

Try the following and see if you get any closer.

1) create a macro called M90000.m1s and put in it the following line:

activateSignal(OUTPUT1)

2) Now create another macro called M90001.m1s and put in it the following line:

SetTriggerMacro(90002)

3) Now create another macro called M90002.m1s and put in it the following line:

deactivateSignal(OUTPUT1)

4) Then save all three macros in the macros folder under your profile. Probably somewhere like "C:\Mach3\macros\Mach3Mill" depending on where you installed Mach.

5) Now whatever you have set in ports and pins for your switch, you need to move those settings to OEM trigger #1 under ports and pins/input signals.

6) Now you need to open Config/General Config in Mach and roughly in the middle of the screen you'll see the "Initialization string" - it usually has something like G80 in it. You need to add M90001 so the string will now look something like "G80 M90001".

7) Finally you need to open Config/System Hot Keys and over at the top right set Trigger # 1 to OEM code 301

Now restart Mach. Then when you call M90000 in your g-code or from the MDI line the motor will start. Then when your switch is hit it will stop your motor. Run M90000 again and it will start again etc. etc.

Cheers

Ian

Re: How can i activate a signal until a LED turns on?
« Reply #6 on: September 14, 2010, 10:52:03 AM »
Hey,

i tried this. And the motor starts when i call M90000 from the MDI line. But if i hit the switch the motor doesn't stop. I've also tried to set the switch to Active Low in the Input Signals. Also i deactivate the X-Ref.

But, when i start Mach3 and hit the "START STOP" Button to activate, then a Message comes up in the information-line:
Error on line: 1 - Overflow

Do you have any idea, where the problem can be?
Thanks :)

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How can i activate a signal until a LED turns on?
« Reply #7 on: September 14, 2010, 12:11:31 PM »
what happens if you call M90000 and then M90002 from the MDI
Re: How can i activate a signal until a LED turns on?
« Reply #8 on: September 14, 2010, 12:18:08 PM »
After calling M90000 the motor starts.
Calling M90002 and the motor stops.
Re: How can i activate a signal until a LED turns on?
« Reply #9 on: September 14, 2010, 01:24:05 PM »
and if i call M90001, the same error appears "Error on line: 1 - Overflow"