. .
Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    Chaz's Avatar
    Lives in Ickenham, West London, United Kingdom. Last Activity: 26 Minutes Ago Has been a member for 9-10 years. Has a total post count of 1,601. Received thanks 110 times, giving thanks to others 69 times.
    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;
    }
    }
    }

  2. #12
    I’m new to Arduino so at the moment that does not make a owl lot of sense but I’ll have a read through it latter today and try to figure out what it is doing
    Thanks SO much for you help with this

    Cheers. Paul


    Sent from my iPhone using Tapatalk

  3. #13
    Chaz's Avatar
    Lives in Ickenham, West London, United Kingdom. Last Activity: 26 Minutes Ago Has been a member for 9-10 years. Has a total post count of 1,601. Received thanks 110 times, giving thanks to others 69 times.
    No problem. Another option is to go via something like a Click PLC or do the 'code' inside whatever controller you are going to use, if it supports the inputs / outputs.

  4. #14
    How many inputs and outputs are we talking about?


    Sent from my iPhone using Tapatalk

  5. #15
    I’ve used arduinos on 3D printers I’ve built but that is just downloading martin as the sketch and loading to the arduino. I’ve never actually done any coding it the arduino language


    Sent from my iPhone using Tapatalk

  6. #16
    Chaz's Avatar
    Lives in Ickenham, West London, United Kingdom. Last Activity: 26 Minutes Ago Has been a member for 9-10 years. Has a total post count of 1,601. Received thanks 110 times, giving thanks to others 69 times.
    The language isnt too difficult to understand. There is a lot of resource out there.

  7. #17
    Looking at the video I can see the arduino at the top and a four relay board below it
    What are the two green boards at the right hand middle ?
    I can make out what I think are proximity sensors at the very bottom.
    What are the three units on the Din rail that light up?


    Sent from my iPhone using Tapatalk

  8. #18
    Did you have it hooked up to the turret and indexing it from tool to tool ok ?


    Sent from my iPhone using Tapatalk

  9. #19
    Chaz's Avatar
    Lives in Ickenham, West London, United Kingdom. Last Activity: 26 Minutes Ago Has been a member for 9-10 years. Has a total post count of 1,601. Received thanks 110 times, giving thanks to others 69 times.
    Quote Originally Posted by depronman View Post
    Looking at the video I can see the arduino at the top and a four relay board below it
    What are the two green boards at the right hand middle ?
    I can make out what I think are proximity sensors at the very bottom.
    What are the three units on the Din rail that light up?


    Sent from my iPhone using Tapatalk
    Green boards are opto couplers from memory. I have it all in a box somewhere, can check over the weekend.

    The din units are just relays.

  10. #20
    That would be great if you can. Don’t want to order the wrong stuff


    Sent from my iPhone using Tapatalk

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FOR SALE: Denford Cyclone
    By m_c in forum Items For Sale
    Replies: 5
    Last Post: 27-06-2022, 10:55 PM
  2. WANTED: Denford cyclone cnc lathe
    By mark35gun in forum Items Wanted
    Replies: 0
    Last Post: 24-11-2020, 11:17 AM
  3. FOR SALE: Denford Cyclone
    By Lee.b in forum Items For Sale
    Replies: 6
    Last Post: 03-10-2020, 08:06 PM
  4. Denford Cyclone -turret positioning error
    By Dangle_kt in forum Denford Lathes
    Replies: 8
    Last Post: 01-03-2018, 01:37 PM
  5. Fanuc Denford Cyclone X axis Alarms
    By jamesgates1000 in forum Denford Lathes
    Replies: 7
    Last Post: 02-12-2015, 05:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •