CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How can I translate g codes to ccs code ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fatihsen



Joined: 12 Dec 2021
Posts: 1

View user's profile Send private message

How can I translate g codes to ccs code ?
PostPosted: Sun Dec 12, 2021 8:07 am     Reply with quote

I am new to ccs programming. I need to drive 2 stepper motors according to the given g code text file for a project. But I couldn't figure out how to do it. My first problem was I couldn't figure out how to translate g codes into ccs. What code structures will I need to use? And how do I transfer the given codes to the relevant engine? My biggest problem is interpreting g codes. Can you help?
PrinceNai



Joined: 31 Oct 2016
Posts: 452
Location: Montenegro

View user's profile Send private message

PostPosted: Sun Dec 12, 2021 9:47 am     Reply with quote

Maybe this will be of some help. At least to see how somebody did it:

https://repository.najah.edu/bitstream/handle/20.500.11888/12151/hwreport.pdf?sequence=1&isAllowed=y

Samo
temtronic



Joined: 01 Jul 2010
Posts: 9100
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 12, 2021 4:02 pm     Reply with quote

Been decades since I used it but...
Generally speaking...
G code is a simple string of ASCII formatted commands.
Each line is one command.
So 1st you'll need to receive a command. After that, you'll have to 'parse' (decode' what that command is, then have the PIC execute the appropriate function).

Now the code issues are that you have to write 'functions' for the 2 motors, I assume 'x' and 'y' and that they are mechanically connected to do 'something' ?
You'll have to figure out that for the 'x' motor to turn, say 90 degrees, that the function 'turn_x_motor' will need to send the correct number and sequence of bits to the motor driver chip.

You need to tell us what hardware (PIC, stepper drivers and motors). In choosing a PIC, I suggest one with at least 1 hardware UART and lots of memory.

As for software, begin with creating the stepper driver code (CCS supplies a basic version). Test it to be sure it works, using fixed values, say turn motor 90* (degrees), 180*, 270*, 360*. Also be sure it can go in reverse.
Once that works, then make the serial receive function. This normally will be an ISR. Again CCS does have example code.
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 2:09 am     Reply with quote

and remember the stepper driver is going to have to handle acceleration
and deceleration of the motor, as well as things like maintaining some
current through the motors when stopped for braking.
The hard part is this driver, not the G code translation.

The physical driving of the steppers also has it's own difficulties. Lots
of potential interference to the PIC. Really careful electrical design needed.

You then have to decide whether the G code translation is going to be a
'compiler' or 'interpreter' approach. The latter adds increased difficulties
with timing if the stream is not arriving fast enough. The stepper driving
will need to be interrupt based, since each motor has to be independant
of the other, and of the actual G Code translation.

At the end of the day as Jay says, you need to start at the hardware end.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group