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
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to