I finally have Mach 3 reading both my encoder and a limit switch. It turned out the inpout32.dll file was conflicting with Mach. I hooked up another hard drive, installed XP and installed Mach. I simply told Mach 3 the correct pins for my encoder and limit switch. Every thing worked very well. Mach is an awesome program. They will get my money next week when I order it. The "trial version" does everything I need, but those guys deserve the money. Its only $140 for the software.
Mach3 is reading my encoder weird. I have a 360PPR encoder. I configured the encoder in Mach3 as 360/ppr. Unfortunately it isn't reading that way. I will figure out the problem tomorrow.
I start the actual coding tomorrow. Here is the basic logic:
DesiredAnglePos = GetUserDRO(2000) 'angle entry dro on your screen
CurrentAngPos= GetOEMDRO(29) 'encoder1 DRO from your die
if GetOEMLED(164) or GetOEMLED(165) then 'if the CW or CCW led is on
if GetOEMLED(164) then 'if the spindle CW led is on.
if CurrentAngPos <= DesiredAnglePos then
ActivateSignal(OUTPUT2) 'coil A cw
else
DeActivateSignal(OUTPUT2)
end if
end if
if GetOEMLED(165) then 'if the spindle CCW led is on.
if CurrentAngPos >= DesiredAnglePos then
ActivateSignal(OUTPUT3) 'coil B ccw
else
DeActivateSignal(OUTPUT3)
end if
end if
end if
The above code should, in theory, work. I haven't tried it, nor do I have any experience using VB in Mach. The above code seems pretty basic. From Mach's view, my machine is extremely simple to control. I really only have one axis to worry about. Other than that, I am just using logic to turn on or off coils in a valve.
I now have another project to start once this one is complete. I want to make a plasma tube profile cutter. I am going to control a 3 jaw chuck with a gear box and a stepper motor. I am going to run the torch along an axis perpendicular to the chuck. Once again, the machine will be easy to make; the programming will be the hard part.