Thread: Denford cyclone conversion
Threaded View
-
16-11-2021 #11
I think that's the final code. I have one more version where I had started to add 4 bit logic to read the positions but not sure if this was ever used or if it works.
#define TRUE 1
#define FALSE 0
#define TURRET_MOVE_PIN 2
#define STROBE_SIGNAL_STATUS_PIN 3
#define INDEXING_CONTROL_SWITCH_PIN 4
#define LOCKING_CONTROL_SWITCH_PIN 5
#define POS1 6
#define POS2 7
#define POS3 8
#define POS4 9
#define POS5 10
#define POS6 12
#define POS7 13
#define POS8 1
#define INDEXING_SOLENOID_PIN 23
#define TURRET_CLOCKWISE_RUN_PIN 24
#define TURRET_COUNTER_CLOCKWISE_RUN_PIN 25
#define TURN_OFF_THE_TURRET_MOVE_COMMAND_PIN 26
#define BITONE 27
#define BITTWO 28
#define BITTHREE 29
#define BITFOUR 30
// State variables
int running_cycle = FALSE;
int stopping_cycle = FALSE;
int moving_clockwise = FALSE;
int moving_counter_clockwise = FALSE;
// signals evaluated on each loop
int strobe_signal = FALSE; //Start with Strobe Signal off
int index_control_switch = FALSE; //Start with ICS off
int lock_control_switch = FALSE; //Start with LCS off
int bit_one = FALSE;
int bit_two = FALSE;
int bit_three = FALSE;
int bit_four = FALSE;
void setup() {
pinMode(TURRET_MOVE_PIN, INPUT_PULLUP); //Turret Move
pinMode(STROBE_SIGNAL_STATUS_PIN, INPUT_PULLUP); //Strobe Signal Status
pinMode(INDEXING_CONTROL_SWITCH_PIN, INPUT_PULLUP); //Indexing Control Switch
pinMode(LOCKING_CONTROL_SWITCH_PIN, INPUT_PULLUP); //Locking Control Switch
pinMode(POS1, INPUT_PULLUP);
pinMode(POS2, INPUT_PULLUP);
pinMode(POS3, INPUT_PULLUP);
pinMode(POS4, INPUT_PULLUP);
pinMode(POS5, INPUT_PULLUP);
pinMode(POS6, INPUT_PULLUP);
pinMode(POS7, INPUT_PULLUP);
pinMode(POS8, INPUT_PULLUP);
pinMode(INDEXING_SOLENOID_PIN, OUTPUT); //Indexing Solenoid
pinMode(TURRET_CLOCKWISE_RUN_PIN, OUTPUT); //Turret Clockwise Run
pinMode(TURRET_COUNTER_CLOCKWISE_RUN_PIN, OUTPUT); //Turret Counter Clockwise Run
pinMode(BITONE, OUTPUT);
pinMode(BITTWO, OUTPUT);
pinMode(BITTHREE, OUTPUT);
pinMode(BITFOUR, OUTPUT);
}
void loop() {
if (digitalRead(POS1) == LOW) {
digitalWrite(BITONE, HIGH);
digitalWrite(BITTWO, LOW);
digitalWrite(BITTHREE, LOW);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS2) == LOW) {
digitalWrite(BITONE, LOW);
digitalWrite(BITTWO, HIGH);
digitalWrite(BITTHREE, LOW);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS3) == LOW) {
digitalWrite(BITONE, HIGH);
digitalWrite(BITTWO, HIGH);
digitalWrite(BITTHREE, LOW);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS4) == LOW) {
digitalWrite(BITONE, LOW);
digitalWrite(BITTWO, LOW);
digitalWrite(BITTHREE, HIGH);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS5) == LOW) {
digitalWrite(BITONE, HIGH);
digitalWrite(BITTWO, LOW);
digitalWrite(BITTHREE, HIGH);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS6) == LOW) {
digitalWrite(BITONE, LOW);
digitalWrite(BITTWO, HIGH);
digitalWrite(BITTHREE, HIGH);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS7) == LOW) {
digitalWrite(BITONE, HIGH);
digitalWrite(BITTWO, HIGH);
digitalWrite(BITTHREE, HIGH);
digitalWrite (BITFOUR, LOW);
}
if (digitalRead(POS8) == LOW) {
digitalWrite(BITONE, LOW);
digitalWrite(BITTWO, LOW);
digitalWrite(BITTHREE, LOW);
digitalWrite (BITFOUR, HIGH);
}
// running_cycle gets set once per cycle, so the TURRET_MOVE_PIN signal just initiates a cycle
// This would be the place to initialise with a counter that counts down for moving x number of positions
// This sets the intial cycle start state, which is the state it should be in anyway, but it's belt and braces!
if(running_cycle == FALSE && digitalRead(TURRET_MOVE_PIN) == LOW) {
running_cycle = TRUE;
stopping_cycle = FALSE;
digitalWrite(TURRET_CLOCKWISE_RUN_PIN, LOW);
moving_clockwise = FALSE;
digitalWrite(TURRET_COUNTER_CLOCKWISE_RUN_PIN, LOW);
moving_counter_clockwise = FALSE;
digitalWrite(INDEXING_SOLENOID_PIN, LOW);
}
// While the cycle is running, constantly evaluate the state
while(running_cycle) {
strobe_signal = digitalRead(STROBE_SIGNAL_STATUS_PIN);
index_control_switch = digitalRead(INDEXING_CONTROL_SWITCH_PIN);
lock_control_switch = digitalRead(LOCKING_CONTROL_SWITCH_PIN);
// If the stopping_cycle state hasn't been reached, and the turret isn't moving, start clockwise movement
// Wait one second just so the strobe signal doesn't immediately trigger the stopping_cycle state
// Can probably make that more efficient, recording state for when it turns off, before checking for it again.
if (stopping_cycle == FALSE && moving_clockwise == FALSE) {
digitalWrite(TURRET_CLOCKWISE_RUN_PIN, HIGH);
moving_clockwise = TRUE;
delay(1000);
continue;
}
// If the stopping_cycle state has not already been reached, check for the strobe signal
// if we've hit the strobe signal, then start to engage the locking pin
// also set the 'stopping_cycle' state
if (stopping_cycle == FALSE && moving_clockwise ==HIGH && strobe_signal == LOW) {
digitalWrite(INDEXING_SOLENOID_PIN, HIGH);
stopping_cycle = TRUE;
continue;
}
// If the stopping_cycle state is reached, check the index control switch, if it's set, stop clockwise rotation
// Wait 50ms and start moving counter-clockwise
// if(stopping_cycle && moving_clockwise && index_control_switch == HIGH) {
if(stopping_cycle && moving_clockwise == HIGH && index_control_switch == LOW) {
digitalWrite(TURRET_CLOCKWISE_RUN_PIN, LOW);
moving_clockwise = FALSE;
delay(50);
digitalWrite(TURRET_COUNTER_CLOCKWISE_RUN_PIN, HIGH);
moving_counter_clockwise = TRUE;
continue;
}
// If the cycle stopping_cycle state has been reached, and counter clockwise rotation is still taking place
// Check the lock control switch, and stop motion. Wait 200ms and then release the indexing solenoid
if (stopping_cycle && moving_counter_clockwise == HIGH && lock_control_switch == LOW) {
digitalWrite(TURRET_COUNTER_CLOCKWISE_RUN_PIN, LOW);
moving_counter_clockwise = FALSE;
delay(200);
digitalWrite(INDEXING_SOLENOID_PIN, LOW);
running_cycle = FALSE;
delay(1000);
continue;
}
}
}
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
FOR SALE: Denford Cyclone
By m_c in forum Items For SaleReplies: 5Last Post: 27-06-2022, 10:55 PM -
WANTED: Denford cyclone cnc lathe
By mark35gun in forum Items WantedReplies: 0Last Post: 24-11-2020, 11:17 AM -
FOR SALE: Denford Cyclone
By Lee.b in forum Items For SaleReplies: 6Last Post: 03-10-2020, 08:06 PM -
Denford Cyclone -turret positioning error
By Dangle_kt in forum Denford LathesReplies: 8Last Post: 01-03-2018, 01:37 PM -
Fanuc Denford Cyclone X axis Alarms
By jamesgates1000 in forum Denford LathesReplies: 7Last Post: 02-12-2015, 05:35 PM
Bookmarks