Input an external couple of x-y in GCode

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
17 Jun 2014 01:51 - 18 Jun 2014 13:42 #48011 by gfxx
Now I try with succes these:

I Define custom M100 code. -> M100 launch mypythonprogram.py

(mypitonprogram.py bringh a couple of coordinates from vision system and rewrite a custom gcode mysubroutines.ngc files)

When start my GCode program (myGCode.ngc) ->

myGCode.ngc program call mysubroutines.ngc ->

myGCode.ngc execution is ok ->

a custom myfile.hal start again (with hal timer) myGCode.ngc program.

It's all ok but I want to change the coordinates in to mysubroutines.ngc without restart myGCode.ngc program.

It is possible these in linuxcnc?? with or without python??
Last edit: 18 Jun 2014 13:42 by gfxx.

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 15:42 #48027 by ArcEye
Hi

The reason a re-load is necessary is because the interpreter reads ahead and stores the code.
Unless you restart, you will get the values that were present when it last read the code.
That goes for sub-routines too, it does not differentiate, just follows the trail wherever it goes.

Passing a value to a running Linuxcnc is very tricky.

If it is not running you can update the value of parameters via MDI and use those parameters in your sub instead of fixed values.
But if it is not running you can just reload, which is what you appear to be doing.

There may be some python method to change parameter values on the fly, you can certainly fetch them, but I am not really into python.
Someone else may be able to assist

regards

Please Log in or Create an account to join the conversation.

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
17 Jun 2014 17:43 - 17 Jun 2014 17:44 #48029 by gfxx
@ArkEye ... tanks for reply

Tryky or not is not a problem .... the question is: is it possible?

I read that I can pass value from cable pin of analog input, there is some other alternatives? .... using linuxcncrsh may be .... but I dont understand if is possible using linuxcncrsh with axis or some other gui.... is possible?
there are some other triks?

For example is possible set value on encoder input in hal using some c/c++ component?

other ideas? :blink:
Last edit: 17 Jun 2014 17:44 by gfxx.

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 19:05 #48033 by ArcEye
If you are running a program based upon external data, one option would be to run remotely via MDI in axis-remote or linuxcncrsh.

I used to do whole operations on the MDI line, often stacking up several pending moves and just walking away for a bit until it got near finishing the last one before checking all was well and entering a few more.
There was talk of doing away with this on safety grounds, but thankfully does not seem to have happened

If your principle input is external you could write a program to fed the moves necessary, substituting variables for actual data as required.

You can run linuxcncrsh with an instance of Axis running, but normally best not to and of course Axis is required for axis-remote

regards
The following user(s) said Thank You: gfxx

Please Log in or Create an account to join the conversation.

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
17 Jun 2014 22:59 #48040 by gfxx
:laugh:

tanks a lot ..... other information .... the best solution is axis-remote or linuxcncrsh ??

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 23:38 #48041 by ArcEye

tanks a lot ..... other information .... the best solution is axis-remote or linuxcncrsh ??


The simplest to start with, which does not require telnet or similar, is axis-remote.

Start axis in one terminal, take it out of estop, home it etc

Then in another terminal run axis-remote --mdi 'G0 X20 Y20 Z20'
The MDI tab in Axis will open and the command will be pasted in and run

You can then quite simply use system("axis-remote --mdi 'G0 X20 Y20 Z20'") from a C program to do the same

If what you want to do could be done on a MDI line, that is possibly as technical as you need to get

regards

Please Log in or Create an account to join the conversation.

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
18 Jun 2014 00:36 #48042 by gfxx
ok I try with success system("axis-remote --mdi 'G0 X20 Y20 Z20'") ..... I put these line in a c++ thread
QString command;
command = "axis-remote --mdi 'G0 X20 Y20 Z20'";
system(command.toStdString().c_str());
command = "axis-remote --mdi 'G0 X120 Y120 Z20'";
system(command.toStdString().c_str());

work perfect but axis return these error...

unknown parameter instead of a unary operation ......

You know why?

tanks a lot

Please Log in or Create an account to join the conversation.

More
18 Jun 2014 13:13 #48047 by ArcEye

unknown parameter instead of a unary operation ......


It is telling you there is a character in the string it does not like.

Could be the single quote marks, which tell bash the arguments are a single string, try without.

In the past I have had to use a char buffer to pass arguments to system(), the output from a QString is not always as required.

If removing the quotes does not work, try that

regards
The following user(s) said Thank You: gfxx

Please Log in or Create an account to join the conversation.

  • gfxx
  • gfxx's Avatar Topic Author
  • Visitor
  • Visitor
18 Jun 2014 13:38 - 18 Jun 2014 14:08 #48048 by gfxx
:laugh: :laugh: tanks my mistache ..... really my thread is a little ore longher than the post .... I did not realize that you wrote GG0 instead of G0 on a line ... now it's all ok.

Tanks a lot ArcEye....

I use QString because is the value that step with my signal from my funtion to thread ... function read from soket x -y couple an pass these signal to QTharead. QThread execute system axis-remote statment with QString command. .....

I have a doubt: this approach does not allow you to perform the individual rows one at a time, as in reality LinuxCNC run everything in the buffer ..... the buffer is loaded with strings of commands without LinuxCNC can tell if it's done or not previous command. is that correct?

I need to create custom M1xx command that tell at my c++ program when previous mdi command is terminate? or I can lauch some custom c/c++/puthon program from hal custom component when every mdi command finish?

The second idea seems better, do you have any suggestion to study to accomplish this?
Last edit: 18 Jun 2014 14:08 by gfxx.

Please Log in or Create an account to join the conversation.

More
18 Jun 2014 15:29 #48052 by ArcEye

I use QString because is the value that step with my signal from my funtion to thread


I use Qt a lot, and thus QString. There are occassions when interfacing with C code which requires a char*, where no matter how you cast the QString, it does not work properly.

I have a doubt: this approach does not allow you to perform the individual rows one at a time, as in reality LinuxCNC run everything in the buffer ..... the buffer is loaded with strings of commands without LinuxCNC can tell if it's done or not previous command. is that correct?


I am not quite sure what you mean.
MDI commands are queued and will be executed in sequence that they were input, until the last one is finished.

If you need to know when a MDI command has finished before doing something else, you could just send 2 lines each time, the first being the command and the second being a M code which executes a program that flags up that the command has finished
eg
system("G01 X23 Y45");
system("M101");

Trying to determine programatically through a component when a MDI command has finished might be quite complicated, the above is simple because M101 will only be executed when the preceding line is finished.

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum