An Overview of the Model
To be quite honest, there is no model! To me, the electronics are more important than the building of a full scale model. The circuit described can be used in, for instance, a cliff lift, but for the gathering in Mechelen (Belgium) I made a very simple crane (shown below). Later on, the electronics was used in my cliff lift model which is described at the end of this article.
An elevator, shown here with three Lego figures, goes up 50cm, comes back down again, and stops 1mm above the table. The design is my own.
The electronics are used here to compensate for the shortcomings of the mechanics. When the movement has to stop exactly, it is not sufficient to switch off the motor, because it continues to rotate for a while and the stop position depends on the mechanical resistance and inertia of the model. In my design the motor turns - at the end of the mechanism’s travel - at a very low speed so that the motor can be stopped immediately by short-circuiting the motor winding.
The speed and direction of the motor is controlled by a microcontroller which obtains positional information about the motor from four slotted opto switches fitted to the model. A block diagram of the system is shown in figure 1.
A gear wheel (no 27c) with 95 teeth is connected to the winding drum of the lift, via a set of gears, so that it makes half a turn every time the lift goes up or down. Four slotted opto switches are mounted with 1” angle brackets around the gear as shown in figure 2. A fishplate is mounted on the gear with a long bolt and washers such that it can pass through the centre of each slotted opto switch.
Slotted Opto Switches
The slotted opto switches I have used in the model consist of two separate sections as shown in figure 3. The first section is an infrared light emitting diode (LED) acting as a transmitter. The receiver, in the second section, is a phototransistor. Between the two sections there is a small gap so that an object may cut the infrared beam of light that passes between the two sections.
The circuit that makes the switch useful is shown in figure 4. The phototransistor is wired as shown so that when an object cuts the infrared beam of light, the output of the switch becomes 5V instead of the usual 0V when there is no object obstructing the beam.
In order to mount the slotted opto switches in a Meccano model I have developed a printed circuit board (PCB) that is the same size as perforated strip part no 6a (1” x 1/2”).
An slotted opto switch mounted on a printed circuit board
Using a Microcontroller
I have used the PIC16C84 microcontroller from Microchip before and so have discovered the advantages of a software design:
The block diagram of the system in figure 1 shows the four inputs from the slotted opto switches connected to a port of the microcontroller and the two Speed and Direction outputs from another port which are fed into another IC, the L6219.
The L6219 Motor Driver from SGS-Thomson
The L6219 is a bipolar monolithic integrated circuit intended either to control and drive the windings of a bipolar stepper motor, or to bi-directionally control up to two DC motors. The power stage is a dual full bridge capable of sustaining 46V and including four diodes for current recirculation. Internal pulse width modulation (PWM) can control an output current of up to 750mA with a maximum start-up current of 1A. More information about this IC can be obtained from the SGS Thompson website at http://us.st.com/stonline/index.shtml.
In order to short-circuit the motor winding when the motor is required to stop dead as mentioned previously, it is connected to the L6219 driver via the Normally Open (N.O.) contacts of a relay. The PWM pulses produced by the L6219 continually trigger a 555 time delay (monostable) circuit, the output of which keeps the relay switched on. 40ms after the PWM pulses cease, the monostable time period ends and the relay is switched off, and the motor stops rotating immediately because its winding is short-circuited.
To write the PIC16C84 program I used the JAL (Just Another Language) compiler which was developed by Wouter van Ooijen (Holland). It is a combination of the C & BASIC languages, specially developed for the Microchip PIC16x84 microcontrollers. The compiler and libraries can be downloaded from his website, www.xs4all.nl/~wf/wouter/pic/jal/index.html. For information about the PIC series of microcontrollers, visit the Microchip website at www.microchip.com.
The program model I used is a ‘finite state’ machine. The state of the program can be followed on a 7-segment display mounted on the main PCB:
The Auto Run Mode
As a demonstration model, it can be run fully automatically by pushing the Reset button while the Start button is already pushed in so the Auto Run mode starts. The lift then goes up and down automatically every 15 seconds.
The Cliff Lift
Below are some pictures of my cliff lift model. It works with the PIC16C84 board as described
above. The four slotted opto switches are now fixed in the model. At the bottom of picture 1 are the end switches.
In the middle of the track, picture 4, are the left and right switches used to slow down the motor speed.
The resistors given below are those used in Figure 4. The slotted opto switch in the photo is not available from Maplin, but they do stock a similiar reflective opto sensor. A range of slotted opto switches is available from Rapid Electronics (see links page for contact details).
Order the above items from Maplin via our Circuits Shop and help support the Electronics in Meccano website, without affecting the price you pay! Just click on an item for information about it and/or to add it to your Maplin order.
Orders can also be placed by telephoning Maplin on 0844 557 6000, or visiting their website at www.maplin.co.uk. Prices quoted are taken from the Winter 2013 Maplin catalogue and include VAT at 17.5%.