Here you can find information about the used electronics and their implementation in the project.

Microcontroller

The microcontroller is the heart of the electronic circuit. Ours was a PIC16F876A of Microchip. A block diagram of the controller:

To ensure a correct functioning, some basic components are needed. First of all, the controller needs a stabilized source of 5V. This can be done by using a voltage regulator and a set of capacitors to stabilize the incoming voltage:

Next, we need to determine the frequency at which the controller works. Each command is executed at the hand of clock pulses. An oscillator and some capacitors can be used for this purpose:

 

In our case, an oscillator of 8 MHz was used. The most instructions need 4 clock cycles to be executed; a few statements need double the time. At 8 MHz, this leads to 0.5 µs processing time for each command.

These are the basic components that the controller needs. A reset function can be added in order to restart the program when the controller ceases to respond or is not reacting properly. A MCLR pin of the microcontroller is provided for this reason. It is an active low pin; the reset will happen if the pin is low. A circuit to manually reset can be designed as:


 

These our the basic requirements for the controller.

More information about this CHIP can be found in this dutch document or in the datasheet.

Back

Shift Register

Because the number of inputs in the PIC is limited we chose to use a shift register to read out the status of each button. As shift register we chose for the HC597.


  
We needed 7 buttons ( 3 for the selection of floor 1,2 and 3 inside the elevator and 4 buttons for outside the elevator on the different floors, the buttons 1UP, 2DOWN, 2UP and 3DOWN). We chose to connect these buttons to the entries D1,D2,...,D7.

In order to read out this buttons a procedure must be followed.



The pic is connected to the shift registers as followed

Q PinA,4
SHcp PinA,3
STcp PinA,2
PL PinA,1


MR is always connected to the +5V.
First the status of al the buttons must be transferred from the pin to the input latches. This is done by setting a rising flank on STcp. Then pin PL is set low to transfer the status from the input latches to the input flipflops. Afterwards this pin is set high again.

Now the value of D7 is given at the exit Q of the shift register.  The pic reads this value and if we now send a rising edge to SHcp the next value is given (D6) this is repeated 6 times to get all the statusses of the input buttons.

An overview flowchart of how de shift register was used is given below:


Motor Drive Chip


The motor that feeds our elevator needs to be controlled in sense and speed of rotation.
 
A possibility would be to directly feed the motor by the microcontroller. However, the latter is limited to 25 mA output current. A few tests on the motor revealed that larger currents up to a few hundred mA could be possible during service. Thus, a current amplification device is needed between microcontroller and motor terminals.
 
An interesting possibility is the use of an H-bridge to accomplish this. The two basic states of the H-bridge are shown below.

Four switches allow the motor to be run backwards or forwards. When the switches S1 and S4 (left up and right down) are closed (and S2 and S3 are open (left down and right up) )) a positive voltage will be applied across the motor. By opening S1 and S4 switches and closing S2 and S3 switches, this voltage is reversed, allowing reverse operation of the motor.

Next the speed of the motor needs to be controlled. Best suited is the use of a Pulse Width Modulation technique. By chopping the voltage at the motor terminals and controlling the duty cycle, the motor sees a partial voltage and hence it's speed will be easy adjustable. Fortunately, a PWM mode is available on the microcontroller. The logic control scheme would be:


The microcontroller sends a digital control signal 1 or 0, which due to the inverters, implicate that either transistors one and three, or two and four, are closed whilst the other pair is opened. That way the direction of the motor is controlled. The enable signal needs to be high in order to feed the motor. A low enable signal opens all switches and thus the motor will cease to rotate. Sending a PWM-signal as enable input, therefore allows speed control of the motor. 

Thus, this electronic circuit can be built with some transistors and inverters. Although possible, this would be quite time-consuming. Luckily, these kind of circuits already exist as integrated circuits and are commercially available. An example of such a motor driver chip is the L293b. It is capable of delivering 1A continuosly and 2A non repititve, which is satisfactory for our configuration.

The circuit with the motor driver chip and the microcontroller looks like this:

De thruth table:


The direction of the motor is controlled by sending a set of complementary digital signals to Input1 and Input2. The speed of the motor is controlled by varying the time that the chip is on and off. By modulating the duty cycle of the enable input, the supply voltage fed to the chip is chopped resulting in a reduced voltage and speed.

Experimentally, it was noticed that the chopped voltage at the enable input needed to be at least three volts in order to slowly move the lift. Therefore, as you can verify in the code, the duty cycle during the variable speed regulation was limited to a certain minimal value during braking.

Back

Analog to Digital conversion


A potentiometer was used as a sensor to read the height of the elevator at any time. It generates a voltage between 0V and 5V. The higher the cage, the higher the voltage. However, in order to use this information, it needs to be transformed into a digital signal.
 
Fortunately, the microcontroller has a ADC built in. The analogue signal charges a sample and hold capacitor. The converter then generates a 10-bit digital number via successive approximation. The value of the most significant bit is determined by whether the input signal is in the upper or lower half of the valid input range. The next most significant bit is determined by whether the input is in the upper or lower half of the remaining range, and so on, until the least significant bit is determined. For programming purposes, the 8 most significant bits of this number our stored and used in the rest of the program. Thus the resolution is about 1/256th of 5V. 5V corresponds to a height of about 80cm, thus a resolution of 3mm, which is sufficient for our goals.
 
A few steps are required to properly set up the converter and to perform a conversion. First, the I/O pin to be used for analog-to-digital conversion is configured as an analog input. This channel to convert is then selected and the module configured and enabled. A delay for the acquisition time is then provided.  Acquisition time is the amount time required to charge the holding capacitor on the front end of an analog-to-digital converter. The holding capacitor must be given sufficient time to settle to the analog input voltage level before the actual conversion is initiated. Once the conversion has completed, the result can be read. Thus, the steps in our program to execute a correct conversion are:

 

  • ·        Configure I/O pins
  • ·        Select channel to convert
  • ·        Configure and enable the A/D
  • ·        Wait the acquisition time
  • ·        Initiate the conversion
  • ·        Wait for the conversion to complete
  • ·        Read the result
 The ADCON0 and ADCON1 registers are used to configure the converter; more information can be found in the datasheets.
Back

Traxmaker

A working test-circuit using these components was made.



SInce this is not a very neat way of working a printboard of that circuit was drawn using traxmaker.



It was also made! After attaching the compontents it looked like this.
Front:


Back:



Back

Datasheets   PIC16F876A HC597
L293

Pictures