Thursday, January 05, 2017

Make Yourself an MSP430 LunchBox for 1$

Dhananjay V. Gadre,  Nikhilesh Prasannakumar and Divanshu Dodeja
NSIT
_________________________________________________


Microcontroller Kits for the Masses


Arduino is one of the nicest things to happen to the DIY community in the last 10 years. It brought microcontroller usage within easy reach of non-specialists (from a technical viewpoint) such as artists, tinkerers, architects and musicians. It’s low threshold of learning, simple and reliable programming environment brought it to the workbench of high school students as well. Apart from being a great, low learning-curve platform, what has helped Arduino to gain such traction worldwide, in no small measure, is the relative low cost too! Although the original Arduino boards cost tens of dollars, variants and knockoffs cost as little as $4! No wonder we find them popular with high and middle school students, everywhere.

A large majority of Arduino variants feature microcontrollers from the AVR family of Atmel (now acquired by Microchip). Some variants using the ARM Cortex M0 microcontrollers as well as higher end Intel processors are also available. Although TI’s MSP430 is a strong competitor to AVR, boasting of superior features such as a 16-bit CPU, significantly lower power consumption and versatile peripherals, it doesn’t have a presence in the Arduino ecosystem. Even with significant software support in terms of the Energia (a fork of the Arduino IDE) which extends the simplicity of Arduino programming to TI microcontrollers, MSP430 has not been able to gain the same popularity as Arduino among enthusiasts. The relatively high cost of the MSP430 LaunchPad development kit ($10 and above) with no corresponding lower cost variants (as with Arduino family) is a likely deterrent.

What the MSP430 ecosystem needs to reach the masses is an extremely low cost entry-level platform which can stand up to the $3 Arduino variants. Such a platform is what we set about trying to design.
 

Microcontroller Essentials

Typically, a microcontroller system requires 4 support elements – power supply, clock, reset and code download ability. Let’s take the example of the Arduino: It is powered by a 5V supply, either provided directly through a USB port, or from an external DC source via an onboard voltage regulator. It uses a crystal oscillator (8/16 MHz depending on the variant) for the system clock. It has a push button switch as well as a clever mechanism attached to the USB to Serial converter chip to reset the microcontroller. The user program is downloaded on to the chip from the Arduino IDE using the above mentioned USB to Serial Bridge, aided by a bootloader program which has to be manually loaded into each fresh chip.

Inexpensive MSP430 Evaluation Kit: The MSP430 LunchBox

With the MSP430, the job is a whole lot easier. Turns out, the MSP430 already has a built-in bootloader on-chip. All that is required is a mechanism to invoke the bootloader and send serial data to it – both of which can quite easily be achieved by a USB to UART Bridge. One of the cheapest USB to UART Bridge chips available in the market today is the CH340G – a full speed USB device that emulates a standard serial interface with speeds up to 2 Mbps and support for all modem handshaking signals – which costs less than half a dollar! CH340 is also one of the major reasons for the 4$ Arduinos. 
All this brings us to this – A $1 (conditions apply) MSP430 LunchBox – a low cost, maker-friendly microcontroller development platform featuring the 20-pin MSP430G2553 Value Line controller. The board supports any 14-pin or 20-pin DIP package MSP430 G series microcontroller, which a hobbyist can obtain for free through Texas Instruments’ free sample programme. The entire bill of materials of the board, excluding the controller, is under $1. The PCB has been designed to be a single sided, toner transfer friendly one, allowing enthusiasts to fabricate one for themselves at little or no cost. The photograph in below shows the early lab prototype of the MSP430 LunchBox.
Figure 1: Lab prototype of the LunchBox 
 

Comparing Various Variants of 'Apples'

The MSP430 LunchBox has a feature set comparable to that of TI’s own MSP430 LaunchPad Development Kit and can quite easily rival Arduino. Here’s a side by side comparison of the $1 MSP430 LunchBox, TI’s MSP430 LaunchPad and an Arduino Nano. 
Feature
$1 MSP430 LunchBox
MSP430 LaunchPad
Arduino Nano
Microcontroller
MSP430G2553 & others
MSP430G2553 & others
ATMega 328
CPU Architecture
16-bit
16-bit
8-bit
Operating Voltage
3.3V
3.3V
5V
Operating Clock
10 kHz to 16 MHz
10 kHz to 16 MHz
10 kHz to 16 MHz
Operating Current
4.5 mA @ 16 MHz
4.5 mA @ 16 MHz
15 mA @ 16 MHz
Programming
Factory UART BSL
Onboard Spy-Bi-Wire
Custom Bootloader
Debugging
Not supported
Spy-Bi-Wire debugger
Not supported
Supported IDEs
CCS, Energia
CCS, Energia
Arduino, Atmel Studio
Available I/Os
14
16
20
Analog Inputs
8
8
6
PWM Outputs
6
6
6
Peripherals
1 LED, 1 Switch, UART
2 LEDs, 1 Switch, UART
1 LED, UART
Cost
$1
$10
$4

The LunchBox functionality as listed above, can be seen in a block diagram format here:
 
Figure 2: Block diagram of MSP430 LunchBox

The design of the MSP430 LunchBox was not without challenges. While the MSP430 has an in-built UART bootstrap loader (BSL), they are not brought out on the same pins as the standard UART interface of the MSP430. This meant that a provision for switching the CH340 USB to UART Bridge between the BSL UART and the MSP UART peripheral – implemented using a pair of shorting jumpers on board – had to be made. 
Another major challenge was on the software side – the UART BSL utility provided by Texas Instruments is quite outdated and contains a few bugs. One of the most critical is the issue with how the BSL Utility handles the flash memory. Graphics below shows the memory map of the MSP430 and it shows the flash memory on MSP 430 is divided into two parts – the code memory, which contains the user code and the information memory, which typically contains data such as calibration constants, Digitally Controlled Oscillator (DCO) settings etc. The calibrated DCO settings, which are required to generate accurate high speed clocks in the MSP are stored in Segment A of the Flash Information Memory (INFO-A).

 
Even though the BSL Software Utility provides an option to preserve the contents of the INFO-A segment, it does not seem to work properly and ends up erasing the entire information and code memory when invoked. Without the DCO constants, it is extremely difficult to implement UART communication due to errors in the system clock. As the bug fixes on an outdated software utility was quite a cumbersome task, we decided to implement a hardware solution to this issue – an external 32.768 kHz crystal oscillator which can be used as an accurate clock source for implementing UART communication. This ends up reducing the number of I/O pins available to the user by 2 pins, but also gives the advantage of having a crystal oscillator that can be easily used for real-time clock applications.
Here is the complete schematic diagram of the LunchBox. It shows the power supply for the MSP430 3.3V, derived from the 5V available on the USB connector and also available on the output headers. The clock for the microcontroller generated using an external crystal of 32.768 KHz frequency, connected to the Xin and Xout pins of the MSP430. The user interface peripherals are a simple pushbutton and an LED apart from the Reset switch. Jumpers J1 and J2 allow the user to switch the CH340 USB to UART bridge from the MSP’s UART peripheral pins to MSP’s BSL pins. These jumpers are manipulated manually. 




An image of the LunchBox PCB layout is seen below. As can be seen, the PCB can be fabricated as a single sided board with a few jumpers (represented in red color) or one can get the PCB fabricated as a double sided board through a suitable PCB manufacturer.


To enrich the learning experience, we also developed a simple and inexpensive I/O expansion board, the Mini-Voyager (a smaller version of the larger Voyager we have had for some time). As with the LunchBox, the Mini-Voyager is also a single sided PCB that can be fabricated at home or lab. The Mini-Voyager offers the user a 4-digit seven segment display, a set of charlieplexed LEDs, an RGB LED, a capacitive touch input, a potentiometer, an LDR and a thermistor as well as a navigation switch configuration. The picture here shows a Mini-Voyager in the company of a LunchBox, ready to be used.




The photograph below shows LunchBox and Mini-Voyager in action together. More than 50 experiments and small projects can be performed using this combination.



The MSP430 LunchBox and Mini-Voyager duo were recently used in a training program with 180 students of 5th semester of the Instrumentation and control division at NSIT and the experience with them was quite rewarding. See what they soldered and used!



We hope to use this platform as an inexpensive way to teach about the MSP430 family of microcontrollers in future and take this package to high school students as well. If you need further details and/or help with replicating the system at your end, we would be happy to hear from you.
 

Epilogue

How does one justify a BOM cost of 1$ for the LunchBox? The trick lies in ordering free samples from TI: the relevant MSP430 G series microcontroller and the LM1117 linear regulator. The only component you may need to purchase would be the CH340 USB to UART bridge and currently, this sells for 50 cents in volumes. The rest of the components are easily available in your, the electronics enthusiast's components box!

Monday, August 01, 2016

Odd Semester-2016 Time Table


Friday, June 03, 2016

In Support of the Venerable 8085!

If you were to hear '8085 Microprocessor', you would probably cringe. Perhaps, you may be right too. However, we, like many others across the world, still teach 8085 microprocessor. Personally, I feel it is a great first architecture to teach. Apart from simple, easy to follow architecture, the 8085 ecosystem comes with a 40 year old history and therefore, is mature and thankfully, components of this ecosystem are still available.

However, we at the electronics and communication engineering division at the Netaji Subhas Institute of Technology, have made great departure from the standard paradigm of a course work with a laboratory with some standard experiments. Since 2011, I have made (or forced) my students to propose, get approval and then build a standalone 8085 Microprocessor based project. I am going to write a more detailed blog about the entire exercise but for now, I am going to share some YouTube videos of the projects, my students have completed.

So, here goes..

  1. 8085 based Function Generator
  2. Digital Slot Machine
  3. Ultrasonic Distance Measurement
  4. RGB LED Game
  5. Attendance Recording System
  6. Track Lap and Distance Measurement
  7. 8085 Tengu
  8. Penalty Shootout!
  9. Cricket Super Over
  10. Semiconductor Curve Tracer
  11. 1-D Pong
  12. Elevator Control
  13. Game of Sieve
  14. EGGS Game
  15. Hit When Red!
  16. Battleship
  17. Tambola Controller
  18. Card Game (Patte Pe Patta)
Many more are on the way...
 

Monday, November 09, 2015

Microcontroller Evaluation Platforms - Managing Variety

Embedded computers, the computers embedded deep inside everyday products that you neither see nor care for, are actually responsible for the safe and continued operation of your device. Microwave oven, washing machine, refrigerator, printer, TV set, even the lowly but ubiquitous TV remote are numerous examples of embedded computers at work, silently. You don't think of these devices as computers but without the computer chips installed in them and programmed to perform the given task over and over again, your gadget would not work flawlessly.

How does one learn about them? How does one learn about them for the purpose of creating similar devices? Embedded computers or embedded system design, is in fact a field of study in most electronics and computers related engineering courses. Of course, it is possible to know more about them even without enrolling in such courses, all thanks to the availability of copious information on the Internet.

TI-CEPD Activities

We, at NSIT have a collaboration with Texas Instruments, India and have formed a centre called The Texas Instruments Centre for Embedded Products Design. There are several objectives that this Centre tries to achieve. Amongst them are (a) create pedagogy material for electronics and embedded computer education (b) conduct training programs for students, teachers and hobbyists to further TI technologies which span a wide spectrum of components from specialized analog components to embedded computers (c) and to create innovative embedded products.

As part of our training activity, we have been organizing a 4-week long internship programme called The TI Internship Workshop on Embedded System Design during summer and winter vacations since June 2013. The next such program will be held from December 7 2015. In our last internship programme, we had over 100 participants spread over four tracks on (i) MSP430 (ii) TIVA ARM (iii) C2000 Digital Signal Controller and (iv) BeagleBone Black.

Infrastructure for Training

While the focus of the training is on understanding track specific architecture in the general context of embedded system design enabling each participant to complete a stand alone project using the microcontroller from the chosen track, having a good grip on programming fundamentals becomes critically essential for the success. To help with the programming, each participant is provided with a LaunchPad for the chosen microcontroller. A LaunchPad is a simple and inexpensive microcontroller evaluation kit that allows a user to download and debug a program from the development platform (usually a PC/laptop) into the memory of the microcontroller on the LaunchPad. The following picture shows four LaunchPads from TI.



TI LaunchPads and BoosterPacks

The LaunchPad exposes the pins of the microcontroller through connectors and allows the user to connect peripheral devices such as push-buttons, LEDs, LCD and other I/O devices. To help with connecting various I/O interfaces to the LaunchPad, there is a rich ecosystem of interface boards called BoosterPacks. BoosterPacks come in all shapes, sizes and features and connect to the LaunchPad through the connectors on the LaunchPad and offer specific input-output functionality. The picture below is a sensorhub BoosterPack which hosts a variety of sensors that the user can connect to a LaunchPad. Sensorhub BoosterPack is a TI product.



Use of BoosterPacks together with a LaunchPad for personal use during self exploration of embedded systems is a fine method. However, in a group learning environment such as our internship workshop, it can increase the cost of training program substantially besides becoming a logistics nightmare of having to keep track of large number of BoosterPacks. We, at TI-CEPD, therfore decided to explore an alternative approach. We decided to create a 'motherboard' that could host a LaunchPad. The idea of motherboards and daughterboards is common and quite old in the field of electronics and computers. However, instead of creating an individual motherboard for each and every microcontroller family LaunchPad, we decided to create a common motherboard which could host as many as possible, different LaunchPads for the various microcontroller tracks we offer in our training programs. In the past we have created a motherboard for the Tiva LaunchPad but at the time we did not consider compatibility with LaunchPads for other microcontrollers (such as the MSP430, MSP432, and C2000 and others).

Managing Variety

The most popular LaunchPad from the TI stable is the MSP430 LaunchPad for the G series of microcontrollers. However, these are entry level microcontrollers and have low I/O pin count. Microcontrollers from other families of MSP432, Tiva and C2000, on the other hand have substantially more pins and that is reflected in the LaunchPads of these microcontroller families. The G series MSP430 LaunchPad has two rows of expansion pins whereas, the rest of the microcontroller family LaunchPads have four rows, doubling the number of available pins. Incidentally, even the LaunchPad for the F series MSP430 offers four rows of expansion pins. So, we decided to create our motherboard compatible with the LaunchPads that offer four rows of expansion pins. Since this was our second attempt at creating a motherboard, we wanted a solution that would be common to as many LaunchPads as possible. The result is Starship-XP. Choice of this name is obvious. Starship would be the mothership hosting a LaunchPad. XP stands for cross platform, indicating the cross platform compatibility.

The block diagram  below shows the original plan. The actual implementation has added more features than originally planned.



The features that we managed to offer on the Starship-XP are as follows

Communication Protocols

UART, Bluetooth, Wi-Fi, I2C and SPI

User Interface

320x240 Color Graphics LCD, 16x2 Character LCD, 16-key Keypad, 5-key Navigation keys, RGB LED and Buzzer

Sensors

Temperature (I2C digital sensor), Humidity and Temperature (1-wire digital sensor), Potentiometer, LDR, Thermistor and Microphone with preamplifier.

Storage

SD Card

Motion

Servo motor, External Stepper and DC motor Interface

Misc.

RTC with NVRAM and Battery Backup, Audio Input Left and Right Channel,  2-Ch DAC and Stereo Audio Output, 8-bit Shift Register

Here are pictures of the first version of the Starship-XP with four different LaunchPads. The picture below is with a Tiva LaunchPad.

Then we have Starship with F series MSP430 LaunchPad.


The picture below is Starship with MSP432 LaunchPad.


And, the one here is Starship with a C2000 digital signal controller LaunchPad.
We have tested the Starship with Tiva LaunchPad and few shortcomings have been noticed and in the second version these are being ironed out. Also, the second version will have bigger push-buttons with caps and more liberal arrangement of the components. We hope to have the second version in time for the forthcoming TI Internship Workshop starting from December 7, 2015!