PYTHON PROGRAMMING AND GUIS FOR ELECTRONIC ENGINEERS DOWNLOAD

adminComment(0)

For Electronic Engineers. In Python all this is wrapped up in relatively simple functions. The book Practical demonstration circuits and downloadable, full software examples are Software-Python Programming and GUIs (Size: MB). This is the second edition of a book aimed at engineers, scientists, and The programming language used is Python 3. Immediately available (download) in Python, allowing you to access your electronic hardware over the Internet. Python 3: Programming and GUIs for Electronic Engineers .. At the time of writing, Debian can be obtained by download from.


Python Programming And Guis For Electronic Engineers Download

Author:BRAIN BREADY
Language:English, Arabic, Dutch
Country:Iran
Genre:Politics & Laws
Pages:142
Published (Last):21.04.2016
ISBN:796-5-72242-186-8
ePub File Size:23.55 MB
PDF File Size:10.71 MB
Distribution:Free* [*Registration needed]
Downloads:21745
Uploaded by: KOREY

Practical demonstration circuits and downloadable, full software examples are presented that can be Python Programming and GUIs for Electronic Engineers. Python Programming and GUIs for Electronic Engineers on cotubesina.ml *FREE * a site? Get your site here, or download a FREE site Reading App. Python Programming and GUI's [Andrew Pratt] on cotubesina.ml *FREE* shipping on Python Programming and GUIs for Electronic Engineers. Paperback.

The approach of this book is to use the Arduino Uno as a slave. No code writing is required for the Uno as an Arduino Uno universal sketch is provided. This makes the Arduino respond to programs written in Python on the PC which is the master. A Python tool is provided in the programs. This chapter shows how to program and configure Arduinos and will give an overview of how to use the communication functions in Python to command the slaves.

At the end of the chapter, more details on the protocol will be given, although useful information on fault finding can be read later. The Arduino Uno provides a hardware interface of digital and analogue inputs and outputs IO that can be connected to electronic circuits. The Arduino is the slave and the PC running the Python program is the master. For reliable communications between the Python program and the IO, a serial communications protocol is provided that has a number of functions that transmit data in frames back and forth.

Each frame has an error detecting check sum. A Python GUI tool is presented here to make it easy. Figure on page 82 shows the user interface. Figure Slave programming tool To use the programming tool, proceed as follows.

Start the program without your Arduino USB lead unplugged. Ensure that you run the program from this directory, see the explanation below. The port used by the Arduino should appear.

The output window should display as shown above. The programming tool has to access the hex file that it knows by the name of slave.

If you move the programming tool to a different directory you must move the file slave. Also you might have more than one Arduino in your project so the slaves are given an address within this project. The address and the project numbers are retained in the EEPROM when the Arduino is powered off so they only have to be entered once for each project. IntVar Control variables self. IntVar self. The speed of the change of position is controlled by a scale.

This program introduces a useful technique for calling a method at intervals. Top level windows, in this case our master has a function called self. Here we are using it at the end of the method drive to call drive again. The time interval is determined by the position of the scale.

Unlike using time. A point to remember is that sleep has the time interval expressed in seconds using a float, and the after method has the time interval expressed in milliseconds using an integer. Program Call a method at intervals! The GUIs will be all about interfacing with the Arduino slave.

You must read Chapter 5 on page 81 before trying the projects in this chapter in order to understand how the Arduino is used here. The programs presented will be object oriented. The programs will be getting longer and more complicated. This is where object oriented programming starts to make things more manageable. If you have trouble understanding parts of the code, try experimenting by changing one part at a time; this can be great help towards understanding.

Also some more Python features will be introduced. Often something similar crops up in more than one program that would result in duplicating code and wasting time. One such example is to plot a graph of the analogue inputs against time.

The following program is a class that can be used to create instances of an object that will do this and require very little code to include it in other projects.

The class that is called Graph and it will be in a module or separate file. Figure shows a GUI that will be Program on page , the custom widget with the canvas and two buttons Reset and Flyback can be seen with its raised border, is an instance of the class Graph.

This widget can be placed in any GUI you write, simply by importing the module plotter and creating an instance of Graph and calling its methods. Program below is plotter.

The class plots up to six analogue inputs simultaneously against time. Measurements on the graph can be taken by using the mouse to point to a position on the graph and left clicking. The Flyback button causes the graph to restart plotting from the left end without deleting anything.

The Reset button also restarts from the left end but also clears the canvas. As well as the time saving, this approach gives the benefit of dependability that the code can be relied upon and only needs to be imported and used. Suppose that we want to pass different numbers of arguments depending on the application. Here we can pass up to 6 analogue input values to be plotted.

In the function, args is a tuple that contains all the arguments passed from the calling function. The word args is not mandatory, it is just the convention.

Here is an example you can try in an interactive session. The function prints args; you can see that this is a tuple. If we use the built in method enumerate we can obtain index numbers and values for the arguments that have been passed regardless of how many there are. The function enumerate yields two values: one being an enumeration of the position of the argument and the other being its value.

The variable palette is a list of different colours for each analogue input. They are after the two positional arguments height and width. Keyword arguments have default values that they take if they are not passed by the calling method these are the values after the equal signs.

In the last chapter the canvas widget was used to draw on when producing GUIs in Tkinter. What if you want to plot a graph and save it as an image file?

Python does provide a method for saving canvases as postscript files, but what we will do in this chapter is create and modify bitmap images that can be saved and read by any image viewer. Bit map images are very easy to manipulate as they are an array of pixels like points on a piece of graph paper. As an illustration Figure represents an image 8 by 6 pixels. There is a square for each pixel and a byte for each of the three colours.

The image is white except for a red line across the top and the three pixels starting from the bottom left hand corner are red, green and blue. Figure Image of 8 pixels by 6 pixels Not shown on Figure the bit map file starts with a string of 54 bytes which is the header.

How to Make Your First Simple Software Using Python

This contains information about the image - we needn't worry about the content of the header for now. Following the header is the actual image content, starting from the bottom left hand corner of the image, the next three bytes are the blue, green, and then red values of the first pixel.

This continues for each pixel in the bottom row. After the bottom row is the left most pixel of the next row up and then so on for the rest of the image. In order to view and modify images I recommend KolourPaint. To view it you will need maximum zoom. Figure shows how the bytes that define the image are sequenced in the file.

The first four pixels and the last two from Figure Note that the order of the bytes for each pixel is blue, green and then red. Figure Byte sequence in the file The object of the exercise is to write an image file with our own program. This will be referred to as the output file. Although we don't need to worry about the content of the header, we do need a header for any file we create.

Fortunately the header does not depend on the image content but only on the geometry of the image and colour depth. The easiest way to write the header for your file is to copy the header from another image of the same size and colour depth. We will look at the makeup of the header later in the chapter. We will take an existing bit map file, our template image, and read it.

The header will be re-used as the header for the output file. The template file can give the program a head start by having a background such the grid lines for a graph or the face of an instrument to draw on top of. Looking again at Figure on page , each square is a pixel and needs three bytes to set its colour. We can create a list with three members each being an integer from 0 to This would mean the third pixel from the left hand corner would be [, 0, 0].

If we have a separate list for each pixel we need some way of identifying these lists in terms of where they are on the image. One python object that is ideal for this is the dictionary.

Related Searches

Dictionaries were covered in paragraph 2. See below on how any pixel from Figure could be held in a dictionary. The keys that we are going to use to index the lists that define the pixel colours are tuples with two integer members. These integers are the horizontal and vertical offsets from the bottom left hand corner of the image.

The first thing to point out that there is no direct connection to the mains wiring required. A non-invasive technique is used involving a coil of wire placed near to the supply cables. The probe will measure the current flowing and transmit the value to the receiver that will be connected to the Arduino slave.

A graph of current against time will be plotted. The next chapter gives details of how to use a web browser as a GUI that can be viewed on a mobile phone or other computer.

This will allow you to view the output when away from home. The reason for the radio link is that very often the mains incomer to a building is not at a convenient place for a computer. The remote sensing head driven by the coil comprises a filter, amplifier, and precision half wave rectifier, a PIC microcontroller and a low power radio transmitter. The PIC microcontroller is a 12F and it can be programmed using a tool written in Python that uses the Arduino slave. The code for the PIC is provided.

Chapter 0 – Introduction

The transmitter and receiver are readily available from Farnell Components who have international distribution. Figure Block diagram of mains supply monitor This chapter will also introduce some new topics by making use of the desktop application used for this project.

The pickup coil is connected to the sensing head by a length of coaxial cable. A twisted pair could be used. This is not the usual way of measuring current in a supply cable. Normally a current transformer with a magnetic core that one of the supply cables runs through is used. The core has a winding on it connected to a low impedance circuit. This has the disadvantage that either the current transformer must be fitted to the cable before it is connected or a split core transformer must be used.

Either option is not suitable for a home construction project as even if you use a split core you probably won't have room to fit it on a domestic installation. The method described here is completely non-invasive.

The way that this sensing coil works is that some of the magnetic field from the two supply cables links with the coil. As one of the cables is closer to the coil than the other, there will be a resultant field that induces a voltage in the coil.

Account Options

Now this is where this method is flawed. The instantaneous magnetic flux from the supply current is proportional to the instantaneous current in the supply cable but the voltage induced in the coil is proportional to the rate of change of the magnetic flux. However there are harmonics present in the supply current, if you compare the maximum rate of change of a Hz sine wave with the maximum rate of change of a 50Hz sine wave of equal amplitude it is three times greater, five times greater for the fifth harmonic.

To overcome this problem a low pass filter is included in the sensing head to reduce the effect of any harmonic content in the supply. It must be pointed out that this will not give results accurate enough for metering purposes. Please note, on the photograph the supply cables are the two running above the coil. In the UK these are referred to as the meter tails. Figure Prototype probe Figure shows the circuit diagram for part of the sensing head. There are three LF operational amplifiers used.

The first one 'U1' is used as a two pole Sallen and Key low pass Butterworth filter with a corner frequency around 50Hz. If your local supply is 60Hz this won't matter. The second stage 'U2' is a non-inverting preamplifier with a gain of Another low pass filter is added using 'R3' and 'C3'. The last stage 'U3' is a precision half wave rectifier. The gain of the last stage is set by selecting a value for 'R7'. The gain is the ratio of 'R7' to 'R6'.

You might find it more convenient to use a variable resistor here. Its value will be determined on test. Note carefully that the first two opamps U1 and U2 are connected as non inverting amplifiers and the third U3 is connected as an inverting amplifier; in other words get pins 2 and 3 the right way round. Capacitor C4 should be a non-polarized type such as metalised polyester. Menu self. X self. Graph master,self. X, self. Toplevel self. Text self. Button self. Label self. StringVar self.

Entry self.

S self. N self. END for data in self. END except: self. X, 90 : draw1. Y, [0,,0] for y in range 0, self. Y, 50 : draw1. X, y, [0,,0] for segment in segments: draw1. Y - segment[1], segment[2], self.

Y - segment[3], [0,0,] draw1. It is however often more convenient to use a mobile device such as a tablet computer or mobile phone. This allows you to remotely access your hardware devices even when away from home. Security and safety have to be considered when remotely controlling real electrical and electromechanical devices.

This chapter will only cover enough to give you a practical GUI for you own projects; it is certainly not a reference for web design. This chapter is being presented as following on from the current monitoring project started in the last chapter.

You can easily apply the information in this chapter to other projects of your own invention that might want to monitor similar analogue or digital inputs to the Arduino slave. It defines a web page in elements and these are represented by tags. Only the most basic coverage of this topic will be given here.

We only need to generate and display an image similar to the Python canvas widget in the desktop program. The code that we need to write here is remarkably simple. Program Index. The file name is index.

The first line is a comment and does nothing to the web page. The next declares to the browser what type of document it is. The next pair of tags enclose the header, and then there is the SVG code enclosed in the svg tags. The opening tag defines the size of the graphic.

The lines are defined in a way similar to that used on the Python canvas, with x and y coordinates for each end of the line, colour defined by the red, green and blue values, and stroke-width value. Figure shows the resulting graphic being viewed locally by using the path to the file. To view a web page on a different device to the one that the file is on you need a web server.

The Apache Web Server was used in the first edition of this book and common gateway interface CGI scripts were used to generate interactive web pages. Figure 9.

Program CherryPy! Curses is a Python package for the ncurses library that allows you to write text based user interfaces that are independent of the terminal being used. The work of an electrical engineer includes designing, developing, hire freelancers online , testing and organizing the manufacturing of electrical devices plus equipment.

This comprises electric motors navigation systems, as well as power generation apparatus. It contains Algorithm growth, Modeling, Data acquisition, simulation, plus prototyping, exploration, Data analysis, and visualization, Application development, Scientific plus engineering graphics, comprising graphical user interface constructing.

Occasionally using merely C might leave you by a lot of over head. However, it actually depends upon the app. Though, the choice of a programming language varies from project to project. Numerous electrical plus computer engineering works will need knowledge of this language as well. You can find freelancers for this programming language as experts is not that available.

C C is a preferred and extensively used programming language, mainly inside the fields of science plus engineering. C programming language applies toward resolving engineering and scientific difficulties. C is totally the language you requisite to know. C is simple, sophisticated and wicked fast; it is compact plus efficient.There are three LF operational amplifiers used.

The next chapter gives details of how to use a web browser as a GUI that can be viewed on a mobile phone or other computer.

Unicode is a very important topic that needs to be understood. It is particularly useful for control applications because it mimics a traditional analogue control device.

The programming language used is Python, an object-oriented scripting language; a higher level language than, say, C. The Python interpreter has to be installed on the computer for the operating system you are using. In the last chapter the canvas widget was used to draw on when producing GUIs in Tkinter.

RUBEN from New York
Please check my other posts. I'm keen on sculling. I enjoy reading books cautiously .
>