hello
i have a project that cut brass with fly cutter at 12000 rpm.
the fly cutter and dc motor need to move back and forth with ballscrew
and stepper motor.
i need a sensor that when the tip fly cutter touch the tip of brass
the fly cutter move backward.
i have tried like the picture above but sometimes it work sometime it didnt
i used attachInterrupt in the program for reverse the flag direction(reversing the x axis after it touch the brass)
fly cutter diameter is 40mm
i calculate that the fly cuter touch the brass within aproximately 40microsecond
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Your code will be most helpful, thanks for the mechanical setup.
You may indeed have a problem in sensing the touch, but there are a few things in the program which don't look correct.
attachInterrupt(0, OnCheck, CHANGE);
This should be placed set up, and not in loop. Given the wiring, I think this should be RISING. There also needs to be a resistor in the path from the brass to ground.
void OnCheck() {
EIFR = 1; //clear flag interrupt
state = HIGH;
noInterrupts();
}
Interrupts are automatically disabled within the ISR and you don't need the noInterrupts(). Why did you use it here?
i calculate that the fly cuter touch the brass within aproximately 40microsecond
DTime is 1000. When you hit the brass during the delay period, the interrupt will fire, and the code will return to the delay period. You will then continue to move until you get to the next pass through the for loop and the changed state is recognized. Is this OK?
hi cattledog thx for the suggestion i will try add the resistor.
yes i forgot to change the RISING that code was in the last my experiment.
Interrupts are automatically disabled within the ISR and you don't need the noInterrupts(). Why did you use it here?
i want to make sure that interrupts only fire once between this lines of program
for(a=0;a<g && state==LOW;a++){
TurnX(); //turn x axis to move forward (at this line of program interrupt() occured)
}
DTime is 1000. When you hit the brass during the delay period, the interrupt will fire, and the code will return to the delay period. You will then continue to move until you get to the next pass through the for loop and the changed state is recognized. Is this OK?
yes it doesnt matter when the interrupts happen it will only turn x axis one step of the stepper motor
it means 1/200 * 4mm (ballscrew 4mm per revolution) = 0.02mm then it goes reverse.(in my theory )
what do you think am i wrong?
sorry for the bad english
if i want to connect 5v and gnd from standalone power supply how do you wire it (the resistor etc)?
thx
thx for the suggestion i will try add the resistor.
if i want to connect 5v and gnd from standalone power supply how do you wire it (the resistor etc)?
I don't understand. It looks like the 5v is coming from the arduino, not a stand alone power supply. If you are going to use a separate supply for the 5v, make sure that the ground is connected to the Arduino ground.
Is the fly cutter rotating when it makes contact with the brass? Why do you think that the Arduino is not reliably sensing the 5v and that the interrupt sometimes works and sometimes doesn't.
I think the resistor needs to be in the wire from the brass to ground. With a resistor in the path, the voltage drop will be across the resistor and the Arduino will see the 5v on the interrupt pin. In the current diagram there is a short to ground through unknown resistances, and its not clear what voltage the Arduino interrupt pin will see when contact is made.
So rather than the (dubious) connection of the tool with the material, why not use eg an optocoupler or hall effect sensor to detect the cutter shaft rotation?
yes the fly cutter rotate 12000rpm when it touch the brass.
from my calculation
12000rpm = 200 rotation per second ==> 1 rotation = 0.005 second
fly cutter diameter 40mm = circumference approx 125mm
assume the tip of fly cutter when it touch the brass 1mm
1/125 * 0.005 second = 40 microsecond
i think the electricity didnt pass from fly cutter to the brass it is too slow to conduct, what do you think?
because i tried with the dc motor 3000 rpm it always touch and move back.
hi allan
i want to engrave the brass with fly cutter. ok will learn the hall effect sensor and optocoupler first how to apply to my project.
thx
hi allan i dont think the hall effect sensor can be apply to my project because the from what i learn in youtube that is non contact sensor and the accuracy is within milimeter.
In the machine tool world, the tool touch sensor is independent of the cutting tool. Typically there is a touch probe with a known mechanical reference to the cutting tool. I suppose you could also use an accurate proximity sensor for non contact location of the work surface. You determine the work piece location, and then bring the cutter to that location and remove some amount of material.
It looks you bring the tool into contact, remove one step,(.02mm) and then back up. Are you going to use the position of the touch point to make a second cut? Or are you removing a non conductive coating from the brass? Or are you trying to use the interrupt on CHANGE to back up one step until the contact breaks, and then go forward again for another step of cutting?
Can you please explain more about what you are doing in your process?
Your code looks for an interrupt in the reverse direction, but with RISING I don't see how that could happen as you are moving away from the brass.
If you can sense electrical contact at 3000 rpm, but not 12000 is it due to mechanical vibration leading poor contact? You say that ath 12000 you don't always detect the touch. Do you detect the contact after the cut goes a few steps deeper?
If there is rapid make and break of the contact, leading to retriggering of the interrupt and unwanted reversals, you can add a "debounce" lockout to the response. The way you are trying to get only one interrupt with the noInterrupts() will not work as the interrupt is re-enabled on exit from the isr.
I'm suggesting you read the rotation of the tool - perhaps about 1/2 rev away from the contact point.
Then decide what to do .... step in, step out.......
I'm conversant with manual machine tools - lathes, mills - but not CNC stuff, so excuse my ignorance of standard methods.....
when i use 12000rpm the flycutter some times move backward after contact has been made sometimes it doesnt move backward it cut deeper and deeper until the torque motor cannot cut the brass and it stuck.
yeah maybe the x axis need more rigidity i am working on it.
If there is rapid make and break of the contact, leading to retriggering of the interrupt and unwanted reversals, you can add a "debounce" lockout to the response.
i dont understand what is debounce lockout how to do it ?thx
hi allan thx for your suggestion but i need the accuracy and mostly i need the zero position when it made contact to cut more.
after i read again the link about interrupt in gammon i think i was wrong to put noInterrupt() in isr, it should be dettachInterrupt() what do you think?
void OnCheck() {
EIFR = 1; //clear flag interrupt
state = HIGH;
detachInterrupt(0);
}
Have you added a resistor (10K) in the ground path between the brass and ground?
Did you move attachInterrupt() to setup()?
If the cutter is not rotating, does the interrupt fire reliably?
i dont understand what is debounce lockout how to do it ?thx
There are many ways to do this. This will accept the first trigger, and then not take another one for a lock out period. You can experiment with the time required. It's not immune to electrical noise causing an unwanted trigger but it should work in your case.
void OnCheck() {
static unsigned long lastInterruptTime = 0;
unsigned long interruptTime = micros();
if (interruptTime - lastInterruptTime > 1000) //1 ms lockout
{
EIFR = 1; //clear flag interrupt
state = HIGH;
//noInterrupts();
}
lastInterruptTime = interruptTime;
}
Yes this is true, but interrupts are already disabled within the ISR and automatically re-enabled on exit. Your use of noInterrupts in this case is not doing anything that is not already happening.
after i read again the link about interrupt in gammon i think i was wrong to put noInterrupt() in isr, it should be dettachInterrupt() what do you think?
No. That is a bad idea and can lead to what is called "race conditions" with the detachInterrupt and the attachInterrupt().
The interrupt () and noInterrupts() calls are typically used to ensure that any non atomic data read from the interrupt is unchanging. You only read a byte (state) which is atomic.