Encoder Reading using LabVIEW and Arduino

November 16, 2020 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Encoder Reading using LabVIEW and Arduino...

Description

Ain Shams University Faculty of Engineering Credit Hours Engineering Program MCT 432 Hybrid Control

LAB 1 Reading Quadrature Encoder Position

Prof. Farid A. Tolbah Eng. Waleed A. El-Badry Fall 2016

TABLE OF CONTENTS 1. OBJECTIVE OF CONDUCTED EXPERIMENT

1

2. HARDWARE REQUIREMENTS

1

3. SOFTWARE REQUIREMENTS

2

4. PROCEDURE

2

4.1. DISPLAY ENCODER POSITION ON AN LCD 4.2. PROTEUS SIMULATION 4.3. EXERCISE 4.4. COMMUNICATION WITH LABVIEW 4.4.1. ARDUINO CODE 4.4.2. LABVIEW VI 4.4.3. LABVIEW BLOCK DIAGRAM

2 4 6 6 6 6 7

5. RESULTS

8

6. FURTHER EXERCISE

8

7. REFERENCES

9

LIST OF FIGURES FIG. 1 ARDUINO UNO R3 BOARD ........................................................................................................... 1 FIG. 2 SIX POLES, TWO CHANNELS MAGNETIC ENCODER ................................................................................ 1 FIG. 3 LIQUID CRYSTAL DISPLAY .............................................................................................................. 2 FIG. 4 ARDUINO USB CABLE .................................................................................................................. 2 FIG. 5 ENCODER LIBRARY BY PAUL STOFFREGAN ......................................................................................... 2 FIG. 6 PROTEUS MODEL......................................................................................................................... 5 FIG. 7 ARDUINO CODE AND PROTEUS ....................................................................................................... 5 FIG. 8 SIMULATION RESULT .................................................................................................................... 6 FIG. 9 COM PORT CONNECTIONS ............................................................................................................ 7 FIG. 10 LABVIEW BLOCK DIAGRAM......................................................................................................... 7 FIG. 11 LABVIEW - ARDUINO CO-SIMULATION FOR ENCODER READING.......................................................... 8 FIG. 12 GITHUB COURSE REPOSITORY ...................................................................................................... 9

MCT 432 Hybrid Control

Lab 1: Reading Quadrature Encoder Position

1. Objective of conducted experiment After completing this lab, you will be able to:   

Prepare the necessary hardware for reading motor position (angle) from mounted magnetic encoder. Understand the Arduino code for successful reading of encoder pulses and show reading on LCD. Transfer Arduino reading to LabVIEW.

 Prevent recurring transfer and LCD update when no change in reading. 2. Hardware requirements 

Arduino Uno R3 (or any board with at least two pins supporting external interrupt).

Fig. 1 Arduino UNO R3 board



Quadrature magnetic encoder. Experiment was conducted using Sha Yang Ye geared motor with onboard encoder available in Mechatronics lab.

Fig. 2 six poles, two channels magnetic encoder

P a g e 1 | 12

MCT 432 Hybrid Control



Lab 1: Reading Quadrature Encoder Position

2x16 alphanumeric LCD.

Fig. 3 Liquid Crystal Display



USB cable for connecting Arduino to PC.

Fig. 4 Arduino USB cable

3. Software requirements     

Arduino IDE for programming Arduino. NI LabVIEW 2015 or later. NI VISA 16 or later to allow LabVIEW to connect to available serial ports. Proteus ISIS 7.5 or later for offline simulation. FabulaTech Virtual serial port kit or any alternative to allow serial communication between LabVIEW and Arduino.

4. Procedure 4.1.

Display encoder position on an LCD The code will utilize encoder library by Paul Stoffregan which can be downloaded from library manager

Fig. 5 Encoder library by Paul Stoffregan

P a g e 2 | 12

MCT 432 Hybrid Control

Lab 1: Reading Quadrature Encoder Position

After installing the library, create a new sketch and copy the below code, then save it with any name appropriate. #include #include const int encaPin=2; const int encbPin=3; int oldPosition char buffer[6];

= -999;

LiquidCrystal lcd(12, 11, 7, 6, 5, 4); Encoder myEnc(encbPin, encaPin); void setup() { Serial.begin(9600); lcd.begin(16, 2); lcd.setCursor(0,0); lcd.print("Encoder Count:"); } void loop() { int newPosition = myEnc.read(); if (newPosition>231) myEnc.write(0); if (newPosition231) myEnc.write(0); if (newPosition
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF