Hello Guest it is April 23, 2024, 03:16:50 AM

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

0 Members and 1 Guest are viewing this topic.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #30 on: October 18, 2021, 10:08:11 AM »
Go to the Parameters.ini in your profile.
Look for [5081] and [5082]
Those are the head shift parameters for x and y

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #31 on: October 18, 2021, 10:50:55 AM »
Never mind.
Mine does not have them either and it works.
Are you actually hooked up to a machine?
Some things will not function in demo mode.
Re: How to use USB camera with Mach4
« Reply #32 on: October 18, 2021, 01:45:13 PM »
Multiple things are wrong with your macro
 1. You don't declare 'inst' so this will likely be nil and cause the API to fail - you should check the return code to test for this
 2. You are missing 'end' from the function
 3. I would declare YShift as a local variable

If you hit F7 on your keyboard in ZeroBraneEditor it will compile the code and tell you if there are any mistakes... but won't tell you all the mistakes  ;)

Try the following
Code: [Select]
function m111 ()
local inst = mc.mcGetInstance()
local YShift = 10
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, YShift)
end

if (mc.mcInEditor () == 1) then
m111 ()
end
« Last Edit: October 18, 2021, 01:47:48 PM by SwiftyJ »

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #33 on: October 18, 2021, 01:56:30 PM »
Thanks Swifty
Re: How to use USB camera with Mach4
« Reply #34 on: October 18, 2021, 05:14:52 PM »
Mach4 worked.

Current Position
From 0 to -10

Head Shift
From 0 to +10

Is this result normal?
The motor didn't work, only the numbers seemed to change.

* What should I do with the X-axis code?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to use USB camera with Mach4
« Reply #35 on: October 18, 2021, 05:50:28 PM »
It does not make the motor move.
It just changes where the machine thinks it is.
You do the same thing for the x axis just use the x shift.
If you want it to move you need to tell it to move.
Re: How to use USB camera with Mach4
« Reply #36 on: October 18, 2021, 07:29:30 PM »
Should the code be as follows?

function m111 ()
local inst = mc.mcGetInstance ()
local YShift = 10
mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_Y, YShift)
--X axis
local inst = mc.mcGetInstance ()
local XShift = 10
mc.mcCntlSetPoundVar (inst, mc.SV_HEAD_SHIFT_X, XShift)



end
.
if (mc.mcInEditor () == 1) then
m111 ()
end
Re: How to use USB camera with Mach4
« Reply #37 on: October 19, 2021, 10:54:00 PM »
Mr. Bill_O. Hello.

I understand that this program is a program that changes the "Current Position" to the value after movement even though the head is not moving.
Thank you.
« Last Edit: October 19, 2021, 10:57:19 PM by Toshio.K »