Hi John,
I think you want to use a C Program not Console Commands. Below is a C Program that should measure the frequency and place the result in an Axis Dest so you can observe the result in the Axis Screen to check if it is working. You might want to wait multiple WaitTimeSlices (each is 180us) in order to improve the resolution of the frequency measurement while sacrificing update rate. I think after this is working you will want to expand it to convert the frequency to a voltage with maybe some other logic and use it as the Destination for your Z axis.
Or actually what normally works best is a "dual loop" approach. First configure a normal Z axis (either open loop stepper or closed loop) that can move Z in a normal manner. This will be the "inner" loop. This works for moves when there is no plasma voltage etc... Then at some point switch (using an MCode) to a dual loop mode. Another axis channel is configured as an Outer Servo loop with the Plasma Voltage (Frequency) as feedback and a Target Voltage. The Output of this loop will be a controlled velocity command to the inner loop.
Code:
#include "KMotionDef.h"
#define FAXIS 6
main()
{
double T0, T1, Pos,Pos0, Freq;
T0=Time_sec();
Pos0=chan[FAXIS].Position;
for (;;)
{
T1=WaitNextTimeSlice();
Pos = chan[FAXIS].Position;
Freq = (Pos - Pos0)/(T1 - T0);
T0=T1;
Pos0=Pos;
// as a diagnostic put the result into the
// Dest so it can be observed on the Axis Screen
chan[FAXIS].Dest = Freq;
}
}
HTH
Regards