SlideShare a Scribd company logo
1 of 33
Download to read offline
May 1
2015
The project objectives include generation and control of an infrared
transmitter/receiver circuit within Labview. A 38KHz modulation
scheme will be implemented to transmit the signal. A counter should
also be made active in Labview to record how many times the infrared
beam has been broken,
Project
Ciaran
Cooney
May 1, 2015
Page 1
May 1, 2015
Page 2
Contents
Table of Figures.......................................................................................................................................3
Abstract...................................................................................................................................................4
Introduction.............................................................................................................................................5
Hardware.................................................................................................................................................6
Infrared LED ........................................................................................................................................6
Infrared Receiver.................................................................................................................................6
USB-6008.............................................................................................................................................6
NI MyDAQ ...........................................................................................................................................7
Additional Components ......................................................................................................................7
Software..................................................................................................................................................7
Labview ...............................................................................................................................................7
Technical Description..............................................................................................................................8
Analysis of Transmitter/Receiver........................................................................................................8
38KHz Modulation ..............................................................................................................................9
Generating a pulsed signal................................................................................................................10
Pulsing the Infrared LED....................................................................................................................13
Receiving the infrared signal.............................................................................................................14
Bringing the signal into Labview.......................................................................................................15
Creating a SubVI................................................................................................................................17
Implementing the counter................................................................................................................18
Case Structure...............................................................................................................................20
Event Structure .............................................................................................................................21
Boolean Crossing PtByPt...............................................................................................................22
Complete VI...........................................................................................................................................24
Block Diagram ...................................................................................................................................24
Front Panel........................................................................................................................................25
Discussion and Analysis of Results........................................................................................................26
Conclusions ...........................................................................................................................................28
Appendix ...............................................................................................................................................29
References ............................................................................................................................................31
Datasheets ....................................................................................................................................31
Websites........................................................................................................................................31
Videos............................................................................................................................................31
May 1, 2015
Page 3
Lecture Notes................................................................................... Error! Bookmark not defined.
Table of Figures
Figure 1 Block Diagram of the system ....................................................................................................5
Figure 2 Infrared LED ..............................................................................................................................6
Figure 3 Infrared Receiver.......................................................................................................................6
Figure 4 USB-6008...................................................................................................................................6
Figure 5 NI MyDAQ .................................................................................................................................7
Figure 6 ISIS Transmitter Schematic .......................................................................................................8
Figure 7 Two pulses taken from the virtual oscilloscope........................................................................9
Figure 8 Square Waveform.vi ...............................................................................................................11
Figure 9 Implementation of Modulation ..............................................................................................12
Figure 10 Front panel (4 waveforms)....................................................................................................12
Figure 11 Current driver block diagram................................................................................................14
Figure 12 Counter Input to Labview .....................................................................................................16
Figure 13 Error correction SubVI...........................................................................................................16
Figure 14 Converting frequency to '1' or '0' .........................................................................................18
Figure 15 set dynamic data attributes..................................................................................................19
Figure 16 Case Structure.......................................................................................................................20
Figure 17 Event Structure .....................................................................................................................21
Figure 18 Boolean Crossing PtByPt.......................................................................................................23
Figure 19 Block Diagram of final VI.......................................................................................................24
Figure 20 Front Panel of final VI............................................................................................................25
Figure 21 Alternative Oscilloscope simulation......................................................................................29
Figure 22 Breadboarded transmitter circuit.........................................................................................29
Figure 23 Boolean PtByPt Sub-diagram ................................................................................................30
Figure 24 Comparison between receiver circuits .................................................................................30
Figure 25 Infrared LED transmitting......................................................................................................31
May 1, 2015
Page 4
Abstract
The project documented in this report is a final semester individual project contributing to the
award stage of a Bachelor of Engineering in Electrical and Electronic Systems. The basic
premise of this project is analysis of a traditional infrared transmitter/receiver circuit with the
aim of implementing a similar system within National Instruments’ Labview software.
Labview provides a platform for building measurement and control applications, allowing the
user to display data streams on a laptop or PC monitor. As well as receiving signals for
measurement, Labview is able to generate signals specified by the user. This function has
proved to be a cornerstone of this project.
As a result of the work undertaken, external circuitry required to execute the
transmitter/receiver system has been minimized as this streamlined version is largely
contained within Labview.
The main body of this report will include a detailed account of lab work undertaken and the
theory underpinning any methods used. Particular attention is paid to obstacles faced and
solutions advanced. The report will conclude with overall impressions of the project, with
discussion on possible applications for the system alongside ideas for further development of
concept.
Keywords
 Labview
 Infrared Technology
 Modulation
 Carpark Control
 NI MyDAQ
May 1, 2015
Page 5
Introduction
Infrared (IR) technology is an inexpensive and extremely common form of wireless
communication with applications ranging from simple television remote controls to
thermographic cameras used for heat detection maps. The project described in this report
involves interfacing this IR technology with Labview so that it can be controlled and
monitored.
Infrared light has a wavelength within a range of 700nm to 1mm, making it impossible for
the human eye to detect and therefore ideal for use in wireless communication. However,
sources of infrared light exist almost everywhere and specific techniques are required to
enable a receiver to differentiate between the wanted and unwanted signals. A common
technique employed for this purpose is known as modulation. One of the initial challenges
faced in this project was to control this modulation in Labview.
Before going into any greater detail on the techniques used to implement the type of system
required, it is important to convey a more general synthesis of the project. To this end the
block diagram, inserted below in figure 1, depicts the key areas of the infrared
transmitter/receiver system and how its flow is controlled by the central hub, which is
Labview.
Figure 1 Block Diagram of the system
As the diagram displays, Labview is used to generate a pulse at the required frequency to
control the transmitter via an appropriate Data Acquisition (DAQ) system. The infrared
receiver accepts this pulsed signal (if at the correct frequency) which is then sent to Labview
via a selected input pin on the same DAQ already in use. The information received can be
processed to obtain the information required. In this instance the information is a simple
count of the number of times the infrared beam is broken.
The concept for this project has been conceived with applications such as counting footfall in
a shopping centre or the level of traffic passing through a car-park as potential uses for the
system. However this in no way inhibits its potential for use in other areas due to the
simplicity of the system and the ease with which changes can be implemented.
May 1, 2015
Page 6
Hardware
Although this project is by no means a hardware intensive one there are nevertheless a
number of key components and devices that warrant a descriptive explanation of their own as
to why they have been included. The following is not an exhaustive list of all the hardware
employed on this project but an overview of the most important.
Infrared LED
The infrared LED pictured below is a simple device that can be
used to transmit infrared light with a wavelength in the 940nm
– 950nm range. It is very typical of the type commonly seen in
television remote controls and is perfect for this type of remote
sensing system. It is important that the LED is paired with a
compatible receiver, of which there are many varieties. Each
IR LED has its own forward current requirement, generally
ranging from 50mA to 100mA. This current requirement is a
factor that must be taken into consideration, especially with the
limited current capabilities associated with Labview.
Infrared Receiver
An Infrared Receiver is a module designed to detect infrared
light within a specific range of frequency. The model pictured
to the right is a TSOP31328 which is the device used in this
project. It is a three-pin device, including one pin for the
output which can be connected directly to a microprocessor or,
in this case, to Labview via the Data Acquisition module.
Different versions of these receiver modules are designed to
receive different carrier frequencies. The 31238 accepts a
carrier frequency of 38000Hz.
USB-6008
The National Instruments USB-6008 is described on that
company’s website as a “low-cost multi-function” data
acquisition unit. It is a compatible device for interfacing with
Labview and is often used for control and sensor applications. It
is equipped with 8 analog inputs, 2 analog outputs and 12 digital
I/O lines. Other significant features of the device include a 32-
bit counter and its built-in signal connectivity. The USB-6008 is
the device first used on this project when interfacing the external
circuitry with Labview.
Figure 2 Infrared LED
Figure 3 Infrared Receiver
Figure 4 USB-6008
May 1, 2015
Page 7
NI MyDAQ
The National Instruments MyDAQ is a more recent model
of data acquisition device and is equipped with some
capabilities the USB-6008 does not possess. It is equipped
with a 200kS/s analog sampling rate and provides access to
other instruments such as a Digital Multi-meter and a
function generator. The MyDAQ also features a 16-bit
ADC and a 16-bit DAC and like the USB-6008 a 32-bit-
counter. The reasons behind the inclusion of the MyDAQ
device in this project are predicated on its ability to
perform certain functions that the USB-6008 was unable to.
Additional Components
There were a number of additional components required to complete the transmitter/receiver
circuitry. These include several resistors, transistors and a generic LED implemented as a
warning. Any of these components may be referenced during this report as part of the build
stage of the project.
Software
Labview
The primary basis for this project is the exploration and execution of a small number of the
vast catalogue of functions Labview is capable of performing. In fact, the exploration element
of the project may well prove to have been the most important. Especially as the method of
achieving the desired result was left open to interpretation in the assignment brief.
Labview itself, according to the National Instruments website (http://www.ni.com/), “is a
highly productive development environment for creating custom applications that interact
with real-world data or signals in fields such as science and engineering”. What this basically
means is that Labview provides a more visually intuitive programming model as an
alternative to many of the traditional programming languages.
The software implements the G programming language which enables a graphical data-flow
to be presented at the application layer. Examples, taken from this project, of the graphical
interfaces presented by Labview are inserted throughout the technical description section of
this report.
Another key feature of Labview that makes it an extremely powerful tool across a range of
fields is the hardware support it provides for thousands of devices. Labview is able to
integrate hardware devices from sensors and scientific instrumentation equipment to Data
Acquisition devices like those being used for this project.
Figure 5 NI MyDAQ
May 1, 2015
Page 8
Technical Description
Analysis of Transmitter/Receiver
The initial phase of the project was an investigation of the transmitter/receiver circuit, the
dual schematic having been provided in the assignment brief. This would enable analysis of
the key areas of operation within the circuit, particularly for the generation of the transmitted
signal.
To begin analysis of the circuit a schematic was contructed on ISIS so that simulations could
be run. From these simulations, the frequency of the generated pulse could be determined at
specified points on the circuit.
Figure 6 ISIS Transmitter Schematic
One small problem occurred when the simulation was run for the first time. An Error
Message was received specifying that there was “No Model Specified for RV1”. This was a
simple problem due to a schematic symbol having been placed in the circuit rather than a
model that was available for simulation. It was subsequently replaced with the “3005P-1-
101” and the simulation was able to run successfully.
The specified points on the circuit that required measurements are the output ‘Q’ of U1:A and
output ‘Q’ of U1:B which can be seen on the schematic diagram. Attaching a virtual
oscilloscope to these two points would allow a frequency meaurement to be determined.
From the output of U1:A the frequency of the pulse was determined by first calculating the
period from the time taken at two points on the pulsed waveform and then dividing one by
this answer. These calculations were completed as follows:
Period (T) = 25.88ms – 23.72ms = 2.16ms
Frequency (F) =
1
𝑇
=
1
2.16𝑚𝑠
= 462.96Hz
May 1, 2015
Page 9
At the output of U1:B the investigation was primarily interested in the frequency of the
modulated pulse that occurs on the High time of the original slower frequency pulse. To
ensure that the circuit was calibrated to produce the correct pulse, the potentiometer was set
to 2.7KΩ. The same method as before was used to determine the period and from this the
frequemcy. The calculations were completed as follows:
Period (T) = 867.9µ𝑠 – 841.2µ𝑠 = 26.7µ𝑠
Frequency (F) =
1
𝑇
=
1
26.7µ𝑠
= 37453Hz
Inserted below is a screenshot, taken from the virtual oscillocope available for use on
simulations. The upper waverform (yellow) is the output taken from U1:A and the lower,
higher frequency pulse has been taken from the output of U1:B.
Figure 7 Two pulses taken from the virtual oscilloscope
From the frequency determined from this simulation the conclusion has been drawn that this
tranmitter/receiver circuit is implementing a specific method often employed in infrared
detection applications. The following section provides details behind the operation of this
method.
38KHz Modulation
The frequency of the two pulse outputs determined from the simulations above, provides
proof of a concept that is extemely common for this type of IR transmitter/receiver circuit.
This concept is known as 38KHz modulation and it is a method employed to enable a
receiving device to recognise the data being transmitted. The frequency of the modulated
pulse recorded from the simulation is 37453Hz. Although this is not precisely 38KHz it does
fall within an acceptable band for this type of modulation.
The reason behind the choice of frequency used for 38KHz modulation is simply that there
are very few natural sources of infrared light that exist with a frequency of 38KHz. Therefore
the transmitted data can be safely sent and recognised by the transmitter without being
May 1, 2015
Page
10
contaminated by the ambient sources of infrared light. 38KHz is not the only method of
modulation used in infrared detection circuits but it is by far the most common.
The choice of infrared receiver module is dependant upon the the frequency of the modulated
pulse it is going to be required to receive. The TSOP31328 is a 38KHz receiver module,
perfect for the applications required in this project. Its job, in this project and others, is to
demodulate the signal that has been transmitted and output a binary waveform. In this case
the binary waveform is required for use in Labview.
The neccesity for a binary waveform is the reason for the 462.96Hz pulse that was calculated
from the simulations in ISIS. This lower frequency pulse controls the spacing between the
modulated signals and allows the signal to be decoded and read in as a serial bit-stream.
Generating a pulsed signal
Having analysed the transmitter circuit above to determine the method, and chosen the
receiver module that would be used to implement this transmitter/receiver system, the
challenge was to generate a modulated pulse at the required frequencies, within Labview.
One of the luxuries of using Labview to control this is system is the ability to enter discrete
values for the frequencies required. Due to this, the frequencies calculated above have been
adjusted as follows:
462.96Hz = 470Hz
37453Hz = 38Khz
To begin the process of generating a pulsed signal in Labview online research was
undertaken to discover some of the methods than were available for this purpose. The method
best suited to the demands of this project was determined to be a subVI available within the
Labview libraries titled Square Waveform.vi. A fairly simple VI to operate, even for
someone with little experience of Labview, it allows the user to enter specific values for
parameters such as frequency, amplitude and phase before generating a resultant square-
wave.
As the square waveform VI is unable to generate the type of modulated pulse required for the
transmitter/receiver communication, it was necessary to generate two separate waveforms for
the 470Hz and 38KHz signals before taking additional measures to modulate them as a single
signal. The following block diagram and the information regarding the generation of these
square waves is an extract from the project notebook accompanying this report. It depicts the
parameters required by the SubVI in order to generate the two square-waves necessary for
modulation.
May 1, 2015
Page
11
Figure 8 Square Waveform.vi
Offset – Required to be 2.5volts for the 5 volt waveform. Otherwise the square waveform
will rise and fall between 2.5 and -2.5volts
Frequency – 38KHz signal 1
470Hz signal 2
Amplitude – Set at 2.5volts. Along with the 2.5volt offset this creates a signal range from 0
to 5volts
Sampling – Sampling information of the two signals must be identical when multiplying,
otherwise errors will occur.
As the extract above states, an amplitude offset was required because Labview, by default,
would generate a square wave with a peak-to-peak voltage centred around 0V. This is
perfectly acceptable for many applications. However for the signal required to provide a
pulse for the IR LED it was necessary to apply an amplitude range of 0 to 5volts.
One of the many virtues Labview holds for the user is the excellent front-panel interfaces it
provides for monitoring and control of the data being processed. This was particularly useful
at this stage of the project as the two waveforms initially generated could be viewed and
analysed, before steps could be taken to modulate them. A screenshot of the front panel
during this phase of the project has been inserted further below in this section.
With the parameters entered as stated above, running the square waveform VI produced the
two waveforms expected. One with a frequency of 38KHz, one with a frequency of 470Hz
and both with a 50% duty cycle and amplitudes of 0 to 5volts. The next task was to modulate
these two pulses.
The method used to implement this modulation is quite simple because of the functionality of
the tools available within Labview. By taking the two waveforms of different frequency but
equal amplitude and using the multiply function to combine them both, a resulting,
modulated waveform was produced. The waveform returned was indeed a 470Hz pulse with
a 38KHz modulated pulse during the period the pulse was high. However a subsidiary effect
of utilizing the multiply function to deliver this pulse is the simultaneous multiplication of the
amplitudes of the two original signals. The resultant signal therefore has an amplitude of
May 1, 2015
Page
12
25volts. To rectify this unwanted by-product, a division function with a constant value of five
has been used to counter the increased amplitude and return it to 5volts.
The figure below is a section of a block diagram, taken from Labview, displaying the process
described in the previous paragraph.
Figure 9 Implementation of Modulation
Inserted below is a screenshot of the front panel of this VI. There are four waveform charts
on the front panel, each one to display the four signals generated during this modulation
process, including Waveform D, which is the final result. The front panel in this instance
proved useful for ensuring that the process was effective in delivering the required result.
Figure 10 Front panel (4 waveforms)
This is by no means an accurate representation of the appearance of the front panel at the
conclusion of the project. However it does provide useful insight into the processes followed
when generating the output signal.
May 1, 2015
Page
13
Pulsing the Infrared LED
With the modulated pulse having been successfully generated, the next task to be faced was
using that signal to pulse an external IR LED, a challenge that proved more difficult than
anticipated.
A simple circuit was constructed on a breadboard, consisting of one 390Ω resistor and a
standard LED. The LED was used to simulate the operation of the IR LED simply because its
light can be perceived by the human eye.
To provide a link between Labview software and the external circuitry, a data acquisition
module is required. As with all previous Labview projects undertaken at this Institue, the
DAQ provided for this one was the USB-6008. This is an extremely common data acquisition
unit with many applications.
The USB-6008 was connected to this external circuitry via its analog output Ao.
Unfortunately, when running the VI with the expectation of viewing a pulsing light being
emitted from the LED, there was no evidence any such activity. Despite reassessing the
connections of the external circuitry and the functionality of the LED itself, no solution was
immediately discovered.
An online investigation was then pursued with the intent of discovering possible sources of
the problem and potential remedies. An excellent resource at this time, and throughout this
project, was the National Instruments website (http://uk.ni.com/). On this website are
discussion forums with multiple threads providing extensive information on all kinds of
issues regarding Labview. A very small word of warning would be the importance of
specifying a problem correctly and with detail, simply due to the vast quantity of information
available.
Research into the problem finally led to the discovery that the configuration capabilities of
the USB-6008 were not suitable for the required application. Because of the limitations of the
USB-6008, the DAQ Assistant within the Labview VI could only be configured to enable “ 1
sample on demand”, making it unable to generate the continuous pulsed signal necessary for
this project. With this diagnosis, it was determined that replacement hardware would be
needed.
The NI MyDAQ was provided as the replacement data acquisition module. The device is
described on the National Instruments website as having “the ability to measure and analyse
live signals anywhere anytime” and has some extended capabilities that the USB-6008 does
not possess. Specifically, with relevance to this project, is allows the selection of “N
samples” when configuring a DAQ Assistant and can therefore generate the continuous pulse
required to operate the IR LED correctly.
With the MyDAQ replacing the USB-6008 a pulsed light could now be perceived emitting
from the LED. However, the strength of the light being emitted was rather unimpressive, a
consequence of the current capabilities of the MyDAQ. According to the associated user
manual the MyDAQ has a maximum rated analog output current of 2mA, considerably lower
May 1, 2015
Page
14
than the ideal requirement for a standard LED or an infrared LED. To combat this restriction
a current driver circuit was constructed on the breadboard to increase the current passing
through the LED. A block diagram of this circuitry has been inserted below:
Figure 11 Current driver block diagram
In this circuit configuration the transistor effectively operates as a switch. The analog output
from the MyDAQ is connected to the base of the transistor via 4.7KΩ resistor, meaning the
pulse from the Labview signal controls the operation of the transistor. A 390Ω resistor
connects the collector of the transistor to the LED which is then pulled to 5volts. To complete
the circuit the emitter of the transistor is passed to Ground.
The current-driver circuitry results in the desired increase in the strength of light emitted from
the LED. The LED could then be replaced by the IR LED for the remainder of the project. At
this stage, the digital camera from a mobile phone was used to test the IR LED to ensure that
it was transmitting. Although the human eye is unable to detect infrared light, modern digital
cameras are able to and this test confirmed that the LED was indeed transmitting.
Receiving the infrared signal
Before attempting to read any received signals from the TSOP31328 into Labview it was
decided to use a pre-existing receiver circuit, made available in the lab, to understand how the
received signal changed the output of the receiver module.
The initial investigation was a simple visual inspection of the reaction of the receiver circuit
to the infrared transmission. As the circuit was fitted with two LEDs it was possible to
perceive that both remained off for as long as the beam was being transmitted and received
by the detector. Upon blocking the infrared beam the two LEDs would light to signify the
beam has been broken.
By connecting an oscilloscope to the output of the TSOP31328 on the receiver circuit the
changing voltage levels could be observed as the signal was transmitted and then as the signal
was blocked. The output of the TSOP31328 is active low, and is typically connected to a
microcontroller, or in this case a data acquisition module. This means that the output is High
when no signal in received and only Low when a 38KHz pulse is detected.
As would be expected from a device with an active low output, the oscilloscope confirmed
that the output of the TSOP31328 would be pulled High when the infrared beam was broken
May 1, 2015
Page
15
and would remain High for as long as no transmission was being received. At times when the
infrared LED was transmitting and the TSOP31328 receiving, the receiver output produced a
pulsed DC voltage of approximately 470Hz. Thinking about this logically from the
information compiled for this report, a 470Hz pulse is exactly the output that should be
expected. When the Labview generated signal is transmitting, the receiver module (which
only detects infrared light at 38KHz) emits an active-low output for approximately 1ms. This
1ms period occurs while the infrared pulse is High and the 38KHz frequency IR light can be
detected.
As the carrier signal goes Low, again for approximately 1ms, the output of the TSOP31328
becomes High. It is this shifting between the inactive-high and active-low states that produces
the 470Hz pulsed output of the receiver module when the IR LED is transmitting and being
received.
The pulsing 470Hz output signal of the receiver module is what would enable decoding of the
signal within Labview to decipher when the IR LED was active and when it was being
blocked.
Bringing the signal into Labview
With a sophisticated piece of software like Labview it can be expected that there are always
more than one avenue to explore when attempting to achieve a desired outcome. When it
came to reading in the output signal from the receiver module, the first method pursued was
simply to insert another DAQ Assistant into the VI and configure it to acquire an analog
voltage. Although this method may not have been able to determine the frequency of the
signal it was not expected that there would be any problems acquiring it.
This assumption was incorrect as, upon running the VI, the Error Code 200474 was returned,
stating “some or all of the samples requested have not yet been acquired”. This is an error
that occurs because the timeout has been reached before the samples are received. The
timeout is calculated as follows
Timeout ≥
𝑆𝑎𝑚𝑝𝑙𝑒𝑠 𝑡𝑜 𝑅𝑒𝑎𝑑
𝑆𝑎𝑚𝑝𝑙𝑒 𝑅𝑎𝑡𝑒
Discovery of this formula for determining the Timeout led to a series of adjustments to the
sampling frequency and the number of samples taken. However none of these adjustments
provides a sustainable solution and further investigation was required.
This further investigation led to a solution that would satisfy the requirements of bringing in a
signal that could be measured for frequency as well as avoiding the type of error stated
above.
The primary realisation with regards to the input signal was that it would be necessary to use
the counter input on the MyDAQ as it is the channel used for counter/timer functions. This
meant having to connect the output of the TSOP31328 to DIO 0 for the counter source. The
section of Labview code in the figure below shows how the received signal enters the While
Loop via the counter input and Virtual Channel VI.
May 1, 2015
Page
16
Figure 12 Counter Input to Labview
A virtual channel, such as the one in the VI above, is a collection of settings like a name,
physical channel, input terminal connections and the type of measurement to be employed.
From this section of the block diagram it can be seen that the type of measurement is a Low
Frequency Counter and the physical channel is the counter input. This section of the code
occurs outside the loop and the Start Task VI is used to pass the signal inside where it can be
used to display the frequency.
Within the While Loop a SubVI known as DAQmx Read.vi is used to read the signal and
return a frequency value to a front-panel indicator.
The use of the counter input along with the virtual channel did not however solve the problem
with timeouts occurring. The specific problem with this method of inputting and measuring
the frequency is that some versions of DAQmx drivers will return this error when the
frequency drops below 100Hz. As an operating requirement of the system being developed is
that the frequency is zero when the signal is blocked, this is a problem that could not be
ignored.
The section of code extracted from the block-diagram shows how this problem was
overcome. It operates basically by clearing the specific error number on each iteration of the
loop.
Figure 13 Error correction SubVI
May 1, 2015
Page
17
By using the equal to function with the error code number acting as the constant value and
then a selector the code will continue to act as normal when no error occurs. However when
an error occurs that is equal to the constant error code the selector will implement a different
output of the code which is able to clear the error. Interestingly, this is a solution that can be
implemented for other errors by changing the constant code input to the equal to function.
With the signal received by the TSOP31328 now being measured and the frequency
displayed in Labview the next challenge was to implement a counter to increment once upon
the IR beam being broken. However before approaching this task a process of modularising
the block-diagram into SubVIs was undertaken.
Creating a SubVI
By modularising a Labview block-diagram, sections of code are separated into smaller
blocks, known as SubVIs. SubVIs are exactly the same as normal Vis and exist as blocks of
code within the overall system in a way that is similar to a sub-routine in other programming
languages.
Among the virtues of using a SubVI are improving the clarity of a block-diagram that
contains a large amount of code and with this improving the ease of troubleshooting when
errors occur.
There are two main ways of creating a SubVI in Labview. One is to create it as you would a
normal VI with the code required for a certain section and save it as so. This can then be
brought into another block-diagram by entering the controls menu and clicking on ‘Select a
VI’. A little box indicator of the VI is placed on the block-diagram, including connectors for
any inputs and outputs required.
The second method involves creating a SubVI from code that has already been developed and
placed onto the block-diagram. Simply by highlighting the section of code to be included in
the SubVi and then clicking on Edit and Create SubVI a SubVI will be generated and a
corresponding indicator placed on the diagram to replace the code.
It is important when creating and implementing a SubVI that the connector pane is correctly
configured as this provides inputs from and outputs to the greater block-diagram. The SubVI
icon can also be edited so that the appearance matches more closely the task the code is being
asked to perform. The figure below displays the connector pane and the icon of the SubVI
created to generate the 38KZ modulated pulse.
Figure 14 SubVI connector pane and icon
May 1, 2015
Page
18
Implementing the counter
Having completed the task of bringing the received signal into Labview, via the counter
input, and displaying the frequency on a front panel indicator, measures were to be taken to
process this information so that a counter would increment each time the Infrared beam was
broken. It was an important feature of this counter that it would only increment once per
instance of the beam being broken, regardless of how long the blockage may occur. It was
equally important to ensure that upon re-detection of the IR signal that the count was not
incremented.
To begin the process of implementing this counter, a little logic was required to produce a
Boolean 1 or 0. A ’1’ would be used to signify the beam had been broken and a ‘0’
representing the opposite state.
The first step taken at this stage was to construct a range of frequencies from which to
determine that the infrared signal was currently being received. The reason for doing this was
that, from the front panel indicator it was noticeable that the frequency from the counter input
was not completely stable. This instability is likely to be the effect of noise or a similar
factor.
The chosen frequency range is between 455Hz and 485Hz, as can be seen in the figure below.
Figure 15 Converting frequency to '1' or '0'
This figure, a direct extract from Labview, also depicts the use of the “Greater or Equal” and
“Less or Equal” comparative functions, which in conjunction with an AND Gate, produce a
binary 1 or 0 output. This small section of code works as follows:
 The frequency value, having been read in from the counter input, is directed
concurrently to both the “Greater or Equal” and “Less or Equal” functions.
 For the “Greater or Equal”, if the frequency is greater than the constant value 455, a
value of ‘1’ is produced at the output.
 For the “Less or Equal”, if the frequency is less than the constant value 485, a value
of ‘1’ is produced at the output.
 These two output values are then sent as inputs to the AND Gate. As an AND Gate
only produces a HIGH output when both inputs are HIGH, the output of the AND
Gate will be ‘1’ only when the frequency is approximately 470Hz. This signifies that
the TSOP31328 is currently receiving an infrared beam.
 The output of the AND Gate is inverted (or alternatively a NAND Gate could be
used) to produce a ‘0’ when the signal is transmitting and thereby a ‘1’ when the
beam is broken.
May 1, 2015
Page
19
With a front panel indicator inserted that would display a 1 or 0 depending on the
transmitter’s reception of an infrared signal or not, the intention was to use the values
displayed for three separate tasks. First, to control a warning light on the front panel of the VI
that would turn on each time the IR beam has been broken. Second, to control an external
LED that would perform the same function. And third, to provide the data for a counter that
would increment by one each time the beam was broken. The first two tasks proved to be
relatively simple to implement. The third required much more time research than anticipated
at the outset.
Inserting a front panel LED to turn on when the infrared beam is broken was quite a simple
task. By right clicking on the front panel, which opens the controls menu, and subsequently
opening the Boolean menu, a Round LED was selected and placed on the front panel. A
corresponding icon then appears on the block diagram which can be attached to the output of
the previously discussed inverter.
Employing an external LED to perform the same notification function required a little more
effort. To begin with, external circuitry had to be constructed on a breadboard. Remembering
that the output current of the MyDAQ has a maximum value of 2mA, the same type of
current-driving circuitry would be required for this LED as was required for the IR LED.
Once again a transistor was included, with a 4.7KΩ resistor connected to its base. The LED is
connected between the collector and 5volts via a 330Ω resistor. This current-driver circuitry
provides approximately 15mA of current to the LED.
Another DAQ Assistant was necessary so that the signal could be outputted via a digital pin
on the MyDAQ. This signal would control the current driving circuitry and thereby the
operation of the external LED. However it is not possible to take the same Boolean signal
used for controlling the front panel LED and pass it into the DAQ assistant. The “Set
Dynamic Data Attributes” is used to return the dynamic data that contains the signal set with
this ExpressVI and any unchanged signals from the input. The output of this function is then
sent to the DAQ Assistant and from there to the MyDAQ. The figure below shows the icon
for setting dynamic data attributes connected to the DAQ Assistant.
Figure 16 set dynamic data attributes
May 1, 2015
Page
20
Case Structure
The initial attempts to implement a counter that increment once upon disruption of the
infrared transmission focused of a function within Labview known as a Case Structure. The
basic premise of a case structure is that it will execute one code or other depending on the
value of the data that is used to trigger the case.
Typically within a case structure there will be two sub-diagrams of code, one that will be
implemented when a certain condition is met and another which is implemented when said
condition is not met. An example of a source that could be used to execute a case statement is
an ordinary Boolean on/off control switch. This Boolean switch would be wired up to the
selector terminal so it could determine the case and therefore the code to be run. If the switch
is turned on and the case structure is then true a specified code for that true condition will be
executed.
Figure 17 Case Structure
At first the case structure, with its true condition executing code similar to that seen in the
figure below, appeared to be the perfect solution for activating a count. A simple ‘+1’ to
increment the count and a shift register were able to provide a count but not the count
required.
The problem with attempting to use a case structure in this context is that the code within the
structure will continue to be executed for as long as the selecting condition is met. The
implications of this feature for the system being designed here is that the case structure was
unable to simply increment the count once only for every instance of the beam being broken.
What happened was that instead of a count for each single instance being activated was that
the count would continue to increment for as long as the beam was broken. Due to this
feature of the case structure, blocking the IR beam for several seconds may result in the count
reaching five or ten depending on the timing settings incorporated in the While Loop.
Despite this, the case structure was not immediately dropped as a possible option. A number
of potential solutions were developed and discussed with the lecturer, including the use of a
number of logic gates in conjunction with a shift register. However by completion of the
project there had been no success with any of these ideas and the case statement had to be
shelved in favour of other possibilities.
May 1, 2015
Page
21
Event Structure
An Event Structure is another conditional function within Labview and its operation does
bear some similarities to the case structure. An event structure waits for an event to occur and
then executes the appropriate code to handle that event. It can have several cases containing
sub-diagrams of code which can be selected depending upon depending upon the event that
occurs.
Just as the case structure had appeared to be a viable solution on first impressions, the event
structure does satisfy some of the criteria that a counter may be presumed to require. It waits
for a certain state to occur before executing the desired operation. As well as this it enables
several different events to be catered for and even allows several different sources to act as
triggers for the execution of the an event. One note of caution regarding the use of event
structures is that they are liable to time out when awaiting an event. Care must be taken to
avoid this problem occurring.
A section from one of the block diagrams constructed during this project has been inserted
below to an event structure which has been designed to increment a ‘+1’ count each time
there is a value change from a Boolean indicator. As with the case structure in the previous
section this type of solution would prove elusive.
Figure 18 Event Structure
With the assistance of the supervising lecturer many different configurations were considered
when attempting to implement the count with an event structure and at certain stages it
appeared likely that it would be able to provide the functionality required. One example of
the type of configurations that were developed is a prototype which used a Boolean toggle
switch to execute the event structure and subsequently increment the count by one. When the
switch was pushed back in the reverse direction the ‘+1’ was bypassed, ensuring the correct
procedure for the counter that was being sought.
Unfortunately when attempting to implement an almost identical system within the existing
VI it was impossible to execute the event structure. A significant amount of time was sent in
search of a solution to this particular problem because a viable counter seemed close enough
to grasp at that point. However it was discovered on further research that indicators, such as
the Boolean one in this VI, are not able to trigger an event but that Boolean controls, such as
slide switches are able to. This discovery prompted further search for a method of
successfully implementing this counter.
May 1, 2015
Page
22
Boolean Crossing PtByPt
The difficulty with efforts to implement a counter using the case and event structures forced
further research on the National Instruments website and forums. This led to the discovery of
a rather different method of counting the number of times the IR beam is blocked.
Fortunately this new method proved successful when configured correctly to meet the
demands of this project.
The focal point of this method is the Boolean Crossing PtByPt VI. It is used to in Labview to
detect the transition of a specified input. A description of the Vis operation, taken directly
from the National Instruments website has been inserted below:
Detects transitions of input. You can choose one of the following directions: either, false-true,
or true-false.
initialize, when TRUE, initializes the internal state of the VI.
input is a Boolean input value.
direction is the kind of Boolean crossing.
0 either
1 false-true
2 true-false
crossing is TRUE if a Boolean crossing occurred.
As you can see from the extract above, there are three inputs to the Boolean PtByPt and one
output. The system being developed for this project would not require an initialize input as it
was key a transition could be detected at all times. The input, which is the value whose
transition is to be measured, must be a Boolean input. This is perfect in this context as a
Boolean indicator is used to signify whether the IR beam is broken or not and can therefore
also operate as the input.
The direction input to the Boolean PtByPt allows the user to program which transition should
be detected. There are three options, ‘either’, ‘false-true’ and ‘true-false’. The ‘either’
condition means that a TRUE output would be produced upon a transition regardless of the
direction, making it a setting that is unsuitable in this instance. The other two direction
settings could both be implemented for this counter depending upon how the inputs were
configured.
Figure 19 below displays the configuration of the entire counter system based around the
Boolean Crossing PtByPt. Some elements that were featured in the previous concepts are still
featured here, for example the ‘+1’ increment function and the shift register.
May 1, 2015
Page
23
Figure 19 Boolean Crossing PtByPt
The input to the Boolean Crossing PtByPt as it is configured in the diagram above, is set-up
to detect a true to false transition is the Boolean input. This corresponds to a detection of the
IR transmission being blocked. When this condition is met the selector will enable the count
to be incremented by one. If the detection of a transition has not occurred than the FALSE
output of the Boolean Crossing will enable the shift-register to bypass the ‘+1’ and the count
will remain static.
The output of the selector is connected to a front-panel indicator which displays the current
value of the count. This same output is also passed to a subtract function, which has a
constant value associated (arbitrarily set to 512 in this example). The count is then subtracted
from the constant value and this number displayed on a front-panel indicator.
The Boolean PtByPt Crossing set-up in the above configuration proved to be a successful
method for implementing the count as required. It seems that the reason for its successful
application in this project is that it detects a transition rather than an ‘event’ or ‘case’.
Because it detects a transition, and more specifically the direction of that transition it has
provided the ideal solution to this problem.
Note: A sub-diagram of the Boolean PtByPt Crossing has been included in the appendix of
this report.
May 1, 2015
Page
24
Complete VI
This section includes pictures and descriptions of both the final black diagram and the final
front panel of the project.
Block Diagram
The figure inserted below is a screenshot, taken from Labview, of the final block diagram. It
includes all of the different functions required to operate the system correctly as well as any
SubVIs such as the one created to generate the modulated Infrared pulse. The final block
diagram has been annotated with text boxes providing information on how and why the
system operates as it does.
Figure 20 Block Diagram of final VI
It can be seen from viewing the block diagram above that the majority of the code exists
within the structure of a While Loop. This While Loop functions by repeating the code
housed within it until some specified condition occurs. It is this function that enables the
system to run continuously after it has been initialised.
Inside the While Loop are all the pieces of code that could be viewed as separate but also
integrated. The SubVI which generated the 38KHz modulated pulse is there as is the front
panel indicator and the DAQ Assistant which are used to turn on the internal and external
LEDs.
Towards the top of the While Loop is the section of code that increments a count each time
the IR beam is broken. This includes the Boolean PtByPt and shift register as well as some
the other logic that is required to make the counter function correctly.
Outside of the While Loop is the portion of the code that has been inserted to bring in to
Labview the output of the TSOP31328 receiver. This code creates a virtual channel for the
input voltage and allows the user to specify the type of input before beginning the task. The
output from the Start Task VI is then fed into the While Loop where the frequency can be
displayed and this information used to perform other functions.
May 1, 2015
Page
25
Front Panel
The final front panel of the project provides the user interface for the monitoring system. It
includes a number of indicators and controls that are relevant to the operation of the system.
Several indicators and controls that may have been part of the front panel at various stages of
the project have been omitted from the final version. The reason for this is simply that they
provide no functionality for anyone who may be using this system. For instance, the
waveform charts of the two original pulses and the subsequently modulated versions could
have been left in the front panel if required, however they would have no real functionality
for the user.
Figure 21 Front Panel of final VI
The screenshot of the front panel depicts how Labview enables customization through a
number of different features. The pane tool allows the user to separate sections of the front
panel if desired. The front panel above has been sectioned off to display the system indicators
in the larger central pane and the controls in the pane to the right of the screen. The top of the
screen has also been sectioned off to include some basic information such as the name of the
system.
The front panel has been further customised by the insertion of the National Instruments and
the Institute logos. There are several ways to do this, one being to save pictures into the
Labview program files on the C drive. However a much simpler method, which was used
here, is to click and drag the pictures from a folder into Labview.
It is important to lay out the front panel in a manner that makes the necessary information
visible and clear with a secondary consideration being to make in at attractive to the user as
possible. Further customization tools that have been utilised to make this possible include the
ability to change background colours, font colours and font sizes, all of which are visible on
the front panel shown above.
May 1, 2015
Page
26
Discussion and Analysis of Results
The object of this assignment was to control an Infrared transmitter/receiver circuit and to
implement a counter that would increment each time the IR beam has been broken. Before
discussing in greater detail specific areas of the project and possible future expansion of the
work completed, it is important to note that these basic components of the project have been
successfully realised.
The ability to control this type of transmitter/receiver system from a central hub such as
Labview, provides easily accessible control, even for someone completely untrained in this
type of technology. For instance, adjustable controls enable the user to set the frequency of
the pulse used to generate the infrared transmission. A virtue of this feature is that the
transmission frequency can be changed, if required, to match the accepted carrier frequency
of a different receiver module. This is a much more efficient system than the one used for
investigation purposes during this project. That circuits use of the 555 timer and discrete
components, means that it must be designed to combine its operation with a specific range of
receivers. A visible comparison of the traditional receiver circuit and the one requires when
using this Labview based system can be viewed in the appendix of this report.
Mention of the 555 timer model for the transmitter/receiver circuit leads onto the positive
influence of investigation and analysis of previous projects. This is a system that provides the
functionality that this Labview project was attempting to emulate. Due to a systematic
approach to the analysis of this circuit, it provided invaluable lessons on the operation of both
the transmitter and receiver. Perhaps most significantly, analysis of the output from the
receiver led to an understanding of the fact that this output was only low when the 38KHz IR
signal was being detected. A fact that, once understood, provided a much clearer of how that
signal would need to be processed within Labview.
Reviewing the results of this project while compiling this report has led to the realisation that
the functionality of Labview is restricted by the hardware it is being interfaced with.
Beginning with the USB-6008, which has been used with success on a number of previous
projects, it is obvious that this device is not able to handle many of the complex actions
Labview is able to execute. That is not to say that the USB-6008 is not an excellent device in
many circumstances, but merely that it placed a restriction on this project that could only be
lifted by a substitution of the hardware.
This substitution for the MyDAQ proved a successful solution for the primary issue of the
USB-6008 being unable to generate the required output. However it the device is not a
panacea for the problems that can be caused due to the limitation of hardware. This is
highlighted by the fact that the omission of a second input counter on the MyDAQ prevented
the inclusion of a second transmitter/receiver circuit which would have greatly improved the
technical achievement of this project.
The use of SubVIs within the overall VI is a subject worthy of a separate report. SubVIs
serve a number of functions within Labview, not least to provide clarity as increasingly dense
Vis become indecipherable. This was certainly the case within the final block diagram on this
May 1, 2015
Page
27
project. Modularizing the VI into sections, for example the block which generated the signal,
helped to structure the flow of the code and made it much easier to troubleshoot problems.
Modularizing a block diagram into SubVIs not only helps to de-clutter the working
environment but it can also assist in preventing problems arising from having too much code
situated on one block diagram.
As the final date for completion of the project drew closer, presentation of the work became
an increasingly important factor. Specifically within Labview this related to the front panel
that would provide the user interface for the entire system. Labview comes equipped with
several features that assist with customization of the front panel and once again the National
Instruments website and forums provided excellent direction.
Background colouring, descriptive text and importing pictures all combine towards making
an attractive front panel. Perhaps the cleverest tool at the user’s disposal is the ability to pane
the window into separate sections. This style has been implemented in the final front panel
for this project and enables separation of controls, indicators and titles.
In terms of the potential for further expansion within this project the most obvious
improvement would be the inclusion of a second transmitter/receiver circuit that would be
used to counteract the count of the original. If the system as it stands is used to count the
number of cars going into a carpark then the additional components would be used to
decrement this count each time a car leaves. The logic required to activate this is incredibly
simple to implement within Labview but the limitations of the MyDAQ with regards to the
input counter made it unachievable on this occasion.
A secondary expansion which has been considered as a possibility for this system is the use
of functions within Labview to export data acquired into a Microsoft Excel spreadsheet. This
is an idea sourced from a previous project and may have had some relevance in this instance
for recording keeping or volume analysis.
In a project like this one it is not uncommon for the benefits of the process to outweigh the
benefits of the final result. This is probably the case here. Although the project was
successful in that it achieved basically what was its object in the beginning, more lessons
were learnt from the obstacles faced in the process. For instance, the research and
investigation, along with the trial and error, that took place when attempting to refine a
working counter will probably prove to be the most beneficial part of the project. For
instance, the understanding gained about the inability of an indicator to execute an Event
Structure, came directly from a problem that required research to resolve.
May 1, 2015
Page
28
Conclusions
There are several positives to be taken away from this project. Perhaps one of the more
important of these is the increased competency developed over the course of the project with
regards to Labview. Having the freedom to explore possible solutions and alternative
methods stimulates a level of development that previous Labview projects were less able to
do.
As mentioned previously in this report, the National Instruments website and Labview
forums together constitute an invaluable resource for learning, understanding and discovering
best practices within Labview. The use of these forums was particularly useful on this project
when researching potential methods for implementing the counter to meet specifications.
Although many of the suggested solutions proved unsuccessful, the reasons for this were
made more clear.
The very nature of this twelve week individual project was quite different to the structure of
any previous projects undertaken. For instance, in previous project modules each student
would have been working on the same assignment simultaneously. This provides a type of
safety-net, in that problems can be discussed and results verified. The fact that each
individual project in final semester is unique to each student puts more emphasis on good
practices such as research and note-taking. As well as encouraging better practice, the fact
that the assignments are individual probably adds a certain amount of pride in the work that
may not have existed when the projects were shared.
The most frustrating element of working on this project has been the time spent attempting to
correctly implement a counter and the effect this may have had on expanding the overall
scope of the project. There is certainly potential for improvements to be made to the
completed system, however the time spent in consideration of a counting system severely
limited the time that could be allocated to these improvements.
Despite the frustration it may have caused, the process of determining a method and
implementing a working counter was ultimately a rewarding one. It undoubtedly contributed
to improving understanding of the way Labview works and through research and
experimentation many functions that had hitherto been unknown became familiar resources
that can only be helpful in the future.
In many ways the final semester individual project condenses some of the key elements that
combine to make a competent engineer. These include analysis of a problem or requirement,
consideration of potential solutions and implementation of a solution using the most effective
means available. Other elements are the ability to accurately document the work undertaken
and present these findings to colleagues in a manner that is comprehensible.
In completing this project several, if not all, of the skills described in the preceding paragraph
have been demonstrated while the work undertaken has contributed to the overall progression
of this skill-set.
May 1, 2015
Page
29
Appendix
Figure 22 Alternative Oscilloscope simulation
Figure 23 Breadboarded transmitter circuit
May 1, 2015
Page
30
Figure 24 Boolean PtByPt Sub-diagram
Comparison of Receiver circuitry required:
Figure 25 Comparison between receiver circuits
May 1, 2015
Page
31
Figure 26 Infrared LED transmitting
References
Datasheets
MyDAQ: http://www.ni.com/pdf/manuals/373061f.pdf
USB-6008: http://www.ni.com/datasheet/pdf/en/ds-218
TSOP31328: http://www.vishay.com/docs/82459/tsop48.pdf
Websites
http://uk.ni.com/
http://forums.ni.com/t5/LabVIEW/bd-p/170
http://labs.physics.dur.ac.uk/skills/skills/labskills/labview/tips_and_tricks.php
http://electrons.psychogenic.com/modules/arms/art/13/InfraRedSignaling.php
https://learn.sparkfun.com/tutorials/ir-communication
http://ie.rs-online.com/web/
http://www.mouser.com/catalog/specsheets/Everlight-HIR204C-H0_V4%20.pdf
Videos
Labview DAQ Assistant for Analog IO - https://www.youtube.com/watch?v=FEIQJa522aY
Labview Basics of front panel - https://www.youtube.com/watch?v=tKT2K9tMrh0
Measurements with DAQ NI USB 6008 - https://www.youtube.com/watch?v=BXice6P9F7I
May 1, 2015
Page
32

More Related Content

Similar to Generating and Receiving Infrared Signals in Labview

Optimization of an Energy-Generating Turnstile
Optimization of an Energy-Generating TurnstileOptimization of an Energy-Generating Turnstile
Optimization of an Energy-Generating TurnstileWayne Smith
 
Control engineering assignment
Control engineering assignment Control engineering assignment
Control engineering assignment Abdo Ali Alsharai
 
Irrigation Design Manual
Irrigation Design ManualIrrigation Design Manual
Irrigation Design ManualStephen Musimba
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Bilal Amjad
 
Protective Device Coordination
Protective Device CoordinationProtective Device Coordination
Protective Device Coordinationjoeengi
 
CCFF_Full Report_En_Final
CCFF_Full Report_En_FinalCCFF_Full Report_En_Final
CCFF_Full Report_En_FinalUng Soeun
 
Ad kautoscan.com uusp upa usb user manual
Ad kautoscan.com uusp upa usb user manualAd kautoscan.com uusp upa usb user manual
Ad kautoscan.com uusp upa usb user manual星田 龚
 
Feasibility Planning & Costing.pdf
Feasibility Planning & Costing.pdfFeasibility Planning & Costing.pdf
Feasibility Planning & Costing.pdfTiaraManani
 
Project Implementation Plan
Project Implementation PlanProject Implementation Plan
Project Implementation PlanAjjaWalker
 
How to manage future grid dynamics: system value of Smart Power Generation in...
How to manage future grid dynamics: system value of Smart Power Generation in...How to manage future grid dynamics: system value of Smart Power Generation in...
How to manage future grid dynamics: system value of Smart Power Generation in...Smart Power Generation
 
100302 going mobile
100302 going mobile100302 going mobile
100302 going mobileErin Mote
 
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas Emissions
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas EmissionsStudy: LNG and Coal Life Cycle Assessment of Greenhouse Gas Emissions
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas EmissionsMarcellus Drilling News
 

Similar to Generating and Receiving Infrared Signals in Labview (20)

Optimization of an Energy-Generating Turnstile
Optimization of an Energy-Generating TurnstileOptimization of an Energy-Generating Turnstile
Optimization of an Energy-Generating Turnstile
 
Control engineering assignment
Control engineering assignment Control engineering assignment
Control engineering assignment
 
Irrigation Design Manual
Irrigation Design ManualIrrigation Design Manual
Irrigation Design Manual
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
 
Protective Device Coordination
Protective Device CoordinationProtective Device Coordination
Protective Device Coordination
 
Lab_Projekt
Lab_ProjektLab_Projekt
Lab_Projekt
 
CCFF_Full Report_En_Final
CCFF_Full Report_En_FinalCCFF_Full Report_En_Final
CCFF_Full Report_En_Final
 
Ad kautoscan.com uusp upa usb user manual
Ad kautoscan.com uusp upa usb user manualAd kautoscan.com uusp upa usb user manual
Ad kautoscan.com uusp upa usb user manual
 
Tommy Marker
Tommy MarkerTommy Marker
Tommy Marker
 
Feasibility report
Feasibility reportFeasibility report
Feasibility report
 
Feasibility Planning & Costing.pdf
Feasibility Planning & Costing.pdfFeasibility Planning & Costing.pdf
Feasibility Planning & Costing.pdf
 
CEI China Port Development Report 210
CEI China Port Development Report 210CEI China Port Development Report 210
CEI China Port Development Report 210
 
Sample Global Jump Starter Market
Sample Global Jump Starter Market  Sample Global Jump Starter Market
Sample Global Jump Starter Market
 
Sample Global Jump Starter
Sample Global Jump Starter  Sample Global Jump Starter
Sample Global Jump Starter
 
Project Implementation Plan
Project Implementation PlanProject Implementation Plan
Project Implementation Plan
 
How to manage future grid dynamics: system value of Smart Power Generation in...
How to manage future grid dynamics: system value of Smart Power Generation in...How to manage future grid dynamics: system value of Smart Power Generation in...
How to manage future grid dynamics: system value of Smart Power Generation in...
 
Tesi_Gasparetto_Walter
Tesi_Gasparetto_WalterTesi_Gasparetto_Walter
Tesi_Gasparetto_Walter
 
Energy saving
Energy savingEnergy saving
Energy saving
 
100302 going mobile
100302 going mobile100302 going mobile
100302 going mobile
 
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas Emissions
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas EmissionsStudy: LNG and Coal Life Cycle Assessment of Greenhouse Gas Emissions
Study: LNG and Coal Life Cycle Assessment of Greenhouse Gas Emissions
 

Generating and Receiving Infrared Signals in Labview

  • 1. May 1 2015 The project objectives include generation and control of an infrared transmitter/receiver circuit within Labview. A 38KHz modulation scheme will be implemented to transmit the signal. A counter should also be made active in Labview to record how many times the infrared beam has been broken, Project Ciaran Cooney
  • 3. May 1, 2015 Page 2 Contents Table of Figures.......................................................................................................................................3 Abstract...................................................................................................................................................4 Introduction.............................................................................................................................................5 Hardware.................................................................................................................................................6 Infrared LED ........................................................................................................................................6 Infrared Receiver.................................................................................................................................6 USB-6008.............................................................................................................................................6 NI MyDAQ ...........................................................................................................................................7 Additional Components ......................................................................................................................7 Software..................................................................................................................................................7 Labview ...............................................................................................................................................7 Technical Description..............................................................................................................................8 Analysis of Transmitter/Receiver........................................................................................................8 38KHz Modulation ..............................................................................................................................9 Generating a pulsed signal................................................................................................................10 Pulsing the Infrared LED....................................................................................................................13 Receiving the infrared signal.............................................................................................................14 Bringing the signal into Labview.......................................................................................................15 Creating a SubVI................................................................................................................................17 Implementing the counter................................................................................................................18 Case Structure...............................................................................................................................20 Event Structure .............................................................................................................................21 Boolean Crossing PtByPt...............................................................................................................22 Complete VI...........................................................................................................................................24 Block Diagram ...................................................................................................................................24 Front Panel........................................................................................................................................25 Discussion and Analysis of Results........................................................................................................26 Conclusions ...........................................................................................................................................28 Appendix ...............................................................................................................................................29 References ............................................................................................................................................31 Datasheets ....................................................................................................................................31 Websites........................................................................................................................................31 Videos............................................................................................................................................31
  • 4. May 1, 2015 Page 3 Lecture Notes................................................................................... Error! Bookmark not defined. Table of Figures Figure 1 Block Diagram of the system ....................................................................................................5 Figure 2 Infrared LED ..............................................................................................................................6 Figure 3 Infrared Receiver.......................................................................................................................6 Figure 4 USB-6008...................................................................................................................................6 Figure 5 NI MyDAQ .................................................................................................................................7 Figure 6 ISIS Transmitter Schematic .......................................................................................................8 Figure 7 Two pulses taken from the virtual oscilloscope........................................................................9 Figure 8 Square Waveform.vi ...............................................................................................................11 Figure 9 Implementation of Modulation ..............................................................................................12 Figure 10 Front panel (4 waveforms)....................................................................................................12 Figure 11 Current driver block diagram................................................................................................14 Figure 12 Counter Input to Labview .....................................................................................................16 Figure 13 Error correction SubVI...........................................................................................................16 Figure 14 Converting frequency to '1' or '0' .........................................................................................18 Figure 15 set dynamic data attributes..................................................................................................19 Figure 16 Case Structure.......................................................................................................................20 Figure 17 Event Structure .....................................................................................................................21 Figure 18 Boolean Crossing PtByPt.......................................................................................................23 Figure 19 Block Diagram of final VI.......................................................................................................24 Figure 20 Front Panel of final VI............................................................................................................25 Figure 21 Alternative Oscilloscope simulation......................................................................................29 Figure 22 Breadboarded transmitter circuit.........................................................................................29 Figure 23 Boolean PtByPt Sub-diagram ................................................................................................30 Figure 24 Comparison between receiver circuits .................................................................................30 Figure 25 Infrared LED transmitting......................................................................................................31
  • 5. May 1, 2015 Page 4 Abstract The project documented in this report is a final semester individual project contributing to the award stage of a Bachelor of Engineering in Electrical and Electronic Systems. The basic premise of this project is analysis of a traditional infrared transmitter/receiver circuit with the aim of implementing a similar system within National Instruments’ Labview software. Labview provides a platform for building measurement and control applications, allowing the user to display data streams on a laptop or PC monitor. As well as receiving signals for measurement, Labview is able to generate signals specified by the user. This function has proved to be a cornerstone of this project. As a result of the work undertaken, external circuitry required to execute the transmitter/receiver system has been minimized as this streamlined version is largely contained within Labview. The main body of this report will include a detailed account of lab work undertaken and the theory underpinning any methods used. Particular attention is paid to obstacles faced and solutions advanced. The report will conclude with overall impressions of the project, with discussion on possible applications for the system alongside ideas for further development of concept. Keywords  Labview  Infrared Technology  Modulation  Carpark Control  NI MyDAQ
  • 6. May 1, 2015 Page 5 Introduction Infrared (IR) technology is an inexpensive and extremely common form of wireless communication with applications ranging from simple television remote controls to thermographic cameras used for heat detection maps. The project described in this report involves interfacing this IR technology with Labview so that it can be controlled and monitored. Infrared light has a wavelength within a range of 700nm to 1mm, making it impossible for the human eye to detect and therefore ideal for use in wireless communication. However, sources of infrared light exist almost everywhere and specific techniques are required to enable a receiver to differentiate between the wanted and unwanted signals. A common technique employed for this purpose is known as modulation. One of the initial challenges faced in this project was to control this modulation in Labview. Before going into any greater detail on the techniques used to implement the type of system required, it is important to convey a more general synthesis of the project. To this end the block diagram, inserted below in figure 1, depicts the key areas of the infrared transmitter/receiver system and how its flow is controlled by the central hub, which is Labview. Figure 1 Block Diagram of the system As the diagram displays, Labview is used to generate a pulse at the required frequency to control the transmitter via an appropriate Data Acquisition (DAQ) system. The infrared receiver accepts this pulsed signal (if at the correct frequency) which is then sent to Labview via a selected input pin on the same DAQ already in use. The information received can be processed to obtain the information required. In this instance the information is a simple count of the number of times the infrared beam is broken. The concept for this project has been conceived with applications such as counting footfall in a shopping centre or the level of traffic passing through a car-park as potential uses for the system. However this in no way inhibits its potential for use in other areas due to the simplicity of the system and the ease with which changes can be implemented.
  • 7. May 1, 2015 Page 6 Hardware Although this project is by no means a hardware intensive one there are nevertheless a number of key components and devices that warrant a descriptive explanation of their own as to why they have been included. The following is not an exhaustive list of all the hardware employed on this project but an overview of the most important. Infrared LED The infrared LED pictured below is a simple device that can be used to transmit infrared light with a wavelength in the 940nm – 950nm range. It is very typical of the type commonly seen in television remote controls and is perfect for this type of remote sensing system. It is important that the LED is paired with a compatible receiver, of which there are many varieties. Each IR LED has its own forward current requirement, generally ranging from 50mA to 100mA. This current requirement is a factor that must be taken into consideration, especially with the limited current capabilities associated with Labview. Infrared Receiver An Infrared Receiver is a module designed to detect infrared light within a specific range of frequency. The model pictured to the right is a TSOP31328 which is the device used in this project. It is a three-pin device, including one pin for the output which can be connected directly to a microprocessor or, in this case, to Labview via the Data Acquisition module. Different versions of these receiver modules are designed to receive different carrier frequencies. The 31238 accepts a carrier frequency of 38000Hz. USB-6008 The National Instruments USB-6008 is described on that company’s website as a “low-cost multi-function” data acquisition unit. It is a compatible device for interfacing with Labview and is often used for control and sensor applications. It is equipped with 8 analog inputs, 2 analog outputs and 12 digital I/O lines. Other significant features of the device include a 32- bit counter and its built-in signal connectivity. The USB-6008 is the device first used on this project when interfacing the external circuitry with Labview. Figure 2 Infrared LED Figure 3 Infrared Receiver Figure 4 USB-6008
  • 8. May 1, 2015 Page 7 NI MyDAQ The National Instruments MyDAQ is a more recent model of data acquisition device and is equipped with some capabilities the USB-6008 does not possess. It is equipped with a 200kS/s analog sampling rate and provides access to other instruments such as a Digital Multi-meter and a function generator. The MyDAQ also features a 16-bit ADC and a 16-bit DAC and like the USB-6008 a 32-bit- counter. The reasons behind the inclusion of the MyDAQ device in this project are predicated on its ability to perform certain functions that the USB-6008 was unable to. Additional Components There were a number of additional components required to complete the transmitter/receiver circuitry. These include several resistors, transistors and a generic LED implemented as a warning. Any of these components may be referenced during this report as part of the build stage of the project. Software Labview The primary basis for this project is the exploration and execution of a small number of the vast catalogue of functions Labview is capable of performing. In fact, the exploration element of the project may well prove to have been the most important. Especially as the method of achieving the desired result was left open to interpretation in the assignment brief. Labview itself, according to the National Instruments website (http://www.ni.com/), “is a highly productive development environment for creating custom applications that interact with real-world data or signals in fields such as science and engineering”. What this basically means is that Labview provides a more visually intuitive programming model as an alternative to many of the traditional programming languages. The software implements the G programming language which enables a graphical data-flow to be presented at the application layer. Examples, taken from this project, of the graphical interfaces presented by Labview are inserted throughout the technical description section of this report. Another key feature of Labview that makes it an extremely powerful tool across a range of fields is the hardware support it provides for thousands of devices. Labview is able to integrate hardware devices from sensors and scientific instrumentation equipment to Data Acquisition devices like those being used for this project. Figure 5 NI MyDAQ
  • 9. May 1, 2015 Page 8 Technical Description Analysis of Transmitter/Receiver The initial phase of the project was an investigation of the transmitter/receiver circuit, the dual schematic having been provided in the assignment brief. This would enable analysis of the key areas of operation within the circuit, particularly for the generation of the transmitted signal. To begin analysis of the circuit a schematic was contructed on ISIS so that simulations could be run. From these simulations, the frequency of the generated pulse could be determined at specified points on the circuit. Figure 6 ISIS Transmitter Schematic One small problem occurred when the simulation was run for the first time. An Error Message was received specifying that there was “No Model Specified for RV1”. This was a simple problem due to a schematic symbol having been placed in the circuit rather than a model that was available for simulation. It was subsequently replaced with the “3005P-1- 101” and the simulation was able to run successfully. The specified points on the circuit that required measurements are the output ‘Q’ of U1:A and output ‘Q’ of U1:B which can be seen on the schematic diagram. Attaching a virtual oscilloscope to these two points would allow a frequency meaurement to be determined. From the output of U1:A the frequency of the pulse was determined by first calculating the period from the time taken at two points on the pulsed waveform and then dividing one by this answer. These calculations were completed as follows: Period (T) = 25.88ms – 23.72ms = 2.16ms Frequency (F) = 1 𝑇 = 1 2.16𝑚𝑠 = 462.96Hz
  • 10. May 1, 2015 Page 9 At the output of U1:B the investigation was primarily interested in the frequency of the modulated pulse that occurs on the High time of the original slower frequency pulse. To ensure that the circuit was calibrated to produce the correct pulse, the potentiometer was set to 2.7KΩ. The same method as before was used to determine the period and from this the frequemcy. The calculations were completed as follows: Period (T) = 867.9µ𝑠 – 841.2µ𝑠 = 26.7µ𝑠 Frequency (F) = 1 𝑇 = 1 26.7µ𝑠 = 37453Hz Inserted below is a screenshot, taken from the virtual oscillocope available for use on simulations. The upper waverform (yellow) is the output taken from U1:A and the lower, higher frequency pulse has been taken from the output of U1:B. Figure 7 Two pulses taken from the virtual oscilloscope From the frequency determined from this simulation the conclusion has been drawn that this tranmitter/receiver circuit is implementing a specific method often employed in infrared detection applications. The following section provides details behind the operation of this method. 38KHz Modulation The frequency of the two pulse outputs determined from the simulations above, provides proof of a concept that is extemely common for this type of IR transmitter/receiver circuit. This concept is known as 38KHz modulation and it is a method employed to enable a receiving device to recognise the data being transmitted. The frequency of the modulated pulse recorded from the simulation is 37453Hz. Although this is not precisely 38KHz it does fall within an acceptable band for this type of modulation. The reason behind the choice of frequency used for 38KHz modulation is simply that there are very few natural sources of infrared light that exist with a frequency of 38KHz. Therefore the transmitted data can be safely sent and recognised by the transmitter without being
  • 11. May 1, 2015 Page 10 contaminated by the ambient sources of infrared light. 38KHz is not the only method of modulation used in infrared detection circuits but it is by far the most common. The choice of infrared receiver module is dependant upon the the frequency of the modulated pulse it is going to be required to receive. The TSOP31328 is a 38KHz receiver module, perfect for the applications required in this project. Its job, in this project and others, is to demodulate the signal that has been transmitted and output a binary waveform. In this case the binary waveform is required for use in Labview. The neccesity for a binary waveform is the reason for the 462.96Hz pulse that was calculated from the simulations in ISIS. This lower frequency pulse controls the spacing between the modulated signals and allows the signal to be decoded and read in as a serial bit-stream. Generating a pulsed signal Having analysed the transmitter circuit above to determine the method, and chosen the receiver module that would be used to implement this transmitter/receiver system, the challenge was to generate a modulated pulse at the required frequencies, within Labview. One of the luxuries of using Labview to control this is system is the ability to enter discrete values for the frequencies required. Due to this, the frequencies calculated above have been adjusted as follows: 462.96Hz = 470Hz 37453Hz = 38Khz To begin the process of generating a pulsed signal in Labview online research was undertaken to discover some of the methods than were available for this purpose. The method best suited to the demands of this project was determined to be a subVI available within the Labview libraries titled Square Waveform.vi. A fairly simple VI to operate, even for someone with little experience of Labview, it allows the user to enter specific values for parameters such as frequency, amplitude and phase before generating a resultant square- wave. As the square waveform VI is unable to generate the type of modulated pulse required for the transmitter/receiver communication, it was necessary to generate two separate waveforms for the 470Hz and 38KHz signals before taking additional measures to modulate them as a single signal. The following block diagram and the information regarding the generation of these square waves is an extract from the project notebook accompanying this report. It depicts the parameters required by the SubVI in order to generate the two square-waves necessary for modulation.
  • 12. May 1, 2015 Page 11 Figure 8 Square Waveform.vi Offset – Required to be 2.5volts for the 5 volt waveform. Otherwise the square waveform will rise and fall between 2.5 and -2.5volts Frequency – 38KHz signal 1 470Hz signal 2 Amplitude – Set at 2.5volts. Along with the 2.5volt offset this creates a signal range from 0 to 5volts Sampling – Sampling information of the two signals must be identical when multiplying, otherwise errors will occur. As the extract above states, an amplitude offset was required because Labview, by default, would generate a square wave with a peak-to-peak voltage centred around 0V. This is perfectly acceptable for many applications. However for the signal required to provide a pulse for the IR LED it was necessary to apply an amplitude range of 0 to 5volts. One of the many virtues Labview holds for the user is the excellent front-panel interfaces it provides for monitoring and control of the data being processed. This was particularly useful at this stage of the project as the two waveforms initially generated could be viewed and analysed, before steps could be taken to modulate them. A screenshot of the front panel during this phase of the project has been inserted further below in this section. With the parameters entered as stated above, running the square waveform VI produced the two waveforms expected. One with a frequency of 38KHz, one with a frequency of 470Hz and both with a 50% duty cycle and amplitudes of 0 to 5volts. The next task was to modulate these two pulses. The method used to implement this modulation is quite simple because of the functionality of the tools available within Labview. By taking the two waveforms of different frequency but equal amplitude and using the multiply function to combine them both, a resulting, modulated waveform was produced. The waveform returned was indeed a 470Hz pulse with a 38KHz modulated pulse during the period the pulse was high. However a subsidiary effect of utilizing the multiply function to deliver this pulse is the simultaneous multiplication of the amplitudes of the two original signals. The resultant signal therefore has an amplitude of
  • 13. May 1, 2015 Page 12 25volts. To rectify this unwanted by-product, a division function with a constant value of five has been used to counter the increased amplitude and return it to 5volts. The figure below is a section of a block diagram, taken from Labview, displaying the process described in the previous paragraph. Figure 9 Implementation of Modulation Inserted below is a screenshot of the front panel of this VI. There are four waveform charts on the front panel, each one to display the four signals generated during this modulation process, including Waveform D, which is the final result. The front panel in this instance proved useful for ensuring that the process was effective in delivering the required result. Figure 10 Front panel (4 waveforms) This is by no means an accurate representation of the appearance of the front panel at the conclusion of the project. However it does provide useful insight into the processes followed when generating the output signal.
  • 14. May 1, 2015 Page 13 Pulsing the Infrared LED With the modulated pulse having been successfully generated, the next task to be faced was using that signal to pulse an external IR LED, a challenge that proved more difficult than anticipated. A simple circuit was constructed on a breadboard, consisting of one 390Ω resistor and a standard LED. The LED was used to simulate the operation of the IR LED simply because its light can be perceived by the human eye. To provide a link between Labview software and the external circuitry, a data acquisition module is required. As with all previous Labview projects undertaken at this Institue, the DAQ provided for this one was the USB-6008. This is an extremely common data acquisition unit with many applications. The USB-6008 was connected to this external circuitry via its analog output Ao. Unfortunately, when running the VI with the expectation of viewing a pulsing light being emitted from the LED, there was no evidence any such activity. Despite reassessing the connections of the external circuitry and the functionality of the LED itself, no solution was immediately discovered. An online investigation was then pursued with the intent of discovering possible sources of the problem and potential remedies. An excellent resource at this time, and throughout this project, was the National Instruments website (http://uk.ni.com/). On this website are discussion forums with multiple threads providing extensive information on all kinds of issues regarding Labview. A very small word of warning would be the importance of specifying a problem correctly and with detail, simply due to the vast quantity of information available. Research into the problem finally led to the discovery that the configuration capabilities of the USB-6008 were not suitable for the required application. Because of the limitations of the USB-6008, the DAQ Assistant within the Labview VI could only be configured to enable “ 1 sample on demand”, making it unable to generate the continuous pulsed signal necessary for this project. With this diagnosis, it was determined that replacement hardware would be needed. The NI MyDAQ was provided as the replacement data acquisition module. The device is described on the National Instruments website as having “the ability to measure and analyse live signals anywhere anytime” and has some extended capabilities that the USB-6008 does not possess. Specifically, with relevance to this project, is allows the selection of “N samples” when configuring a DAQ Assistant and can therefore generate the continuous pulse required to operate the IR LED correctly. With the MyDAQ replacing the USB-6008 a pulsed light could now be perceived emitting from the LED. However, the strength of the light being emitted was rather unimpressive, a consequence of the current capabilities of the MyDAQ. According to the associated user manual the MyDAQ has a maximum rated analog output current of 2mA, considerably lower
  • 15. May 1, 2015 Page 14 than the ideal requirement for a standard LED or an infrared LED. To combat this restriction a current driver circuit was constructed on the breadboard to increase the current passing through the LED. A block diagram of this circuitry has been inserted below: Figure 11 Current driver block diagram In this circuit configuration the transistor effectively operates as a switch. The analog output from the MyDAQ is connected to the base of the transistor via 4.7KΩ resistor, meaning the pulse from the Labview signal controls the operation of the transistor. A 390Ω resistor connects the collector of the transistor to the LED which is then pulled to 5volts. To complete the circuit the emitter of the transistor is passed to Ground. The current-driver circuitry results in the desired increase in the strength of light emitted from the LED. The LED could then be replaced by the IR LED for the remainder of the project. At this stage, the digital camera from a mobile phone was used to test the IR LED to ensure that it was transmitting. Although the human eye is unable to detect infrared light, modern digital cameras are able to and this test confirmed that the LED was indeed transmitting. Receiving the infrared signal Before attempting to read any received signals from the TSOP31328 into Labview it was decided to use a pre-existing receiver circuit, made available in the lab, to understand how the received signal changed the output of the receiver module. The initial investigation was a simple visual inspection of the reaction of the receiver circuit to the infrared transmission. As the circuit was fitted with two LEDs it was possible to perceive that both remained off for as long as the beam was being transmitted and received by the detector. Upon blocking the infrared beam the two LEDs would light to signify the beam has been broken. By connecting an oscilloscope to the output of the TSOP31328 on the receiver circuit the changing voltage levels could be observed as the signal was transmitted and then as the signal was blocked. The output of the TSOP31328 is active low, and is typically connected to a microcontroller, or in this case a data acquisition module. This means that the output is High when no signal in received and only Low when a 38KHz pulse is detected. As would be expected from a device with an active low output, the oscilloscope confirmed that the output of the TSOP31328 would be pulled High when the infrared beam was broken
  • 16. May 1, 2015 Page 15 and would remain High for as long as no transmission was being received. At times when the infrared LED was transmitting and the TSOP31328 receiving, the receiver output produced a pulsed DC voltage of approximately 470Hz. Thinking about this logically from the information compiled for this report, a 470Hz pulse is exactly the output that should be expected. When the Labview generated signal is transmitting, the receiver module (which only detects infrared light at 38KHz) emits an active-low output for approximately 1ms. This 1ms period occurs while the infrared pulse is High and the 38KHz frequency IR light can be detected. As the carrier signal goes Low, again for approximately 1ms, the output of the TSOP31328 becomes High. It is this shifting between the inactive-high and active-low states that produces the 470Hz pulsed output of the receiver module when the IR LED is transmitting and being received. The pulsing 470Hz output signal of the receiver module is what would enable decoding of the signal within Labview to decipher when the IR LED was active and when it was being blocked. Bringing the signal into Labview With a sophisticated piece of software like Labview it can be expected that there are always more than one avenue to explore when attempting to achieve a desired outcome. When it came to reading in the output signal from the receiver module, the first method pursued was simply to insert another DAQ Assistant into the VI and configure it to acquire an analog voltage. Although this method may not have been able to determine the frequency of the signal it was not expected that there would be any problems acquiring it. This assumption was incorrect as, upon running the VI, the Error Code 200474 was returned, stating “some or all of the samples requested have not yet been acquired”. This is an error that occurs because the timeout has been reached before the samples are received. The timeout is calculated as follows Timeout ≥ 𝑆𝑎𝑚𝑝𝑙𝑒𝑠 𝑡𝑜 𝑅𝑒𝑎𝑑 𝑆𝑎𝑚𝑝𝑙𝑒 𝑅𝑎𝑡𝑒 Discovery of this formula for determining the Timeout led to a series of adjustments to the sampling frequency and the number of samples taken. However none of these adjustments provides a sustainable solution and further investigation was required. This further investigation led to a solution that would satisfy the requirements of bringing in a signal that could be measured for frequency as well as avoiding the type of error stated above. The primary realisation with regards to the input signal was that it would be necessary to use the counter input on the MyDAQ as it is the channel used for counter/timer functions. This meant having to connect the output of the TSOP31328 to DIO 0 for the counter source. The section of Labview code in the figure below shows how the received signal enters the While Loop via the counter input and Virtual Channel VI.
  • 17. May 1, 2015 Page 16 Figure 12 Counter Input to Labview A virtual channel, such as the one in the VI above, is a collection of settings like a name, physical channel, input terminal connections and the type of measurement to be employed. From this section of the block diagram it can be seen that the type of measurement is a Low Frequency Counter and the physical channel is the counter input. This section of the code occurs outside the loop and the Start Task VI is used to pass the signal inside where it can be used to display the frequency. Within the While Loop a SubVI known as DAQmx Read.vi is used to read the signal and return a frequency value to a front-panel indicator. The use of the counter input along with the virtual channel did not however solve the problem with timeouts occurring. The specific problem with this method of inputting and measuring the frequency is that some versions of DAQmx drivers will return this error when the frequency drops below 100Hz. As an operating requirement of the system being developed is that the frequency is zero when the signal is blocked, this is a problem that could not be ignored. The section of code extracted from the block-diagram shows how this problem was overcome. It operates basically by clearing the specific error number on each iteration of the loop. Figure 13 Error correction SubVI
  • 18. May 1, 2015 Page 17 By using the equal to function with the error code number acting as the constant value and then a selector the code will continue to act as normal when no error occurs. However when an error occurs that is equal to the constant error code the selector will implement a different output of the code which is able to clear the error. Interestingly, this is a solution that can be implemented for other errors by changing the constant code input to the equal to function. With the signal received by the TSOP31328 now being measured and the frequency displayed in Labview the next challenge was to implement a counter to increment once upon the IR beam being broken. However before approaching this task a process of modularising the block-diagram into SubVIs was undertaken. Creating a SubVI By modularising a Labview block-diagram, sections of code are separated into smaller blocks, known as SubVIs. SubVIs are exactly the same as normal Vis and exist as blocks of code within the overall system in a way that is similar to a sub-routine in other programming languages. Among the virtues of using a SubVI are improving the clarity of a block-diagram that contains a large amount of code and with this improving the ease of troubleshooting when errors occur. There are two main ways of creating a SubVI in Labview. One is to create it as you would a normal VI with the code required for a certain section and save it as so. This can then be brought into another block-diagram by entering the controls menu and clicking on ‘Select a VI’. A little box indicator of the VI is placed on the block-diagram, including connectors for any inputs and outputs required. The second method involves creating a SubVI from code that has already been developed and placed onto the block-diagram. Simply by highlighting the section of code to be included in the SubVi and then clicking on Edit and Create SubVI a SubVI will be generated and a corresponding indicator placed on the diagram to replace the code. It is important when creating and implementing a SubVI that the connector pane is correctly configured as this provides inputs from and outputs to the greater block-diagram. The SubVI icon can also be edited so that the appearance matches more closely the task the code is being asked to perform. The figure below displays the connector pane and the icon of the SubVI created to generate the 38KZ modulated pulse. Figure 14 SubVI connector pane and icon
  • 19. May 1, 2015 Page 18 Implementing the counter Having completed the task of bringing the received signal into Labview, via the counter input, and displaying the frequency on a front panel indicator, measures were to be taken to process this information so that a counter would increment each time the Infrared beam was broken. It was an important feature of this counter that it would only increment once per instance of the beam being broken, regardless of how long the blockage may occur. It was equally important to ensure that upon re-detection of the IR signal that the count was not incremented. To begin the process of implementing this counter, a little logic was required to produce a Boolean 1 or 0. A ’1’ would be used to signify the beam had been broken and a ‘0’ representing the opposite state. The first step taken at this stage was to construct a range of frequencies from which to determine that the infrared signal was currently being received. The reason for doing this was that, from the front panel indicator it was noticeable that the frequency from the counter input was not completely stable. This instability is likely to be the effect of noise or a similar factor. The chosen frequency range is between 455Hz and 485Hz, as can be seen in the figure below. Figure 15 Converting frequency to '1' or '0' This figure, a direct extract from Labview, also depicts the use of the “Greater or Equal” and “Less or Equal” comparative functions, which in conjunction with an AND Gate, produce a binary 1 or 0 output. This small section of code works as follows:  The frequency value, having been read in from the counter input, is directed concurrently to both the “Greater or Equal” and “Less or Equal” functions.  For the “Greater or Equal”, if the frequency is greater than the constant value 455, a value of ‘1’ is produced at the output.  For the “Less or Equal”, if the frequency is less than the constant value 485, a value of ‘1’ is produced at the output.  These two output values are then sent as inputs to the AND Gate. As an AND Gate only produces a HIGH output when both inputs are HIGH, the output of the AND Gate will be ‘1’ only when the frequency is approximately 470Hz. This signifies that the TSOP31328 is currently receiving an infrared beam.  The output of the AND Gate is inverted (or alternatively a NAND Gate could be used) to produce a ‘0’ when the signal is transmitting and thereby a ‘1’ when the beam is broken.
  • 20. May 1, 2015 Page 19 With a front panel indicator inserted that would display a 1 or 0 depending on the transmitter’s reception of an infrared signal or not, the intention was to use the values displayed for three separate tasks. First, to control a warning light on the front panel of the VI that would turn on each time the IR beam has been broken. Second, to control an external LED that would perform the same function. And third, to provide the data for a counter that would increment by one each time the beam was broken. The first two tasks proved to be relatively simple to implement. The third required much more time research than anticipated at the outset. Inserting a front panel LED to turn on when the infrared beam is broken was quite a simple task. By right clicking on the front panel, which opens the controls menu, and subsequently opening the Boolean menu, a Round LED was selected and placed on the front panel. A corresponding icon then appears on the block diagram which can be attached to the output of the previously discussed inverter. Employing an external LED to perform the same notification function required a little more effort. To begin with, external circuitry had to be constructed on a breadboard. Remembering that the output current of the MyDAQ has a maximum value of 2mA, the same type of current-driving circuitry would be required for this LED as was required for the IR LED. Once again a transistor was included, with a 4.7KΩ resistor connected to its base. The LED is connected between the collector and 5volts via a 330Ω resistor. This current-driver circuitry provides approximately 15mA of current to the LED. Another DAQ Assistant was necessary so that the signal could be outputted via a digital pin on the MyDAQ. This signal would control the current driving circuitry and thereby the operation of the external LED. However it is not possible to take the same Boolean signal used for controlling the front panel LED and pass it into the DAQ assistant. The “Set Dynamic Data Attributes” is used to return the dynamic data that contains the signal set with this ExpressVI and any unchanged signals from the input. The output of this function is then sent to the DAQ Assistant and from there to the MyDAQ. The figure below shows the icon for setting dynamic data attributes connected to the DAQ Assistant. Figure 16 set dynamic data attributes
  • 21. May 1, 2015 Page 20 Case Structure The initial attempts to implement a counter that increment once upon disruption of the infrared transmission focused of a function within Labview known as a Case Structure. The basic premise of a case structure is that it will execute one code or other depending on the value of the data that is used to trigger the case. Typically within a case structure there will be two sub-diagrams of code, one that will be implemented when a certain condition is met and another which is implemented when said condition is not met. An example of a source that could be used to execute a case statement is an ordinary Boolean on/off control switch. This Boolean switch would be wired up to the selector terminal so it could determine the case and therefore the code to be run. If the switch is turned on and the case structure is then true a specified code for that true condition will be executed. Figure 17 Case Structure At first the case structure, with its true condition executing code similar to that seen in the figure below, appeared to be the perfect solution for activating a count. A simple ‘+1’ to increment the count and a shift register were able to provide a count but not the count required. The problem with attempting to use a case structure in this context is that the code within the structure will continue to be executed for as long as the selecting condition is met. The implications of this feature for the system being designed here is that the case structure was unable to simply increment the count once only for every instance of the beam being broken. What happened was that instead of a count for each single instance being activated was that the count would continue to increment for as long as the beam was broken. Due to this feature of the case structure, blocking the IR beam for several seconds may result in the count reaching five or ten depending on the timing settings incorporated in the While Loop. Despite this, the case structure was not immediately dropped as a possible option. A number of potential solutions were developed and discussed with the lecturer, including the use of a number of logic gates in conjunction with a shift register. However by completion of the project there had been no success with any of these ideas and the case statement had to be shelved in favour of other possibilities.
  • 22. May 1, 2015 Page 21 Event Structure An Event Structure is another conditional function within Labview and its operation does bear some similarities to the case structure. An event structure waits for an event to occur and then executes the appropriate code to handle that event. It can have several cases containing sub-diagrams of code which can be selected depending upon depending upon the event that occurs. Just as the case structure had appeared to be a viable solution on first impressions, the event structure does satisfy some of the criteria that a counter may be presumed to require. It waits for a certain state to occur before executing the desired operation. As well as this it enables several different events to be catered for and even allows several different sources to act as triggers for the execution of the an event. One note of caution regarding the use of event structures is that they are liable to time out when awaiting an event. Care must be taken to avoid this problem occurring. A section from one of the block diagrams constructed during this project has been inserted below to an event structure which has been designed to increment a ‘+1’ count each time there is a value change from a Boolean indicator. As with the case structure in the previous section this type of solution would prove elusive. Figure 18 Event Structure With the assistance of the supervising lecturer many different configurations were considered when attempting to implement the count with an event structure and at certain stages it appeared likely that it would be able to provide the functionality required. One example of the type of configurations that were developed is a prototype which used a Boolean toggle switch to execute the event structure and subsequently increment the count by one. When the switch was pushed back in the reverse direction the ‘+1’ was bypassed, ensuring the correct procedure for the counter that was being sought. Unfortunately when attempting to implement an almost identical system within the existing VI it was impossible to execute the event structure. A significant amount of time was sent in search of a solution to this particular problem because a viable counter seemed close enough to grasp at that point. However it was discovered on further research that indicators, such as the Boolean one in this VI, are not able to trigger an event but that Boolean controls, such as slide switches are able to. This discovery prompted further search for a method of successfully implementing this counter.
  • 23. May 1, 2015 Page 22 Boolean Crossing PtByPt The difficulty with efforts to implement a counter using the case and event structures forced further research on the National Instruments website and forums. This led to the discovery of a rather different method of counting the number of times the IR beam is blocked. Fortunately this new method proved successful when configured correctly to meet the demands of this project. The focal point of this method is the Boolean Crossing PtByPt VI. It is used to in Labview to detect the transition of a specified input. A description of the Vis operation, taken directly from the National Instruments website has been inserted below: Detects transitions of input. You can choose one of the following directions: either, false-true, or true-false. initialize, when TRUE, initializes the internal state of the VI. input is a Boolean input value. direction is the kind of Boolean crossing. 0 either 1 false-true 2 true-false crossing is TRUE if a Boolean crossing occurred. As you can see from the extract above, there are three inputs to the Boolean PtByPt and one output. The system being developed for this project would not require an initialize input as it was key a transition could be detected at all times. The input, which is the value whose transition is to be measured, must be a Boolean input. This is perfect in this context as a Boolean indicator is used to signify whether the IR beam is broken or not and can therefore also operate as the input. The direction input to the Boolean PtByPt allows the user to program which transition should be detected. There are three options, ‘either’, ‘false-true’ and ‘true-false’. The ‘either’ condition means that a TRUE output would be produced upon a transition regardless of the direction, making it a setting that is unsuitable in this instance. The other two direction settings could both be implemented for this counter depending upon how the inputs were configured. Figure 19 below displays the configuration of the entire counter system based around the Boolean Crossing PtByPt. Some elements that were featured in the previous concepts are still featured here, for example the ‘+1’ increment function and the shift register.
  • 24. May 1, 2015 Page 23 Figure 19 Boolean Crossing PtByPt The input to the Boolean Crossing PtByPt as it is configured in the diagram above, is set-up to detect a true to false transition is the Boolean input. This corresponds to a detection of the IR transmission being blocked. When this condition is met the selector will enable the count to be incremented by one. If the detection of a transition has not occurred than the FALSE output of the Boolean Crossing will enable the shift-register to bypass the ‘+1’ and the count will remain static. The output of the selector is connected to a front-panel indicator which displays the current value of the count. This same output is also passed to a subtract function, which has a constant value associated (arbitrarily set to 512 in this example). The count is then subtracted from the constant value and this number displayed on a front-panel indicator. The Boolean PtByPt Crossing set-up in the above configuration proved to be a successful method for implementing the count as required. It seems that the reason for its successful application in this project is that it detects a transition rather than an ‘event’ or ‘case’. Because it detects a transition, and more specifically the direction of that transition it has provided the ideal solution to this problem. Note: A sub-diagram of the Boolean PtByPt Crossing has been included in the appendix of this report.
  • 25. May 1, 2015 Page 24 Complete VI This section includes pictures and descriptions of both the final black diagram and the final front panel of the project. Block Diagram The figure inserted below is a screenshot, taken from Labview, of the final block diagram. It includes all of the different functions required to operate the system correctly as well as any SubVIs such as the one created to generate the modulated Infrared pulse. The final block diagram has been annotated with text boxes providing information on how and why the system operates as it does. Figure 20 Block Diagram of final VI It can be seen from viewing the block diagram above that the majority of the code exists within the structure of a While Loop. This While Loop functions by repeating the code housed within it until some specified condition occurs. It is this function that enables the system to run continuously after it has been initialised. Inside the While Loop are all the pieces of code that could be viewed as separate but also integrated. The SubVI which generated the 38KHz modulated pulse is there as is the front panel indicator and the DAQ Assistant which are used to turn on the internal and external LEDs. Towards the top of the While Loop is the section of code that increments a count each time the IR beam is broken. This includes the Boolean PtByPt and shift register as well as some the other logic that is required to make the counter function correctly. Outside of the While Loop is the portion of the code that has been inserted to bring in to Labview the output of the TSOP31328 receiver. This code creates a virtual channel for the input voltage and allows the user to specify the type of input before beginning the task. The output from the Start Task VI is then fed into the While Loop where the frequency can be displayed and this information used to perform other functions.
  • 26. May 1, 2015 Page 25 Front Panel The final front panel of the project provides the user interface for the monitoring system. It includes a number of indicators and controls that are relevant to the operation of the system. Several indicators and controls that may have been part of the front panel at various stages of the project have been omitted from the final version. The reason for this is simply that they provide no functionality for anyone who may be using this system. For instance, the waveform charts of the two original pulses and the subsequently modulated versions could have been left in the front panel if required, however they would have no real functionality for the user. Figure 21 Front Panel of final VI The screenshot of the front panel depicts how Labview enables customization through a number of different features. The pane tool allows the user to separate sections of the front panel if desired. The front panel above has been sectioned off to display the system indicators in the larger central pane and the controls in the pane to the right of the screen. The top of the screen has also been sectioned off to include some basic information such as the name of the system. The front panel has been further customised by the insertion of the National Instruments and the Institute logos. There are several ways to do this, one being to save pictures into the Labview program files on the C drive. However a much simpler method, which was used here, is to click and drag the pictures from a folder into Labview. It is important to lay out the front panel in a manner that makes the necessary information visible and clear with a secondary consideration being to make in at attractive to the user as possible. Further customization tools that have been utilised to make this possible include the ability to change background colours, font colours and font sizes, all of which are visible on the front panel shown above.
  • 27. May 1, 2015 Page 26 Discussion and Analysis of Results The object of this assignment was to control an Infrared transmitter/receiver circuit and to implement a counter that would increment each time the IR beam has been broken. Before discussing in greater detail specific areas of the project and possible future expansion of the work completed, it is important to note that these basic components of the project have been successfully realised. The ability to control this type of transmitter/receiver system from a central hub such as Labview, provides easily accessible control, even for someone completely untrained in this type of technology. For instance, adjustable controls enable the user to set the frequency of the pulse used to generate the infrared transmission. A virtue of this feature is that the transmission frequency can be changed, if required, to match the accepted carrier frequency of a different receiver module. This is a much more efficient system than the one used for investigation purposes during this project. That circuits use of the 555 timer and discrete components, means that it must be designed to combine its operation with a specific range of receivers. A visible comparison of the traditional receiver circuit and the one requires when using this Labview based system can be viewed in the appendix of this report. Mention of the 555 timer model for the transmitter/receiver circuit leads onto the positive influence of investigation and analysis of previous projects. This is a system that provides the functionality that this Labview project was attempting to emulate. Due to a systematic approach to the analysis of this circuit, it provided invaluable lessons on the operation of both the transmitter and receiver. Perhaps most significantly, analysis of the output from the receiver led to an understanding of the fact that this output was only low when the 38KHz IR signal was being detected. A fact that, once understood, provided a much clearer of how that signal would need to be processed within Labview. Reviewing the results of this project while compiling this report has led to the realisation that the functionality of Labview is restricted by the hardware it is being interfaced with. Beginning with the USB-6008, which has been used with success on a number of previous projects, it is obvious that this device is not able to handle many of the complex actions Labview is able to execute. That is not to say that the USB-6008 is not an excellent device in many circumstances, but merely that it placed a restriction on this project that could only be lifted by a substitution of the hardware. This substitution for the MyDAQ proved a successful solution for the primary issue of the USB-6008 being unable to generate the required output. However it the device is not a panacea for the problems that can be caused due to the limitation of hardware. This is highlighted by the fact that the omission of a second input counter on the MyDAQ prevented the inclusion of a second transmitter/receiver circuit which would have greatly improved the technical achievement of this project. The use of SubVIs within the overall VI is a subject worthy of a separate report. SubVIs serve a number of functions within Labview, not least to provide clarity as increasingly dense Vis become indecipherable. This was certainly the case within the final block diagram on this
  • 28. May 1, 2015 Page 27 project. Modularizing the VI into sections, for example the block which generated the signal, helped to structure the flow of the code and made it much easier to troubleshoot problems. Modularizing a block diagram into SubVIs not only helps to de-clutter the working environment but it can also assist in preventing problems arising from having too much code situated on one block diagram. As the final date for completion of the project drew closer, presentation of the work became an increasingly important factor. Specifically within Labview this related to the front panel that would provide the user interface for the entire system. Labview comes equipped with several features that assist with customization of the front panel and once again the National Instruments website and forums provided excellent direction. Background colouring, descriptive text and importing pictures all combine towards making an attractive front panel. Perhaps the cleverest tool at the user’s disposal is the ability to pane the window into separate sections. This style has been implemented in the final front panel for this project and enables separation of controls, indicators and titles. In terms of the potential for further expansion within this project the most obvious improvement would be the inclusion of a second transmitter/receiver circuit that would be used to counteract the count of the original. If the system as it stands is used to count the number of cars going into a carpark then the additional components would be used to decrement this count each time a car leaves. The logic required to activate this is incredibly simple to implement within Labview but the limitations of the MyDAQ with regards to the input counter made it unachievable on this occasion. A secondary expansion which has been considered as a possibility for this system is the use of functions within Labview to export data acquired into a Microsoft Excel spreadsheet. This is an idea sourced from a previous project and may have had some relevance in this instance for recording keeping or volume analysis. In a project like this one it is not uncommon for the benefits of the process to outweigh the benefits of the final result. This is probably the case here. Although the project was successful in that it achieved basically what was its object in the beginning, more lessons were learnt from the obstacles faced in the process. For instance, the research and investigation, along with the trial and error, that took place when attempting to refine a working counter will probably prove to be the most beneficial part of the project. For instance, the understanding gained about the inability of an indicator to execute an Event Structure, came directly from a problem that required research to resolve.
  • 29. May 1, 2015 Page 28 Conclusions There are several positives to be taken away from this project. Perhaps one of the more important of these is the increased competency developed over the course of the project with regards to Labview. Having the freedom to explore possible solutions and alternative methods stimulates a level of development that previous Labview projects were less able to do. As mentioned previously in this report, the National Instruments website and Labview forums together constitute an invaluable resource for learning, understanding and discovering best practices within Labview. The use of these forums was particularly useful on this project when researching potential methods for implementing the counter to meet specifications. Although many of the suggested solutions proved unsuccessful, the reasons for this were made more clear. The very nature of this twelve week individual project was quite different to the structure of any previous projects undertaken. For instance, in previous project modules each student would have been working on the same assignment simultaneously. This provides a type of safety-net, in that problems can be discussed and results verified. The fact that each individual project in final semester is unique to each student puts more emphasis on good practices such as research and note-taking. As well as encouraging better practice, the fact that the assignments are individual probably adds a certain amount of pride in the work that may not have existed when the projects were shared. The most frustrating element of working on this project has been the time spent attempting to correctly implement a counter and the effect this may have had on expanding the overall scope of the project. There is certainly potential for improvements to be made to the completed system, however the time spent in consideration of a counting system severely limited the time that could be allocated to these improvements. Despite the frustration it may have caused, the process of determining a method and implementing a working counter was ultimately a rewarding one. It undoubtedly contributed to improving understanding of the way Labview works and through research and experimentation many functions that had hitherto been unknown became familiar resources that can only be helpful in the future. In many ways the final semester individual project condenses some of the key elements that combine to make a competent engineer. These include analysis of a problem or requirement, consideration of potential solutions and implementation of a solution using the most effective means available. Other elements are the ability to accurately document the work undertaken and present these findings to colleagues in a manner that is comprehensible. In completing this project several, if not all, of the skills described in the preceding paragraph have been demonstrated while the work undertaken has contributed to the overall progression of this skill-set.
  • 30. May 1, 2015 Page 29 Appendix Figure 22 Alternative Oscilloscope simulation Figure 23 Breadboarded transmitter circuit
  • 31. May 1, 2015 Page 30 Figure 24 Boolean PtByPt Sub-diagram Comparison of Receiver circuitry required: Figure 25 Comparison between receiver circuits
  • 32. May 1, 2015 Page 31 Figure 26 Infrared LED transmitting References Datasheets MyDAQ: http://www.ni.com/pdf/manuals/373061f.pdf USB-6008: http://www.ni.com/datasheet/pdf/en/ds-218 TSOP31328: http://www.vishay.com/docs/82459/tsop48.pdf Websites http://uk.ni.com/ http://forums.ni.com/t5/LabVIEW/bd-p/170 http://labs.physics.dur.ac.uk/skills/skills/labskills/labview/tips_and_tricks.php http://electrons.psychogenic.com/modules/arms/art/13/InfraRedSignaling.php https://learn.sparkfun.com/tutorials/ir-communication http://ie.rs-online.com/web/ http://www.mouser.com/catalog/specsheets/Everlight-HIR204C-H0_V4%20.pdf Videos Labview DAQ Assistant for Analog IO - https://www.youtube.com/watch?v=FEIQJa522aY Labview Basics of front panel - https://www.youtube.com/watch?v=tKT2K9tMrh0 Measurements with DAQ NI USB 6008 - https://www.youtube.com/watch?v=BXice6P9F7I