Hello,
Sorry for possible doubling the post of other user, but I need to clear things a little.
I bought a simple touch plate from Aliexpress for my 3 Axis router with Kflop control.
After reading some information about using DoPCFloat(PC_COMM_SET_X,0.0) I have more questions than answers.
The touch probe is connected via optocoupler board to Pin 6 of JP7. I need a C program that will work as follows:
1. I connect the sensor to an instrument
2. Press the button
3. Z axis starts moving down
4. When instruments touches the sensor it sets G54 Z work offset as 20mm (sensor's height)
5. Z axis moves up for 5-10mm
Most of hobby machines' users don't need a hassle with Tool Lenght Tables etc., just a simple routine like this. Thanks for an upcoming answer.
regards, Alex
Simple C Program to Z Work Offset
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Simple C Program to Z Work Offset
Hi Alex,
You might look at tthe ProbeZ.c example on how to move Z and stop when the probe triggers:
The SetFixtureZ.c example shows how to set the current Fixture Offset based on current Position which doesn't involve any Tool Offsets or Tables. You can include some probe offset if you wish.
HTH
You might look at tthe ProbeZ.c example on how to move Z and stop when the probe triggers:
Code: Select all
#include "KMotionDef.h"
main()
{
Jog(2,-100); // move Z down slowly
while (!ReadBit(1040)) ; // wait for switch to go high
Jog(2,0); // Stop
}
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define Zaxis 2
main()
{
int FixtureIndex;
double NewOriginOffset,OriginOffsetZ;
double DROx, DROy, DROz, DROa, DROb, DROc;
GetFixtureIndex(&FixtureIndex);
GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
// Adjust Origin Offset to make DRO zero
NewOriginOffset = OriginOffsetZ + DROz;
SetUserDataDouble(TMP,NewOriginOffset);
SetVars(5201+FixtureIndex*20+Zaxis, 1, TMP);
DoPC(PC_COMM_UPDATE_FIXTURE);
}
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Simple C Program to Z Work Offset
Hello, Tom
Thank you for your answer. I've attached resulting program, but can't figure out how to include probe offset (20mm) in it.
regards, Alex
Thank you for your answer. I've attached resulting program, but can't figure out how to include probe offset (20mm) in it.
regards, Alex
- Attachments
-
- Z Probe.c
- (849 Bytes) Downloaded 131 times
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Simple C Program to Z Work Offset
Hi Alex,
Subtract 20.0 from NewOriginOffset.
Note a call to Jog requires only 2 parameters and needs a semicolon.
A MoveRelAtVel (axis, distance, velocity); would probably be more appropriate.
Subtract 20.0 from NewOriginOffset.
Note a call to Jog requires only 2 parameters and needs a semicolon.
A MoveRelAtVel (axis, distance, velocity); would probably be more appropriate.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.