Hi tom,
I am using estop program for disabling all axes.
And if i release the estop all axes are still disabled.
I want to make such that if i release estop, all axes should auto enable. and if i press estop all axis should disable.
I defined bit no 16 as my estop bit.
How to make estop in infinite loop. ? as said above.
Waiting for your kind reply.
Regarding estop making in for loop
Moderators: TomKerekes, dynomotion
-
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Regarding estop making in for loop
Thank You
AMIT KUMAR
AMIT KUMAR
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Regarding estop making in for loop
Hi Amit,
It may not be a good idea to have the axes automatically enabled when EStop is released, it is up to you to add any and all safety precautions.
But here is some sample code:
It may not be a good idea to have the axes automatically enabled when EStop is released, it is up to you to add any and all safety precautions.
But here is some sample code:
Code: Select all
#include "KMotionDef.h"
#define ESTOP 16
#define XAXIS 0
#define YAXIS 1
// state variables for switch debouncing
int elast=0,elastsolid=-1,ecount=0;
int Debounce(int n, int *cnt, int *last, int *lastsolid);
void main()
{
int result;
for (;;) // loop forever
{
WaitNextTimeSlice();
// Handle ESTOP debounce and detect when changed
result = Debounce(ReadBit(ESTOP),&ecount,&elast,&elastsolid);
if (result == 1) // pushed?
{
DisableAxis(XAXIS);
DisableAxis(YAXIS);
}
else if (result == 0) // released?
{
EnableAxis(XAXIS);
EnableAxis(YAXIS);
}
}
}
// Debounce a bit
//
// return 1 one time when first debounced high
// return 0 one time when first debounced low
// return -1 otherwise
#define DBTIME 300
int Debounce(int n, int *cnt, int *last, int *lastsolid)
{
int v = -1;
if (n == *last) // same as last time?
{
if (*cnt == DBTIME-1)
{
if (n != *lastsolid)
{
v = *lastsolid = n; // return debounced value
}
}
if (*cnt < DBTIME) (*cnt)++;
}
else
{
*cnt = 0; // reset count
}
*last = n;
return v;
}
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Re: Regarding estop making in for loop
Hi tom,
thanks for the reply.
I will test and keep you updated.
thanks for the reply.
I will test and keep you updated.
Thank You
AMIT KUMAR
AMIT KUMAR