AVR GCC Structures

Structures in GCC are used in a variety of applications, such as: Basically, Structures are nothing more than collections of variables so, called members. Structures allow to reference of all members by a single name. Variables within a structure don’t have to be the same type. General structure declaration: or In the second example, we declared the variable name. Otherwise, variables can be declared this way: Members of the structure can be accessed by using the member operator (.). The member operator connects the member name to the structure. Let’s take an example: We can set the robot’s position by using following sentence: or simply Structures can be nested. A nested structure is a structure that contains another structure as one of its members. To access robot x coordinate, we have to write: Nested structures can be used in various applications, such as representing complex data types, like records or objects, and organizing data in a more readable and maintainable manner. They’re also helpful in systems programming, where you might need to represent hardware or software components as nested data structures. Actions can be taken with structures: Of course, you can treat a structure like a variable type. So you…

Continue reading

Raspberry Pi 3 goes 64-bit and adds more features

Raspberry Pi 3

When the first Raspberry Pi board was introduced it changed the understanding of small computers by bringing Linux closer to us. With great support, low board prices, and the vast community, it stayed on top next to Arduino for four years. Of course, in to keep that success, updates in hardware and software are mandatory. We know how fast things change computer industry, so time to time, Raspberry Pi foundation kept upgrading Pi boards From first to second and now the newest third generation – Raspberry Pi 3. At first glance, you may see that Raspberry Pi 3 board is practically identical to version 2. component layout is the same, including all peripherals. So all enclosures that worked with Pi2 should fit fine for Pi3 boards. But not the most obvious things that make it stand out.

Continue reading

Linear regression – learning algorithm with Python

In this post, we will demystify the learning algorithm of linear regression. We will analyze the simplest univariate case with single feature X wherein the previous example was temperature and output was cricket chirps/sec. Let’s use the same data with crickets to build learning algorithm and see if it produces a similar hypothesis as in excel. As you may already know from this example, we need to find linear equation parameters θ0 and θ1, to fit line most optimally on the given data set: y = θ0 + θ1 x x here is a feature (temperature), and y – output value (chirps/sec). So how are we going to find parameters θ0 and θ1? The whole point of the learning algorithm is doing this iteratively. We need to find optimal θ0, and θ1 parameter values, so that approximation line error from the plotted training set is minimal. By doing successive corrections to randomly selected parameters we can find an optimal solution. From statistics, you probably know the Least Mean Square (LMS) algorithm. It uses gradient-based method of steepest descent.

Continue reading

Simplest machine learning algorithm – linear regression with excel

Some may say that linear regression is a more statistical problem. And this is true at some level. But when the problem is solved from a machine learning perspective, things gets more accessible, especially when moving towards more complex problems. First of all, let’s understand few essential terms. We can start with regression. When speaking of linear regression we try to find a best-fitting line through given points. In other words, we need to find an optimal linear equation to fit given data points. This is a supervised learning problem when we have set of data pairs that can be plotted on x-y axis. I understand theory is a boring thing, even for me, so let’s move to practical examples and learn by solving some problems. In order to work with some examples we need sample data. There are many data sources available on the internet. For instance, a great source is college Cengage, that have several sets with data pairs meant for linear regression problems. For our example, we are going to use Cricket Chirps Vs. Temperature data where each data point consists of chirps/sec and temperature in degrees Fahrenheit. You can send data in three formats: excel, mtp and…

Continue reading

6 Frugal Tips to Help Pay Down Debt

paying down debt tips

Debt. Ugh, what a horrible word. Can we just erase this word from the dictionary completely? If you carry around debt with you, then you know exactly how the sound of that word feels. It is stressful, it causes frustration, and it makes you want to curl up and not face reality. But before you panic, consider these strategies (especially for college students) to help you start paying down your debt, whether it is from student loans, personal missteps, or both. 1. Don’t Just Pay the Minimum Whether you are paying your student loan or a credit card bill, do not simply just pay the minimum. Of course, if you are short one month, the minimum is all that is required to keep your account in good standing, but the more you pay, the quicker you can pay down your debt. To ensure financial efficiency, try to send in additional money that you have instead of pulling from your savings account or your other funds. For example, if you plan to spend $200 on groceries, but you only spend $150, then send the extra $50 to your debt.

Continue reading

Electrical signal power and energy calculations by example

In electronics and signal processing, you have to deal with electrical signals. In many cases, you may need to calculate signal power and energy. Power and energy for DC In a standard situation, when DC power supply is applied to a known resistor or another device like an LED motor you can calculate its power very easy by applying Ohms law: If we run this device for time T then we can calculate total energy used: In some cases, you may not know the resistance of your circuit. In this case, you can measure the current flow. So your power formula can be transformed by using same Ohms law:

Continue reading

Echolocation with HC-SR04 ultrasonic distance sensor

Ultrasonic echolocation is common practice in many areas, including nature itself. We all know how bats or dolphins navigate – they emit ultrasonic waves, and depending on the time delay of reflected echoes, they can determine the distance from obstacles or catch. From an engineering perspective, it is relatively easy to measure distances with ultrasound – all you need to know is sound speed in the air and time delay between sent and received pulses. L is the measured distance; CAIR – ultrasound speed; t – the time between transmitted and received pulses. The accuracy of measured distance mainly depends on air temperature. The following formula can calculate sound speed in the air approximately : For instance, at 25ºC, the speed of sound in dry air CAIR = 346.13 m/s. If you want greater accuracy, you should also measure temperature to adjust sound speed.

Continue reading

Ultrasound wave propagation and parameters

Ultrasound waves are acoustic pressure waves that interact with propagation media. Ultrasound visualization is typically based on wave reflectance from regions with different acoustic properties. When a wave meets different acoustic media, part of it transmits further while others reflect. This happens due to different acoustic impedance. The ration between reflected and transmitted energy purely depends on the difference in acoustic impedance in both regions. As you can see each material can be characterized by its acoustic impedance Z which is equal to ultrasound speed v and material density r.

Continue reading

Testing NEO-6M GPS receiver module

If your project requires a global positioning feature, then you should use one of many GSP modules. There are many receiver modules and expansion boards available for your choice. They vary in PCB size, functionality, antennas used, and price. In most cases, you are probably looking for a simple, small-in-one solution where GPS receiver and antenna would be on the same package. Recently I have picked one that might fit most needs – GPS receiver NEO-6M module with ceramic antenna and TTL serial interface. It is a very compact GPS module with the most needed features:

Continue reading

Using wavelet transform in biomedical engineering – heart signal analysis

In previous post, we cleared out that wavelet transform is used to analyze short-time and non-stationary signals. Since base wavelet function has to parameters – translation and scaling, it is possible to achieve good time and frequency localization. In other words, we can equally analyze the slow signal and fast signal structures without losing resolution and so evaluate signal frequency characteristics and time dynamics. Heart signal analysis is one of the most common problems in biomedical engineering. Practically every part of ECG signal carries some sort of information about heart conditions, possible pathologies, and diseases. So equally, frequency and timing characteristics of ECG signal is essential. As you know standard ECG signal consists of several typical waveforms like P-QRS-T, where in P and T waves low frequency component dominates, and in QRS, mid and high. The common condition of hear is myocardial ischemia when blood flow through coronary arteries to the heart is reduced, what prevents receiving enough oxygen. This can damage the heart muscle and lead to a heart attack. In order to notice this pathology it is we need to analyze S-T segment of ECG waveform. Insignificant changes in the signal can indicate ischemia. In order to find…

Continue reading