Hello Guest it is March 28, 2024, 08:32:44 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - marekesz

Pages: 1
1
VB and the development of wizards / Input/Output control as it should be
« on: November 17, 2018, 10:34:02 PM »
Hi guys,
For more automated solutions (like a control of the material feeders for lathes or for the collaborating robot control) I need the better control over I/O ports.
Since there's a solution ready in LinuxCNC (M64, M65, M66 commands) I'm trying to recreate them in Mach3 (I don't use Linux for now giving a chance to MAch3).

Can some brainyac check - pretty please - on my code for the M66 macro? It's not working and giving an error on the "Case 3" for no reason...

The code is as follows:

>

Option Explicit

Dim Signal_nr As Integer   'gets signal nr from the P-word
Dim Trigger As Integer  'gets the trigger event variant from the Q-word
Dim Input_nr As String 'to combine SIGNAL string with its number from the P-word for the IsActive command


Signal_nr = Param1() 'Get P-value
Input_nr="INPUT" & Signal_nr 'this one should create a string "SIGNAL#" with the # number from P-word to use as parameter for commands
Select Case Trigger
  
   Case 0 'IMMEDIATE - triggered immediately on the given signal HIGH detection.
      SystemWaitFor(Input_nr)
   
   Case 1 'RISING EDGE - triggered immediately on the given signal RISING EDGE
      While IsActive(Input_nr)
      Wend
      SystemWaitFor(Input_nr)
  
   Case 2 'FALLING EDGE - triggered immediately on the given signal FALLING EDGE
      While IsActive(Input_nr)
   
   Case 3 'HIGH - triggered on the detection of the HIGH state of the signal as opt. 0 but waits for the previous move to finish
      SystemWaitFor(Input_nr)
      While IsMoving()
      Wend
   
   Case 4 'LOW - triggered on the detection of the LOW state of the signal as opt. 1 but waits for the previous move to finish
      While IsActive(Input_nr)
      Wend
      While Ismoving()
      Wend
   
End Select
 
<

Thanks in advance

Pages: 1