Thursday, November 20, 2014

Sequence Control Using Arduino

I am considering Arduino as one of the method to making controller programming easier.

Nowadays it seems that everyone is using Arduino, you can even see elementary school kids programming using Arduino.

Accessibility of Arduino is incredible.
Leaving performance out of discussion, I have never seen anything like Arduino, which makes programming sooooo easy, in my lifetime. 

Thus, I started to think "what if I make controller using Arduino...?"

MPU and libraries used in Arduino are good enough to use for controller.
This is very obvious because ATmega328 that are being used for Arduino are already widely used for controller.

However, MPU is too exposed in Input/Output circuit. CANNOT BE USED
Also, it seems that designer has not thought of any power system. CANNOT BE USED

If you think about it in another way, you can use Arduino as controller if you make modification to Input/Output circuit and power system.

Modifying Arduino as whole will be too tiresome so I am suggesting a following experimental changes.

Input/Output Circuit -> Remote IO Module for FA
Power System -> Power Supply for FA

This is the first example.

I have tried Feedback Control and Sequence Control using Arduino.

The controlled system is Drilling Machine.

Drilling Machine

Drilling Machine Structure



Machine is composed of 3 parts.


PRESS

Drilling Machine Press - holds samples that are going to be drilled firmly

DC 24V Motor with reduction gear and worm gear drives metal structure to move up and down with powerful strength.

Top part has a limit switch that decides the stop location. However bottom part does not have limit switch. Location of bottom limit changes depending on the thickness of the sample, thus it is impossible to put limit switch.

Instead of limit switch, we measure the load on the press motor to decide the bottom limit. We need to constantly measure the current in the press motor and stop the motor when the current skyrockets. This step requires lots of site tuning.


ELEVATOR

Drilling Machine Elevator - holds drill motor

This also has a DC 24V Motor with reduction gear and rack and pinion gear drives drill motor to move metal structure up and down.

It has limit switch at both top and bottom.


DRILL

Drilling Machine Drill

On platform, there is big motor with AC 220V. On the axis there is drill bits.
The motor load needs to be monitored all the time, because if the sample does not get drilled easily because it is too firm the drill bits needs to move up and down multiple times and also because if this does not work the drilling needs to be stopped.
To measure the motor current, the motor power line wraps CT twice.



Arduino Interface


For direct connection with the machine I am going to use ADAM-4050 and ADAM-4017, which are both made for industrial purposes. ADAM-4050 has 8 channel Digital Out and 7 channel Digital In and ADAM-4017 has 8 channel Analog In. Both use RS-485 connections.

Below is channel list.

ADAM-4050

DO0: Elevation Motor ON
DO1:                         Direction(+)
DO2:                         Direction(-)
DO3: Press Motor       ON
DO4:                         Direction(+)
DO5:                         Direction(-)
DO6: Drill Motor        ON
DO7: Fan Motor         ON

DI0: Limit Switch Position UP
DI1:                                 MID
DI2:                                 BOTTOM
DI3: Manual Switch           START
DI4:                                 STOP
DI5:
DI6:

Elevator Motor and Press Motor both moves up and down, which means it is controlled both ways thus it needs 3 ch per motor. Drill Motor is one way, since it only needs to start the motor. Fan Motor is 24V DC. It also only needs to be turned on. It sends air to the drill bits cooling it down. Fan Motor is kept ON for 30 seconds even after the drilling.

We use three limit switch: PRESS' midpoint, top, and bottom.

There are two switches for manual control. One for starting and another one for stop.


ADAM-4017

VIN0: Elevation Motor Current
VIN1: Press Motor Current
VIN2: Drill Motor Current
VIN3:
VIN4:
VIN5:
VIN6:
VIN7: 

It reads current flowing in each motor.
Elevation Motor and Press Motor puts shunt resistance on the motor drive and measures the current. For Drill Motor we use CT sensor to read the converted current value. Readings from CT sensor are AC, thus it shows value that goes through full-wave rectifier and integrated using 60Hz LPF. In this case we only need to know the relative value of the load thus we do not measure the RMS value.


Below are connection diagram for ADAM-4050/ADAM-4017 and the machine.
(Detailed circuit diagram for the machine is company's asset thus it is not released publicly; however, if you really need the diagram please contact privately.)

ADAM-4050/ADAM-4017 and the Machine Connection Diagram

OR

ADAM-4050/ADAM-4017 and the Machine Connection Diagram

OR

ADAM-4050/ADAM-4017 and the Machine Connection

ADAM-4050/ADAM-4017 and the Machine Connection


Sequence Control

STANDBY

At standby PRESS and ELEVATOR are all resting at the top. All motors are switched OFF and waits for the START switch to be ON.


PRESS DOWN

START switch is ON. Until one of the stop condition is satisfied run the Press Motor downward.

Stop Conditions:
  1. If the Press Motor Shunt current value has passed 120% of moving average line.
    Moving average line is the calculated average value before the press reaches the sample. When the press starts to push down on the sample the motor current rapidly increases and when it exceeds 120% it should stop.
  2. If the Press Motor Shunt voltage has passed 3V.
    This is FAIL-SAFE. For some reason if there are too much pressure pushing down on the sample with large moving average line the Press should stop.
  3. If it has been over 17 seconds after the press motor has started working.
    This is also FAIL-SAFE. The press should not be working more than 17 seconds.


ELEVATOR DOWN

Now we start to lower the elevator that holds the drill. Turn ON the Drill Motor and Fan Motor. Until one of the stop condition is satisfied run the Elevator Motor downward.

There is only one stop condition:
  1. If the elevator has reached the bottom point.
    Bottom limit switch decides this. The drill bits have successfully penetrated the sample.

For the following cases, we higher the drill for a little bit and lower it again. When it does not drill well it is better to move up and drill again rather than continuously trying to drill. 
  1. If the Drill Motor's current rises more than 7% of the moving average line.
    Raise the drill (raise elevator) until the current falls below the 7% line and then lower the drill (lower elevator) again.
  2. If the Drill Motor has been on for more than 17 seconds.
    Move the drill up until the top line (raise the elevator) and then lower (lower the elevator). This is the same as restarting. Thus set the maximum of this action to 6. If it exceeds 6, we can safely conclude that the sample is impenetrable.

ELEVATOR UP

Drill work has finished whether it succeeded or not. Let's quickly put the elevator back to where it was.

Run the Elevator motor in UP mode until it reaches the top point. Keep the Drill Motor ON. If the Drill Motor has been turned OFF it might get stuck in the sample thus preventing it from being raised.

When it reaches the top point, turn both Elevator and Drill Motor OFF.


PRESS UP

Run the Press Motor in UP mode until it reaches the MID point.
When it reaches MID point, turn the Press Motor OFF. Leave the Fan Motor ON for extra 30 seconds.


In any stages, if the STOP switch is ON, go back to STANDBY mode.



SOURCE CODE

Source code can be viewed in the following site.
https://github.com/michelleseo/Arduino_Web/blob/master/SequenceControl/MicroFactory.ino

Explanation of code will be difficult since there are too much. If necessary I will answer any questions.



The following is the working video.