mjstone wrote:I have a somewhat unconventional use for an XYZ gantry machine. I am not milling, but attaching a camera to the tool holder; the idea is to have the machine follow flatworms around for use in research.
Interesting
Anyway: I am not sure that it makes any sense at all to use LinuxCNC in this situation. You might be better using Matlab and external step-generation hardware (perhaps a SmoothStepper).
However, given that what you have almost works:
I think you should move the motion control into Matlab and use only the parts of LinuxCNC which are useful to you. I am fairly sure that flatworms are not well-known for their speed.
You could do what you want mainly in HAL, not loading the LinuxCNC GUI and the G-code interpreter. (And quite possibly not the motion controller either).
Assuming that the control loop is velocity-mode based on image data, then you could use velocity-mode stepgens and set the velocity directly from Matlab.
put the following in a file called test.hal
loadrt threads name1=base-thread period1=50000 name2=servo-thread period2=1000000
loadrt stepgen control_type=v,v,p #velocity control X and Y, position Z.
loadrt hal_parport cfg="0"
addf stepgen.0.make-pulses base-thread
addf parport.0.write base-thread
addf stepgen.0.capture-position servo-thread
addf stepgen.0.update-freq servo-thread
net xstep stepgen.0.step parport.0.pin-01-out # Edit to suit..
net xdir stepgen.0.step parport.0.pin-02-out
net ystep stepgen.0.step parport.0.pin-03-out
net ydir stepgen.0.step parport.0.pin-04-out
net zstep stepgen.0.step parport.0.pin-05-out
net zstep stepgen.0.step parport.0.pin-06-out
setp stepgen.0.maxvel XXXX #set to suit the machine limits
setp stepgen.0.maxaccel YYYY # ditto
setp stepgen.0.scale 200 #to suit machine
start
You can then halrun -I -f test.hal
That will load up the realtime system and HAL, and interpret the above HAL file, but won't load any of the more visible parts of LinuxCNC.
In a separate terminal windo you should now be able to type
halcmd setp stepgen.0.velocity-cmd 0.1
And see the X-stepper move at a constant rate of 0.1 units/second. It will carry on moving until you set the velocity to zero.
You can set the Y velocity independently.
For a gantry controlled like this I think you would need to net both sets of of parport pins to the same stepgen.
It is rather useful that stepgen enforces velocity and accel limits internally, or this would not work.
halcmd getp stepgen.0.position-fb can be used to check the current position.
How you communicate with Matlab depends on what suits best. You could simply use halcmd as shown in place of your emcrsh. Or you could write a simple HAL component to interpret serial data or similar.