Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
Member Login
Site Notices
9/22/2017 12:11:25 AM
Posted: 9/30/2005 6:32:52 PM EDT
I am doing a read a cnc file

M1 G0 F1
m2 G1 X2.333 Y-4.555 Z2.444
m3 G3 Etc! etc!

int main()
{
int x = 0;
int y = 0;
int z = 0;

ifstream ifile("myfile.txt");

if (!ifile)
{
cout << "Error";
return -1;
}

while (ifile.get(ch))
{
switch(ch)
{
case ' ':
blank_count++;
break;
case '\n':
case '\t':
break;
case '.':
sentence_count++;
break;
case 'm':
ms_count++;
break;
case 'X':
case 'x':
x++;
break;
case 'Y':
case 'y':
y++;
break;
case 'Z':
case 'z':
x++;
break;
default:
char_count++;
break;
}
}
return 0;
}

how would I get the numbers off the x y z m G f values and program them too a stepper controller motor I am trying to build a simulator for a CNC file reading program! I need some help and I have too seperate the values to the switch command and send each value to a stepper motor yea I am learning so no steppers are hooked to anything but iam in the building part now. any code gurus here could help me out I thank you!
Link Posted: 9/30/2005 6:41:16 PM EDT
I don't know if your going down the right road or not. But it looks to me the FOrmat by XYZ would be dictated by some sort of DAC (Digital to Analog Controller), plus some sort of way to pass
feedback information (Motor Load, Current, rpm, etc to the program. Even if you are emulating it it would seem that you would still have to emulate the DAC. Nobody may be able to answer your question without knowing A] what kind of logic is controlling the motor. ( IE, How does the XYZ work is it ran off the same Bus to the different logic networks necessary to control the motor?)
The motor , no problem , but how does the computer interface with the actual physical mechanics of said motor? Do you have a schematic, Which would probably help you immensly, ? Is the data going to be transfered serially? Where are you going and what do you have??

Just some suggestions
Link Posted: 9/30/2005 6:43:32 PM EDT
If you are just trying to emulate the read of the CNC, then you will need to emulate the reader? There again you are talking about basically????

Interesting problem for sure.

You might end up having to build the program around you trying to read the CNC code, in other words the interpretation of the CNC code my be the last thing you end up programming??

Link Posted: 9/30/2005 6:44:24 PM EDT
#include <unfindable_library.h>

send_to_motor(x);
Link Posted: 9/30/2005 6:48:03 PM EDT
the data will be sent by parallel port i can use the dlls and header files so prgrammatically sending data to the controller itself will be a lot easy! don't know how accurate it would be but testing and learning!
Link Posted: 9/30/2005 6:48:19 PM EDT
You will need to have some sort of schematic.
SO you can rebuild the logic in C++ form.

Just your question raised about 100 questions with me and I no only a little about this stuff.
NEED MORE INFO!!

Link Posted: 9/30/2005 6:55:30 PM EDT
What is the control format???
I mean when you shove the data do the parallel port what MUST it look like??

Cause chances are the Controller will be able to move the in three axis at once this allows you a couple of options . See most CNC will move in 3 axis at the same time. Will parrallel allow you to put all three commands (xYZ) to the motor at the same time or are you going to have to load three individual words and not let the CNC do anything until it has taken recent of all three words(just a for instance).
Link Posted: 9/30/2005 6:58:01 PM EDT
ok the x y x values in my program the values would be unknowing but the X Y Z would be let say
x2.3333 y-23334.67 Z12345.65

how would I access the unknowing values of of XYZ and store them in a variable for later use!
and the G1 or G2 etc! would be read has a set value!
Link Posted: 9/30/2005 6:59:45 PM EDT
[Last Edit: 9/30/2005 7:02:10 PM EDT by LocknLoaded]

Originally Posted By Benjamin0002:
What is the control format???
I mean when you shove the data do the parallel port what MUST it look like??

Cause chances are the Controller will be able to move the in three axis at once this allows you a couple of options . See most CNC will move in 3 axis at the same time. Will parrallel allow you to put all three commands (xYZ) to the motor at the same time or are you going to have to load three individual words and not let the CNC do anything until it has taken recent of all three words(just a for instance).




yes there would be a delay wouldnt there be hum!!! parrallel would let you send faster data!
Link Posted: 9/30/2005 7:01:29 PM EDT

Originally Posted By LocknLoaded:
ok the x y x values in my program the values would be unknowing but the X Y Z would be let say
x2.3333 y-23334.67 Z12345.65

how would I access the unknowing values of of XYZ and store them in a variable for later use!
and the G1 or G2 etc! would be read has a set value!




ommm, to store them in other variables:
float A;
A=x;

float B;
B=y;

float C;
C=z;
Top Top