Monthly Archives: December 2013

Our ECG Amplifier works!

Last month an important milestone in this project was achieved! The final ECG circuit was finally assembled, specified, and tested! That was the first time we achieved a real-time ECG signal on the screen of our laboratory’s oscilloscope.

You can check out the video of our first ECG signal here (I apologize for the quality of the video, we did not have a good camera to register this moment).

The tutorial for this accomplishment and the steps to reproduce it are listed here. Please feel free to check it out. Any comments and suggestions are welcomed!

A Brief Tutorial for the OMAP L-138

Before continuing this tutorial, please make sure to reflash your OMAP board and to adequately install the Code Composer Studio (CCS).

We assume that you have visited and completed both tutorials listed above. Now, we need to execute a couple steps before connecting your OMAP DSP to your computer. We recommend you to follow the steps below:

  1. Verify that all development board DIP switches (two packages of eight switches, each) are in the “OFF” position. If you look closely, the switch positions are labeled.
  2. Power on the board, connecting the power supply to the 5 V barril (power connector), and turning on the board using the large black slide switch. Three LEDs should now be energized on the development board.
  3. Start up and allow the computer that you installed CCS on to fully finish its boot-up process. Plug the USB cable into the development board and then plug the other end of the cable into your PC. Be sure that you allow the computer to finish loading the device drivers before you move to the next step.
  4. Launch CCS by double clicking on its icon. After a standard CCS install, this icon will be located on your computer’s “desktop”. You are looking for the icon shown below.
CCS icon
CCS icon

Now you have your board set up and ready to run your first code! When the CCS software initialize, you should be able to see a window similar to the one below:

Screen Shot 2013-12-25 at 11.52.33 AM


Important Note: As part of this project, code will be generated and compiled in a nice final folder. All of the codes regarding our work with Biomedical Signal Processing (i.e. the processing and analysis of digitalized biosignals) will be posted in this webpage shortly. At this point, we will keep providing tutorials on the code and examples listed in our text book. This way, you will be familiar with the board and its applications before starting with the analysis of biosignals. For this reason, all the files needed to run and implement the example codes on our text book can be found the the CD that comes with the book.

As explained in the Getting Started with the OMAP L-138 tutorial, we assume that you followed the instructions and have already installed the software that was included on the provided CD- ROM. 

  1. In your computer, use Windows Explorer to verify that the directory common_code exists at C:CDcodecommon_code (please keep in mind that C:CD may be some other name or disk location that you specified when you installed the provided software). If this directory structure does not exist, you either need to create it or install the provided software. There should be several files in the common_code directory. If these files are not already in the directory, they can be copied from the common_code directory of the provided CD-ROM.
  2. Some form of organization is required for your projects and the dozens of files you will eventually create. CCS uses the concept of a workspace to organize groups of projects. A single workspace can be used to manage any number of projects.
  3. If you copied the files from a CD-ROM, the files most likely have a “read-only” attribute. Removing this attribute may prove helpful later in this process.

Installing the Code Composer Studio (CCS)

Please visit the post Getting Started with the OMAP L-138 before continuing with this tutorial! We recommend you to reflash your board before running C code.

Ok, now that you have successfully reflashed your OMAP DSP, we need to move on to the Code Composer Studio tool from Texas Instruments. The Code Composer Studio (CCS) is Texas Instruments’ integrated development environment (IDE) for developing routines on a wide variety of their DSPs. In CCS, the editing, code generation, and debugging tools are all integrated into one unified environment. You can select the target DSP, adjust the optimization parameters, and set the user preferences as you desire.

Let’s get started downloading the CCS. The latest version can be found here. Before allowing you to download the software, TI will ask you for a couple information, including your full name, email, and institution. You will also be required to answer some questions, and shortly after you will be granted the access to download this software.

Access granted! Now you can move on and download the CCS
Access granted! Now you can move on and download the CCS

When being approved to receive the CCS software, click on Download. You will be prompted to select the Processor Architectures to be installed. Please make sure to check the following two options:

  • OMAPL 13x & C6A8 processors; and
  • OMAP Processors.

Screen Shot 2013-12-25 at 11.26.49 AM
When prompted to select the components you wish to install, select all of the boxes. It includes “Compiling Tools, Device Software and Simulators.”

In the next window, make sure to check all the boxes under the JTAG emulator support.

Screen Shot 2013-12-25 at 11.32.06 AM


Click on Next until you see a window similar to the above one. Your CCS is now being installed.

Screen Shot 2013-12-25 at 11.32.36 AM

If prompted about a software license, select the “FREE LICENSE…” option for the time being. This license supports the XDS100 JTAG emulation used on the OMAP-L138 board. Click Finish.

Screen Shot 2013-12-25 at 11.43.26 AM Screen Shot 2013-12-25 at 11.43.33 AM


You have just finished installing CCS. Now let’s move on to the next tutorial, where we will walk you through the settings to run your first code onto the OMAP board.


Getting Started with the OMAP L-138

In this tutorial we will walk through the process of getting started with your OMAP L-138 out of the box and the book Real‐ Time Digital Signal Processing from MATLAB to C with the TMS320C6x DSPs, 2nd Edition (Welch, Wright, and Morrow; CRC 2012).

This book provides a valuable material for the understanding of the OMAP Digital Signal Processor (DSP) and has several examples of both Matlab and C code to implement DSP algorithms. In a further tutorial, we will walk you through the Code Composer Studio (CCS), which is the Texas Instruments’ integrated development environment (IDE) for developing routines on a wide variety of their DSPs. Now, all we want to do is to get your board ready to go and ready to process some digital signals.

To get started with your board, follow these steps:

  1. Unpack the OMAP LCDK. The SD card that comes in the box can be ignored — it contains a Linux OS distribution for use with other applications, not with the WWM book. You can also ignore the Quick Start Guide. Choose the correct power supply connector for your location and snap it into place on the power supply brick. Do not connect power to the LCDK yet. You will also need an XDS100v2 emulator pod (a very small board, sold separately), in addition to the LCDK. Unpack it also.

    XDS100v2 emulator attached to the OMAP DSP (click to enlarge)
    XDS100v2 emulator attached to the OMAP DSP (click to enlarge)
  2. Place the WWM textbook CD in your CD/DVD drive and follow the instructions given by the self‐ installer. The authors of the book recommend that you install all the files; the required disk space is modest.
  3. There is a website where the authors of this book provide updated files. It is a neat source for the latest software updates. After running the CD that comes with the book and installing all the files, please check the book’s website for new updates.
  4. After the WWM textbook CD files and any new files from the web site have been installed, you should have a directory called pc‐apps, and in that directory is a subdirectory called reflashing_OMAPL138_for_winDSK8. Note that this is NOT for the OMAP‐L138 LCDK, but for another board (the Logic PD Zoom Experimenters Kit). Instead, you need to follow the reflashing instructions for the LCDK; this enables use of the winDSK8 application and increases the stability of the LCDK board. For this project, we will use the winDSK8 application in many stages of implementation. Reflashing your OMAP is, therefore, the first step and you should not ignore it.
      1. Note: you need to know the PC’s COM port number for the port to which you have attached the OMAP‐L138 LCDK in order to correctly execute the command to reflash the board. The port number is dependent upon your installation. If you aren’t sure what it is, it can be found several ways, for example by selecting “Devices and Printers” in Windows 7 and looking for the entry for the USB port to which the LCDK is connected. Alternatively, you can start up winDSK8 even before you have reflashed the LCDK (with the LCDK connected directly to your PC via the USB connector J3), and on the main winDSK8 GUI screen, on the right side, you’ll see the choices for COM Port. Click the down arrow for the “COM Port:” list. Typically the highest number listed in the winDSK8 COM port choices is the port the LCDK is using. You may need to click on “Rescan COM Ports” if you’ve changed something since starting winDSK8.
      2. According to the authors, many users have found that the reflashed OMAP‐L138 LCDK is more stable even when running C programs using Code Composer Studio (CCS), so we encourage you to reflash the board before using CCS. This avoids potential issues with Linux kernel conflicts that appear to exist if you do not reflash the board.
      3. We recommend you run winDSK8 at this time, and at least click on the “Get BoardVersion” button, to be sure everything is working properly. When finished with winDSK8 for now, disconnect the LCDK’s USB connector J3 from the PC’s USB port.
  5. Install Code Composer Studio (CCS) software development environment from Texas Instruments. Do not connect the OMAP‐L138 LCDK to the PC (via the small XDS100 emulator pod) until after this installation, or the correct drivers may not be found. A newer version of the CCS may be available online.
      1. Note that a full installation of CCS supports many Texas Instruments processor types. If you choose a custom installation to reduce the disk space requirements, the choice for “Processor Support” depends on what you plan to use with CCS. If you will only use one of the OMAP‐L138 boards (e.g., the LCDK or the Experimenter Kit), you can choose just “OMAP.” If you will also use the C6713 DSK, then also select “C6000 Single Core DSPs.” Similarly, for “Components,” you probably don’t need the C5500 and C5400 compiler tools, if you are trying to conserve disk space.
      2. After CCS is installed, verify that the LCDK board DIP switch SW1 is set with switch 1 OFF and switches 2, 3, 4 and 8 are ON. If you look closely, the switch positions are labeled.
      3. Remove the power connector from the LCDK if you haven’t already. Connect the XDS100v2 emulator pod to the LCDK (either directly or with the short ribbon cable supplied with the XDS100v2 board) using the 14‐pin header J6 on the LCDK. Note the header connection is keyed so that it can only be connected to the pod in the correct orientation. Connect the USB port on the XDS100v2 emulator pod to a USB port on your PC, and the correct drivers should now be found automatically. There is no need to turn the power on to the LCDK for this to occur; the USB port will be recognized.
  6. You are now ready to power up the LCDK again and use both winDSK8 and CCS with the OMAP‐ L138 LCDK, in conjunction with the WWM text. 


Important notes:

  •  If you wish to use winDSK8, be sure that switch SW1 switch 8 is set to ON (and SW1 switches 6 and 7 to the setting for your desired UART port speed; we suggest both switches ON). In this mode of operation, you communicate between your host PC and the OMAP‐L138 LCDK using the J3 UART USB connector on the LCDK.
  • If you want to use CCS and run compiled C programs, you also want to be sure that switch SW1 switch 8 is set to ON, except for the one situation described in the next bulleted item. When using CCS, you communicate between your host PC and the OMAP‐L138 LCDK via the XDS100v2 emulator pod’s USB connector. In this mode of operation, SW1 switches 6 and 7 settings can be read by a user program if desired. If this is your first time using CCS with the LCDK, we highly recommend you now turn to the Appendix A tutorial written for the LCDK and your version of CCS, as found on the www.rt‐ web site. This short document guides you through selecting the license options, creating a simple CCS

The ECG Amplifier Design

The main goal of our Biomedical Signal Processing Project is to design and implement an ECG amplifier from scratch, acquire an amplified and clean biosignal, sample this signal (i.e. digitalize it), and finally process it (i.e. filter, find patterns, provide diagnosis) using the low-cost OMAP L-138 Digital Signal Processor from Texas Instruments.

This is actually the big picture of this project and we are working to provide a series of tutorials to make these goals easily available for free! We wish to be able to provide full support to any student that is interested in the field to start conducting his/her own Biomedical Signal Processing and Analysis!

This is the first of a series of tutorials that will walk you through the design, implementation, and testing of our hardware and software solutions. Please enjoy it and feel free to post any suggestions in our comment box in the end of each post.

Now let’s talk about the actual science and design behind this ECG amplifier. First of all, a biosignal is characterized by high common mode signal, low amplitude differential signal, low frequency noise, drift, and cycle to cycle variability. All of these variables increase the difficulty to process these kind of signals using the average digital signal processor. So before starting with the filtering and actual digital signal processing of these signals, we have to step back and build an amplifier that will:

  1. amplify the the signal’s amplitude; and
  2. “clean” the signal

After having a clean and amplified signal, the next stage of this project will be to sample this signal — turning it to digital samples — and process it using our Texas Instruments OMAP L-138 Digital Signal Processor.

OMAP L-138 DSP and XDS100v2 JTAG Emulator
OMAP L-138 DSP and XDS100v2 JTAG Emulator

This is our next important milestone and shall be further discussed in a later post. Now, all we are interested about in on the ECG design!

We started with the design present in the Tompkins book (please refer to the bibliography in the end of this post).

(figure 2: ECG design from Tompkins book)

We assembled that design, which consists of 4 operational amplifiers, capacitors and resistors, and then changed the original design to satisfy our needs. The operational amplifiers used were the uA741, which are good for this application and are very low-cost chips.

Our final design was as follows:

ECG analog circuit
ECG analog circuit


ECG amp schematic
ECG amplifier schematic (ADS simulation)

The circuit above was first specified and tested using a simple sinusoid signal. As input, we had a 36.0 mV peak-to-peak sinusoid and the output of our ECG amplifier was a 7.20 V peak-to-peak sinusoid signal. This means that our ECG had a final gain of 200, and now we have a signal with a greater amplitude — meaning that we are one step closer to digitalize and process such signal.

Input signal (yellow) with 36.0 mV pk-pk and Amplified signal (blue) with 7.20 V pk-pk
Input signal (yellow) with 36.0 mV pk-pk and Amplified signal (blue) with 7.20 V pk-pk

In contrast, we had a very low amplitude common-mode signal gain — close to 0 V. This is desired in order to make sure our ECG circuit is working properly. In more detail, when a 60 Hz signal is the input of both buffers seen in figure 3, the output from our ECG circuit is an approximately constant wave form of 220 mV amplitude, or in other words, the circuit has no Common-mode Gain.

Common-mode gain: Note that the output signal (blue) has an amplitude close to zero
Common-mode gain: Note that the output signal (blue) has an amplitude close to zero



1. Tompkins,  W.J.  and  Webster,  J.G.,  1981,  Design  of  Microcomputer-Based  Medical Instrumentation, Prentice Hall, Englewood Cliffs, NJ, 496p. 

Assembly of the Platform – Part 1

The robotic platform will consist of the following components: IMG_20131209_134136

Assembling the platform is relatively simple. The first part will be the assembly of the chassis provided by DFRobot. Instructions are provided and easy to follow. One suggestion when assembling the chassis is to install the optical encoders before installing the motors . Instructions are provided on the DFRobot’s website:

Here’s what the chassis looks like when assembled. Next  is to wire up the components then upload the code to begin using the platform.


Implementing Optical Encoders

So far, I have enabled the platform to move forward, in reverse, and to turn at an angle using optical encoders. The encoders measure the rotation of the wheels by triggering an interrupt 10 times per revolution. This allows me to calculate the distance that the platform travels and its speed when moving or turning. However, there’s a problem. Based on the measurements taken, the encoder produces much more interrupts than it should resulting in inaccurate calculations. This problem is typically due to contact  bouncing which is when a switch or sensor bounces between values several times before settling.

There are two solutions for this problem that were discovered by previous undergraduate students who worked with these encoders. One was a software solutions that incorporated delays in the Arduino code to record an interrupt after the signal from the encoder has settled. I’ve implemented this solution and obtained readings from 1000 interrupts to about 46 interrupts.  This is significantly more accurate than initially but still not very accurate. I’ve determined that at maximum speed, the platform’s wheels rotate for 2.3 to 2.5 revolutions every 2 seconds. Thus, the encoders should produce about 23 to 25 interrupts.

The next solution is a hardware solution. It incorporates NAND gates into the circuit in order to minimize the amount of bouncing in the encoders. I’ve also implemented this solution along with the software solution and obtained readings of 26 to 28 interrupts. This is very close to the desired readings but not yet sufficient to increase the precision of the platform. More work needs to be done in order to accurately measure the distance the platform travels which is key for implementing PID algorithms.