Vibration Sensor / Trip Switch

This Section is for users to discuss hardware

Vibration Sensor / Trip Switch

Postby mdb » Thu Jan 21, 2021 2:59 pm

I am nearly finished converting a mill to CNC and I had noticed on the expensive commercially available CNC mills they had a vibration or G sensor. I thought it would be nice to have to potentially catch my machine before it wrecks an end mill or the material. So I built a vibration sensor system. I should note it has not been tested in anger yet. If anyone would like the design, let me know and I will put together a picture, schematic and include my Arduino code. I am not one to make videos of my work so there wont be one forthcoming. If anyone has tweaks etc, perhaps you'll post updates here. If there's no interest I wont bother with the extra legwork...
mdb
 
Posts: 3
Joined: Fri Jan 01, 2021 9:28 am

Re: Vibration Sensor / Trip Switch

Postby dezsoe » Thu Jan 21, 2021 3:27 pm

That sounds good! I'd be happy to see it.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Vibration Sensor / Trip Switch

Postby Soler » Thu Jan 21, 2021 7:58 pm

I'm interested to see this, I was going to make one myself using an ESP32 and accelerometer.
Soler
 
Posts: 32
Joined: Sun Feb 02, 2020 12:20 am

Re: Vibration Sensor / Trip Switch

Postby mdb » Fri Jan 22, 2021 10:31 am

OK, I'll put together the diagrams etc today. If you do the G sensor/ESP32 design perhaps you'll share that here?
mdb
 
Posts: 3
Joined: Fri Jan 01, 2021 9:28 am

Re: Vibration Sensor / Trip Switch

Postby mdb » Sat Jan 23, 2021 10:54 am

The objective of this tool is to identify when excessive vibrations are being felt by the CNC machine, indicating excessive cutting speed/depth or some other factor. Upon experiencing these, the microcontroller will trigger a relay which opens the NC circuit. I am connecting mine in series with my E-stop switch which means both the E-stop and the vibration switch are able to halt the controller. A key requirement is that the vibration sensor is placed in direct, hard mounted, contact with the machine frame. Or maybe better yet, in contact with the machine head. I have assumed you have a stable 5V power supply available. Current consumption should be much less than 500ma (this will depend on which relay you choose to a large extent) when the emergency stop is activated and less than 50ma when in the monitoring state. I have also included a switch to disable the vibration sensor as it could trigger while setting up or for any other reason that you dont want it triggering.

Parts list:
Arduino microcontroller (I used a Digispark as these are dirt cheap [<$2], have the smallest pinout available, have an integrated bootloader and a USB connection for programming)
SW420 vibration sensor (Should be laid with blue sensor horizontal for optimal results. NOTE: It has a sensitivity potentiometer that you can adjust to tune your setup)
MOSFET (I used a IRLR7843 but this is really overkill for the current requirements but something like a BS170 would be just fine - KEY REQUIREMENT is that it is logic level)
Resistors (2.2k, 220 and 100 ohms but you could play with these values to an extent - I tried to spec these with those available in assortment packs from china)
5V Relay (This must have a 5V coil and must have 5 pins [2 pins for coil, 3 pins for COM, NO and NC] - many relays do not have an NC connection on them and this a KEY REQUIREMENT)
Switch (I used a toggle switch but you can use whatever you prefer)
Diode (Almost any will work but I used a 1N4007, possibly the post common diode in the world and costs about 1 cent each)
LED (Any will work and you could play with the resistor value for this if you wanted)

Below is schematic: [/EDIT: Tried to include this but it doesnt want to show up. Here is the link: https://imgur.com/mO2EjSG)
Image

Here is my Arduino code:
const int vibrPin = 2; // Define input pin for SW420
const int relayPin = 4; // Define output pin for MOSFET gate/relay trigger

void setup() {
pinMode (vibrPin, INPUT); // Set pin mode as input for SW420
pinMode (relayPin, OUTPUT); // Set pin mode as output for MOSFET gate
digitalWrite (relayPin, LOW); // Set pin low (or off) to not trigger upon microcontroller bootup - NOTE: without the LED the Digispark turns the pin high on bootup and triggers the relay!
// Serial.begin (9600); // This does not work on the Digispark but I used it for setting my values on an Arduino Nano while designing it and you can uncomment should you choose to
}

void loop() {
long vibration = pulseIn (vibrPin, HIGH); // Define variable called "vibration" and use the pulse length recorded when the SW420 pin goes high
if (vibration > 2000) { // This was a value I decided upon but I may change it in the future
delay (50);
// Serial.println (vibration); // Commented out - see note above in setup
long vibration = pulseIn (vibrPin, HIGH); // IMPORTANT: Everything from here on down in this IF statement is to differentiate between a single bump and excessive cutting vibrations
if (vibration > 2000) {
delay (50);
// Serial.println (vibration);
long vibration = pulseIn (vibrPin, HIGH);
if (vibration > 2000) {
delay (50);
// Serial.println (vibration);
long vibration = pulseIn (vibrPin, HIGH);
if (vibration > 2000) {
delay (50);
// Serial.println (vibration);
long vibration = pulseIn (vibrPin, HIGH);
if (vibration > 2000) {
delay (50);
// Serial.println (vibration);
long vibration = pulseIn (vibrPin, HIGH);
if (vibration > 2000) {
delay (50);
// Serial.println (vibration);
digitalWrite (relayPin, HIGH); // If vibration is continuous then activate MOSFET gate to trigger relay and halt CNC controller
delay (1000);
}
}
}
}
}
}
delay (50);
}


Total parts cost is less than $5. I cannot promise it will work the way you want it to. You can tune the code and the sensitivity potentiometer on the SW420. If you find settings which work better for you or any alterations you have made which have improved your setup please post them here.
mdb
 
Posts: 3
Joined: Fri Jan 01, 2021 9:28 am


Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests