1
PoKeys / Re: External LEDs to Indicate MPG1 Axis
« on: February 05, 2011, 03:47:48 PM »
Scott,
I interpreted your advice as follows:
Macropump code:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
SetUserLED(1501,MPGXLED)
Brain code
OEMLED:1501 --- No-Operation --- Output 1
Ports and Pins > Output Signals
Output #1 Enabled Port 10 Pin Number 25 Active Low
PoKeys55
Pin 25 digital output
The LED does not work.
I believe the problem is in the macropump and I have spent several hours experimenting with just the X Axis.
If I programme the macropump as:
MPGXLED = OEMLED(59) ‘MPG drives X Axis LED
Set OEMDRO(800,MPGXLED) ‘The X Axis DRO
The result is a 0 or -1 depending on whether the MPG drives X Axis LED is Off or On
This surprised me as I thought the Mach3 screen LEDs would output a binary 0 or 1.
I then wrote the following macropump test code:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
SetUserLED(1501, MPGXLED) ‘Load User LED
Var = GetUserLED(1501) ’Read User LED
SetOEMDRO(800,var) ‘The X Axis DRO
The X Axis DRO stopped showing the digital value of the LED.
I then inserted logic to change the -1 to +1 and the X Axis DRO started working
I then rewrote my macro pump code as follows:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
If MPGXLED = -1 THEN
MPGXLED = 1
End If
SetUserLED(1501,MPGXLED)
The PoKeys LED started working correctly. Eureka!
I was also able to configure the PoKeys Plug-In and map pin 25 directly as follows:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
If MPGXLED = -1 THEN
MPGXLED = 1
End If
SetUserLED(2024,MPGXLED) ‘Direct pin 25 mapping.
The Po-Keys LED continued to work and indicated correctly after I inverted pin 25 in PoKeys.
It was a simple matter to duplicate the code for MPG drives Y Axis LED and the Z Axis LED.
For someone who had not heard of the exciting world of macropumps or brains before, this forum topic has been an interesting and challenging learning experience.
Why does Mach 3 use 0 and -1 for its LED logic?
I interpreted your advice as follows:
Macropump code:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
SetUserLED(1501,MPGXLED)
Brain code
OEMLED:1501 --- No-Operation --- Output 1
Ports and Pins > Output Signals
Output #1 Enabled Port 10 Pin Number 25 Active Low
PoKeys55
Pin 25 digital output
The LED does not work.
I believe the problem is in the macropump and I have spent several hours experimenting with just the X Axis.
If I programme the macropump as:
MPGXLED = OEMLED(59) ‘MPG drives X Axis LED
Set OEMDRO(800,MPGXLED) ‘The X Axis DRO
The result is a 0 or -1 depending on whether the MPG drives X Axis LED is Off or On
This surprised me as I thought the Mach3 screen LEDs would output a binary 0 or 1.
I then wrote the following macropump test code:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
SetUserLED(1501, MPGXLED) ‘Load User LED
Var = GetUserLED(1501) ’Read User LED
SetOEMDRO(800,var) ‘The X Axis DRO
The X Axis DRO stopped showing the digital value of the LED.
I then inserted logic to change the -1 to +1 and the X Axis DRO started working
I then rewrote my macro pump code as follows:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
If MPGXLED = -1 THEN
MPGXLED = 1
End If
SetUserLED(1501,MPGXLED)
The PoKeys LED started working correctly. Eureka!
I was also able to configure the PoKeys Plug-In and map pin 25 directly as follows:
MPGXLED = GetOEMLED(59) ‘MPG drives X Axis LED
If MPGXLED = -1 THEN
MPGXLED = 1
End If
SetUserLED(2024,MPGXLED) ‘Direct pin 25 mapping.
The Po-Keys LED continued to work and indicated correctly after I inverted pin 25 in PoKeys.
It was a simple matter to duplicate the code for MPG drives Y Axis LED and the Z Axis LED.
For someone who had not heard of the exciting world of macropumps or brains before, this forum topic has been an interesting and challenging learning experience.
Why does Mach 3 use 0 and -1 for its LED logic?