Mechatronics Laboratory Report:
The computer control is an embedded microprocessor, and so the experiment illustrates the principals involved in mechatronic products. In this procedure the operation of an electromechanical combination lock is investigated.
The experiment consists of two parts:
1) To determine the lock combination manually as in experiment 2.
2) To program a microprocessor to control the stepper motor to produce the same sequence of moves, both in open and closed loop.
1) To relate theoretical and experimental results.
2) To illustrate the elements of a mechatronic system.
3) To introduce concept of microcontroller systems.
1) The stepper motors, the outputs from the optical sensors, and the power supply to the housing were connected. The microcontroller circuit housing was connected to the computer parallel port and to the drive housing. It was ensured that microcontroller was in run mode. The power to the microcontroller circuit was then switched to on.
2) It was ensured that the stepper motor was switched off. The lock combination was determined using the manual dial.
3) The first lock wheel was set in the initial position by turning the manual dial clockwise. The LED was turned green. The combinations were noted after this.
4) It was made sure that the dial was moved manually whilst the motor was powered up as this would have damaged the gearing system.
5) The combination found from the manual dial was translated into equivalent number of steps for the motor.
6) The microprocessor programming instructions given in the handout were followed and the results obtained from the motor were recorded.
7) The obtained combination had to be converted into units as the PIC has a 8 bit wide data bus, it counts in terms of 8 bit roll over's and units.
8) The IO had to be assigned for the pins on each port as part of the experiment.
9) Several changes were made in the program as instructed and so the required output was obtained.
10) At first an open loop system was used to program the microcontroller to control the stepper motor and give the output.
11) The values inputted were not accurate and so some errors were shown, it was because the open loop system did not have any feedback, changes weren't made by itself.
12) A closed loop system was then used to program the microcontroller and control the stepper motor to give output.
13) The closed loop system was able to give a proper output by itself.
14) This is because the system can use the information from the optical sensors for correcting any error in the inputs.
LABORATORY: EMBEDDED CONTROL OF A STEPPER MOTOR
ThE workbooks must be INCLUDED IN THE REPORT THAT
YOU SUBMIT FOR LAB SESSIONS 2 AND 3 TOGETHER
(Please note that the two lab work sheets are available on the module website as word doc and you must submit typed version of the worksheets and not the handwritten ones.)
Answer the following series of questions as you progress through the laboratory.
1. What binary values must be written to the direction registers for PORTA and PORTB to ensure that they operate as in figure 1 on the programming instructions sheet?
00011100 to PORT A
10000000 to PORT B
2. Write down the four assembly language instructions that will set up PORTA and PORTB as per figure 1.
3. Write down your lock combination and convert it to the equivalent number of roll-overs and units.
4. Run the open-loop program several times – are the results consistent? Explain your answer.
The results are not consistent. They are approximately the same. There is a slight difference between the values. This may be due to human error and friction between the lock wheels.
5. Write down the two assembly language instructions that are needed to test the status of the first red LED and loop back to label ROT1 if the LED is not on. Write down the instructions for the other two loops.
6. What is the lock combination returned by the microcontroller? Run the program several times – are the results consistent? Explain your answer.
The lock combination that was returned by the microcontroller was
After running the program several times it was seen that the results were not consistent. There is a slight difference between the values. This may be due to friction between the lock wheels. Even though the program is the same there may be delay in the transmissions of signals to lock wheels. Thus there may be slight difference in the value of the combination obtained.
7. Why is this experimental setup now classed as an embedded mechatronics system? Give some other examples of mechatronics products that contain microcontrollers – what are the advantages of using embedded control in these devices?
The setup is classified as an embedded system as instead of computer a PICmicro is used to control the motor Eg of products containing microcontrollers - mp3 players, videogame consoles, digital cameras, mobile phones An embedded control enables to reduce the size and cost of the device it is planted in. This in turn increases the reliability and performance of the device. *4
8.Will the lock combination be the same if it is found in the opposite direction – i.e. by initialising the lock in an anti-clockwise direction and then reversing the stages? How would you do this in the program? How could this be achieved in the interfacing circuitry?
The lock combination wont be the same after initialising the lock in an anti – clockwise direction and also reversing the stages.
This can be done by changing the program appropriately so that the lock combination would be in the reverse direction. The program made earlier will have to be altered several ways.
Another way is to bring changes in the setup of the apparatus itself. The wires that connect the paired wings could be altered in order to initialise the lock in an anti – clockwise direction.
9. A simpler logic circuit can be designed to decode the two outputs from the microcontroller into the hexadecimal sequence 9A65.
If the microcontroller were to send out the repeated sequence 0,1,3,2, instead of 0,1,2,3, and this sequence was still to correspond to thehexadecimal sequence 9A65 needed by the stepper motor, design a suitable decoder to do this.
In other words, design a logic circuit that will decode [P Q] to [W1 W2 W3 W4] –
the truth table is given as follows:
PORTA bit 1
PORTA bit 0
Stepper motor winding switch commands
1) The results obtained manually and that from the system were in accordance with each other.
2) The results obtained from the motor by programming a microprocessor were more accurate than that obtained manually.
3) The closed loop system is better than open loop system as in open loop system if the values inputted are not correct then the output would not be accurate, while in closed loop even if there is an error in the values inputted it is able to correct the mistakes itself
4) Using a program to control systems is more convenient and can produce more accurate results.
5) A closed loop system has feedback , it can give the output values even if there is an error in the inputs.
6) After performing the experiment it can be concluded that using a closed loop system is an easier way for obtaining accurate results.
7) A closed loop control is best employed by using an embedded control system as the components can be reused in many applications and have space saving and other properties.
*1, *2,* 3 – Taken from the MECH2660 Lab Handout.
* 4 – Taken from http://en.wikipedia.org/wiki/Embedded_system .