Mini-Project Referral: Fan Control Using a Shaft Encoder and LabVIEW

Mini-Project Referral: Fan Control Using a Shaft Encoder and LabVIEW.

Module Name: Applied Instrumentation
Module Code: 5312ELE
Level: 5
Credit Rating: 20
Weighting: 75% of module mark
Lecturer: C Wright
Contact: If you have any issues with this coursework you may contact your lecturer. Contact
details are:
Email: c.wright@ljmu.ac.uk
Tel: 2505
Room: 509a
Issue Date: 26/02/2018
Assessment Deadline: 10/08/2018
AssessmentMethod: Hand in printed report at Avril Robarts LRC
FeedbackDate: After Referral Exam Board
You may start working immediately and request assessment at any time before the assessment deadline
date.
NO EXTENSIONS CAN BE GIVEN as the date shown is the LJMU referral coursework deadline date.
School of Engineering,
Technology and Maritime Operations
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
Introduction
This assignment is to design a LabVIEW VI that will decode the A and B signals from a rotary encoder and
output a value on the PWM output to control the speed of a fan.
Learning Outcomesto be assessed
LO2, LO3, LO4
Referral Assignment
Decoding signals from a quadrature type incremental rotary encoder using LabView and a
K8055 interface card, then using this to control the speed of a fan.
Background Information: The Rotary Encoder
Rotary encoders have many applications in automation systems. They are used to measure the
angle through which a shaft has been rotated, from which the position and speed of equipment
connected to the shaft can be determined. The wheel on a computer mouse is an example one of
these devices.
A rotary encoder may be an absolute encoder or an incremental encoder. Incremental encoders
are much simpler (and usually much cheaper) but they only output changes in angle, not the angle
itself. A device using an incremental encoder needs to be able to remember its present position
and adjust that value appropriately when the encoder is moved. It also needs to be able to move to
a reference position at power up. If the device makes a mistake (maybe the shaft is rotated too
quickly) then this error will remain until the next reset. If an absolute encoder is used then the error
is likely to be corrected the next time the shaft moves.
A major advantage of incremental encoders is the small number of wires and computer or
controller inputs required. An absolute encoder with N bit single turn resolution (i.e. one that can
output 2N different position values) generally has at least N connection wires, possibly a few more.
The commonest type of incremental encoder has only three wires, one common and two signals A
and B that operate in quadrature to one another. This simply means that their signals are 90º out of
phase with each other. Some encoders also have another output, usually designated Z which is
used to indicate a zero position.
Using a single output it would be possible to measure the angular movement and hence speed of
rotation but not the direction. By using two signals in quadrature the direction of rotation can also
be worked out.
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
Figure 1. Quadrature Encoder Output Signals
(The TRUE and FALSE conditions are generated by the “switches” in the encoder being either
closed or open.)
Normally, A leads B for clockwise rotation, although this is pretty arbitrary because it depends
which end of the shaft we are on!
If we do define A leading B as “clockwise” we get the sequences shown in table 1.
Table 1. Determining Direction from Output Sequences
Converting these binary logic bits to numbers we get
0,1,3,2 – Clockwise
0,2,3,1 – Anticlockwise
A controller making use of the encoder must have a decoder. This can be done using a simple
electronic circuit or, since the controller will usually have some programming capability, by
software. You will do it using a LabView VI.
Anticlockwise code
sequence
B A
0 0
1 0
1 1
0 1
Clockwise code
sequence
B A
0 0
0 1
1 1
1 0
Time
True
False
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
LabView Decoding.
There is more than one option available when decoding the A and B signals in LabView. The first
(and one which is not open to you) is to use a National Instruments DAQ card with a built in counter
chip that is compatible with quadrature signals and use LabView’s DAQ Assistant VI’s to set
everything up automatically!
Discarding that option, two different approaches to the problem will be outlined here. In both cases,
the object of the exercise will be to convert the A and B signals into two pulsed signals, one
signalling a clockwise movement and the other signalling an anti-clockwise movement. If the
encoder is being used as a control knob we might think of these as up and down changes of the
knob’s value.
The up and down pulses would normally be used to increment or decrement a counter. The
counter value would probably be stored in a shift register and displayed on an indicator. The value
of the counter might be scaled and then, for example, used to control an analogue output on the
Velleman card.
Two approaches to decoding. (There are others.)
1. “Logic based” approach.
Looking carefully at the signals expected for the two directions of rotation it can be seen that the
direction of rotation can be identified by looking at the B signal level whenever there is a rising
edge on the A signal (defining the “rising edge” as a transition from Boolean FALSE to TRUE,
irrespective of what the voltage is doing!)
Coincident with a rising edge of A, if the rotation is clockwise then B is FALSE, if the rotation is anticlockwise
B is TRUE.
The hardest part of this is probably implementing the rising edge detector.
To detect a rising edge we are looking for a change in the value of a signal. To do that we need to
remember what the signal value was and then check it periodically to see if it is still the same. In
electronics, this would require a sequential circuit, which by definition has some sort of memory. In
LabView this almost always means a While loop with at least one shift register.
The key here is using a shift register to store the value of the A bit. On each loop cycle we can then
compare the value in the shift register to the value coming from the K8055. If they are different we
have had a transition (rising or falling). If they are different and A is now TRUE, then it was a rising
edge.
Once the rising edge has been detected, check the value of B and set the clockwise (Up) or anticlockwise
(Down) output bit as required.
The loop delay time depends on the expected application. In this case we are only implementing a
control knob, so speed is not a huge concern. A 10ms loop delay might be a good starting point;
slow enough to see “diagnostic” front panel leds flash.
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
2. “Numeric based” approach.
If we convert the two incoming bits from Boolean to Integer digits 0 or 1 and turn this pair of digits
into a number between 0 and 3, we can tell the direction of rotation by storing the value in a shift
register from one cycle to the next and looking at the
new value.
For example if the stored value is 3 and the new
value is 2 then, according to Table 1, we have
detected clockwise movement. If the new value is 1
we have detected anti-clockwise movement.
Again the basic overall structure would be a While
loop with a cycle delay of about 10ms.
Relative merits of the two techniques.
You are free to use either of these techniques, or one of your own. If you are not happy with
Boolean logic use the numeric approach.
The first method only detects a movement on every rising edge of A, whereas the second detects a
movement for every transition, up or down, of both A and B, giving four times as many pulses for
the same rotation. For the encoder we are using that means 24 instead of 6 pulses per rotation.
The logic based approach could be altered to give more sensitivity, by checking the value of B for
both transitions of A, giving 12 pulses. You could go further and also check the value of A on
transitions of B but this would make it considerably more complicated. (Don’t try these changes
unless you finish the simpler version really quickly. Save the working simple version under another
name!)
Assignment Specification
You will be given a Bourns – 3315 quadrature rotary encoder, a small breadboard, a K8055 I/O
card and a small fan unit.

Figure 2. Encoder connected to K8055
To convert a Boolean bit (T,F) to
integer (0,1) use this function

It is found in function menu
Programming – Boolean
Connect the middle pin to digital
inputs connector GND and the other
two pins to I1 and I2.
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
You have to create two LabVIEW VIs.
Part 1 – Decoder.VI Decodes the A and B Signals
Create a VI that will take the A and B signals from the rotary encoder and produce two Boolean
signals “Up” and “Down” which will pulse depending on which direction the shaft is rotated.

On the Front Panel of Decoder.VI, display any indicators/controls you feel appropriate, for example
you might have leds for A and B or the Up and Down pulses for diagnostic purposes.
Part 2 – FanSpeedSetting.VI Uses Decoder.VI as a subVI and Controls Fan Speed
Create a VI that uses the Decoder.VI created in Part 1 as a subVI.
The “Up” and “Down” signals should be used to control a numeric indicator called “Speed Setting”
that has a range from 0 to 10, which should be displayed on a LabView VI Front Panel. Winding the
encoder clockwise should cause “Speed Setting” to increase, stopping when it reaches the
maximum value, ten. Winding anticlockwise should cause “Speed Setting” to decrease, stopping
when it reaches the minimum value, zero. The value of SpeedSetting (range 0-10) will be used to
control a fan using 8 bit PWM output. Design the system so that a value of SpeedSetting = 10
makes the fan run at full speed.
Use one of the small fan units used in the second assignment. There is no need to wire up the
temperature sensor or the heater. Make the following connections.
Blue wire – Variable 9V supply +ve
Thin Black wire – Variable 9V supply –ve
Thin Black wire – K8055 card GND
Grey wire – K8055 card PWM1 output
Hint. The first thing you need to do is modify the K8055.VI
connector so that the two digital input Boolean indicators
that you connect to wires A and B are connected to
terminals that can then be “wired” into your VI.
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
Hints:
Boolean Logic Functions in LabView
In order to perform this assignment you will probably have to use Boolean logic functions. The only
ones you really need are the AND function and the NOT function.
You can find these from the Block Diagram in the Boolean function menu.
One other function that may be useful is the “Select” function from the Comparison function menu.
The behaviour of both of these functions is very simple.
The AND function has two inputs (left side) and one output
(right side). The output is TRUE if both inputs are TRUE,
otherwise it is FALSE.
The NOT function has one input and one output. If the input is
TRUE, the output is FALSE and vice versa.
You can also use some other functions with Boolean data.
However, the function has to make sense with Boolean input
data. So, for example, you could test if two Boolean elements
are not equal using the Comparison function “Not Equal?”
(returns TRUE if the inputs are not equal to each other) but
you cannot use functions that require numeric input like “Equal
to 0?”
This function attaches one of two input values (t,f) to its
output, depending on the value of the central Boolean
input (s). The data on the t and f inputs can be of any
type, integer, Boolean or whatever, as long as both they
and the output are the same type.
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
SINGLE MOST IMPORTANT PIECE OF ADVICE!!
If in doubt about any function in LabView, press CTRL-H to open the Context Help window and put
the pointer on the function’s symbol for information.
In both VIs, appropriate data representation should be used for all data.
Assessment
This is an individual assignment.
Assessment will be made via a Lab demonstration in front of two members of staff on or before the
date shown on the Front Page.
DO NOT LEAVE IT UNTIL THIS DATE because you WILL forget how to use LabVIEW and there
will be very high demand for lab space during the summer when other students are trying to access
the labs for referral work in between summer school use and the annual lab shakedown/refits.
You must book lab time with the technicians. Do not just turn up and expect to be given access.
Assessment will be made using the following criteria:
Front Panels 20%
Block Diagrams 40%
Use of subVIs 10%
Understanding of the operation of the system 30%
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
Guide to Performance Criteria
70% and above:
Your work must be of professional quality and fully meet the requirements of the coursework specification and
learning outcomes stated. Front Panel(s) should be extremely well laid out, all controls and indicators should be
chosen sensibly and appropriately sized and neatly laid out. Bloc k Diagram should be easy to understand, clearly laid
out with appropriate comments. All elements are correctly labelled. Appropriate data types and ranges should be
applied. VI must function perfectly. Explanation of operation must show deep understanding.
60% – 70%:
Your work must be of good quality and meet the requirements of the coursework specification and learning outcomes
stated. Front Panel should be well laid out. Block Diagram should be easy to understand and clearly laid out, with
comments. VI should function correctly. You should be able to explain how the system works.
50% – 60%:
Your work must be comprehensive and meet all of the requirements stated by the coursework specification and
learning outcomes. Front Panel should be well laid out. VI should function reasonably well.
40% – 50%:
Your work must be of a standard that meets the requirements stated by the coursework specification and learning
outcomes. Front Panel should have required controls and indicators. VI should function to some degree.
Below 40%:
Your work is of poor quality and does not meet the requirements stated by the coursework specification and learning
outcomes. There is a lack of understanding of key concepts. Design won’t work properly.
Extenuating Circumstances
If something serious happens that means that you will not be able to complete this assignment, you need to
contact the module leader as soon as possible. There are a number of things that can be done to help, such as
extensions, waivers and alternative assessments, but we can only arrange this if you tell us. To ensure that the system
is not abused, you will need to provide some evidence of the problem. More guidance is available at
http://www.ljmu.ac.uk/corporate/SPR/60399.htm.
Any coursework submitted late without the prior agreement of the module leader will receive 0 marks.
Academic Misconduct
The University defines Academic Misconduct as ‘any case of deliberate, premeditated cheating, collusion,
plagiarism or falsification of information, in an attempt to deceive and gain an unfair advantage in assessment’. The
School takes Academic Misconduct very seriously and any suspected cases will be investigated through the
University’s standard policy (Academic Misconduct Policy). If you are found guilty, you may be expelled from the
University with no award.
It is your responsibility to ensure that you understand what constitutes Academic Misconduct and to ensure that
you do not break the rules. If you are unclear about what is required, please ask.
Cheating includes:
Reference ENR-PP-LA-3-07
Document title Template for Coursework
Revision 1.0
Date 10/10/2010
Author SE/IJ
(i) any form of communication with, or copying from, any other source during an examination;
(ii) communicating during an examination with any person other than an authorised member of staff;
(iii) introducing any written, printed or other material into an examination (including electronically stored
information) other than that specified in the rubric of the examination paper;
(iv) gaining access to unauthorised material in any way during or before an assessment;
(v) the use of mobile phones or any other communication device during an assessment or examination;
(vi) the submission of false claims of previously gained qualifications, research or experience in order to
gain credit for prior learning;
(vii) the falsification of research data, the presentation of another’s data as one’s own, and any other forms
of misrepresentation in order to gain advantage;
(viii) the submission of work for assessment that has already been submitted as all or part of the
assessment for another module without the prior knowledge and consent of the Module Leader for
the subsequent assessments;
(ix) the submission of material purchased or commissioned from a third party, such as an essay-writing
service, as one’s own.
Plagiarism is defined as the representation of the work, artefacts or designs, written or otherwise, of any other person,
from any source whatsoever, as the student’s own. Examples of plagiarism may be as follows:
i) the verbatim copying of another’s work without clear identification and acknowledgement including the
downloading of materials from the Internet without proper referencing of materials;
ii) the paraphrasing of another’s work by simply changing a few words or altering the order of presentation,
without clear identification and acknowledgement;
iii) the unidentified and unacknowledged quotation of phrases from another’s work;
iv) the deliberate and detailed presentation of another’s concept as one’s own.
Collusion includes:
(i) the conscious collaboration, without official approval, between two or more students in the preparation
and production of work which is ultimately submitted by each in an identical or substantially similar form
and/or is represented by each to be the product of his or her individual efforts;
(ii) collusion also occurs where there is unauthorised co-operation between a student and another person in
the preparation and production of work which is presented as the student’s own.
For more information you are directed to following the University web pages:
 Information regarding academic misconduct: http://www.ljmu.ac.uk/studysupport/81924.htm
 Information on study skills: http://www.ljmu.ac.uk/studysupport/
 Information regarding referencing: http://www.ljmu.ac.uk/studysupport/69049.htm

find the cost of your paper