0% found this document useful (0 votes)
490 views33 pages

PROJECT NI myRIO - ISLEM1

1. The NI myRIO is an embedded hardware device designed by National Instruments for students to provide a small, portable device with many input/output ports to use for a variety of projects. 2. The myRIO has features like analog inputs/outputs, digital I/O, audio I/O, and an FPGA that allow students to interface with sensors and control systems. LabVIEW software is used to program the myRIO. 3. Creating a LabVIEW project helps manage resources and target code deployment when programming the myRIO. A simple temperature conversion program is created as an example.

Uploaded by

Eslem Drira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
490 views33 pages

PROJECT NI myRIO - ISLEM1

1. The NI myRIO is an embedded hardware device designed by National Instruments for students to provide a small, portable device with many input/output ports to use for a variety of projects. 2. The myRIO has features like analog inputs/outputs, digital I/O, audio I/O, and an FPGA that allow students to interface with sensors and control systems. LabVIEW software is used to program the myRIO. 3. Creating a LabVIEW project helps manage resources and target code deployment when programming the myRIO. A simple temperature conversion program is created as an example.

Uploaded by

Eslem Drira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Project NI myRIO :

I- Introduction:
National Instruments Corporation, or NI, is an American company with international
operation. Headquartered in Austin, Texas, it is a producer of automated test
equipment and virtual instrumentation software. Common applications include data
acquisition, instrument control and machine vision.

Since 1976, NI has made it possible for engineers and scientists to solve the world’s greatest
engineering challenges with powerful, flexible technology solutions that accelerate
productivity and drive rapid innovation. Customers from a wide variety of industries, from
healthcare to automotive and from consumer electronics to particle physics, use NI’s
integrated hardware and software platform to improve the world we live in.

Over the next several years, the engineers at NI continued to stretch the boundaries of virtual
instrumentation, releasing machine vision software and hardware, which allow cameras to
act as sensors, and motion control hardware and software. NI also introduced the NI Test
Stand, which provides for tracking high-volume manufacturing tests, to solve their problem.
The myRIO is a very capable embedded hardware device designed by National
Instruments and aimed at students to provide a small device with lots of ports which allow
it to be used for a wide variety of projects.

II- What Is NI myRIO?


The NI myRIO embedded student design device was created for students to
“do real-world engineering” in one semester.
NI myRIO is a reconfigurable and reusable teaching tool that helps students
learn a wide variety of engineering concepts as well as complete design
projects.
The myRIO features has ten analog input channels, six analog output channels and
forty digital input/output channels. It also has audio input and output, a USB host port, a
USB device port, an accelerometer, a programmable button and four programmable
LEDs.
Three connectors (two NI myRIO expansion ports [MXP] and one NI mini Systems
port [MSP] that is identical to the NI myDAQ connector) send and receive signals
from sensors and circuitry that students need in their systems.
Forty digital I/O lines overall with support for SPI, PWM out, quadrature encoder
input, UART, and I2C ; eight single-ended analog inputs; two differential analog
inputs; four single-ended analog outputs; and two ground-referenced analog
outputs allow for connectivity to countless sensors and devices and programmatic
control of systems.
All of this functionality is built-in and preconfigured in the default FPGA
functionality. These features allow students to do real-world engineering.
NI myRIO is a simple device to set up, and students can easily determine its
operational status. A fully configured FPGA personality is deployed on the device,
at the beginning, we can start with a functional foundation without having to
program an FPGA to get their systems working. However, the power of
reconfigurable I/O (RIO) becomes apparent when we start defining the FPGA
personality and molding the behavior of the device to the application.
A field programmable gate array (FPGA) that students can use to start developing
systems and solve complicated design problems faster, students can use the
LabVIEW graphical program to focus on constructing their systems and solving
their design problems.

One of the goals of the NI myRIO design is to simplify hardware setup. To


accomplish this, NI myRIO software provides a custom setup and configuration
utility separate from the NI Measurement & Automation Explorer (MAX)
configuration utility. You can still use MAX for setup, software installation, and to
configure more advanced settings. The NI myRIO device has a USB monitor
application that runs when you connect the device to the host computer. Learn
how to use the NI myRIO USB monitor and the NI myRIO Getting Started Wizard
in the following section.

II- Creating a LabVIEW Project :


Create de LabVIEW project, require to deploy a code to embedded targets, such as
myRIO. Using LabVIEW project, for simple applications, is efficient for programming
practice, it will help us to manage the application if it pass into something more complex, in
order to become familiar with the LabVIEW project.

The LabVIEW Project Explorer helps you manage all resources related to an
application. These resources might include multiple VIs, use interface objects,
images, text documents, configuration files and deployment information. The
project structure allows for quick and easy resource control and you can use
the LabVIEW Project Explorer to allocate certain resources to certain devices
(typically called targets).

The LabVIEW Project Explorer is familiar and its use will be mostly the same.
LabVIEW is a cross-platform language with comprehensive support for add-ons
and libraries. You can write most VIs while targeting them to the development
machine and easily retarget them to an NI embedded device, such as NI
myRIO, because these targets run an OS that works with LabVIEW applications
and add-on libraries.

The following steps are to create a new project:

1. If it is not already open, launch LabVIEW


2. Select the Create Project button on the LabVIEW Getting Started window.
3. The Create Project window opens and offers several options.
You can explore all of the options using the More information link.
4. For now, select the Blank Project option as the starting point for the project.
5. Then click the Finish button. This creates an empty project and opens the
LabVIEW Project Explorer.
To save the new project:

a. From the LabVIEW Project Explorer window, select File»Save.


b. A save dialogue box opens and requests a destination directory and
project name. Navigate to myRIO Workshop\Exercises\Exercise
0 folder which you will find on your desktop. Give the VI a meaning ful
name, such as Exercise 0 Project.

The LabVIEW Project Explorer window is showing a new project that is ready to
be populated with resources and source code. The LabVIEW Project Explorer
features a standard menu of familiar options (File, Edit, View and so on) along
with some options exclusive to LabVIEW.
The LabVIEW Project Explorer itself has two panes : items and files.
The items page shows the items in a project organised in a hierarchy,
The files page shows where project items are stored on the hard drive.

In the items tab of the LabVIEW Project Explorer, you can see the organization of
the project. The first item on the list, of the project root shows which project we
are working in.

Under the project root, the next level of the tree contains all of the targets that
the project is pointing to. A blank project defaults to the local development
computer or “My Computer”. Under the My Computer target, the build
specifications for the target are shown.
Build specifications include the build configurations for source distributions
and other builds available in LabVIEW toolkits and modules. We use these
when distributing applications to colleagues/customers or deploying
applications to embedded systems.

The LabVIEW Project Explorer becomes particularly useful when developing


complex applications. However, using projects, even for simple applications, is
good practice, as it will help you to manage the application more complex in the
future.

Figure 2.1 : LabVIEW Project Explorer


III- Creating a LabVIEW VI in Windows:
We create a simple, but functional application. The application will convert a temperature
value from Fahrenheit to Celsius, in order to become familiar with the LabVIEW
development environment and fundamental graphical programming concepts.

To enter the programming portion of LabVIEW, you must create a new VI (virtual
instrument). To create a VI, I will execute a right-click on my Computer and select
New » VI in the LabVIEW Project Explorer.

Figure 3.1: Example of the front panel of a VI


Figure 3.2: Creating a Blank VI

This creates a blank VI under the My Computer target in the project. This new blank
VI consists of two windows: the front panel and the block diagram.

Save the new VI by selecting File»Save from either the front panel or the block
diagram. When the save dialog appears, give the VI a meaningful name (for
example, Exercise 0)

Then, w e can create the temperature conversion code.

The following steps are to write the VI:

1. We want our code to run continuously and, just like text-based languages,
LabVIEW uses loops to continuously execute tasks. W e can terminate
loops with a button on the front panel or by using logic to determine when
a task has been completed.
We use a While Loop to continuously monitor the Fahrenheit value and
convert it to Celsius. Use a button on the front panel to control termination.
a. Switch to the block diagram by either selecting the block
diagram window (white background) or pressing <Ctrl+E> from the
front panel (this shortcut can be used to quickly switch back and forth
between these two windows).

b. Right-click on the block diagram to open the Functions palette.


This palette contains all of the nodes and VIs you use to program in
LabVIEW. You can customize the palette display, but by default all add-
ons and VIs are available.
Navigate to Programming»Structures»While Loop
and select the While Loop.

Notice that the cursor changes to the draw-loop icon

Figure 3.3: Selecting a While Loop

c. W e draw a while loop on the block diagram with Left-click and move the cursor
to create the loop. We can resize loops by pointing the cursor over the
placed while loop, then dragging one of the eight blue resizing squares.

d. Switch back to the front panel (grey background) using the <Ctrl+E>
shortcut. Now right-click to open the Controls palette. This palette contains
all of the elements used to create the VI’s user interface. Navigate to
Modern»Boolean»Stop Button.
Figure 3.4: Selecting a Stop Botton

e. Left-click on the stop button in the palette and drag it onto the front panel,
then left-clicking on an appropriate location

f. Switch to the block diagram and locate the new stop button terminal. Left-
click and drag the stop button terminal : relocate it next to the conditional
terminal (located in the lower right corner of the While Loop)

g. Wire the stop button to the conditional terminal by left-clicking on the wiring
terminal on the stop button and then left clicking the conditional terminal.
A green wire should appear between the two icons. The color green
indicates that Boolean values will pass through the wire (other data types
have differently colored wires).

Figure 3.5: While Loop with Stop Condition Wired


Terminals are the block diagram representation of front panel objects. They can be
viewed in two different styles. One is smaller and more compact. The other is larger,
but more descriptive.

You can switch between these two styles by right clicking on the terminal and selecting
View as Icon.

2. We create the Fahrenheit control and Celsius indicator on the front panel in
The following steps :

a. Switch to the front panel and right-click to open the Controls palette.
Navigate to Modern»Numeric»Numeric Control.

b. Place the control on the front panel by left-clicking it in the palette,


moving the cursor over the front panel and left-clicking again to place it.

c. Notice that the control is labeled “Numeric Control.” This is not a very
descriptive name.
Rename the control by double-clicking on the text label, then typing
“Fahrenheit.”

d. Open the Controls palette (right-click) and navigate to Modern»


Numeric»Thermometer. Place the thermometer on the front panel.
Right-click the thermometer and select Visible Items»Digital Display.

e. In a similar fashion to the Fahrenheit control, rename the thermometer


indicator by double-clicking the label. Name this indicator “Celsius.”

f. Now add a virtual LED to the front panel, which will illuminate when the
temperature falls below freezing. Place an LED on the front panel by
navigating to Modern»Boolean»Round LED.

g. Place the LED on the front panel.

h. Rename the LED “Below Freezing?”


Figure 3.6: Front Panel with controls and indicators

3. With the proper controls and indicators on the front panel, you must
implement the mathematics and logic to convert Fahrenheit to Celsius
on the block diagram.

a. Switch to the block diagram and observe the new icons for the
Fahrenheit, Celsius and Below Freezing controls and indicators. Move
the Fahrenheit icon inside the While Loop on the left and both the
Celsius and Below Freezing icons inside the While Loop on the right.
Give yourself plenty of space between the icons for the code.

IV- Software Basics:


National Instruments provide myRIO which is controlled using the visual programming
language LabVIEW, it works by attaching functioned or virtual instruments (VIs) to each
other by ‘wires’, the language follows a data flow approach where the data ‘flows’ down
the wire and is acted upon by the VIs.

The LabVIEW programs can be run on a PC or programmed to the myRIO allowing for on
board processing and control of components on the robot. The myRIO has many I/O ports
dedicated to specific tasks and LabVIEW provides pre-existing VIs that greatly simplify
many tasks speeding up program development. Particularly useful when working with the
myRIO are the myRIO VIs that utilise the FPGA and enables specific pins on the myRIO to
be used for dedicated purposes such as reading an encoder or sending a pulse width
modulated signal, the VIs also allow for simpler communication such as using digital I/O
ports in the same manner.
Using the VIs is a simple matter of placing the VI on the LabVIEW back panel and selecting
the channel the component is wired to, the inputs and output soft that VI can then be
‘wired’ to send or receive information.
The process of creating LabVIEW code can be time consuming and requires a new way of
thinking about the program for people coming from text based programming
environments but some of the available VIs do make tasks very simple and like any
programming language.
Figure 4.1: A very simple program showing the code to add two numbers on the back panel (right)
and the inputs to enter the numbers and output to display the numbers on the front panel (left).

1. Basic Control of Components:

Being able to communicate and control electronic devices through software is an essential
task in being able to control and navigate the robot.
The following shows the core of the communication and control which act as the building
blocks and the ability to use the sensor data for other tasks such as using the encoder data
to predict the position of the robot.
The VI also allows for additional functions, such as resetting the count to zero,
determining the direction of the motor and also detecting if the count overflows its
maximum value.

a- Start Button:
The start button is a momentary switch which needs to be wired to a digital input, when
the button is pressed it will supply the digital input with a 5 volt signal that registers in
LabVIEW as ‘true’. The myRIO has a number of digital input outputs (DIO). the start button
is connected to port A pin31 (A/DIO10).
Figure below shows the configuration screen of the myRIO digital input VI that allows the
programmer to select a specific DIO using a drop down menu. To the right of the
configuration screen is code showing a continuous while loop with the button wired up to
the loops condition terminal.

Figure 4.2: Creating a basic button using the myRIO digital input VI(left).
An idle loop linked to the button(right).
This piece of code allows the program to run in an idle loop until the button is pressed, once
the button is pressed a ‘true’ signal is sent to the condition terminal causing the while loop
to exit its idle status and allowing the program to execute tasks outside the while loop.

c- Encoders:

Figure 4.3: NImyRIO Starter Kit rotary encoder and a LabVIEW front panel.
Figure 4.4: LabVIEW code for a rotary encoder and an interface for controlling the Encoder.

A rotary encoder, also known as a quadrature encoder, combines a rotary knob and two
switches that open and close in a staggered fashion as the knob turns. The knob angle
and rotation direction can be sensed with suitable decoding of the switching waveforms.
The demo VI displays the encoder A and B switch states as either “open” or “closed.”
Slowly turn the encoder shaft clockwise and we observe the following sequence:
- A switch state closed with B switch state open,
- Then both closed,
- Then A open with B closed,
- And finally both open again.
You should also observe that both switches are open when the encoder shaft is at rest in
one of its twelve detente positions. Rotate the shaft in the counter-clockwise direction and
you should see a similar sequence, but with switch B closing first.
The demo VI also maintains a counter of A/B switch transitions, and should increment by
four counts for each click of the encoder in the clockwise direction and decrement by four
counts for each click in the counter-clockwise direction.
A front-panel indicator also displays the counter direction:
- Click the Reset Counter control to clear the counter to zero;
- Click again to continue counting.
- Click the Stop button or press the escape key to stop the VI and to reset NImyRIO.

Expected results:
The demo VI displays the encoder A and B switch states as either “open” or “closed” Slowly
turn the encoder shaft clockwise and you should observe the following sequence: ’A’ switch
state closed with ’B’ switch state open, then both closed, then A open with B closed, and
finally both open again. You should also observe that both switches are openwhen the
encoder shaft is at rest in one of its twelve detente positions. Rotate the shaft in the counter-
clockwise direction and you should see a similar sequence, but with switch B closing first.
The demo VI also maintains a counter of A/B switch transitions, and should increment by
four counts for each click of the encoder in the clockwise direction and decrement by four
counts for each click in the counter-clockwise direction.
A front-panel indicator also displays the counter direction. Click the Reset Counter control
to clear the counter to zero; click again to continue counting.
Click the Stop button or press the escape key to stop the VI and to reset NImyRIO.

Build the interface circuit:


Refer to the schematic diagram and recommended breadboard layout shown in Figure 3.5.
The rotary encoder interface circuit requires three connections to the NI myRIO MXP
Connector B :
1. Encoder A  B/ENC.A (pin 18)
2. Encoder A  B/DIO0 (pin 11)
3. Encoder B  B/ENC.B (pin 22)
4. Encoder B  B/DIO1 (pin 13)
5. Encoder COM  B/GND (pin 20)

Interface circuit:
The rotary encoder translates shaft rotation into a pair of switch opening/closing patterns
known as quadrature encoding. The pair of switches called A and B connect directly to one
of four NI myRIO encoder inputs shared with the standard digital input/output (DIO)
terminals.
The Encoder Express VI decodes the switching patterns to produce a count value as well
as the counter direction. These outputs indicate the relative position of the rotary encoder
shaft since the last time the counter was initialized.

NOTE: The additional connections to B/DIO0 and B/DIO1 simply provide another way to
observe the switching activity.
Figure 4.5: Demonstration circuit for rotary encoder and schematic diagram,
recommended breadboard layout, and connection to NI myRIO MXP Connector B.

The myRIO can connect up to four encoders to specific pins allocated for encoder signals
and an existing VI which utilises the FPGA then returns the encoder count.
Figure below shows how to set up an encoder connected to specific pins on the myRIO and
then display the encoder count values.

Figure 4.6: Encoders can be easily set up in LabVIEW


if they are connected to the correct IO port on the myRIO.

d- Light Emitting Diodes “LED” :

LEDs, or light-emitting diodes, provide simple yet essential visual indicators for system
status and error conditions. Figure below shows some typical LEDs; the clear LEDs on the
right are included in the NImyRIO Starter Kit.

Figure 4.7: Typical LEDs including standard red and green,


high-efficiency in various colors, and RGB.
Objectives:

1. the essential concepts related to LEDs:


- An LED is a diode that permits only one-way current,
- The LED forward-bias voltage drop varies with color (wavelength),
- The interface circuit design depends on knowledge of the DIO output resistance
and source voltage,
- LEDs may be direct-connected to the DIO under some circumstances, and
2. Select a suitable current-limiting resistor (or no resistor) based on the LED type.

Parts from the NI myRIO Starter Kit:


 Two 100 resistors connected in series or two 470 resistors connected in parallel
 Two-terminal LED
 Breadboard
 Jumper wires,M-F

The interface circuit:


Refer to the schematic diagram and recommended breadboard layout shown in Figure below.
The discrete LED interface circuit requires two connections to NImyRIO MXP Connector B:
- Anode B / +3.3V (pin 33)
- LED control B / DIO Ø (pin 11)

Figure 4.8: Demonstration circuit for discrete LED


Schematic diagram, recommended breadboard layout, and connection to NimyRIO MXP Connector B.
Expected results:
The schematic diagram indicates a single 220 current-limiting resistor; you may instead use
two series-connected 100 resistors or two parallel-connected 470 resistors from the NI
myRIO Starter Kit.
Also, all of the LEDs in the Starter Kit have clear plastic lenses with a wide variety of colors.
(You try multiple LEDs to investigate your color options).
Your discrete LED should be blinking on and off in synchronism with the front-panel indicator
digital output state. Click the enable blinker front-panel button to disable blinking and to
enable the digital level button; click this button to manually set the digital output state either
high or low.
Because this interface circuit is the sinking current form, the LED is active when the digital
output is in the low state, (this is an active-low LED interface circuit).
Click the Stop button or press the escape key to stop the VI and to reset NI myRIO; a myRIO
reset causes all of the digital I/O pins to revert to input mode.

We should Confirm the following points:


 Glowing power indicator LED on NI myRIO,
 Black Run button on the toolbar signifying that the VI is in run mode,
 Correct LED orientation: the diode conducts current in one direction only; remove the
LED and reinsert it in the opposite direction, and
 Correct resistor value: use an ohmmeter to verify that the resistance is near
220ohms.

Interface circuit:
We try to make modifications to the interface circuit:
1. Add a front-panel control to adjust the blink frequency specified in Hertz;
2. Blink two adjacent LEDs to simulate a railroad crossing signal.
3. Blink the green and blue LEDs of the RGB LED using the same LabVIEW code as the
railroad crossing signal; refer to Figure below for the RGB LED pin out diagram.
Use the current-sourcing interface circuit. Then create an LED variable-intensity dimmer
with the PWM Express VI, to create a pulse-width modulated digital output. Set the
Frequency to the default constant value of 1000 Hz and create a pointer slide control to
adjust the duty cycle;

Select the logarithmic mapping option for the control, too. Add some code to account for the
active-low current-sinking LED interface (bonus points with a Boolean control to select
between current-sinking and current-sourcing interfaces).

Figure 4.9: RGB LED pins and schematic diagram.

e- Motor Controller and Motors:

Figure 4.10: LabVIEW code for motor controller and a LabVIEW front panel
as an interface for controlling the motor.

The motor controller is controlled by sending two signals from zero to 5 volts to the motor
controller, each of those signals controls one of the two motors. The signal sent to the motor
controller will control the speed of the motors, a signal of zero volts rotates the motor at full
speed in the anti-clockwise direction, as the voltage increases to 2.5 the speed of the motor
in the anti-clockwise direction decreases until it is stationary.
From 2.5 to 5 volts the speed of the motor in the clockwise direction increases until at 5volts,
the motor rotates at full speed in the clockwise direction.
To spend a 0 to 5 volt signals to the motor controller from the myRIO, two 0 - 5V Analog
Out (AO) pins are wired up, The LabVIEW code then uses two myRIO AO Vis referencing
the specific pins used on the myRIO and wired inputs so that the voltage can be set. The
input wires can be connected to a controller VI so that it can be adjusted while the program
is running or a routine could be written to adjust the speed of the motors based on sensor
inputs.
Figure below shows an example of how to set up an AO pin on the myRIO under LabVIEW
and send a 2.5v signal to each motor.

Figure 4.10: If the motor controller is attached to AO pins on the myRIO, the motors speeds
can be easily adjusted by sending different numeric values to the Analog Output VIs.
f- Motor:
The low-voltage DC motor pictured in Figure below provides sufficient mechanical power to
drive small fans or to spin lightweight objects. While the voltage is relatively low at 1.5 to 4.5
volts, the current can get as high as several hundred milliamps or even several amps install
(blocked rotor) conditions. For this reason a power MOSFET is used as a motor driver.

Figure 4.11: NI myRIO Starter Kit DC motor

Build the interface circuit:


Refer to the schematic diagram and recommended breadboard layout shown in Figure3.13
on the following page. The interface circuit requires four connections to NI myRIO MXP
Connector B:
 5 volt power supply  B / +5V (pin 1)
 3.3 volt power supply  B / +3.3V (pin 33)
 Ground  B / GND (pin 30)
 Motor control  B / DIO8 (pin 27)

NOTE: If we select the “Close on successful completion”, the VI start automatically.

Expected results:
Click the DIO state button to set the digital output to its low state and your motor should spin
at high speed, then click the button again to stop the motor. Note that the motor driver
interface circuit is active low.
Click the Stop button or press the escape key to stop the VI and to reset NI myRIO;
A myRIO reset causes all of the digital I/O pins to revert to input mode.

Figure 4.12: LabVIEW code for motor controller and a LabVIEW front panel
as an interface for controlling the motor.

We should confirm the following points:


 Glowing power indicator LED on NI myRIO,
 Black Run button on the toolbar signifying that the VI is in run mode,
 Correct transistor orientation : carefully follow the pin diagrams for each transistor;
especially note that the IRF510 has the gate pin on the side rather than in the middle
as do the lower-power MOSFETS, and
 Correct rectifier orientation: when the rectifier is backwards the motor will never reach
the voltage level necessary to turn on.

Interface circuit:
The motor requires approximately 180 mA (at 3.3V) when unloaded and over 1000 Ma when
running at maximum efficiency, three times higher than the maximum available current from
all three NI myRIO connectors combined.
Stalling the motor due to excessive loading or blocking the rotor demands even higher
current because effective resistance of the motor is less than 1. For these reasons the
IRF510 n-channel enhancement power MOSFET serves as a high-current solid-state switch
to operate the motor. Because the IRF510 gate-to-source threshold voltage VGS(th) ranges
from 2 to 4 V the NI myRIO DIO output voltage of 3.3 V is not sufficient to turn on the IRF510.
The two low-power MOSFETS arranged as a standard CMOS logic inverter supplied by the
5 V supply act as a 3.3 to 5 V level shifter to ensure that the IRF510 gate voltage is either
0 V (off) or 5 V (on).
Figure 4.13: Demonstration circuit for DC motor: schematic diagram,
recommended breadboard layout, and connection to NImyRIOMXP Connector B.

g- Servos:
A servomotor, usually called a servo for short, combines a DC motor, gearbox,
potentiometer, and controller electronics to provide relatively precise angular position control
of a rotating shaft. Servos provide motion control for robot arms, rotating sensor scanners,
and other actuators.

Pictures the GWS S03N STD servo included in the NI myRIO Mechatronics Kit; the kit also
includes the GWS S35+ XF continuous-rotation sensor that can serve as the basis of a robot
drive train.
Figure 4.14: NI myRIO Mechatronics Kit servo.

Figure 4.15: Demonstration setup for the GWS S03N STD servo
Connected to NI myRIO MXP Connector B.
The servos are controlled through pulse width modulation (PWM) so they were each wired
to PWM pins on the myRIO. The my RIO has a built in VI for PWM control which takes two
inputs, a duty cycle and a frequency.

Most basic analog servos work well with a frequency of 50Hz and take a duty cycle of
between 0.05 and 0.1 to move from full left to full right.

The code in figure below shows an example programmed in LabVIEW of how to get those
values using an input of -90◦ to 90◦ .

Figure 4.16: LabVIEW code for controlling two servos and a LabVIEW front panel
as an interface for controlling the servos.
Expected results:

The demo VI includes a pointer slide control to adjust the servo angle so that you can easily see
the servo rotation angles.
The slider is calibrated in “percent full scale”(%FS). Estimate the servo angle at 100%FS and then
at -100%FS. Use the direct entry box at the top of the slider to apply step changes, e.g., +100%FS
to -100%FS; how quickly does the servo rotate between these two angles?
The default limits on the slider allow a (2* “over travel” factor). At what %FS values does the servo
reach its rotation limits?
The servo command input is a variable-width pulse with 1.0 ms at -100%FS and doubling to
2.0ms at +100%FS; the midpoint pulse width 1.5 ms — called the neutral-position pulse width —
corresponds to 0%FS.
The pulse must be repeated at a sufficiently fast rate and yet not too fast. Try adjusting the freq
[Hz] control to a lower frequency (say, 10 Hz) and to a higher frequency (say, 200 Hz), each time
moving the position slider to command different angles. Note the two indicators under this control
that indicate the pulse width and “duty cycle” (percent of time that the pulse is active) of the signal
sent to the servo command input.
Then Click the Stop button or press the escape key to stop the VI and to reset NImyRIO.

h- Sensor Infrared (IR Range Finder):

An IR range finder uses a beam of reflected infrared light to sense the distance between the
sensor and a reflective target. The range to an object is proportional to the reciprocal of the
IR range finder’s output voltage.
Figure below is the pictures of the IR range finder included with the NI Mechatronics Kit.
Figure 4.17: NI myRIO Mechatronics Kit range finder IR and its LabVIEW front panel.

Two infrared sensors were considered :


 The first sensor was a Sharp GP2D120XJ00F, distance measuring sensor meant to
go above the seeds attached to a lid on the chute and would measure the distance
to the seeds. In this way the sensor would be able to get an initial reading to determine
the number of seeds in the chute, be able to detect if a seed had been successfully
dropped and also ensure the chute was empty before returning to the home area.
 The other infrared sensor tested was a Sharp GP2Y0D810Z0F proximity sensor
which returns a high signal if it detects something between 2cm and 10cm away. The
sensor was placed at the bottom of the chute to ensure the seed released correctly.
This sensor was determined to be unnecessary because the dropping mechanism
worked well enough without the sensor so using it would be more likely to introduce
a fault than to make the release mechanism more reliable.
Both infrared sensors were setup in the same way. The signal wire was connected to an
analog input pin on the myRIO while in LabVIEW analog input VI was used to assign the
incoming signal to a floating point variable. The value from the IR distance sensor was
then used to determine how many seeds were initially loaded.

Approximately 0.4 V indicated 1 seed, 0.65 V indicated 3 seed sand 2.2 V indicated 6 seeds.

In the case of the Sharp proximity sensor only a low and high signals are returned with the
high signal indicating there is a block being held in the chute and a low signal indicating the
chute is clear.
Figure 3.18 : Analog Input and voltage indicator
Figure 4.19: Demonstration setup for range finder IR connected to NI myRIO MXP Connector B.
Figure below shows the setup of the analog input VI in LabVIEW and a while loop to
continually read the analog voltage signal.

the Sharp IR range finder used to determine the distance to the nearest object, using infrared
light. On one side of an infrared LED sensor radiates a light beam which is reflected by the
nearest object and detected by the receiver on the other side of the sensor. The sensor then
uses a method called triangulation to determine how far the object was.

The basis of triangulation is that objects at different distances reflect the infrared beam at
the receiver at different angles. The variable angles produce different voltage levels in the
sensor, and values to the turning sensor that can be used to calculate the distance.
We get Range = K scale * (1 / V0) + K offset

Figure 4.20: Sharp IR detector angle, check-object for reflection near and far

The angle of incidence of the reflected light varies depending on the distance
to the object. The receiving portion of the IR detectors is a precision lens that
transmits the light reflected from different parts of the linear CCD array.

Figure 4.21 : : LabVIEW diagram of the IR range finder.

i- Sonic Range Finder:


A sonic range finder measures the round trip time-of-flight of short pulses of sound just
beyond human hearing (42 kHz) reflected back (echoed) from a target. Multiplying the time-
of-flight by the speed of sound in air yields the distance (range) to the target. Applications of
a sonic range finder include non contact distance measurement, object detection, proximity
sensing.

Ranging sensors that detect objects within an area. These sensors are not affected by the
color or other visual characteristics of the detected object. Ultrasonic sensors use high
frequency sound to detect and localize objects in a variety of environments. Ultrasonic
sensors measure the time of flight for sound that has been transmitted to and reflected back
from nearby objects. Based upon the time of flight, the sensor then outputs a range reading.

Figure below shows the sonic range finder included with the NI Mechatronics Kit.

Figure 4.22: NI myRIO Mechatronics Kit sonic range finder.

Figure 4.22: a LabVIEW front panel of sonic range finder connected to NI myRIO.
Figure 4.23: Demonstration setup for sonic range finder connected to NI myRIO MXP Connector A.

NOTE : Temperature Compensation for Sonic Range Finders by Max Botix, The speed of sound
varies significantly with temperature.

j- Gyroscope:
A gyroscope measures the angular velocity (rate of rotation) about an axis. The rate is
reported in degrees per second and when integrated yields relative angular displacement.
A three-axis gyroscope mounted to a robot platform yields 3-D attitude (pitch, roll, and yaw)
and provides valuable information to maintain stability of the vehicle.
Figure below shows the NI myRIO Mechatronics Kit gyroscope based on the ST
Microelectronics L3G4200D triple-axis digital-output gyroscope with I2C-bus serial
communications.

Figure 4.24: NI myRIOMechatronics Kit gyroscope


Figure 4.25: Demonstration setup for gyroscope connected to NI myRIO MXP Connector A.

Interface circuit:
The ST Microelectronics L3G4200D triple-axis gyroscope at the heart of the P mod GYRO
supports the I2C-bus serial interface (commonly denoted “I2C”); the L3G4200D also
supports the SPI serial interface. The L3G4200D includes two interrupt outputs designated
“INT1” and “INT2.” These pins provide access to various interrupt sources which may be
enabled as needed. Twenty-six addressable registers provide access to the three angular
rate measured values as well as a wide variety of configuration options.
This example shows how to do in the following:
 Set the data rate and full-scale range
 Set up a high-level threshold to generate a comparator-style interrupt on the “INT1”
output pin
 Generate a “data ready” interrupt on the “INT2” output pin
 Read the three sets of data registers and convert these rate values into measured
acceleration in “dps” (degrees per second) units
 Integrate the rate values to obtain relative angular displacement, and
 Estimate the zero-rate level offset to reduce integrator ramp-up.
Figure 4.26: a LabVIEW front panel of gyroscope connected to NI myRIO

q- myRIO button and LEDs:


The myRIO has a momentary switch button which can be programmed. The selection would be
made by pressing the button and the selection would be shown on the LEDs.
 myRIO Button:
LabVIEW provides a VI for a button on the myRIO it self, it has built in debouncing giving
a value of true if pressed and false if not pressed. To enhance the code to ensure an
increase count by only one rather than accidentally incrementing multiple counts a
previous and current state check is used to return a true value only when the state changes
from pressed to not pressed.

The method of setting up the button using the LabVIEW dialogue is shown in figure below
Figure 4.27: The myRIO button can be easily configured in LabVIEW using a simple dialog
which returns a true or false value based on button presses.

 myRIO LEDs:
LabVIEW provides a VI for the LEDs on the myRIO. This allows the lights to be controlled
simply by providing a true or false value to the specific inputs on the LED VI.
An example of how the myRIO LEDs are setup is shown in figure below.
Figure 4.28: The LEDs on the myRIO can be setup easily using a LabVIEW
Dialog box and then enabled or disabled using true and false values.

You might also like