C program to run G codes

Moderators: TomKerekes, dynomotion

Post Reply
baburdy
Posts: 10
Joined: Sun May 20, 2018 3:35 pm

C program to run G codes

Post by baburdy » Wed Oct 24, 2018 8:55 am

Hi!
Is it possible to FLASH a G code program into KFLOP?
If it is not so, How can I run KmotionCNC program using C program?

I want to flash a Gcode program into the device. It is easier for me to run my application. Kindly suggest me a way to do that.

I think it is possible to run a G code program using C program.
Kindly guide me or send me a sample C program to "Run a G code program using a C program".


With regards,

Mani

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

Re: C program to run G codes

Post by TomKerekes » Wed Oct 24, 2018 3:10 pm

Hi Mani,

Does your system have a PC? If so it would be easier and better to run the GCode from a PC Application.

Without a PC, KFLOP only has ~1 MByte of Flash Data storage.
Regards,

Tom Kerekes
Dynomotion, Inc.

baburdy
Posts: 10
Joined: Sun May 20, 2018 3:35 pm

Re: C program to run G codes

Post by baburdy » Thu Oct 25, 2018 4:05 am

Hi Tom,

We are using Kflop + Kstep device. Now we are running the application using KmotionCNC software without flashing the data. It is easy for us to run the application using the G-codes. But G codes cannot be flashed into the device directly. i.e. We are running the application by connecting the device with PC.

So, kindly suggest us a way to flash G codes.

If it is not possible, send us any sample C program to run the G codes.


With regards,

Mani.

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

Re: C program to run G codes

Post by TomKerekes » Thu Oct 25, 2018 3:24 pm

Hi Mani,

I still don't understand.

If you have a PC in your system there is no reason to Flash GCode. Just save it on the PC and run it using our PC Libraries.

You might see the SimpleGCode C++ example or the KMotion_dotNet Console RunInterpreterExample() C# example.

See here for information on PC samples.
Regards,

Tom Kerekes
Dynomotion, Inc.

baburdy
Posts: 10
Joined: Sun May 20, 2018 3:35 pm

Re: C program to run G codes

Post by baburdy » Fri Oct 26, 2018 4:17 am

Hi Tom,
My question is, Now we are using the device with the help of PC without flashing the G codes we are running our application,
but we want to run the application without the help of PC.
For that I need to flash my G-codes into the device.
Kindly suggest me an idea to flash G codes.



Regards,
Mani.

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

Re: C program to run G codes

Post by TomKerekes » Fri Oct 26, 2018 4:56 pm

Hi Mani,

Ok so you don't want to use a PC.

KFLOP itself doesn't have a GCode Interpreter or Coordinated Motion Trajectory Planner. So Flashing GCode to KFLOP wouldn't work.

Maybe you could describe more clearly exactly what you need to do. Is it simple and small amount of GCode? Does it ever change?

Some users have created stand-alone systems that run fixed, simple, motion patterns using the technique described below. One of the first Users to do this created a stand-alone machine to write "Happy Birthday" on a cake with icing.

#1 - Connect a PC
#2 - Run a small GCode Job. This downloads "coordinated motion" to KFLOP's Coordinated Motion Buffer. This is basically a big list of equations.
#3 - Write the Coordinated Motion Buffer data to USER_FLASH memory
#4 - Disconnect the PC
#5 - Cycle Power
#6 - Copy the data from Flash back into the Coordinated Motion Buffer
#7 - Execute the motion


Here is a Yahoo Thread where a User created code to save multiple motion jobs to Flash memory and was able to selectively run them.

Does this seem like something you could do?
Regards,

Tom Kerekes
Dynomotion, Inc.

baburdy
Posts: 10
Joined: Sun May 20, 2018 3:35 pm

Re: C program to run G codes

Post by baburdy » Mon Oct 29, 2018 4:53 am

Hi Tom,

Regarding your previous reply, Can you elaborate the steps #3 , #5, #6.

Can you provide any sample Coordinated Motion Buffer program which could be flashed to USER_FLASH memory.





Regards,

Mani.

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

Re: C program to run G codes

Post by TomKerekes » Mon Oct 29, 2018 3:53 pm

Hi Mani,

Did you read through the Thread I linked to?

Cycle Power means to turn power off and back on.

The Motion Program would be something you create (any simple GCode Program)
Regards,

Tom Kerekes
Dynomotion, Inc.

baburdy
Posts: 10
Joined: Sun May 20, 2018 3:35 pm

Re: C program to run G codes

Post by baburdy » Tue Oct 30, 2018 7:31 am

Hi Tom,

I followed your instruction, I ran my G code program which i had attached with this message.
After running the G code program, i want to flash that same G code program into the device.
So i used the below code

#define FLASH ((volatile char *)0x90000000) // beginning of FLASH - first 1MByte is for System Use

#define FLASH_USER ((volatile char *)0x90100000) // 2nd MegByte is for User use

I does'nt work.

My Question is, G code is already in running status, How can i run the COORDINATED MOTION BUFFER PROGRAM?
What should that COORDINATED MOTION BUFFER program have?
Because i am running the COORDINATED MOTION operation already with the G code itself?. Kindly explain..(i.e. Step #3)

Kindly send me a sample COORDINATED PROGRAM for my reference. It is easy for my to understand and execute.

I have read the Thread which you have sent. By i cant able to download or view the attachment with that thread.
Kindly send me any sample program to FLASH G codes.

Regards,
Mani
Attachments
G code for my project.txt
(4.02 KiB) Downloaded 83 times

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

Re: C program to run G codes

Post by TomKerekes » Wed Oct 31, 2018 4:46 am

Hi Mani,
So i used the below code

#define FLASH ((volatile char *)0x90000000) // beginning of FLASH - first 1MByte is for System Use

#define FLASH_USER ((volatile char *)0x90100000) // 2nd MegByte is for User use

I does'nt work.
Those are just defines for the compiler. It doesn't generate any code. You will need to study C Programming to be able to do this.

I plotted your GCode:

ManiGCode.png
ManiGCode.png (8.3 KiB) Viewed 3025 times
How much Coordinated Motion Buffer that is used will depend on the Trajectory Planner Smoothing and corner rounding. I ran the code with these typical settings:

ManiTP.png
ManiTP.png (4.87 KiB) Viewed 3025 times
The GCode took 42 seconds to execute and generated 4068 Coordinated Motion Segments and used 878KBytes of memory. Just under the 1MByte of Flash space available.

Attached is a MonitorParametricIndex.c program that will display on the Console how much Coordinated Motion Data has been downloaded as the GCode is running. When the GCode finishes it showed:

ParametricIndex=4068 (878688 bytes) 83.80 % TimeDownloaded=42.441sec

The attached example program called FlashCoordMotionWriteData.c will write the data to Flash.

The attached example program called FlashCoordMotionReadData.c will read the data from Flash and execute it.

Let me know how much of this you can understand.
Attachments
MonitorParametricIndex.c
(514 Bytes) Downloaded 77 times
FlashCoordMotionWriteData.c
(1.12 KiB) Downloaded 84 times
FlashCoordMotionReadData.c
(1.21 KiB) Downloaded 75 times
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply