back...

interface and application programming

<<<<<<< local


=======
>>>>>>> other


using python for a small ADC-interface

This week’s assignment was to write an application that interfaces with an input and/or output device.
Considering the available time this week where I have to plan already ahead for the final project (such as materials and parts needed) I wanted to focus especially on one programming language enabling me to write small interface programs and to explore from there.
Python as weel as and Java Script came into my closer consideration; since I had used now some python files already without really having a closer look inside, and in addition I learned that it is very helpful to explore the possibilites of this language, I decided for the first.

For the input-device week I did an ADC-converter, whereby until today I checked the proper functioning by using Neil’s rx.py program and measuring a calibration curve. However, now I wanted to visualize the readout; this should enable me to measure the generated voltage output from my tiny hydro generator - which is the core of my final project. In doind this, I will not need any additional equippment.

So I had a closer look at Neil’s rx.py as well as the hello.light.45.py program for a start; the goal was to understand them and to combine them so that the serial byte on the serial (comming from the hello.button board which is functioning as an on demand adc converterserial) gets read and then the voltage can be calculated and displayed.
Since I did some object-oriented programming many years ago (that time using Delphi), the related syntax-conventions (with methods passed on from parents-object) was some kind of familiar to me. However, I spend some time to look up the functions of the respective methods used.


the python program

figure 1 shows my small modified python program entitled adc45interface; Just a view words to the syntax:
- with root = Tk() we have an instance "root" of the object Tk, which is a canvas-object. Such allocations are very powerful since TK has now passed all functionallity it has to root;
- we get excess to the functionality by calling the respective function or method in adding a point after the instance, such as root.title;
- canvas is another object; canvas.create_rectangle does according the name – in needs the two (x/y) coordinates of two points to define it

Since with my ADC-program I only use the upper 8 bits from the ADC, the voltage can be calculated by

U[V] = 5V * decimal readout value/255
, whereby 5V was the selected reference Voltage and represents the maximum readout at 255.


In figure 2 you can see two images comparing the voltage measured with a digital multimeter as well as the respective ADC-readout displayed at the computer.


figure 1: the python program adc45interface.py


<<<<<<< local =======

figure 2: measurement setup: by turning on the potentiometer the changing voltage is displayed in a small window


>>>>>>> other

back...