Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bill_O on August 14, 2019, 04:57:12 PM

Title: Jog Speed DRO
Post by: Bill_O on August 14, 2019, 04:57:12 PM
I am having a little problem with the Lua on a couple of buttons I am making.
The script changes the value but does not change the actual speed.
If I type in the DRO the speed will actually change.

Bill
Title: Re: Jog Speed DRO
Post by: Chaoticone on August 14, 2019, 06:51:35 PM
What DRO Code is assigned to that DRO?
Title: Re: Jog Speed DRO
Post by: Bill_O on August 15, 2019, 08:15:41 AM
Jog Rate % is the DRO Code for droJogSpeed
Title: Re: Jog Speed DRO
Post by: Bill_O on August 15, 2019, 09:12:13 AM
If I put in a slider and use the same code to adjust the slider it changes the slider and the dro and works.
I really do not want the slider.

Bill
Title: Re: Jog Speed DRO
Post by: Chaoticone on August 15, 2019, 09:40:56 AM
mc.mcJogSetRate is covered in the Mach4CoreAPI help file. That is what you will need to use. I'm pretty sure changing the value of a DRO (via script) displaying current jog rate will not change jog rates, only the DRO. Your interaction with the DRO is different than clicking in the DRO and entering a value. Therefore different events will or more accurately will not get triggered.

Two things to try.

It may work if you add script including mc.mcJogSetRate in the droJogSpeed "on update" script.

In the script you are changing the DRO value........ instead of changing DRO value set the jog rate using  mc.mcJogSetRate.
Title: Re: Jog Speed DRO
Post by: Bill_O on August 15, 2019, 10:12:20 AM
mc.mcJogSetRate in the API is for single axis.
mc.mcJogSetRate(inst, axis, percentage)
How do I use it for all?
Title: Re: Jog Speed DRO
Post by: Chaoticone on August 15, 2019, 01:05:01 PM
Quote
mc.mcJogSetRate in the API is for single axis.
mc.mcJogSetRate(inst, axis, percentage)
How do I use it for all?

Simple, the same way you use a single pencil to write a lot of different things. You do it for each axis you want to set the rate for. Look at the API calls as colored pencils you are using to create a colored drawing. Some you use more than others. Some cover a lot of canvas, others are for fine details. They each do something specifically. There won't be a fine and wide for each but some do have both and others have one or the other.

One thing you might want to do though is at some point set all axes back to the same rate and it would be whatever the screen says it should be. I think the first example below is pretty much what the Jog Rate % code (function) does in the core.

Code: [Select]
local JogRate = 50

for v = 0,5 do --This will set 0-5 AKA X, Y, Z, A, B, C
mc.mcJogSetRate(inst, v, JogRate)
end

--Or

mc.mcJogSetRate(inst, 0, JogRate)
mc.mcJogSetRate(inst, 1, JogRate)
mc.mcJogSetRate(inst, 2, JogRate)

--Or if you don't want to set them by using a single variable set them independently......... even to different values if you want.

mc.mcJogSetRate(inst, 0, 50)
mc.mcJogSetRate(inst, 1, 25)
mc.mcJogSetRate(inst, 2, 100)


Title: Re: Jog Speed DRO
Post by: Bill_O on August 19, 2019, 08:36:53 AM
OK.
I figured I could do that but was hoping I would not need to.

Thanks,
Bill