On Thu, 2007-08-23 at 18:13 -0400, Stephen Wille Padnos wrote: > Kirk Wallace wrote: > > >On Thu, 2007-08-23 at 17:24 +0000, ben lipkowitz wrote: > > > > > >>This really sounds like a perfect job for classicladder. If you arent > >>interested in learning ladder logic, then writing a custom hal component ... snip > >>btw you are actually having a problem right? or are you just informing us > >>of what you did? > >> > >> --fenn > >> > >> > > > >I still have a problem, sort of. I had to fall back on a less desirable ... snip > >Bottom line (I think), how can I get enough processing done in 30ms to > >decode and match two (32 bit unsigned?) words? > > > >(By the way, this is how I decode the position bits: > >halcmd show inputs > >grep and cut > >change each bit, ones, twos, fours, eights from "T" or "F" to 1 or 0 > >current_tool=$((ones+(2*twos)+(4*fours)+(8*eights))) > >I visit Grandma on the way) > > > >Kirk Wallace > > > > > OK - I see some room for improvement here :) > > First, there's a HAL component called weighted_sum - use that to > generate positions from the input bits. You may want to stick a > debounce on the input bits as well - they're bound to be a little noisy.
This ( http://linuxcnc.org/docs/html/man/man9/weighted_sum.9.html ) weighted sum is great. It takes a least half my lines of script (here in M101 by the way: http://www.wallacecompany.com/cnc_lathe/HNC/emc2/nc_files/ ) and puts it in realtime (?) HAL. > There's also a component called modmath - if the turret can be indexed > in both directions, you can use this component to tell you which way is > the shortest from the current position to the requested one. If the > turret can't move in both directions, CCW only > then you can do the whole thing > with HAL components - no classicladder needed. You'll have to write a > simple component to compare two s32 numbers (strange but true - there's > an 8-bit pattern match with cascade input component, but no integer > comparison :) ) Look at something like xor2.comp for an example of a > simple .comp component. Similar to and2.comp only start by defining the I/O pins to be s32 instead of bit? More homework. > use debounce / weighted_sum to get a stable position reading (current_tool) > use tool_change AND NOT (requested_tool == current_tool) to enable the > turret to index When I see the word "index", I think we still might be misunderstanding each other. Right now, I am using an indexing routine to cope with userspace timing issues (or some other problem). Which is like controlling the turning of a bicycle wheel by putting a stick between each spoke until I get to the position I want. Using the information you have given me, I am going to spin the wheel and at just the right time jamb the stick in and stop it right on the spot I want. Once I get the turret spinning, I'll count the spokes with weighted_sum and jamb the stick with and8.comp(new). > (AND and NOT are both HAL components already, and there are other logic > components) I used NOT to flip-flop my high and low clutch pins. > I think that's about it. Another option is to just write a .comp to do > it all - take in 4 bits, the requested tool number, and the > tool-prep/tool-change signals, output tool_prepped/tool_changed and > turret controls. The comp preprocessor really helps make this kind of > HAL component easy to write. > > - Steve I write a very small C program about once a year, and almost have to start at "Hello World", but I think I am going to like this comp tool thing. Kirk Wallace ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users