PathPilot Lathe with 6 place turret

More
12 Apr 2017 21:02 #91264 by rodw
I don't really know what your code is meant to do but Andy is right, in an Interrupt service routine (which is what the servo-thread is), you can't do loops. All the looping has to be done by waiting until a state is set on a single pass through the routine.

In the last code you passed, this variable appears to be used to do that but a time delay is not set.
variable float sleeptime = 0;           // our own timer to set delay between progress levels 1 and 2

But, in the example, the zero value means no wait is programmed. I suspect you may get a result if you add a delay (which will be a count of servo-threads that you want to wait for).
The following user(s) said Thank You: brianTruck

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

More
13 Apr 2017 22:16 #91329 by brianTruck
Thank's guys ,
Here is my new code based off what I think your telling me.I think I keep the real time moving.

case 1:
turn on turret and increment a variable for short delay so that opto's clear current tool
case 2:
when any opto goes to zero move onto case 3
case 3:
increment a variable for a short delay to let optos center
case 4:
check for tool if wrong tool go back to case 2

sleeptime allways -starts zero
delay_count -starts at zero
times -gets set from HAL or defaults to 500
optodelay -gets set from HAL

Turrets starts and keeps running no matter how short or long I set optodelay,

File Attachment:

File Name: dynachange...-13.comp
File Size:12 KB


Thanks'
Brian
Attachments:

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

More
14 Apr 2017 02:45 #91340 by rodw
As I said before, I have no idea what yo are doing so I'm just looking at your code. Review your break statements in the switch().
case 2: // look for first opto trigger -opto's off when triggered
                 if(!opto1 || !opto2 || !opto3)
                    {
                     progress_level = 3;
                     break;
                    }

So if the if statement is not executed, you just drop down into
case 3:

Is that what you want? Normally break is the last command in a case statement.

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

More
14 Apr 2017 11:36 #91355 by brianTruck
Thanks'
What I'm trying to do is to keep looking at all 3 opto sensors(stay at case 2) , once any of the 3 have been set off (normally on) move on to case 3. I always thought that "break" sends the computer back out to look at the switch.
So do I need a break under the if ?


case 2:
if(opto1 || opto2 || opto3)
{
progress_level = 3;
break;
}
break;

Thanks'
Brian

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

More
14 Apr 2017 12:29 - 14 Apr 2017 12:29 #91359 by andypugh
For the condition when any one sensor out of three is off you need AND logic not OR
case 2:
if (opto1 && opto2 && opto3){
    break;
}
progress_level = 3;
// might as well fall-through to 3
case 3:

Or, if you prefer, this is equivalent
case 2:
if ( !opto1 || !opto2 || !opto3){
    progress_level = 3;
}
break;
case 3:
Last edit: 14 Apr 2017 12:29 by andypugh.
The following user(s) said Thank You: brianTruck

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

More
14 Apr 2017 13:48 #91363 by rodw

Thanks'
What I'm trying to do is to keep looking at all 3 opto sensors(stay at case 2) , once any of the 3 have been set off (normally on) move on to case 3. I always thought that "break" sends the computer back out to look at the switch.
So do I need a break under the if ?


case 2:
if(opto1 || opto2 || opto3)
{
progress_level = 3;
break;
}
break;

Thanks'
Brian

The break in fhe if satement is not required as the second break is always reached. What I'm seeing is that with your earlier code is that you were not staying on level 2 as execution of the level 3 code was occurring when progress_level was still 2. This looked like a bug.

Break does not reevaluate the swirtch statement but breaks out of it and reads the next statement after the terminating } of the switch. Andy shows an example where the break is omitted so the next case is executed. This means level 3 is executed on the same thread instance as level 2 changes rather than the next one so slightly more efficientt.
The following user(s) said Thank You: brianTruck

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

More
14 Apr 2017 18:53 #91370 by brianTruck
SWEET !

Thanks' Guys

Here is the code that works, stops right on the money, It still might need some tweaking,but its way better than it was.

File Attachment:

File Name: dynachange...-14.comp
File Size:12 KB




Thanks' again,
Brian
Attachments:

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

More
14 Apr 2017 19:33 #91374 by brianTruck
Here is the next problem, How do I make the lathe automatically go home when a M6 is called ?

Thanks'
Brian

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

More
14 Apr 2017 21:56 #91379 by rodw
I think section 5.6 on this page tells you how.
linuxcnc.org/docs/html/remap/remap.html
The following user(s) said Thank You: brianTruck

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

More
14 Apr 2017 22:25 #91381 by brianTruck
Thanks'
I did some quick reading and it said I could set the M6 position in the .ini file by

TOOL_CHANGE_POSITION = 0 0 0

Now when I run my M6 I get a "joint1 fallowing error" ,I think joint1 is the turret.

Thanks'
Brian

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

Moderators: cncbasher
Time to create page: 0.130 seconds
Powered by Kunena Forum