I did this on an ALLin1DC retrofit but its applicable for all controls.
My Hurco Hawk 5m has a proxy sensor reading off a 32 tooth gear in the head so 32 counts per revolution.
The Acorn is capable of measuring spindle speed based on 1 count per revolution on an input but the PLC is not fast enough to process 32 per revolution.
My solution was to convert the counts to quadrature encoder signals.
Originally I was going built a circuit but decided to do it all with Arduino. I used an Ebay optoisolator board to bring the 24VDC proxy sensor signal to 5V for the Arduino Nano Every board on D2. D3 is to change direction but I have not tested this. Its currently commented out. D4, D5, D6, and D7 are A, A/, B, and B/
The Arduino pins are run directly to the DB9 A, A/, B, and B/ pins.
The Arduino is powered from the 12V Allin1DC power supply.
I set 32 counts per Rev in CNC12. It works perfectly and matches my Tachometer. Not for use with threading or rigid tapping.
Arduino Code:
Code: Select all
const int PulseIN = 2;
const int DirIN = 3;
const int AOUT = 4;
const int AnotOUT = 5;
const int BOUT = 6;
const int BnotOUT = 7;
int Pulsestate = 0;
int Lastpulsestate = 0;
int cycle = 1;
void setup() {
// put your setup code here, to run once:
pinMode(PulseIN, INPUT_PULLUP);
pinMode(DirIN, INPUT);
pinMode(AOUT, OUTPUT);
pinMode(AnotOUT, OUTPUT);
pinMode(BOUT, OUTPUT);
pinMode(BnotOUT, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Pulsestate = digitalRead(PulseIN);
if (Pulsestate != Lastpulsestate && Pulsestate == 1) {
//if (DirIN == 0 ){cycle++;}
//if (DirIN == 1 ){cycle--;}
cycle++;
if (cycle >= 5){cycle = 1;}
if (cycle <= 0){cycle = 4;}
if (cycle == 1){
digitalWrite(AOUT, HIGH);
digitalWrite(AnotOUT, LOW);
digitalWrite(BOUT, LOW);
digitalWrite(BnotOUT, HIGH);
}
if (cycle == 2){
digitalWrite(AOUT, HIGH);
digitalWrite(AnotOUT, LOW);
digitalWrite(BOUT, HIGH);
digitalWrite(BnotOUT, LOW);
}
if (cycle == 3){
digitalWrite(AOUT, LOW);
digitalWrite(AnotOUT, HIGH);
digitalWrite(BOUT, HIGH);
digitalWrite(BnotOUT, LOW);
}
if (cycle == 4){
digitalWrite(AOUT, LOW);
digitalWrite(AnotOUT, HIGH);
digitalWrite(BOUT, LOW);
digitalWrite(BnotOUT, HIGH);
}
}
Lastpulsestate = Pulsestate;
if (Pulsestate == 1){digitalWrite(LED_BUILTIN, HIGH);}
else {digitalWrite(LED_BUILTIN, LOW);}
}