Bit Band operations with ARM Cortex microcontrollers

I got few questions from our readers about the bit-band feature in ARM Cortex microcontrollers. It may seem to be a prominent topic, still may lead to come confusion while using bit-banding. So let’s look at this feature a little bit closer. Why use bit band? Simply speaking Bit banding method allows performing atomic bitwise operations to memory areas. Why use bit banding? The most straightforward answer is because ARM Cortex doesn’t have something like BIT CSET or BIT CLEAR commands like most of the 8-bit microcontrollers do. So this is somewhat a workaround solution. Another question may rise – Why not using the read-modify-write method? Again this method is not reliable in some cases. For instance, f there is an interrupt during this operation; it can cause data corruption. Other situation may occur in embedded OS when different tasks may modify the same memory location. So we want a method that allows setting or clear individual bits with a single instruction. This is where the bit band method helps.

Continue reading

Electret condenser microphone amplifier for use in microcontroller projects

electret microphone

Most microcontrollers have ADC input, which can sample an analog signal, including sound. Even using Arduino, you can do many cool projects using audio information. For instance, you can make a voice-controlled device such as Audio Recorder, voice-activated switch, and more exciting audio-related projects. In this post, I want to focus a bit on the microphone part – the circuit required between the electret condenser microphone and MCU ADC input. Generally speaking, you cannot connect the electret microphone directly to the ADC pin and expect it to work. The part needed here is called an electret condenser microphone amplifier circuit. Electret microphone with preamplifier stage Condenser microphones require power from a battery or external source. The resulting audio signal is a stronger signal comparing to a dynamic microphone. First of all, the electret microphone isn’t only a condenser inside. It already has a preamplifier inside usually made of FET transistor, which is connected in common source configuration: First, the electret microphone needs to be powered through the drain pull-up resistor. Its value depends on the power supply voltage. The rule of thumb is to add 1kΩ per +1V of the power supply. Up to 10V 10kΩ resistor will work fine.

Continue reading

Working with SQLite in Raspberry Pi using Python 3

Last time we did a few basic operations with SQLite in Raspberry Pi. We learned how to set up SQLite3, create the first database file and fill it with data. Using SQL commands, we were able to select data and print it on the terminal screen. But eventually, you will face more complex queries or store data automatically so other routines could read it. For instance, you will build a simple project that would read data from the digital temperature sensor. One of the great ways of storing data into a database is to use a python script. Anyway, you are probably going to use it for GPIO operations. So let us learn how to store simple data to SQLite database using python.

Continue reading

Getting Your Kids Excited To Learn From A Science, Engineering or Math Tutor

Did you see the new Goldie Blox video? This company, whose tagline is “toys for future engineers,” just released a viral video in which three young girl engineers execute a Rube Goldberg machine set to the tune of the Beastie Boys’ “Girls.” This video is excellent because it helps draw young girls’ attention to the possibilities of engineering. Maybe after seeing the video, they’ll ask their parents for a Goldie Blox kit or try to build a Rube Goldberg machine in their living room. Maybe they’ll learn, as all engineers do, that a successful project means educating yourself in math and physics; that you need to know exactly how far apart to place each domino to make sure your train falls at an even, consistent rate.

Continue reading

Clarity in essay writing

Your essay will be one in a large stack given to a reader or readers after you submit it. In the case of college admissions, readers will have so many essays to read that they will spend only a few minutes on each. Exit and SAT essays will receive somewhat more time and attention, but it still holds that one reader will be responsible for many essays. That is why it is imperative that you not only impress your reader(s) with your unique take on a topic but also say exactly what you mean as clearly and, in many cases, as concisely as you can. Your essay goal is to convey information, including the fact that you can write well. That goal won’t be achieved if your readers don’t understand your first few sentences or paragraphs and stop reading, or if they finish reading but fail to grasp your message. Learning how to be a clear and accurate writer will help make your essay readable and will guarantee that those who read it understand exactly what you mean to say. The five guidelines in this chapter show you how to clarify your writing. Suppose you are facing some problem in…

Continue reading

Using SQLite in Raspberry Pi

If you are doing some data logging, sensor reading, or another routine task with Raspberry Pi, you probably think of using the database. The list of database software choices is quite long, but you will end with a single or few tables in the database in most cases. The first thought might be MySQL – a well-known database server in WWW. Anyway, this is a pretty heavy tool to have running on Raspberry Pi. In my opinion, SQLite is probably the most suitable choice. Because it is serverless, lightweight, opensource, and supports most SQL code. Another handy thing is that SQLite stores data in a single file which can be stored anywhere.

Continue reading

Raspberry Pi – mounting USB drive

Raspberry PI, by default, has only one memory available – an SD card that also holds the kernel itself. Unless you are using a large SD, eventually, you will run out of space -especially if you are dealing with media files or playing with the camera module. The easiest and cheapest way of expanding memory is to use a USB Flash drive. If you are accessing PI from the terminal screen, then probably one of the built-in USB ports is free, and you can attach a drive directly to it; otherwise, use USB HUB – better with an external power option.

Continue reading

Setting up Tiva C Launchpad project template with Sourcery Codebench and Eclipse

Tiva C series TM4C123G (MCU:TM4C1233H6PM)Launchpad is updated version of Stellaris Launchpad LM4F120 (MCU: LM4F120H5QR). Practically this is due to TI’s choice to change the name of the product line. Such action led to some confusion, especially for software developers. This means that software libraries had to be renamed, software tools adapted, and so on. Since this work is most renaming things from one point, this is an easy task; from another point, it may be tricky to check all corners. So if you just into Texas Instruments ARM Cortex microcontrollers, it is better to start with the Tiva C series and forget Stellaris. Otherwise, this might get confusing to switch from one to another. At the moment, TivaWare 1.1 still has some issues due to migration, but most things should work fine. Let’s try to create a project template for Eclipse IDE and Sourcery Codebench Lite GCC compiler tools. First, you need to download and install Eclipse with CDT C/C++ tools (Eclipse Indigo includes this). Next, you need to install the latest Mentor Sourcery Codebench Lite. Also, download and extract TivaWare for the C series, where all libraries and examples are located. To Flash microcontroller, download LM Flash Programmer. Other…

Continue reading

Capacitors Embracing the Green Revolution

One of the pressing concerns of our age is the environmental crisis. With the progressing technological evolution, the need for energy conservation and harvesting has increased. Harvesting energy is not an easy task, and most of the time, generating energy creates pollution in the environment. To deal with it, the international community has changed its approach. It is now focused on identifying the areas where energy is being wasted and rectifying those issues instead of producing more energy. The low power factor is one of those aforementioned issues. Power factor is a measure of lag in current concerning voltage. Its value varies from zero to one.  This lag creates a component of electrical power that is not being used and keeps oscillating between generation and consumer ends. This circulation of power dissipates energy in the form of heat and creates extra load on the generation’s end. A power factor issue arises due to inductive loads, such as electric motors, fans, etc. Now the power companies have started to penalize industries with high inductive loads and a shallow power factor. The industries are taking initiatives to increase their power factor. There are two methods of power factor correction. One is using…

Continue reading

Raspberry Pi camera module

raspberry pi camera

Recently I’ve received a Raspberry pi camera board. So decided to make a post about it. Raspberry PI comes with two interesting connectors onboard. One is between Ethernet and HDMI, and another is near GPIO. The one closer to the Ethernet connector is CSI (Camera Serial Interface) bus interface. This interface is common in mobile phones with cameras. This interface is specially designed for high data rates that are necessary for transferring pixel data. The camera board is a small (25mm x 20mm x 9mm) board where a fixed-focus 5MP camera module (OV5647) is assembled. The camera connects to Raspberry Pi via a 15cm ribbon cable. Camera module is capable of producing 1080p images at 30fps or 720p at 60 fps and 640x480p at 60/90 fps. Obviously, such images and fps require a high-speed interface and processing. So CSI is connected directly to Raspberry Pi GPU, which can process images without ARM intervention. This is why the camera module is a much better choice than the USB camera, which occupies the main processor and slows down the whole system. GPU processing also benefits with fast H264 video encoding and JPEG compression capabilities.

Continue reading