create a c program to run axes.

Moderators: TomKerekes, dynomotion

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Sun Sep 06, 2020 12:07 pm

Sir, can you give an example of a c program according to the G code flow that I created above?
next I will develop myself. because I don't understand the c language and its flow. because previously I only understood grbl arduino.
because yesterday I tried to make the init axis and move the axis when I clicked init, the axis managed to go up, but the DAC still has voltage, even though what I want is when the axis goes up and reaches the target, the DAC must be 0 volts.
this is the c program I created after configuring the axes:

Code: Select all

while (CheckDone (0) || CheckDone (1))
{
Move (0, 1000);
Move (1, 1000);
DAC (2, 1024);
}
each moving axis requires a voltage on the DAC,
3.4 volts to go down, and 5 volts to go up.

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Sun Sep 06, 2020 12:16 pm

TomKerekes wrote:
Sat Sep 05, 2020 6:13 pm
For simple GCode yes, but not sure why you would do this. Operators prefer GCode.
because I want to try to run without host or G code, to keep things safe. because I am worried that the machine operator does not understand G code, forgot to value x or y, so it moves only 1 axis, or maybe it is wrong in editing / filling in the G code, so the ram becomes skewed.
but someday I will teach operators to load G code and explain how it works.

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: create a c program to run axes.

Post by TomKerekes » Sun Sep 06, 2020 6:20 pm

because I want to try to run without host or G code, to keep things safe. because I am worried that the machine operator does not understand G code, forgot to value x or y, so it moves only 1 axis, or maybe it is wrong in editing / filling in the G code, so the ram becomes skewed.
but someday I will teach operators to load G code and explain how it works.
You can protect against those things.

Actually I see you have things configured wrong. A Slave can not be included into the Coordinate System. Only the Master. Instead of x and y

DefineCoordSystem(0,1,-1,-1);

You should define one axis as Z

DefineCoordSystem(-1,-1,1,-1);
Regards,

Tom Kerekes
Dynomotion, Inc.

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Sun Sep 06, 2020 8:04 pm

whether to move both, if i write G code z-100 or z100 ?
what about my previous question about changing g code to c program, can you give an example of a c program according to the g code flow that I made above? then I will develop it myself, after understanding the c program that you created.

because after this machine works normally, I want to buy a kflop and kanalog for the next work, making a cnc gas cutting machine. so later I will not bother you too much.

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: create a c program to run axes.

Post by TomKerekes » Mon Sep 07, 2020 3:53 pm

whether to move both, if i write G code z-100 or z100 ?
Yes moving the Z axis will move both the Master Axis and Slave Axis.

what about my previous question about changing g code to c program, can you give an example of a c program according to the g code flow that I made above? then I will develop it myself, after understanding the c program that you created.
In a C Program:

To Set/Clear bits use SetBit(XX); and ClearBit(XX);

To set a DAC value use DAC(Chan, Counts);

To move an axis rapidly use Move(Axis, Destination);
To move an axis at some feed rate use MoveAtVel(Axis, Destination, Vel);

To wait for an axis to finish moving use: while (!CheckDone(Axis)) ;
Regards,

Tom Kerekes
Dynomotion, Inc.

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Mon Sep 07, 2020 8:19 pm

sir, what's wrong with this G code? DAC2 does not return to 0 volts when the program has finished executing.
Attachments
DAC tetap 5 volt.png

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: create a c program to run axes.

Post by TomKerekes » Mon Sep 07, 2020 8:41 pm

Do you have a command to set it to 0 Volts? Which command is it? What does it do?
Regards,

Tom Kerekes
Dynomotion, Inc.

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Tue Sep 08, 2020 12:52 am

M3, I set it with DAC scale = 1, min = 0 and max = 0.1

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: create a c program to run axes.

Post by TomKerekes » Tue Sep 08, 2020 1:17 am

M3 will not be called to turn on the Spindle at the end of the program. Also the DAC would be associated with the S Spindle speed command not M3 to turn on the Spindle.

M5 will be called at the end of a GCode program to turn off the Spindle. You might configure it to execute a C Program to set the DAC to zero.
Regards,

Tom Kerekes
Dynomotion, Inc.

irmad
Posts: 47
Joined: Sun Jun 07, 2020 1:39 pm

Re: create a c program to run axes.

Post by irmad » Tue Sep 08, 2020 3:17 pm

what causes the DAC to oscillate on CH0 and CH1?
can i put a value of 0 on the dead band range and dead band gain?
velocity in the previous configuration, I set 700, does kmotioncnc automatically calculate when in kmotioncnc? if i want speed at g code F2100 (2100mm / min = 35mm / s).

Post Reply