Hello Guest it is April 16, 2024, 02:11:10 PM

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

0 Members and 1 Guest are viewing this topic.

How to use USB camera with Mach4
« on: October 05, 2021, 05:28:13 AM »

I want to align the origin using a USB camera.
Therefore, I embedded the script below in the button (Orijin).
How are you doing?
Please tell me how.
-------------------------------------------------- -------------
--Camera Origin. Add2021.10.3
-------------------------------------------------- -------------
local inst = mc.mcGetInstance ()

mc.mcCntlGcodeExecute (inst, "G91 G0 Z0.0 \ n G0 Y1.7 \ n G0 X7 2.0")

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #1 on: October 06, 2021, 07:42:29 AM »
Did it work?
I am not sure what you are asking.
Do you want to know how to do it?
Are you asking if that is the correct code?
Re: How to use USB camera with Mach4
« Reply #2 on: October 06, 2021, 08:20:57 AM »
Hello.
My idea is that the axis of the camera and the axis of the main axis are off, so I command the distance to move.
I have to install the camera vertically on the table and it's working fine.
However, I wanted to know your thoughts because my thoughts may be wrong.

This is the YouTube that I referred to.
https://www.youtube.com/watch?v=ZgWkOa7EgDA

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #3 on: October 06, 2021, 08:58:45 AM »
Use the head shift feature

You will need to write some code.
This is for the Y axis;
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, TKOSftYVal)
TKOSftYVal is just a variable.
Re: How to use USB camera with Mach4
« Reply #4 on: October 06, 2021, 05:03:35 PM »
When I pasted the program on the button, an error occurred.
What should I do?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #5 on: October 06, 2021, 05:14:45 PM »
you might need to put "10" or '10'
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, "10")
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, '10')

or just change this mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, 10)
to this
YShift = 10
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, YShift)
Re: How to use USB camera with Mach4
« Reply #6 on: October 06, 2021, 05:38:02 PM »
I changed the program, but I get an error.
I was in trouble.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #7 on: October 06, 2021, 05:49:04 PM »
I do not think the error is from the button.
It looks like it is saying the problem is at line 239.
The script you posted does not have 239 lines.
I do not know what the problem is.
Re: How to use USB camera with Mach4
« Reply #8 on: October 06, 2021, 05:57:29 PM »
Where is line 239?

Offline jbuehn

*
  •  101 101
    • View Profile
Re: How to use USB camera with Mach4
« Reply #9 on: October 06, 2021, 07:36:08 PM »
In line 6, do you have commas separating each of the parameters in the mc.mcCntlSetPoundVar() call? I can't really tell from the pic.