Hello Guest it is March 28, 2024, 08:52:14 PM

Author Topic: Change background color of DRO when not in position  (Read 3172 times)

0 Members and 1 Guest are viewing this topic.

Change background color of DRO when not in position
« on: March 13, 2019, 05:52:14 PM »
I am creating a motion control system based on a mach3 shell. BUT I would really like a feature that I cannot figure out.
I am not very experienced on KlausĀ“s Mach screendesigner, but I have made some custom screensets before (for other motion control applications)
I am using a custom DRO input field to move a servo into the position entered in the DRO field. 

The way I solved this is by using a user defined OEM code for the DRO, and after entering the value I run a script on a button that looks like this:

Xtcp= GetUserDro (1200)
Ytcp= GetUserDro (1201)
Ztcp= GetUserDro (1202)
Feed= GetDRO(18)



Code"G0"                 
Code"G53 Z"&Ztcp
While IsMoving
Wend
Code"G53 Y"&Ytcp
While IsMoving
Wend
Code"G53 x"&Xtcp
While IsMoving
Wend

Setdro(18,Feed)

Now back to my problem: I do not want to mess up the screenset with a DRO showing actual position.
So after entering the value I would like the background of the input DRO to be red as long as the target value and set value are not equal.
Optionally, custom OEM LED show that the machine is moving, and then switching to green when in position.

Is there anyone out there that could help me along with this, or tell me if I am asking to much of the software?

Best regards
Roy
Re: Change background color of DRO when not in position
« Reply #1 on: March 14, 2019, 04:14:16 AM »
Hi Roy

Mach uses one color for all DRO's. You can put a LED in your script to solve your problem. Use MachScreen and
place a LED on your screen.
Set the OEM-code to 1000 or higher, make sure the LED number isn't used already
add a red/green LED
set the "Red/greenLED""  to "YES"
additions in your script
at the beginning
SetUserLED(1000, 1)
at the end
SetUserLED(1000,0)

Klaus
The brain isn't a soap, it doesn't shrink when used.
Re: Change background color of DRO when not in position
« Reply #2 on: March 14, 2019, 10:49:43 AM »
Thank you Klaus for the information Klaus
I tried it and it worked.
So when I input a new value the LED is RED until script is executed. then turns green.

What would make the script perfect would be to have the status of the LED set by comparing the USER DRO value with the axis vDRO value
SO if I input a value in the user DRO the LED turn red until the script is executed and the axis has traveled to the input value, Then turn green.
So some kind of Visual basic command comparing these value saying something like this:

If X DRO value is >< than USER DRO
then SetUserLED(1000, 1)
else SetUserLED(1000, 0)

Or simply just:

If X DRO value is = USER DRO
then SetUserLED(1000, 1)

Sorry, I do not know VB script commands, but I think you understand, as you have made the software:):)

Best reg
Roy
Re: Change background color of DRO when not in position
« Reply #3 on: March 14, 2019, 03:00:31 PM »
Hi Roy

here is a example for setting the LED depending on the compare result

If (GetDRO(0) <> GetUserDRO(1000)) Then     ' 1000 is  user DRO number
   SetUserLED(1000,1)
Else
   SetUserLED(1000,0)
end if

Klaus
« Last Edit: March 14, 2019, 05:28:15 PM by Klaus1311 »
The brain isn't a soap, it doesn't shrink when used.
Re: Change background color of DRO when not in position
« Reply #4 on: March 14, 2019, 05:49:05 PM »
Thanks for the info Klaus.
Is there a script that is continuously running in mach 3, that this could be put in?
I want to loop the script to continuously monitor if there is a difference between these values, and then set the state of the LED

Best reg
Roy
Re: Change background color of DRO when not in position
« Reply #5 on: March 15, 2019, 07:11:28 AM »
You could use the macropump.
To use it, it has to be enabled in the   Config -> General config   by checking the "Run Macro Pump" checkbox.
Your script has to be placed in a file named "macropump.m1s".
This file has to reside in your current profile. Mach3 runs this file approximately 40 times in a second.

Klaus
The brain isn't a soap, it doesn't shrink when used.
Re: Change background color of DRO when not in position
« Reply #6 on: March 15, 2019, 10:20:20 AM »
Thank you VERY much Klaus

That really saved my day.
Just what I was looking for, and it worked perfectly.
I wish you a good weekend.

I might have couple of questions down the road as my application build progresses

best regards
Roy