Interface and applications programming
This week's tasks are:
- Write an application that interfaces with an input and/or output device that you made.
- Describe and explain the process.
For this assignment I decided to use python to create a GUI that displays my audio signal comming from the audio input circuit that I've made at Input devices week.
Step1:Setup python on windows
Python is a high level languge which is general purpose and can be used to program almost anything.
- Install python latest version from their website.
- Add the python to the enviroment Path
Enviroment Variables:Environment variables hold values related to the current environment, like the Operating System or user sessions. These variables are dynamic and affect the way running processes will behave on computer.
Enviroment Path: is an environment variable on operating systems that specify a set of directories where executable programs are located.Each executing process or user session has its own PATH setting.
Go to the location where python is downloaded and copy the path.
Open regedit from windows search then go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.Right click on the path then modify and paste the copied location at the begining and a semi colon to seperate between it and the next location.
- Open the windows command prompet and test the installation of python by just typing python then ctrl+z to exit
You should see something like this.
- Update the library installation tool "pip" by running (python -m pip install -U pip setuptools).
A message appeared that I should use a different command which is (python -m pip --install --upgrade pip)
pip is installed successfully.
- Connect the circuit with the FTDI to the computre then try to figure out which post is the circuit connected to using the command (python -m serial.tools.list_ports) but I've got an error that the serial command is not recognized so I had to install it using (pip install serial).
Serial is installed successfully.
port is recognized now to be com 10
Step2:interpret and edit on python code
I used the code that prof. Neil uploaded in Input devices week schecule under the sound section and modified it to be suitable for my circuit.
- Download the code and move it to the python folder in C.
- change the directory where the code exists and call the code to be excuted by typing (python.exe file name port name)
When I excuted the code it gave me tkinter not found!
- tkinter is a GUI that is used with python. After searching I found that in python3 Tkinter should be written as tkinter will small t letter not capital T. I changed it in the code.
Change the T into t
Change the baud rate to the 19200 as set in my c code of the circuit.
- Change parameters in the code
When I tried to execute the program again there was no error in tkinter but their was error in printing command in the code so I deleted it as it was not needed for plotting.
GUI opened
The signal was too high to be displayed within the screen.
I edited the code gain to be 0.015 instead of 0.2
The result I got
better visible signal is achieved when I reduced the gain to 0.001.
I have tried to flip the signal and make it display at the positive side instead of the negative but I couldn't. The result is good for me as I was able to understand the python code, edit it and deal with python interpreter and may be I will get back to this week if I had extra time.
Files:
Resources I used in this week:
Contacts & Refrences