second or more functions in a component

More
09 Apr 2012 18:21 #19052 by marv-t
Hello!

My name is Thomas and I’m from Austria. My project is to retrofit a Chiron FZ16.
My hardware components are:
2x 4i65
2x7i33
3x7i37
My first component was for the rotary table and this is perfect working.
Now I tried to write a component for ATC and now I have some troubles.
An example for my problem:

Bool homeATC(){
// some code (state machined)
return true; //when ready
}

Function(__){
//main component
switch(state){
case home:
if(inputHomeATC) {
if(!syncWZW()) {
state = nextState;
}
}
break;
.
.
.
case n: break;
}
}

Comp does compile it but when I start linuxcnc, I get a timeout. Is it possible to call a function in the real time function(of course state machined)?
In the manual I found no hint about this topic.
In the source from linuxcnc i have seen the original comps and there is an example to call an another component in an component. Is this the only way? I hope not.

Regards Thomas

Please Log in or Create an account to join the conversation.

More
09 Apr 2012 20:16 #19057 by andypugh
marv-t wrote:

. Is it possible to call a function in the real time function


It ought to be possible, yes. You probably need to define it between the ";;" and the FUNCTION(_) lines in the comp.

It will probably help you to use the correct flags in comp to create the intermediate C code to see what is happening. Then you can see what parameters you need to pass to the function to be able to see the pins and data structure too. You might even want to use the comp "function" statement even though you don't want to export the function to HAL.

Please Log in or Create an account to join the conversation.

More
10 Apr 2012 00:45 #19080 by BigJohnT
While this doesn't answer your question, most tool changers are handled with classicladder. I have an example of my CHNC on my web site including the ladder.

gnipsel.com/shop/hardinge/hardinge.xhtml

John

Please Log in or Create an account to join the conversation.

More
12 Apr 2012 17:39 #19152 by marv-t
Hello!

Now I found the problem with my code in the comp.

In my function homeATC() I called an another small function. It seems the function call stack is only 1 level. When I have another call in a function, I get a this error:

RTAPI: Task 1[0xf6302800]: Fault with vec=14, signo=11, ip=fd718124.
RTAPI: This fault may not be recoverable without rebooting.

Okay, I need to rewrite the code a little bit to get working. :)

But thanks for your answers.

Have a nice day,
Thomas

Please Log in or Create an account to join the conversation.

More
13 Apr 2012 08:27 #19164 by ArcEye
Hi,

There certainly is something about calling externally coded functions in a real time component that is problematic.

I have had to code the same functionality in-line previously, even though that is rather wasteful and certainly not elegant.

Having a small checking routine which was called several times in the main _FUNCTION(), just did not work and it took a while to find out why the component did not work.
That may well be the reason.

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum