Difference between revisions of "ExpEYES/C2/Communicating-to-ExpEYES-using-Python/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 297: Line 297:
 
|| Type '''from pylab import '''<nowiki>*</nowiki>(asterisk).
 
|| Type '''from pylab import '''<nowiki>*</nowiki>(asterisk).
  
'''from pylab import *''' is a program from '''matplotlib library'''.
+
'''pylab''' is a program from '''matplotlib library'''.
 
Press '''Enter'''.
 
Press '''Enter'''.
 
|-
 
|-

Latest revision as of 18:35, 30 January 2017

Visual Cue Narration
Slide Number 1

Title Slide

Hello everyone.

Welcome to this tutorial on Communicating to ExpEYES using Python.

Slide Number 2+3

Learning Objectives

We will learn about,

  • Introduction to Python
  • Measure AC voltage using Plot window & Python
  • Generate a Sine wave
  • Measure external and internal voltages using Python
  • Measure capacitance & resistance using Plot window & Python
  • Generate a Square wave
  • Show connections & circuit diagrams
In this tutorial we will learn:
  • Introduction to Python
  • Measure AC voltage using Plot window and Python
  • Generate a Sine wave
  • Measure external and internal voltages using Python
  • Measure capacitance and resistance using Plot window & Python
  • Generate a Square wave
  • Show connections and circuit diagrams for our experiments.
Slide Number 4

System Requirement

  • ExpEYES v 3.1.0
  • Ubuntu Linux OS v. 14.10
Here I am using,
  • ExpEYES version 3.1.0
  • Ubuntu Linux OS version 14.10
Slide Number 5

Pre-requisties

You should be familiar with:

ExpEYES junior interface.

For relevant tutorials, visit our website.

www.spoken-tutorial.org.

To follow this tutorial, you should be familiar with:

ExpEYES Junior interface.

Basic Python programming.

If not, for relevant tutorials, please visit our website.

Let's begin with introduction to Python.
Slide Number 6

Introduction to Python

  • Simple & easy to learn powerful programming language.
  • Free & Open Source cross platform high level language.
  • Effective approach to object oriented program.
  • Python is simple and easy to learn powerful programming language.
  • It is Free and Open Source cross platform high level language.
  • It has effective approach to Object oriented program.
Let's make sure that Python is installed on our system.
Press CTRL+ ALT and T keys. Press CTRL+ ALT and T keys to open the Terminal.
Type python, press Enter.

Point to the default version of Python

To start Python interpreter type python and press Enter.

Details regarding default version of Python will be displayed on the Terminal.

Point to the angle brackets. The displayed three angle brackets indicate Python prompt(>>>).

Now you are ready to type commands.

Slide Number 7

Details About Python

For more details about Python programming

www.spoken-tutorial.org.

For more details about Python programming, please visit our website.
I will discuss about the channels on the top Panel of the device.
Point to the top Panel On the top Panel each terminal is assigned to a specific channel number.
Point to A1

Point to A2

For example channel 1 is assigned to A1 and channel 2 to A2.
Point to the device. I will show how to connect wires to the device.
Point to the screw terminals. Device has screw terminals on either side.
Point to the screw terminals.


Show the process.

To make the connection, we insert wires into the terminals and tighten the screws.

Here A2 is connected to SINE.

Point to the circuit diagram. This is the circuit diagram.
Slide Number 8

To measure voltage of A2 and show its Sine wave'

Let's perform an experiment to measure the voltage of A2 and show its Sine wave.
Let's see the result on the Plot window.
Point to A2.

Point to voltage.

On the Plot window, click on A2 to display the voltage of A2.

Voltage of A2 is displayed below.

Click on A2, drag to channel CH1. Click on A2 and drag to channel CH1


When we drag A2 to CH1, input data of A2 is assigned to CH1.

Move msec/div slider to show the Sine wave.

Click on A2, show changing voltage of A2.

Move the msec/div slider to show the Sine wave.

Click on A2 to show change in voltages of A2.

Click on CH1, drag to FIT.

Point to voltage.

Click on CH1 and drag to FIT.

The voltage and frequency of A2 are displayed on the right.

We will perform the same experiment and measure voltage of A2 using Python.
Slide Number 9

Note

To avoid errors on the Python interpretor:

  • Connect the device to the system.
  • Close the Plot window.
Please note to avoid errors on Python interpreter:
  • Connect the device to the system.
  • Close the Plot window.
Type at the prompt:

import expeyes.eyesj press Enter.

To import “eyes” library from ExpEYES, type at the prompt:

import expeyes.eyesj press Enter.

Type at the prompt:

import expeyes.eyesj press Enter.

Point to open() function

Point to the lines

Type p=expeyes.eyesj.open() and press Enter.

open() function returns an object if hardware is found.

These lines will load the ExpEYES library and establish connection to the device.

Type print p.get_voltage(2).

Point to voltage.

Point to voltages.

To view the voltage of A2, type

print p.get_voltage within brackets 2 and press Enter.

Output shows voltage of A2

Similarly, we can show the various voltages of A2.


Voltage of A2 changes as it is an AC voltage.

Slide Number 10

Install

To generate plots using Python interpreter:

Install python-matplotlib library using Synaptic Package Manager.

To generate plots using Python interpreter:

Install python-matplotlib library using Synaptic Package Manager.

I have already installed python-matplotlib library on my system.

Slide Number 11

Install

To generate plots on Windows OS:

Download and install,

  • matplotlib v 1.4.3
  • numpy v 1.9 or above.

Copy the installed ExpEYES files and drivers and paste in C drive.

To generate plots on Windows Operating system:

Download and install,

  • matplotlib version 1.4.3
  • numpy version 1.9 or above.

Copy the installed ExpEYES files and drivers and paste in C drive.

Type import expeyes.eyesj, press Enter.

Type p=expeyes.eyesj.open(), press Enter.

To generate Sine wave, at the python prompt,

Type import expeyes.eyesj and press Enter.

Type p=expeyes.eyesj.open() and press Enter as before.

Type from pylab import *(asterisk), press Enter.

Point to from pylab import *

Type from pylab import *(asterisk).

pylab is a program from matplotlib library. Press Enter.

Type ion(), press Enter.

Point to ion()

Type ion()

This command sets pylab interactive mode.

Press Enter.

Type t,v=p.capture(2,200,100), press Enter.

Point to “t,v

Point to “2”,

Point to “200”

Point to “100”

Type t,v=p.capture within brackets 2,200,100.

t,v are time and voltage vectors.

“2” is channel number for A2,

“200” is the number of data points,

“100” is a time interval between subsequent measurements.

Press Enter

type plot(t,v), press Enter.

Point to Sine wave.

To view the output, type plot within brackets t,v

plot within brackets t,v generates a Sine wave on a new window.

Press Enter.

Show the screen. We can generate a Sine wave, using the above commands on Windows command prompt, as well.
Slide Number 12

External Voltage

Measure voltage of A1 using a battery as an external voltage source.

Next, let's measure voltage of A1 using a battery as an external voltage source.
Show the circuit diagram To measure external voltage source, Ground(GND) is connected to A1 through a battery of 3V.
Circuit diagram image This is the circuit diagram.

We will show the value of A1 using Python interpreter.

At the python prompt:

Type import expeyes.eyesj, press Enter.

Type p=expeyes.eyesj.open(), press Enter.

At the python prompt:

Type import expeyes.eyesj, and press Enter.

Type p=expeyes.eyesj.open(), and press Enter.

Type print p.get_voltage(1), and press Enter.

Point to channel1.

Point to voltage of A1.

Type print p.get_voltage within brackets 1 and press

Enter.

Here Channel 1 is assigned to A1.

Voltage of A1 is displayed on the terminal.

Slide Number 13

Internal Voltage

Measure voltage of A1 using PVS as internal voltage source.

let's measure voltage of A1 using PVS as internal voltage source.
Show the circuit diagram. In this experiment PVS is connected to A1.


Show circuit diagram This is the circuit diagram.
Type print p.set_voltage(3), press Enter.

Point to value of PVS.

Point to voltage.

Back to the terminal.

Type print p.set_voltage within brackets 3 and press Enter.

Here voltage of PVS will be set to 3 volts.

Voltage of PVS is displayed.

Type print p.get_voltage(1), press Enter.

Point to voltage.

Type print p.get_voltage within brackets 1 and press Enter.

Voltage of A1 is displayed on the terminal.

Slide Number 14

AC and DC components of a voltage using a capacitor & resistor and generate a square wave.

Now I will demonstrate AC and DC components of a voltage using capacitor and resistor.

And also 'generate a square wave.

Show the picture.

Show the circuit diagram.

In this experiment
  • A1 is connected to SQR1.
  • SQR1 is connected to A2 through a capacitor.
  • A2 is connected to ground(GND) through 200k resistor.


Show the circuit diagram. This is the circuit diagram.
Let's see the result on the Plot window
Point to the Plot window.

Click on Measure C on IN1 button.

Point to Capacitance.

On the Plot window click on Measure C on IN1 button.

Capacitance of IN1 is displayed as -0.6pF(pico farads).

Click on Measure R on SEN button.

Point to the Resistance value of SEN.

Click on Measure R on SEN button.

Resistance of SEN is displayed as 560Ω(ohms)


Please note you may get slightly different values of Capacitance & Resistance.

Click on SQ1, drag to CH1.

Point to assigned value.

Click on SQ1 and drag to CH1.

SQ1 is assigned to channel CH1.

Click on A2, drag to CH2.

Point to assigned value.

Click on A2 and drag to CH2.

A2 is assigned to channel CH2.

Click on SQR1 check box.

Move the msec/div slider.

Click on SQR1 check box to show the Square waves.

Move the msec/div slider to adjust the waves.

Click on CH2, drag to FIT.


Point to displayed voltage and frequency of A2.

Click on CH2 and drag to FIT.

Voltage and frequency of A2 is displayed on the right side.

Slide Number 15

Measure Capacitance, Resistance and generate a Square wave using Python interpreter.

We will perform the same experiment to:
  • Measure Capacitance, Resistance
  • and generate a Square wave using Python interpreter.
At the python prompt:

Type import expeyes.eyesj, press Enter.

Type p=expeyes.eyesj.open(), press Enter.

At the python prompt:

Type import expeyes.eyesj and press Enter.

Type p=expeyes.eyesj.open() and press Enter.

Type p.measure_cap(), press Enter.

Point to displayed capacitance value

To display the Capacitance value:

Type p.measure_cap( ) and press Enter.

Capacitance value is displayed on the terminal.

Type p.measure_res(), press Enter. To display the Resistance value:

Type p.measure_res() and press Enter.

Resistance value is displayed on the terminal.

Type from pylab import *, press Enter.


Type ion() and press Enter.

To generate a Square wave:

Type from pylab import *(asterisk) and press Enter.


Type ion() and press Enter.

Type print p.set_sqr1(100), and press Enter


Type t,v=p.capture(6,400,100) and press Enter

Type print p.set_sqr1 within brackets 100 and press Enter.

Here 100 is the frequency of the square wave.

Type t,v=p.capture within brackets 6,400,100 and press Enter.

Type plot(t,v) and press Enter.

Point to generated square wave.

Type plot within brackets t,v.

plot within brackets t,v generates a square wave on a new window.

Press Enter.

Let's summarize.
Slide Number 16

Summary

We have learnt:

  • Introduction to Python
  • Measure AC voltage using Plot window & Python
  • Generate a Sine wave
  • Measure external and internal voltages using Python
  • Measure capacitance & resistance using Plot window & Python
  • Generate a Square wave
  • Show connections & circuit diagrams for our experiments
  • Introduction to Python
  • Measure AC voltage using Plot window and Python
  • Generate a Sine wave
  • Measure external and internal voltages using Python
  • Measure capacitance and resistance using Plot window and Python
  • Generate a Square wave
  • Show connections and circuit diagrams for our experiments
Slide Number 17

As an assignment,

Measure the resistance of your finger using Plot window.

Using python, generate a combination of Sine and Square waves.

Show circuit diagrams for the above experiment.

As an assignment,

Measure the resistance of your finger using Plot window.

Using python, generate a combination of Sine and Square waves.

Show circuit diagrams for the above experiment.

Slide Number 18

Acknowledgement

Watch the video available at

http://spoken-tutorial.org

/What is a Spoken Tutorial

It summarises the Spoken Tutorial

project.

If you do not have good bandwidth,

you can download and watch it.

  • This video summarises the Spoken Tutorial project
  • If you do not have good bandwidth, you can download and watch it.
Slide Number 19

The Spoken Tutorial Project Team

Conducts workshops using spoken

tutorials

Gives certificates to those who pass

an online test

For more details, please write to

contact@spoken-tutorial.org

* We conduct workshops using SpokenTutorials and give certificates.
  • Please contact us.
Slide number 20

Spoken Tutorial Project is a part of

the Talk to a Teacher project

It is supported by the National

Mission on Education through ICT,

MHRD, Government of India

More information on this Mission is

available at

http://spoken-tutorial.org

/NMEICT-Intro

The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India.
This tutorial is contributed by Kaushik Datta and Madhuri Ganapathi..

Thank you for joining.

Contributors and Content Editors

Kaushik Datta, Madhurig, Nancyvarkey