Hello Guest it is March 28, 2024, 08:32:27 PM

Author Topic: How to use USB camera with Mach4  (Read 3503 times)

0 Members and 1 Guest are viewing this topic.

Re: How to use USB camera with Mach4
« Reply #20 on: October 14, 2021, 05:49:45 AM »
Please tell me the meaning of this function.

mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, YShift)

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #21 on: October 14, 2021, 08:47:16 AM »
 "mcInEditor"
that section lets you run the code while in editor
it is for macros

 "mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, YShift)"
this one thing added in Mach4
it lets you use multiple heads
it shifts the home position
Re: How to use USB camera with Mach4
« Reply #22 on: October 14, 2021, 06:16:54 PM »
question 1
The meaning of mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, YShift) is shown in the picture. Is this way of thinking all right?

I'm using Mach4 Hobby.

Question 2
Is it okay if the script without using the button is as follows?
function YShift ()

YShift = 10
mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, Y Shift)

if (mc.mcInEditor () == 1) then
YShift ()
end

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #23 on: October 15, 2021, 09:13:44 AM »
1)  Yes. It moves where the machine thinks the axis is positioned. It does not actually move it just changes where it thinks it is located.

2)  The code looks correct. I would not use a variable named the same as the macro. Then the button just calls the macro.
Re: How to use USB camera with Mach4
« Reply #24 on: October 15, 2021, 10:39:57 AM »
I don't know what to do in the future.
Would you like to paste this script into a button?

"The last 3 lines let you run or step through the macro while in the editor."
What is an editor?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #25 on: October 15, 2021, 11:24:19 AM »
To make and edit a macro go to Operator then Edit/Debug Macro Scrips
That is the editor.
That is where you will make and save your YShift macro.
I suggest you not use a name for your macro use a number like m111

To make and add a button go to Operator then Edit Screen.
Add your button and program it to do what you want.
Your button will just run that macro.
The code on your button will be like this;
inst = mc.mcGetInstance()
mc.mcCntlGcodeExecute(inst, "m111")
Re: How to use USB camera with Mach4
« Reply #26 on: October 15, 2021, 08:15:37 PM »
I ran as follows, but an error occurred.
I don't know the cause.

function m111 ()
YShift = 10
mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, YShift)
if (mc.mcInEditor () == 1) then
m111 ()
end

Button script
local inst = mc.mcGetInstance ()
mc.mcCntlGcodeExecute (inst, "m111")

Is mcCntlGcodeExecute bad?

How to execute with macro button mach4
Re: How to use USB camera with Mach4
« Reply #27 on: October 16, 2021, 10:00:50 PM »
Hello.
There was a full-width "(" in the code to write to the button.
This was the cause of the error. Fixed to half-width "(".

Now you can press the button.
However, the Y axis doesn't move at all. Is this normal?
The photo is the proof.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #28 on: October 18, 2021, 08:47:45 AM »
It will not move.
It is just supposed to put a value in the head shift so the machine knows how much to compensate.
I did not see a value in the head shift.
Exactly what code did you put in and where?
Re: How to use USB camera with Mach4
« Reply #29 on: October 18, 2021, 09:01:05 AM »
Hello.
The left side of the photo is in the macro script.
I put the right side of the photo in the Orijin button.