Quantcast
Channel: CNCzone.com- Largest Forums for CNC Professional and Hobbyist alike!
Viewing all articles
Browse latest Browse all 72868

NO Touch Plate and NC Touch Probe switch inversion using an Arduino UNO

$
0
0
Just thought since I have learned so much from this site that I would give a little back. With the help of one of our EE/Software guys at work we came up with this simple setup to handle the switching and signaling to Mach 3 for both the Probe and Plates.

Simply using 4 of the digital input/output pins a ground pin we can achieve dealing with the NO and NC switches on the same input for MACH.

Here is the code that gets loaded to the Arduino.

/*
Switch Inversion

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.

int ledPIN = 13; //connected to LED
int ProbePIN = 2; //connected to touch probe
int mPlatePIN = 3; //connected to mobile touch plate
int fPlatePIN = 4; //connected to fixed touch plate
int tMillPIN = 12; //output connected to G540
int led; //output variable
int Probe; //output variable
int mPlate; //input variable for mobile touch plate
int fPlate; //input variable for fixed touch plate
int tMill; //variable for output to G540


// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pins as an input/output.
pinMode(ledPIN, OUTPUT);
pinMode(ProbePIN, INPUT_PULLUP);
pinMode(mPlatePIN, INPUT_PULLUP);
pinMode(fPlatePIN, INPUT_PULLUP);
pinMode(tMillPIN, OUTPUT);
}


// the loop routine runs over and over again forever:
void loop() {
Probe = digitalRead(ProbePIN);
mPlate = digitalRead(mPlatePIN);
fPlate = digitalRead(fPlatePIN);
if ((Probe == HIGH) || (mPlate == LOW) || (fPlate == LOW))
{
tMill = HIGH;
led = HIGH;
}
else
{
tMill = LOW;
led = LOW;
}
digitalWrite(tMillPIN,tMill);
digitalWrite(ledPIN,led);
delay(1);
}

We left the LED connected in place so you can test at the board for operation of the output to Mach without being connected to the MACH PC. When either of the touch plates makes contact with a bit the circuit is closed and pulled high...this causes an active low on pin 12 on the board and light the LED on pin 13.

When the probes breaks the circuit the input is pulled low and the output is then again sent to pins 12 and 13 giving MACH the active low signal it desires for triggering the probing events.

The Arduino is a bit of overkill for what it's doing but all the breakout boards I found that would do this were more expensive than the Arduino at 30 bucks.

Viewing all articles
Browse latest Browse all 72868

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>