 Hi, everyone. I'm here today to discuss the modernization of science laboratories by developing affordable sensing tools and the various roles that the Python programming language can play in the data acquisition, analysis and visualization requirements. Learning by DOE is an integral part of science education, but it's dependent on a variety of tools which can measure in absolute terms physical parameters such as temperature, pressure, angular velocity, luminosity, etc. Now, development of a well-equipped lab therefore requires a fairly large investment in instruments which consist of sensors to measure physical parameters, the necessary electronics to digitize the signals from the sensors and then transmit them to a suitable platform where they can be visualized. Furthermore, this data needs to be analyzed to get further information from this data. Now, in 2005, an open-source project called Phoenix was started by Dr. Ajit Kumar to develop computer interface equipment which were capable of acquiring data and transmitting them to a computer through the parallel port and visualizing them on the computer itself. This work went through several iterations and the latest in the series is called XPISE, to which I am a contributor. Now, XPISE is a Swiss Army knife of control and measurement tools at whose core is a microcontroller, which is programmed to accept commands from a connected computer, make measurements using the analog peripherals that it has been equipped with and respond with the results. Now, here in this schematic, you can see the functioning of XPISE. So, on the bottom half, you have the hardware, which as I said is a microcontroller, which interfaces with the real world. And the top half, you have the software side of things, which communicates with the hardware via USB and allows users to visualize acquired data or have control widgets or analyze this data. The Python tools that went into this work involved PySerial for communication and the struct library for packing data and graphical interfaces were made with PyQt and PyQt Graph. There was NumPy and Sypy used for analysis. Documentation, it was done with Python Sphinx, which compiles REST files into readable html formats or PDFs, etc. There's a Qt web engine, which displays help files within graphical interfaces and packaging, which was done using PyInstaller, PyPy and DPKG. Python Flask was also used to make a remote access server. This is one example of how the state machine works. On the left side, you have the get frequency call in the firmware, which runs on the microcontroller, and a corresponding get frequency call in the Python side of things, which sends across a command, which is basically a byte, a collection of bytes, saying okay, fetch the frequency and the hardware responds with the measured frequency. And these commands leverage the ability of the microcontroller to digitize very fast time signals of the order of 10 nanoseconds or voltages in the millivolt range or even use additional communication channels to fetch data from commonly available sensors which measure physical parameters such as pressure, humidity, acceleration, etc. Now let's look at how we can enhance the measurement capabilities of XPYs by using commercially available sensors. So there are a lot of sensors such as this accelerometer plus angular velocity sensor or this pressure plus humidity sensor, which are available very cheaply for a couple of hundred rupees because they're used in consumer electronics. But even though they have a lot of applications in science labs, it's rather difficult for students to get data from these and use them in an experiment. So XPYs can help there because all the coding part is already covered in Python and all the students need to do is to plug it in and then use the I2C modules UI, scan for the connected sensor, and here. So this sensor measures pressure, temperature and humidity. So it's fit for a thermodynamics lab and here you see that the pressure is 978.9 millibars. That's the atmospheric pressure in Delhi. This is temperature and this is the relative humidity, which is high because it's been raining outside. And you also have a data logger where you can visualize changes, variations in these parameters. So here, for example, if I have pressure, you've probably been taught in high school that as you move into the hill stations, the atmospheric pressure goes down. And you can demonstrate this here itself because if I raise the I2C sensor, it's so incredibly sensitive that you can see the atmospheric pressure has fallen. Or if I lower this, the atmospheric pressure goes up. Now similarly, another thing that students, teachers demonstrate in class is that when you breathe out, the air is humid. So that can be easily measured with this that you can see that the humidity goes up. Now let's try out a different sensor. This one is called the MPU-6050 and it's found in pretty much all phones. It's an accelerometer plus angular velocity sensor in three axes. So similarly, you need to scan again and here. So you have all these readings. The first three are acceleration in X, Y and Z directions. So this is the component of G, okay? That's why they're all different. And the other three, the last three are angular velocity in three directions. Now let me pretend that this is a crude pendulum. So I have this pendulum here and I want to find out what is the period of oscillations. So all that I need to do is that I can use the data logger. And you can see that the behavior is sinusoidal in nature and it's also being damped. Let me pause this, get a few good cycles of this and use sci-pi's regression capabilities to apply a damped sign fit. And now you can see here that the frequency of oscillations is about 2.686 hertz, which makes sense for twice a second. For a large section of the target audience, that is students, educators, hobbies, etc., simply having a Python library is not sufficient because they lack the necessary coding skills. So graphical interfaces were made with PyQt. And in the following slides, I'll talk about how you make interfaces using PyQt. The PyQt UI toolkit was chosen since it offers easy UI design via Qt Designer, which can be easily connected via signals associated with user inputs to functions or slots, which are then defined in the code. Here's the final oscilloscope user interface. And this is also translatable via Qt Linguist, which follows a phrase by phrase approach. And here you can see the UI translated into Malayalam. Now, let's look at a few more sample experiments, this time to do with mechanics. I'll start with the oscillations of a simple pendulum, which I'm sure most of you have tried in school. The goal is to calculate the time period of oscillations and then use the familiar theoretical formula to derive the value of acceleration due to gravity. And I'll show how it becomes more advantages to use digitization tools for this. And the same can also be repeated using an accelerometer, which is used in your smartphones for gaming and to calculate the velocity as a function of position. The value of acceleration due to gravity can be quickly derived from mechanics experiments. The time period of the simple pendulum can be measured using a DC motor shaft acting as a dynamo. Or for a more direct approach, the time of flight of a metal ball can be measured by releasing it from an electromagnet and stopping a timer when it hits a contact switch. There are several other sensors such as this LiDAR, which measures distance using a light pulses, costs three, four hundred rupees only. And for example, this high resolution waveform generator. And now we'll talk about the basic feature set and how this device fits into an electronics laboratory. For example, here you have the four channel oscilloscope. And I'm going to take the waveform generator output from the sine wave generator and connect it via a wire to the A1 input, which measures voltages and also can measure voltages as a function of time. So you see the sinusoidal figure here. And you can also change the output of the function generator, the output frequency. You can analyze the acquired data. You can fit it to a standard sine function and extract the frequency, which gives you 3.05 volts amplitude and frequency. And you can also change the shape of the sine wave to a triangular shape or an arbitrary shape, for example. Now here I have a triple five timer oscillator, which requires a five volt power supply, a ground, and I'm going to take the output and plug it to A2, which is the second input of the oscilloscope. Which I can now enable. And once I enable that, using A2, you see that's the PWM signal output from the triple five generator. So it's in a zero to five volt range and I can also subtract these two signals, which has certain applications. I've frozen the window so that you can see these clearly. They're not moving around. The help window that I talked about earlier using PyQ Web Engine is here. And for example, if I take the voltage measurement experiment, it's a very simple one. It shows you that, okay, a cell needs to be connected between the A1 input and ground in order to measure the voltage. Or if I take this high school experiment of a lemon cell, there is some basic help there that says, okay, this is how you connect the electrodes to the lemon cell. And then you connect a small load and measure what is the output voltage. Now I'm going to show you how Python code can be written to do what the graphical interface does. So let's capture a single waveform. I say capture, I say, I mean the oscilloscope input. So you import the library, you connect to the device, then there is one function called Capture 1. So from Capture 1, from the A1 channel, I fetched 10 data points with 10 microsecond delay between each. If I change that to 500 data points with 50 microseconds delay between each, I will get a few cycles of the sine wave, which we had connected to the A1 input. Now I use PyLab to plot this data and to show it. I can also show you how to generate an arbitrary waveform. So here I've written a small function, which is the first two components of the Fourier expansion of a square wave. So it's sine 3x and sine, sorry, x. So the output waveform you see is heading towards the square wave. So the more terms you add, 1 by 5 sine 5x, 1 by 7 sine 7x1, you'll get a square wave. Now here, for example, I've connected A1 to A2 via a diode. So the diode only allows one-way traffic. So it clips the bottom half in, which is the familiar half-wave rectifier. So you see a half-wave rectifier signal. And there's a small gap, which is caused due to the new voltage of the diode. So here you have the oscilloscope, which measures voltages as a function of time. Let me give you a small demonstration. So in the microphone input of the oscilloscope, I've connected a small condenser mic here. Now I need to enable the microphone channel. And if I, for example, whistle into this mic, the oscilloscope picks up the signal. Now, for example, if I want to know what the frequency of my whistling is, how do I find out? Here, I can use the fitting function. It will fit this to a sine wave and tell you what the frequency is. So if I whistle, let's say, so you can see that frequency can be extracted in this manner. Now, the oscilloscope can also be used to clarify some rather confusing mathematical concepts such as this Fourier transform. Let me give you a demonstration again. So I'm going to whistle and take a Fourier transform of the whistling sound. So the resultant plot here is a single peak at about 2 to 4 2 hertz. Fair enough. Now, what happens if I combine two signals? For that, I have this buzzer connected here. It's a piezo buzzer, which is connected to the waveform generator. So if I set the frequency to about its resonant frequency, it will be pretty loud. So its resonance is about 3000 hertz. So it's pretty loud. Now, to find out the frequency, I can again fit it and say, okay, frequency is 2800, which is what we set here. Now if I combine two signals with this, I whistle at the same time. Let's see what happens. So the resultant waveform is rather confusing and you can't use sine fitting. But a Fourier transform can simply pull out both. Let me see here. I'm going to set one signal. Whistle at the same time and take a Fourier transform. So you see you have two peaks. One is at 3090 about here, which is the buzzer. And this is my whistling here. Okay, so like I told you earlier, the loudness of this buzzer is a function of frequency. Now, what if I want to find out where is this loudest? So I need to sweep the entire frequency region and then find out the amplitude at each point. For that, we have the advanced data logger, which allows you to measure one parameter as a function of another. So I'm going to choose the X parameter to be the frequency of the waveform generator, which is applied to the buzzer. So let's go from 1000 hertz to 5000 hertz. Now the Y parameter is what we're going to measure. We want to measure the amplitude of this, the sound that the buzzer makes. For that, you need the oscilloscope. In the oscilloscope, you're going to pick out the microphone channel. And so you can see that the microphone channel is recording the mic. And you take about a few cycles of the signal and you are interested in the amplitude. So that the amplitude can go up to 3 volts, confirm. I'm going to set a time interval of about 100 milliseconds between each data point. Take 100 millisecond settling delay and take about 200 data points. And then we're going to simply log data. See that this particular buzzer has other different positions where it's loudest. So it has multiple resonant frequencies. We saw earlier during the Fourier series demo that you can make square wave by combining sine waves. And the converse is also true. If you excite this buzzer in this experiment using a square wave, what happens is that the buzzer picks up the closest component of the Fourier expansion. So even if the buzzer has a 3 kilohertz resonance, if you excite it with a 1000 hertz square wave, it will take up the 3x component and still resonate. And to confirm that this is the case, you can track the recorded frequency as a function of the applied frequency. So you can see that the recorded frequency is always along the lines of either 3x of the applied frequency or 5x of the fundamental or 7x. With this flexible approach to sine slabs, students can create their own experiments. For example, here you have standing waves being created inside a box using a buzzer and a reflecting surface, and a microphone is dragged along this to check the amplitudes at the nodes and anti-nodes. So you see it's amplitudes going up and then down at various points. And if you found these experiments interesting, you should check out the blog page at csparkresearch.in which has write-ups on a lot of fancy experiments. For example, here the velocity of sound and how it's calculated. And now I'll talk a little about the hardware design and assembly of this device. So the circuit board made with KiCAD is then fabricated. The PCBs are stenciled first and then they're assembled using a pick and place machine, which, as you can see, picks up components from their tapes and reels and places them exactly on the PCB where they need to be. So here's a close-up view of the same. And after that, there's an optical inspection stage which checks that the components have been placed in their right positions. And once that is confirmed, the entire PCB moves into what's known as a reflow oven where high temperatures melt all the solder simultaneously, giving you a finished PCB product. So here's the paneled PCB. From that, you break off one PCB each and then it's ready for testing. Internationalization. As I discussed earlier, PyQt is pretty easy to translate in different languages. And particularly in the Indian context, a lot of schools still rely on regional languages for education. So I have a few examples here. For example, if I want to translate this UI into, say, Malayalam. Here's the Malayalam UI. Or similarly, Khashoggi or French English. And similarly, the embedded help window with PyQt web engine is also translated. The REST files, which are used to show help within the user interfaces, are also compiled into a PDF form using Python Sphinx. And George Kaznodar, he's also the Debian maintainer for this project, has contributed a French translation of the user manual. And this is the Malayalam contribution from Amal. In the present situation, classes are being conducted online by a lot of schools, but this comes at the expense of labs. Now, XPY is being affordable. Students can actually conduct experiments at home. But the question of instruction arises. How do students, how do teachers, for example, monitor the data that's being collected or instruct students on how to go about this? So we're working on a remote access platform, for which I'll give a short demo first. So these students have their desktop application where they can pick out an experiment, for example, scope or something. And this is the teacher's UI. So the teacher, for example, creates a classroom. I'm going to give it a name. And these students will log into XPY's online with their username, credentials and the classroom name. Once they do that, the teacher gets the data that their students are recording live. So here, for example, if I take the microphone channel, it's recording the buzzer, which I think you can hear. And at the same time, the teacher can either make audio or video calls to the student and even control the UI. So if the teacher wants to change the waveform generator for one student, it's like this. Or even if there are multiple students, you can broadcast data to all students at once and conduct a virtual lab. This brings me to the end of my talk. XPY's is an open hardware project looking for contributors in various fields. And this is the official site of XPY's, XPY's.in. You have the manufacturer's site where you have details, which is user manuals, installers, et cetera. And you even have a Moodle course at sizeschool.in. And thank you all for attending my talk. Nice to see the beautiful demos, I would say. So let's wait for some questions. There is one. I will relay it to you. My audio is fine, right? Yes. OK, people are appreciating the demos they liked in the chat. So, yeah, one of the questions is where can I find the plastic cover or boxes for the device they are making? So some circuit board plus Arduino or some Raspberry Pi or something. What would be the best way to mass produce it or something in India? To mass produce it, you need to approach someone who builds injection molded cases. So there will be an initial cost for building the mold. After that the boxes will be cheaper. But if you're going for small volume, then maybe 3D printed cases or laser cutting. So you just take acrylic sheets and you get them laser cut. So you probably need to use Inkscape for exact dimensions. And if you built your PCB with kikad, you can export as an SVG. Take it to Inkscape and then that's good enough for laser cutting. All your connection holes, everything will come in the right spot. So, yeah, if people, you have any questions, post them on the Q&A. We have around five minutes and Jitin will be more than happy to answer those. I see a few in the Q&A. There's one regarding the IDEs. Let me, yeah, let me get to that. Can we integrate other circuits with XPYs like Adafruit circuits? And can we code this in CircuitPython? So, it's not built with CircuitPython. The hardware runs on C. The entire firmware is in C. It's Python that handles fetching data from the hardware and then it takes care of all the UI and analysis. But as a test and measurement tool, you can use it to debug your Arduino projects or other electronics projects that you're building. Yeah, I think that answers it. This is the IDE. So the IDE, I don't use any fancy ID. I use Gini, which at the bare minimum allows me to execute right from there itself. There's no autocomplete or anything. So for all the Python code, it's Gini. And for the remote access thing, which I talked about, HTML, JQuery, all that is also in Gini. But for the hardware development, the PIC microcontroller family is used. So I use the MPLAB IDE from Microchip. Where can we get XPYs for personal projects? Oh, so you can go to XPYs.in where you have a list of the vendors that are actually distributing this. Or build one yourself using the open handle. Or you can build one yourself. All right. Let's wait for a minute. Will it be accessible for someone who is totally new to the embedded system? This is one more question, Bhavan. Yeah. So it's not like you need to program anything in C. It's ready built with the sole purpose of letting you access sensors, information from the outside world by with, you know, little programming language. It's meant for educators and students. So it tries to take out the embedded part. So for example, when you deal with all these I2C sensors that I showed, all their communication protocols are in Python in the library itself so that you can just, you know, sit at the top of the abstraction layer. But first, if you can code, you will be able to add support for more sensors that you may find on the market. There's about seven, eight sensors already supported right now for the common ones. But of course, if something new comes out, you don't need to change the embedded part. You just need to change the code in Python. Again, it's, like I said, it's an entire list at xpys.n or you can go to csparkresearch.n and just contact. There are several vendors across India and abroad.