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 
>>might be easier, since you seem comfortable with C. I think the issue here 
>>is that your script is not running realtime, and so the timing is off.
>>    
>>
>
>The turret rotates at about one revolution per second, giving 125ms per
>tool position. My guess is that if I can process four or five position
>samples in that time, it should work. The problem is that, I think it is
>taking around 200ms to do it. If I were using a precompiled program, I
>think I should be able to do tens or hundreds of samples per position
>even in userspace(?).
>  
>
>>As you can see, sleep isn't always real accurate:
>>    
>>
>
>It should be accurate enough were I would like to use it - that being,
>just after solenoid commands to let the mechanical parts to come to
>equilibrium. Originally, I had no sleep between "rotate", "sample",
>"activate stop". After the stop, sleeps for the park procedure were all
>minimum times.
>  
>
>>$ firefox; time sleep 0.1
>>real    0m0.313s
>>
>>A C or python program would have the same problem:
>>#include <unistd.h>
>>int main(){ usleep(100000); }
>>
>>$time ./test
>>real    0m0.151s
>>
>>import time
>>time.sleep(0.1)
>>
>>$time python test.py
>>real    0m0.140s
>>
>>you could also try running your script with a higher priority. (renice) 
>>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
>method to get it to work. It now does a complete single tool position
>change using only solenoid commands and sleep - no position processing.
>After the turret parks, I sample the position and if the requested
>position and current position don't match, I have it jump to the next
>position, park and test again until I get a match. What I would prefer,
>is to process the location during rotation and only stop and park after
>I get a match.
>
>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.

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, 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.

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
(AND and NOT are both HAL components already, and there are other logic 
components)

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


-------------------------------------------------------------------------
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

Reply via email to