Ask MATLAB Expert

Lab Objectives:

  • Use Matlab and Labjack to acquire digital inputs from limit switches
  • Use Matlab and Labjack to control a stepper motor
  • Use Matlab to analyze acquired data
  • Use a simple control system to vary an output based upon input data
  • Set-up and Basic Control of the XY Tables

Lab Equipment Required

  • Laptop with Matlab/Labjack software installed
  • Labjack DAQ with USB cable
  • DB25 cable for interfacing with the XY table
  • XY table
  • Power supply
  • Two power lead wires
  • Ruler

Equipment Set Up

The XY tables are pre-wired to interface with the Labjack DAQ units using the DB25 cable.  However, attention must be paid to the channels used for each of the inputs and outputs while writing the program.  Special care must be given to distinguish between digital input and digital output signal types.  It is possible to damage the equipment if these are reversed (i.e. writing an output to a closed switch input).

The axes and limit switch locations are shown in the Figure below.

Notice that A refers to "Away" from the end with the motor, and B refers to "By" the motor.

The table below contains the wiring assignments for the Labjack IO connections. These cannot be changed since they are hard-wired from the circuit to the motors and from the XY tables to the Labjack connector.

363_Programming for the XY Tables.png

The important channels for this lab are:

X-axis: direction commands (channel D1) - outputs, EDigitalOut()

step commands (channel D0) - outputs, EDigitalOut()

limit switch signal (channels D8 and D9) - inputs, EDigitalIn()

Y-axis: direction commands (channel D5) - outputs, EDigitalOut()

step commands (channel D4) - outputs, EDigitalOut()

limit switch signal (channels D10 and D11) - inputs, EDigitalIn()

Direction of MOTOR rotation --- controlled by setting state of channel D1 HIGH or LOW.  If D1 is LOW, the default, the bearing block moves in the plus x direction (towards end A).  The X-axis motor will rotate one step (0.9 degrees) each time a pulse (a HIGH signal followed by a LOW) is sent to channel D0. 

Example:         EDigitalOut (-1, 0, 1, 1, 0) % ch D1 sets direction to plus x direction (state = 0).

                        EDigitalOut (-1, 0, 0, 1, 1) % ch D0 step high pulse (state = 1).

                        EDigitalOut (-1, 0, 0, 1, 0) % ch D0 step low pulse (state = 0).

Several other connections may be of interest in future labs and as the last two weeks will be spent designing an individually developed system.  D2 and D6, when turned on (HIGH) will cause the respective stepper motors to run in a ½ step mode.  These motors turn 0.9 degrees per step, therefore the ½ step mode will produce only 0.45 degrees per step.  This doubles the X and Y resolution as each pulse only travels ½ of the default distance.  Notice that the steps per second (commanded from the computer) do not change and thus it also takes twice as long to move the same distance. Note that each motor may be remotely disabled by setting the outputs D12 and/or D13 to HIGH.

Programming for the XY Tables

1. Set-up and test the XY Table

Connect the hardware as described in the previous section.  Next, open the Labjack LJLogger application and use it to verify that everything is connected and working properly.  In particular, and with the main power supply off, move (by hand) the bearing slides to the various endpoints. When each respective limit switch is contacted, the LJLogger screen should light up the respective input button.

 Verify the function of all four of the limit switches (channels D8, D9, D10, D11).  Finally, set channels D0, D1, D4, and D5 directions to Write and turn on the main power supply; now when the various outputs are toggled between HIGH and LOW the corresponding motor should single step in direction selected.  When finished, turn the main power supply back to OFF, as leaving this on while not in use generates significant heat in the four power resistors located under the main driver circuit board.

2. Move 100 Steps Along the X-axis

Write a simple MATLAB program to move the X axis 100 steps towards end A, followed by moving it back towards end B with another 100 steps.  Think about different ways that this can be accomplished using loops.  Before running this program, move the bearing slide on the X-axis far enough away from end A so that the limit-switch is not contacted.  Write a flowchart for this part in your three ring binder.

3. Measure X-axis Travel Distance, and Find and Move to the Center of the X-axis

Now combine the limit switch feedback with the ability to move the X-axis motor. Write a MATLAB program to perform the following steps:

a. Move the X-axis carrier towards switch A until the limit switch is actuated.  Pause the program.  Make a pencil mark on the stationary axle being traversed.  Continue.

b. Create a STEPS variable and move the X-axis carrier towards switch B until the next limit switch is actuated. Use a WHILE loop to continually increment steps until finished so that when switch B is contacted the number of steps that it took to travel from limit switch A to limit switch B on the X-axis will have been stored. Display the number of steps on the screen.  Pause the program.  Make a pencil mark on the stationary axle being traversed.  Continue.

c. Finally, move the X-axis carrier to its center position (STEPS/2), and end the program. Use a FOR loop instead of a WHILE loop.

d. Measure the distance between your two pencil marks with the ruler.  Fill out the worksheet for the x-axis calculations.

4. Measure Y-axis Travel Distance, and Find and Move to the Center of the Y-axis

Repeat part 3, steps a, b, c, and d for the Y-axis. Consider how easy it is to take the existing code from part 3, copy it in a new program, change several IO variables, and repeat the procedure for the Y-axis.

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M9348919

Have any Question?


Related Questions in MATLAB

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As