Issuu on Google+

EXPERIMENT TITLE:

Controlling a fischertechnik Conveyor Belt with Arduino board

PRODUCTS USED:

CHALLENGE:

Interface and control a conveyor belt model (24 Volts, fischertechnik) with an Arduino board (5 Volts)

AUTHOR:

Pietro Alberti (Media Direct srl, Italia) – pietro@mediadirect.it

CREDITS:

Wohlfarth Laurenz (fischertechnik GmbH, Germany) Dedicated to my family: Marco, Luca, Chiara, Francesco and Maria

10th January, 2013: Final version

© Media Direct srl – Italy

1/11


fischertechnik: MODEL DESCRIPTION This fischertechnik conveyor belt is preassembled and mounted on a base plate. - several conveyor belts can be connected to each other to form a conveyor belt of any length. Technichal specifications: - Power supply required: 24V DC (not included) - Dimensions: about 275 x 210 x 70 mm (LxWxH) - Length: 275 mm - 1 Output, 24 V DC (1 motor to drive the conveyor belt forward and backward) - 3 Digital Inputs, 24 V: 2 light barriers (consisting of phototransistor and lens tip bulb (which can be connected together to an output for the control or directly to the power supply) and 1 pulse counter coupled to the motor axle (can be used as an encoder to get the distance traveled) - 1 workpiece diameter 29 mm, h = 25 mm (it's possible to use workpieces with diameter up to 29 mm)

Š Media Direct srl – Italy

2/11


The fischertechnik model comes with a detailed pinout description:

This fischertechnik model works with 24 Volts! 24 V motor:

Š Media Direct srl – Italy

24 V lamp:

24 V phototransistor:

3/11


ESCRIPTION Arduino: COMPONENTS 1 Arduino Duemilanove board, but any Arduino board can be used

1 TinkerKit Sensor Shield module: only to simplify me the wiring (optional)

2 TinkerKit relays module: to drive the motor (forward and backward) 2 potentiometers (10 kOhm) to reduce 24V 5V (from light barriers) Power supply (for Arduino)

It comes from a USB cable connected to the computer. When programmed, you can use a 9V battery.

Arduino works with 5 Volts!

Š Media Direct srl – Italy

4/11


THE CHALLENGE The fischertechnik model requires 24V, since it’s used as a TRAINING MODEL to be controlled from real life device like PLC from Siemens. So the motor and the lamps needs 24 V. Arduino can drive the 24V motor without problem: I used 2 relays. Fischertechnik now offers two outputs for the driving motor: Q1 to drive forward; Q2 to drive backward: great! But the signal coming from the light barrier is 24 V, too! Arduino accepts only 5 V, not 24 V. The challenge is reading the light barriers signal with Arduino! It’s a problem of signal conditioning (max: 5V, 40 mA). I used a very simple circuit with a 10 KOhm potentiometer. Warning: I connected the ground from fischertechnik (-) to Arduino's ground: without a common ground, the ADC input is just going to read noise.

Before connecting the wires to Arduino I manually tuned the potentiometer with a multimeter: I stopped when I arrived at 5 V. From an maths point of view: Vout = Vin *R2/( R1 + R2) V

R1+R2

R2

Vout = Vin *R2/( R1 + R2)

IMAX

0V 24 V

10.000 Ω 10.000 Ω

≈ 2.000 Ω

0V 5V

0 3 mA

So now the voltage is about 5V and the current is about few mA. I used some fischertechnik plugs to avoid using soldering:

© Media Direct srl – Italy

5/11


HOW THE MODEL WORKS: ALGORITHM’S DESCRIPTION My goal is to move forward and backward a small black cylinder between the two light barriers. I developed a program and then I’ve uploaded it to Arduino (when I give power to Arduino via USB cable or with an external 9V battery, the program starts automatically). I implemented the following actions 1-3, repeated indefinitely (default): 1) Motor forward (from light barrier 1 to the light barrier 2): the workpiece must be placed in the middle of the conveyor belt, only once ;-) 2) when the workpiece arrives on the light barrier 2: stop the motor, wait 3 s, reverse motor backward 3) when the workpiece arrives back on the light barrier 1: stop the motor, wait 3 s, reverse motor backward for 1.5 s, (enough to place the workpiece about in the middle position) 4) repeat cycle from point 1) PROGRAMMING ARDUINO (Processing) I used Processing to program Arduino, in C language. The program is very simple, just to test the system. More improvements can be done and in more different ways. I programmed the system by defining a variable state (“stato”), to understand “where we are”. stato = 0: workpiece in the middle of the conveyor belt and motor forward stato = 1: workpiece arrived on the light barrier 2 (stop motor, wait 5 s, reverse motor) stato = 2: workpiece arrived back on the light barrier 1 (stop motor, wait 5 s, reverse motor) I used the Serial Monitor tool of Processing to show messages on the computer about the state of the system (debug/informations). /* Outputs: Inputs:

pin 10: motor backward (digital output: HIGH/LOW) pin 11: motor forward (digital output: HIGH/LOW) pin A0: light barrier 2 (-> analog input to Arduino 0-5V) pin A1: light barrier 1 (-> analog input to Arduino 0-5V) 0V = object present (phototransistor not illuminated) 5V = object not present (phototransistor illuminated) I decide for a threshold about 2.5V to decide if the object is present or not.

*/ const int MotAvantiPin = 11; const int MotIndietroPin = 10; int stato; int sensorValue; float voltage;

// state of the system

// sensor readings: 0...1023 // sensor readings in voltage: 0...5 Volt

// 'setup' runs once void setup() { Serial.begin(9600); // start serial communication @ 9600 bps (to debug) digitalWrite(MotIndietroPin, LOW); // Motor backward off digitalWrite(MotAvantiPin, HIGH); // Motor forward on Serial.println("Conveyor forward"); Serial.println("Place the cylinder in middle position"); stato=0; // 0 = initial state } // 'loop' runs forever void loop() { if (stato==0) { sensorValue = analogRead(A0); // voltage = sensorValue * (5.0 / 1023.0); // if (voltage < 2.5) { // cylinder arrived at light barrier stato=1; // update variable state digitalWrite(MotAvantiPin, LOW); // Serial.println("Arrived at FC2: stop delay(3000); //pause 3 s Serial.println("Conveyor backward"); © Media Direct srl – Italy

light barrier 2 readings: 0…1023 convert analog reading from 0...1023  0...5V 2 Motor stop 3 s, then go back"); 6/11


}

digitalWrite(MotIndietroPin, HIGH);

// Motor backward on

} if (stato==1) // waiting for light barrier 1 signal { sensorValue = analogRead(A1); // light barrier 1 readings: 0…1023 voltage = sensorValue * (5.0 / 1023.0); // convert analog reading from 0...1023  0...5V if (voltage < 2.5) { // cylinder arrived at light barrier 1 stato=2; // update variable state digitalWrite(MotIndietroPin, LOW); // Motor stop Serial.println("Arrived at FC1: stop 3 s, then go forward"); delay(3000); //pause 3 s digitalWrite(MotAvantiPin, HIGH); // Motor forward on for 1.5  middle position delay(1500); //pause 1.5 s Serial.println("---- STARTING POSITION ----"); digitalWrite(MotAvantiPin, LOW); // Motor stop delay(5000); //pause 5 s digitalWrite(MotAvantiPin, HIGH); // Motor forward on stato=0; // initial state } } }

© Media Direct srl – Italy

7/11


PHOTOS AND NOTES 1st release: fischertechnik conveyor belt + Arduino Duemilanove Wires connected without planning, very alpha stage, but “very bright”. Wires connected to the spring contact on the fischertechnik board.

2nd release: Using a flat cable (26 pin) for a better wiring and making easy to unplug the fischertechnik model from the Arduino world. The 24 V comes from a Siemens LOGO power supply I already used in the past to interface Siemens PLCs with fischertechnik Training Models. Focus on Arduino section: watch the 10 kOhm potentiometer I used to reduce the signal coming from the light barrier pin (24 V).

Final release: I built an interface box between Arduino and fischertechnik: - soldering breadboard - 3 trimmer, 10 Kohm - 2 relays, tinkerkit - 1 header, 8 pin (Arduino side) - 1 header, 8 pin (fischertechnikside) - 1 terminals block (for 24V power supply) I also implemented a pulses counter coming from the switch I3 coupled to the motor shaft (it acts like an encoder), displaying this data in serial. Finally I interfaced the system with the Processing environment, synchronizing information via serial transmission.

LAST UPDATE: 10 January 2013 © Media Direct srl – Italy

8/11


I decided to close the project attempting to build a system as “clear” as possible. I built an interface box between Arduino and fischertechnik: - soldering breadboard - 3 trimmer, 10 Kohm - 2 relays, tinkerkit - 1 header, 8 pin (Arduino side) - 1 header, 8 pin (fischertechnikside) - 1 terminals block (for 24V power supply)

In management software Arduino I implemented a counter of impulses coming from the switch I3 coupled to the motor shaft (encoder type), displaying this data in the serial. Interesting is the software solution to avoid the rebound effect when switching the digital inputs. State: 0,1,2,3 Pulses: 100 + nr_of_real_pulses Finally I interfaced the system with the Processing environment: I’ve dynamically synchronized the motion of a green circle (virtual) with the (real) workpiece. Idem for the light barriers (I1 and I2), with red LEDs on/off. Processing receives Arduino via serial digital data representing the state (values: 0,1,2,3,4) or the number of pulses counted (increased by 100).

© Media Direct srl – Italy

9/11


SCREENSHOTS WITH SOFTWARE “PROCESSING” STATUS 0: The piece (green circle) moves from left to right

SCREENSHOT

1: The piece (green circle) has reached the stroke end on the right: - LED sensor on right - Display Number of Pulses

2: The piece (green circle) moves from right to left

3: The piece (green circle) has reached the stroke end on the left: - LED sensor on left - Display Number of Pulses

The cycle starts again from status =0…

FINAL COMMENTS © Media Direct srl – Italy

10/11


I thought it was a project too simple (only 3 inputs and 2 outputs). Then instead turned out to be very interesting and full of technical hardware/software and ideas for improvements to be implemented later. Here are some ideas. Hardware: - Adaptation electric 24  5 Volts. Note that my solution is probably the simplest and cheapest. Surely you can improve the circuit using operational amplifiers, diodes, etc.. - Number of Inputs/Outputs: you could increase the number of inputs/outputs (thus using more relays, perhaps smaller) and therefore be able to handle even the most complex models of fischertechnik 24V (robotic arm, conveyor, pneumatic station, ... ) -… Software: The software I've realized is "essential" right to operate the system. But many ideas came to me as possible additions and/or variations: - Insert buttons on the screen to start/stop of the model (using serial communication) - Insert sound/animations correlated to the state of the system - Use another development environment, maybe Visual Basic / C - Control the system via the Web, using an Arduino Ethernet (there is even an appropriate shield) and using it as a Web server -…

Thank you for your attention!

Pietro Alberti pietro@mediadirect.it 10th January, 2013

© Media Direct srl – Italy

11/11


Transportband_EN