On 10/02/2016 10:40 AM, Danny Miller wrote:
>
> On 10/2/2016 11:35 AM, Sebastian Kuzminsky wrote:
>>
>> It would probably be easy to add a motion pin with that information, i'd
>> be happy to guide you through that if you like.
>>
>>
> Sounds like a lot of complexity, but it's of great value to know how
> that works.  Shoot!

I should know better by now than to say "It would probably be easy"...

I looked into this a bit and it turns out to be hard instead.  The 
commanded S-word doesn't get sent from Task to Motion until the 
spindle-on command (M3/M4) runs.  So exporting it to HAL from Motion 
won't work without huge plumbing changes.

But the information *is* available in the Interpreter (in Task), and 
shared from there to all other components that want it, via the Status 
structure.  The bests place to export it from is probably halui.  So I 
change my suggestion from "add a pin to Motion", to "add a pin to halui".


In src/emc/usr_intf, look at halui.cc.  In emcTaskNmlGet() it connects 
to the Status channel, and ends up with a pointer named emcStatus, that 
points to the current Status structure.

The Status structure is defined in a bit of a complicated way, but after 
peeling off some of the layers you end up in 
src/emc/nml_intf/emc_nml.hh, in the structure named EMC_TASK_STAT.  It 
has a member called "activeSettings", which contains (among other 
things) the currently programmed S-word, no matter what your M3/M4/M5 
setting is.

The S-word gets put into the Status activeSettings array in 
src/emc/rs274ngc/rs274ngc_pre.cc, by the Interp::active_settings() 
function.  This function gets called by Task every time through its 
loop, Task passes it a pointer to the Status active_settings array as 
the "settings" argument.  active_settings() copies the information from 
one of Interp's internal variables, called "_setup".  _setup gets the 
speed information in src/emc/rs274ngc/interp_write.cc, in the 
write_settings() function.  There you can see that the speed info is at 
index 2 in the array.

So!

Look in halui.cc for where (for example) halui.spindle.is-on is created, 
and use that as a template to create a new (float) pin named (perhaps) 
halui.spindle.selected-speed or .programmed-speed or something.   Add a 
little chunk of code to halui's modify_hal_pins() to copy the Status 
active_settings[2] value to that pin, and you should be done.

Feel free to ask questions if any of that wasn't clear.

Some introductory documentation about hacking on linuxcnc is here:

http://linuxcnc.org/docs/devel/html/code/contributing-to-linuxcnc.html
http://linuxcnc.org/docs/devel/html/code/building-linuxcnc.html


-- 
Sebastian Kuzminsky

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to