applied electronics engineering


Latest Posts

Making RN-52 Bluetooth Breakout Board at Home

- Saturday, May 20, 2017 No Comments
Here you will see illustration of home made RN-52 Bluetooth module Breakout Board. The RN-52 Bluetooth module only is manufactured by Microchip but breakout board is made by others like Sparkfun. Shown below is RN-52 Bluetooth module.

As you can see the pins are difficult to interface with. So if this is to be made useful then we have to add breakout board which is what we going to show here.

The first step is to print out the PCB layout for the RN-52 breakout board. This is shown in the previous tutorial How to make PCB at home using Altium Designer. Once you have printed out the PCB layout(double sided) then you can see here what was obtained.

The picture below shows the RN-52 PCB print on the copper board, both the bottom copper and top copper.

As you can see there is black colored paint on the PCB print. A permanent marker was applied to places where the toner was not transferred properly and also just to ensure that there are no coppers left in the places where we don't want them to be.


After acting the Ferric Chloride solution onto the PCB board we get the following etched circuit board.



Then using toner remover Nail Polisher or Acetone, the toner was removed to expose the underneath copper.



So in this way a breakout board for RN-52 Bluetooth was made at home pcb fabrication. The next step is to reflow solder or iron solder the RN-Bluetooth onto this board.

See other similar PCB design tutorials:

How to make PCB at home using Altium Designer

- Thursday, May 18, 2017 No Comments
Altium Designer is a professional PCB software with lots of PCB design feature. It outputs are fabrication gerber files of each of the different layers that are needed by PCB fabrication houses. But for hobbyist and amateur or for simple PCB prototyping this all is not needed. All you need for making PCB at home are simple bottom copper for single layer or top and bottom copper for double sided layer. Optionally you may want to print the silk screen. In this tutorial we will show how to print double sided layer PCB that you can make at home in Altium Designer.

You can start with creating a new PCB project or just import the PCB layout if you downloaded some PCB files. In this tutorial we will create PCB project first then import PCB files.

What we will make is the following RN-52 breakout board. The PCB and schematic files can be downloaded for free from sparkfun RN-52 guide page. The RN-52 bluetooth module with its breakout board is shown below.

We are going to build this PCB board excluding the RN-52 bluetooth module.

Note that the PCB files and schematic files of the RN-52 are in eagle PCB software file format. But with Altium Designer you can easily import it.

The next step is to create PCB Project. We assume you know how to create a PCB project. After you have created the project, import the PCB and schematic files and put them into the PCB project folder. After you have done that you should have similar project file structure as shown below.

How to make PCB at home using Altium Designer

On the left side you can see the actual PCB layout.

The next step is to print this PCB layout. We are only going to print the top and bottom copper to make double sided PCB.

To do this, File > Page Setup

In the page setup window, set paper size to A4,  set orientation to Portrait, select Scaled Print as Scale Mode, set Scale to 1.00, set Corrections X and Y also to 1.00 as shown below.

Then click on Advanced. From this page you can select what PCB layer to print and delete the unwanted.

To print the Bottom Layer, select Bottom and Multi-layer and delete the rest. To delete any or multiple layer, select those layer that you want to delete and right click and then select delete.

Then check mark the options for all except the Mirror and TT Fonts as shown below.

To check that is indeed that you want, you can print the preview by selecting File > Print Preview. An example is shown below.

If you are satisfied you can now print it to your Laser printer or what printer you use for home made PCB. To do this go to File > Print and select your printer.

Now to print the Top layer copper follow the above steps upto the point you open the Advanced setup page. In this setup window, now you have to delete the Bottom layer by right clicking on the Bottom and then selecting delete and add/insert the Top layer by right click on the window and selecting the top layer.

Now the difference is that now you have to check mark the mirror option because the top copper must be mirrored to make the double sided PCB work. See this below.

How to make PCB at home using Altium Designer

Now you can print the preview and/or directly print the top layer. After that you are good to go making PCB at home using Altium Designer PCB software.

To see how the PCB looks like see below.

How to make PCB at home using Altium Designer

How to make PCB at home using Altium Designer

See other Altium Designer PCB tutorials:

PIC16F877A programming tutorial using MPLAB X IDE and XC8 compiler

- Tuesday, May 16, 2017 No Comments
In this tutorial we will show how to program PIC16F877A pic microcontroller using the MPLAB X IDE and XC8 compiler. We will show simple LED blinking program for the purpose of illustration. The PIC16F877A is a popular microcontroller that can be used for variety of microcontroller application.

Before you continue this project it is assumed that you have already downloaded and installed MPLAB X IDE and the XC8 compiler.

1. Open MPLAB X IDE, you should have similar start up page as shown below.

2. Create a new project by going to File > New Project.

3. Choose the type of project. Here we will create a complete new Standalone project, a project without template and premade files.

4. Select the device. In this tutorial we want the PICF81677A microcontroller which belongs to mid-range 8 bit MCU family of PIC microcontrollers.

5. The next step is the select the programmer we will be using. In this case we select the PICKit 3.

6. Select the Compiler which in our case is the XC8 compiler. If you haven't downloaded and installed this compiler it will not be listed.

7. In the next screen you should provide the name of the project and save the project in some desired directory. 

Once you click on Finish, the project is created and you will see the project folder listed in the left pane as shown below.

Click on Project tab.

If you expand the LEDBlink project folder you will see other inner folders as shown.

Most of these folders are empty, that is there is no files because we haven't yet added any file. Now we have to add c program files and headers etc which will be done in the next step.

8. Add main.c file

Now we add a new source file called main.c which is the main c programming file containing our program. To do this right click on the Sources Files folder, then New and select the main.c file. This is shown below.

In the next window that shows up, type the name of the c file like LEDBlinkProgram in this tutorial and click on Finish. The LEDBlinkProgram.c file has now been created and is listed within the Source Folder as shown below.

The bare minimum code in the LedBlinkProgram.c is below.

 * File:   LEDBlinkProgram.c
 * Author: SYSTEM
 * Created on May 16, 2017, 3:34 PM

#include <xc.h>

void main(void) {

In the above code xc.h header file is used which contains some important definition of files such as __delay_ms() function and TRIS and PORT registers.
Then there is the usual main function.

Now we have to first configure the device by writing oscillator to use and set configuration bits of the device in order that the program works correctly when compiled and uploaded to the device. This is the next step.

9. Oscillator and Configuration bits

The first code we need is the code that defines the oscillator frequency to be used. We will be specifying 20MHz frequency. To do this write the following define preprocessor directive line under the #include <xc.h> as shown below.

#include <xc.h>
#define _XTAL_FREQ 20000000

void main(void) {

Then we have to configure the device using the configuration bits. This is done by using pragmas to tell the compiler XC8 how they are set.

MPLAB X IDE has the Configuration Bits Window which allows you to easily specify the configuration bits. This tool is available under Windows > PIC Memory Views > Configuration bits as shown below.

The configuration window is shown at the bottom pane.

Using this window, select the HS oscillator for external clock of 20MHz. Disable the Watchdog Timer, PWRT and Brown-out Reset Enable Bit. Leave other as default.

Once done click on Generate Source Code to Output.

You will see the configuration code using pragma. Copy those configuration bit setting.

And paste it under the #define _XTAL_FREQ 20000000 as shown below.

10. The main program

Now we will create the main program function. We will create a LED blinking program that turns on/off leds connected to Port B pin 1 of the PIC16F877A microcontroller.

First create a infinite while loop by writing the following code within the main() function.

void main(void) {

See picture below.

Now the next step is to first configure the port B pin 1 as output because we will be sending HIGH and LOW value to this port pin. Then we have to send the actual values to this pin 1 and insert delay between high and low values.

To set the direction of the port B pin 1, we write TRISB1 = 0; before the while(1) loop as shown below.

Next we write logic high and logic low and insert delay between them. We refer to the port pin using RBx where x is the port pin number. In this example, RB1 means port B pin 1. We create the delay of 1 second using the __delay_ms(1000); Note that there is double underscore before delay_ms.

void main(void) {
    TRISB1 = 0;
        RB1 = 1;  //write high
        __delay_ms(1000);  //1 second delay
        RB1 = 0;  //write low

See the following.

The whole program code is as follows.

#include <xc.h>
#define _XTAL_FREQ 20000000

#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF      // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = ON         // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

void main(void) {
    TRISB1 = 0;
        RB1 = 1;  //write high
        __delay_ms(1000);  //1 second delay
        RB1 = 0;  //write low

11. Compile/Build the Project

The final step is to compile and build the project. This is done by clicking on the Build icon in the toolbar.

After you click on it MPLAB X will use the XC8 compiler and compile the program file and build the project. You should see Euild Successful in the output pane window as shown above.

At this point your .hex file is ready to be uploaded into your device, that is the PIC16F877A microcontroller using the PICKit3 we opted in the beginning.

Another way to check your program is to use the proteus simulation software. The following illustrates led blinking at port B pin 1 in proteus.

Programming Arduino Due using Arduino IDE

- Sunday, May 14, 2017 No Comments
Programming Arduino Due is much like programming Arduino UNO using Arduino IDE. The programming language of Arduino resembles the syntax of C++ and supports most of the usual programming syntax of Arduino UNO. But if you want to write program for Arduino Due in plain C or C++ then you can use ATMEL Studio 7. Our previous post like How to program Arduino Due using user board template in ATMEL Studio 7 or How to program Arduino Due using ATMEL studio 7 covers these. There is also another option which is to use graphical programming language such as Simulink. See How to program Arduino Due using Simulink S Function for this kind of programming tutorial.

But here we are going to show how to program arduino due using arduino IDE. The steps are very simple and its same as programming arduino uno. To start with connect Arduino Due to your computer via the programming port(note that there are two usb port in arduino due- programming port and the native port). You can also use native port to upload sketches but the programming port is easier since you don't have to clear the flash to upload the code if you use the programming port.

Then once you have plugged the usb the computer should recognize the usb and your arduino due board. The next step is to fire up the arduino ide. In the IDE you would write sketches or program that tells the arduino due microcontroller ATSAM3X8E  what to do.

In the IDE, you must first select the Arduino Board which in our case is the Arduino Due.

Next you have to check that the com port is recognized and is set to correct com port number, in this tutorials its 9 but yours might be different.

After that you are good to go write program. In this tutorial we will show a simple LED blinking program. The program code is as follows.

void setup() {
  // put your setup code here, to run once:
  pinMode(13, OUTPUT);


void loop() {
  // put your main code here, to run repeatedly:


The pin 13 on the arduino due is set to output first in the setup() function. Then in the main loop() function we write HIGH and LOW using digitalWrite() function to this pin 13. A delay of 1000millisecond between the HIGH and LOW is asserted to create blinking effect. A LED connected to this pin 13 will then turn on and off.

The final step is to compile and upload the code. To do this click on the arrow button at the toolbar.

Telephone Call Receiver Circuit

- Friday, May 12, 2017 No Comments
Ever wanted to make a telephone call receiver then this project is for you. Here we show how to design a telephone call receiver which you can use to talk to your friend on the other side of the line. It does not have dialer so you cannot initiate a call but you can only receive call. A buzzer will ring if there is a call and you can to manually switch on the circuit to receive the call.

The telephone call receiver circuit is shown below.

As shown the telephone line from telephone company goes into jack J1. Usually red and green wire are used. The red wire should be connected to the switch in the above circuit. The switch as you can see is initially connected to the Buzzer.

After hearing the buzzer sound. The switch can be manually switched to the upper position. Then the call is received. The diode bridge is there for polarity reversal protection. After that there are two main sections of the receiver. One is the transmitter which comprises of the condenser microphone, the BC548 transistor with its supporting capacitor and resistors. The receiver section consist of the the LM386 audio power amplifier, the 8Ohm loudspeaker and supporting capacitor and resistor components. The gain of the LM385 power amplifier is achieved using the 100KOhm potentiometer.

Now the following picture shows the actual telephone call receiver circuit.

Arduino and Matlab for Voice Analysis

- Monday, May 8, 2017 No Comments
In this tutorial you will learn how you can use Arduino and Matlab for Voice Analysis. The Arduino and extra circuitry will be used for instrumentation and Matlab will be used as the software for plotting the voice input in real time. Because of Arduino it is now easy sense signal by using its ADC(Analog Digital Converter) and send over USB to computer or software running in the computer like Matlab.

The basic idea here is to create circuit which has microphone and amplifier. The output from the amplifier is then connected to the Arduino ADC. When you speak on the microphone, the sound energy is converted to electrical signal. This electrical signal is amplified by an amplifier(LM386 IC). The output is then fed to Arduino ADC. This ADC takes in the amplified analog signal and converts its to digital signal ranging from 0 to 1023. Afterwards, this digital signal is send to Matlab using the USB.

In matlab, we have various option to get the speech digital signal and plot it. For example we can use program code in python or matlab like in the tutorial Plotting audio analog signal in Matlab using Arduino and How to plot analog signal in Matlab using Arduino in real time. Here we will use simulink program. But it is very easy to use simulink to get arduino data(digital speech signal) and plot it in real time. For basic tutorial see How to make Real Time Oscilloscope using Simulink and Arduino.

So what we are doing essentially is depicted in the figure below.

Microphone and Amplifier and Arduino Circuit Diagram

How to make the the microphone/amplifier circuit and connect with Arduino is shown below.

Arduino and Matlab for Voice Analysis

Matlab Simulink Setup for Speech analysis

The next step is to setup simulink for reading the arduino sent signal and plot it in real time. The following picture shows how to make simulink model to work with Arduino UNO.

Arduino and Matlab for Voice Analysis

Running the simulation and Viewing the Voice in real time

After we run the simulink simulation and view the time scope we we see the following.

The higher peaks shows voice signal when spoken into the microphone.

If we increase change the value of 10kOhm potentiometer, we will see increase(decrease) in gain of the amplifier. We effectively are changing the sensitivity of the amplifier of input voice signal from the microphone.

For example by increasing resistance in the potentiometer we get the following real time signal graph.

Arduino and Matlab for Voice Analysis

Further increase in potentiometer value to maximum possible resulted in the following speech signal real time graph.