Thread: Denford cyclone conversion
Hybrid View
-
16-11-2021 #1
I think this was the original code and in the end more complicated than what was needed. Ill see what else I can find.
#define TRUE 1
#define FALSE 0
#define TURRET_MOVE_PIN 2
#define STROBE_SIGNAL_STATUS_PIN 3
#define INDEXING_CONTROL_SWITCH_PIN 4 // Double-check this
#define LOCKING_CONTROL_SWITCH_PIN 5 // and this one
#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
// 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
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 - 5
pinMode(LOCKING_CONTROL_SWITCH_PIN, INPUT_PULLUP); //Locking Control Switch - 6
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
}
void loop() {
// 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) == HIGH) {
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) {
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 && lock_control_switch == HIGH) {
digitalWrite(TURRET_COUNTER_CLOCKWISE_RUN_PIN, LOW);
moving_counter_clockwise = FALSE;
delay(200);
digitalWrite(INDEXING_SOLENOID_PIN, LOW);
running_cycle = FALSE;
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



Reply With Quote
Bookmarks