[Emc-users] INI file data for a user-defined command in gcode?
If I have a program that gets executed via a user-defined M100 command, can that program get the INI file data somehow? I'd like to put spindle gear ratios in the INI file to make them available to the M100 program. I do see a way to get the information, but not very directly. The INI file name is given as an argument to several running programs, which I can find with 'ps -ux'. Then the INI file can be parsed for the information I need, but is there a more direct way? Thanks. Karl -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
[Emc-users] INI file data for a user-defined command in, gcode?
>>If I have a program that gets executed via a user-defined M100 >>command, can that program get the INI file data somehow? Hi The info you need is in the main axis executable. Axis starts with a commandline argument specifying the path of the .ini file by default. Looks like you are conversant with python, so the below code fragments should point you on your way. import emc . . inifile = emc.ini(sys.argv[2]) . . tooltable = inifile.find("EMCIO", "TOOL_TABLE") regards -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
Re: [Emc-users] INI file data for a user-defined command in gcode?
On 27 June 2011 15:34, Karl Cunningham wrote: > If I have a program that gets executed via a user-defined M100 command, > can that program get the INI file data somehow? There might be an elegant way, but you you could: 1) Create constants in the HAL file, and use setp to store data from the INI file in it. http://www.linuxcnc.org/docview/html/man/man9/constant.9.html eg loadrt constant names=ratio1,ratio2,ratio3 setp ratio1.value [GEAR_RATIOS]ratio1 Then in the shell script halcmd getp ratio1.out should return the value (but I have not tested this) Wait for a better way to do it to be suggested before trying this though. I am not sure why you need the gear ratios, does this HAL component for up to 16 gears help? http://thread.gmane.org/gmane.linux.distributions.emc.devel/4043/focus=4235 -- atp "Torque wrenches are for the obedience of fools and the guidance of wise men" -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
Re: [Emc-users] INI file data for a user-defined command in gcode?
On 06/27/2011 07:57 AM, andy pugh wrote: > On 27 June 2011 15:34, Karl Cunningham wrote: >> If I have a program that gets executed via a user-defined M100 command, >> can that program get the INI file data somehow? > > There might be an elegant way, but you you could: > 1) Create constants in the HAL file, and use setp to store data from > the INI file in it. > http://www.linuxcnc.org/docview/html/man/man9/constant.9.html > eg > loadrt constant names=ratio1,ratio2,ratio3 > setp ratio1.value [GEAR_RATIOS]ratio1 > > > Then in the shell script > halcmd getp ratio1.out > > should return the value (but I have not tested this) > > Wait for a better way to do it to be suggested before trying this though. > > I am not sure why you need the gear ratios, does this HAL component > for up to 16 gears help? > http://thread.gmane.org/gmane.linux.distributions.emc.devel/4043/focus=4235 Thanks Andy. Setting HAL constants is certainly more elegant than what I came up with. I had not seen spindle.comp, and it might do a lot of what I want. I misspoke when I said I wanted to get INI data from an Mnnn program (forgive me, it's Monday morning). Actually it's an emc2 filter program, filtering ngc files, that needs the gear ratios. I really want to avoid hard-coding the gear ratios into the program, and I think your solution of the HAL constants would still work there. The filter program selects the gear based on available ratios and motor operating speed range. Gear changes on this mill are manual, and the motor is driven from a VFD. The program selects the gear so the motor speed will be closest to its nameplate speed, but tries to avoid unnecessary gear changes by giving preference to the current gear if the motor speed would be within allowable range. When it sees an Snnn spindle speed command it decides on a gear and inserts M100 Pnn into the code (nn is the gear). M100 is small python program which puts up a dialog based on the Pnn argument, containing a graphic telling the operator to change the gear. It also sets the scale factors for the 0-10V output to the VFD and the encoder on the motor, to scale them to motor speed instead of spindle speed. Your suggestion of using the constant HAL component should work there too, to communicate from the M100 program to the scale factors. None of this is tested yet. Karl -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
Re: [Emc-users] INI file data for a user-defined command in gcode?
On 27.06.11 09:46, Karl Cunningham wrote: > On 06/27/2011 07:57 AM, andy pugh wrote: > > loadrt constant names=ratio1,ratio2,ratio3 > > setp ratio1.value [GEAR_RATIOS]ratio1 > > > > > > Then in the shell script > > halcmd getp ratio1.out > > > > should return the value (but I have not tested this) > > > > Wait for a better way to do it to be suggested before trying this though. That method looks uncomplicated and therefore relatively easy to implement. IIUC, it is reading values taken from the INI file, so a single point of definition is retained. It looks like a lot less work than some alternatives. [...] > I misspoke when I said I wanted to get INI data from an Mnnn program > (forgive me, it's Monday morning). Actually it's an emc2 filter program, > filtering ngc files, that needs the gear ratios. I really want to avoid > hard-coding the gear ratios into the program, and I think your solution > of the HAL constants would still work there. > > The filter program selects the gear based on available ratios and motor > operating speed range. Gear changes on this mill are manual, and the > motor is driven from a VFD. The program selects the gear so the motor > speed will be closest to its nameplate speed, but tries to avoid > unnecessary gear changes by giving preference to the current gear if the > motor speed would be within allowable range. When it sees an Snnn > spindle speed command it decides on a gear and inserts M100 Pnn into the > code (nn is the gear). While I've never bothered with python, it should be able to do what any other text processing language can. Before beginning to process the gcode on stdin, open the INI file for reading, find the required lines (preferably using regexes), and store the data in a convenient form. If that doesn't sound easy, then Andy's method is doubly the way to go, I think. > M100 is small python program which puts up a dialog based on the Pnn > argument, containing a graphic telling the operator to change the gear. > It also sets the scale factors for the 0-10V output to the VFD and the > encoder on the motor, to scale them to motor speed instead of spindle > speed. Your suggestion of using the constant HAL component should work > there too, to communicate from the M100 program to the scale factors. It sounds neat. Andy's solution is ready to go, and is simple. Doing it in the filter keeps everything in one place, which is especially attractive when coming back later and trying to remember how to make changes. Parsing the INI file to glean the required data does require a few extra lines of code. Python may be a poor language choice for text processing, if my first ever reading of: http://docs.python.org/howto/regex.html#regex-howto is any guide. Regexes seem to very much be an afterthought in this language, and it looks limited at first glance. The howto also admits to python suffering from "The Backslash Plague". Erik -- Happiness isn't having what you want, it's wanting what you have. -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
Re: [Emc-users] INI file data for a user-defined command in gcode?
On 06/28/2011 12:58 AM, Erik Christiansen wrote: > While I've never bothered with python, it should be able to do what any > other text processing language can. Before beginning to process the > gcode on stdin, open the INI file for reading, find the required lines > (preferably using regexes), and store the data in a convenient form. > > If that doesn't sound easy, then Andy's method is doubly the way to go, > I think. > > It sounds neat. Andy's solution is ready to go, and is simple. Doing it > in the filter keeps everything in one place, which is especially > attractive when coming back later and trying to remember how to make > changes. Parsing the INI file to glean the required data does require a > few extra lines of code. > > Python may be a poor language choice for text processing, if my first > ever reading of: > > http://docs.python.org/howto/regex.html#regex-howto > > is any guide. Regexes seem to very much be an afterthought in this > language, and it looks limited at first glance. The howto also admits to > python suffering from "The Backslash Plague". Erik, Thanks for the comments. I've used python regexes, and find it works well although for me it's not all that intuitive. I've got the python code working, parsing the gcode stream for spindle speed and direction changes and ignoring anything inside comments (including nested ones). Andy's solution using the spindle hal component includes several nice features for things that I was doing in other ways. Unfortunately the encoder is on the motor not the spindle itself, so I've modified the spindle component to scale encoder position and velocity by the gear ratio as well. Thanks again. Karl -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users
Re: [Emc-users] INI file data for a user-defined command in, gcode?
On 06/28/2011 09:44 AM, Schooner wrote: > >>If I have a program that gets executed via a user-defined M100 > >>command, can that program get the INI file data somehow? > > Hi > > The info you need is in the main axis executable. > > Axis starts with a commandline argument specifying the path of the .ini > file by default. > > Looks like you are conversant with python, so the below code fragments > should point you on your way. > > > import emc > . > . > inifile = emc.ini(sys.argv[2]) > . > . > tooltable = inifile.find("EMCIO", "TOOL_TABLE") Very cool. Guess I should dig a little deeper into the docs. Thanks. Karl -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 ___ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users