fossasia/pslab-desktop-apps

Name: pslab-desktop-apps

Owner: FOSSASIA

Description: PSLab GUI Experiments using Qt and Python http://pslab.fossasia.org

Created: 2016-06-11 16:43:21.0

Updated: 2018-05-23 17:27:20.0

Pushed: 2018-04-30 11:08:28.0

Homepage:

Size: 7078

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

PSLab-apps

GUI Experiments for PSLab from FOSSASIA

Build Status Gitter Codacy Badge

This repository is for Qt based applications for PSLab - GUI programs, widgets and templates for various experiments. This is also installable on linux machine.

The goal of PSLab is to create an Open Source hardware device (open on all layers) that can be used for experiments by teachers, students and citizen scientists. Our tiny pocket lab provides an array of sensors for doing science and engineering experiments. It provides functions of numerous measurement devices including an oscilloscope, a waveform generator, a frequency counter, a programmable voltage, current source and as a data logger.

We are developing the experiments starting on the hardware to libraries and user interfaces for desktop PCs and Android apps for smartphones. The PSLab project is inspired by the work of the Open Science Hardware community and the ExpEYES project. Our website is at: http://pslab.fossasia.org

Communication

Please join us on the following channels:

Installation
Installing the manual way

To install PSLab on Debian based Gnu/Linux system, the following dependencies must be installed.

Dependencies Now clone both the repositories pslab-apps and pslab. Libraries must be installed in following order :
  1. pslab (Python Communication Library)
  2. pslab-apps (GUI for performing experiments)

Note If user is only interested in using PSLab as an acquisition device without a display/GUI, only one repository pslab needs to be installed

To install, cd into the directories
$ cd <SOURCE_DIR>

and run the following (for both the repos)

$ sudo make clean

$ sudo make

$ sudo make install

Now you are ready with the PSLab software on your machine :)

Install using the installer.sh script

Installation of PSLab desktop app is made easier using the installer.sh script. First you have to make the file an executable. Go to the directory where the installer.sh file is downloaded and then execute the following command.

 chmod +x installer.sh

This will ask for your password to proceed. Once it is completed, run the intaller by the following command;

 ./installer.sh

This will install the PSLab desktop application in the /opt/ directory. Once the installation is completed it will prompt to open the application. Press Y to launch PSLab desktop application for the first time or press N to exit the installer.


For the main GUI (Control panel), you can run the Experiments app from the terminal.

$ Experiments

If the device was not detected , the following splash screen error will be displayed on launch:

Under normal circumstances, the splash screen will be followed by the application's main window


Development Environment

To set up the development environment, install the packages mentioned in dependencies. For building GUI's Qt Designer is used.

Communicating with Pocket Science Lab via USB and understanding the various read/write functions

Design of PSLab combines the flexibility of Python programming language and the real-time measurement capability of micro-controllers.

PSLab, with its simple and open architecture allows users to use the tool for various measurements and to develop new experiments with simple functions written in python.

It is interfaced and powered by USB port of the computer. For connecting external signals it has several input/output terminals as shown in the following figure.

Interfacing with the real world. One small Python script at a time
Example1.py : Connecting to the device , and read a voltage value from one of the analog inputs
from PSL import sciencelab
I = sciencelab.connect()     #Returns None if device isn't found
 example function that measures voltage present at the specified analog input
print I.get_average_voltage('CH1')

The module sciencelab.py contains all the functions required for communicating with PSLab hardware. It also contains some utility functions. The class ScienceLab() contains methods that can be used to interact with the PSLab. The connect() function returns an instance of this class if PSLab hardware is detected. The ScienceLab class does the following crucial jobs during the creation of an instance.

Once the device has been succesfully opened, the instance of ScienceLab.py can be used to access its various features. Here's an example script to read values from a magnetometer connected to the I2C port of the PSLab

from PSL import sciencelab
I = sciencelab.connect()     #Returns None if device isn't found
from PSL.SENSORS import HMC5883L #A 3-axis magnetometer
M = HMC5883L.connect(I.I2C)    #Specify that the I2C bridge is to be used
Gx,Gy,Gz = M.getRaw()           #Returns three decimal numbers that indicate magnetic fields along orthogonal axes
Example 3 : Capturing a sine wave, and plotting it using matplotlib

The function call that is used for acquisition capture1(channel name,number of samples,time gap (uS) between samples, *optional keyword arguments)

from PSL import sciencelab   #These first two lines are always used to create the instance, 
I = sciencelab.connect()     #and will not be repeated in further examples.
I.set_gain('CH1', 3) # set input CH1 to +/-4V range
I.set_sine1(1000) # generate 1kHz sine wave on the waveform generator W1
#USE A WIRE TO CONNECT W1 to CH1.
x,y = I.capture1('CH1', 1000, 10) # measure the voltage at CH1 1000 times, with 10uS interval between successive samples
from pylab import *    #Import the plotting library
plot(x,y)                   #Plot the time axis against the voltage data
show()                  #display the plot

The following image displays the plot output

Example 4 : Capturing two sine waves, and plotting them

The function call that is used for acquisition capture2(number of samples,time gap (uS) between samples, TraceOneRemap)

- coding: utf-8 -*-

 pylab import *
 PSL import sciencelab
iencelab.connect()
t_gain('CH1', 2) # set input CH1 to +/-4V range
t_gain('CH2', 3) # set input CH2 to +/-4V range
t_sine1(1000) # generate 1kHz sine wave on output W1
t_sine2(1000) # generate 1kHz sine wave on output W2
nect W1 to CH1, and W2 to CH2. W1 can be attenuated using the manual amplitude knob on the PSlab
,y2 = I.capture2(1600,1.75,'CH1') 
(x,y1) #Plot of analog input CH1
(x,y2) #plot of analog input CH2
()

Resultant plot :

Example 5 : Capturing four oscilloscope traces simultaneously from various analog inputs

The function call that is used for acquisition capture4(number of samples,time gap (uS) between samples, TraceOneRemap)

- coding: utf-8 -*-

 pylab import *
 PSL import sciencelab
iencelab.connect()
t_gain('CH1', 2) # set input CH1 to +/-4V range
t_gain('CH2', 3) # set input CH2 to +/-4V range
t_sine1(1000) # generate 1kHz sine wave on output W1
t_sine2(1000) # generate 1kHz sine wave on output W2
r1(2000,duty_cycle=50) # generate 1kHz square wave on output SQR1
nect SQR1 to CH1
nect W1 to CH2, and W2 to CH3. W1 can be attenuated using the manual amplitude knob on the PSlab
,y2,y3,y4 = I.capture4(1600,1.75,'CH1')
(x,y1) #Plot of analog input CH1
(x,y2) #plot of analog input CH2
(x,y3) #plot of analog input CH3
(x,y4) #plot of analog input CH4 : MIC
()

Resultant plot :

You can help
se report a bug/install errors here 
 suggestions to improve PSLab are welcome :)
Blog posts related to PSLab on FOSSASIA blog

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.