Showing posts with label Launchpad MSP430. Show all posts
Showing posts with label Launchpad MSP430. Show all posts

Sunday, 3 November 2013

Basic Micro-Controller Unit Connections (Part I)

There are many tutorials on the web that teach you how to program various circuits with Micro Controller Units (MCU) such as the Arduino (www.arduino.cc), Texas Instruments MSP430 (www.ti.com/launchpad) and Microchip PIC Microcontrollers (www.microchip.com). However if you want to design your own circuit, here’s a short guide as to how you can make some basic circuits for your MCU.’

 

1. Power Supply and Programming Circuit

One of the first things that you need to do is connect the power supply and the programming circuit to your MCU. If you are using a  MCU that comes with a programming board such as the Arduino and the Texas Launchpad you can skip this step. If not, I recommend that you read the datasheet for your MCU before connecting any wires from the MCU to a power supply or to a computer. There are many tutorials and YouTube videos online that will help you make these connections.

You will also need to install a programming software and system drivers for your programmer. You can find information regarding this from the place where you obtained your programming board or circuit.

 

2. Buttons and switches

Buttons and Switches are digital devices that can only send either a logical high or low to your MCU. It is possible to connect your button directly to your MCU input pin and one of the power rails. When the button is pressed the Logical High value will be recorded on the MCU input, however when the button is not pressed the input pin is floating around. This means that neither a High voltage or a Low voltage is given to the input pin. The value recorded by the MCU at this instance will be altered by natural factors like electrical interference.

To overcome this problem push buttons and switches are wired with either a pull up or a pull down resistor as shown in the image below. These resistors are used to connect the input of the MCU to either the High or the Low voltage when the button is not pressed. The value of the resistor should be relatively large (10kΩ). This is similar to a potential divider where the resistor representing the button swaps between infinite resistance and zero resistance.

Micro-Controller Unit Connections–Basic

Many MCU’s have a built in pull up or pull down resistor which can be enabled when programming the pin configuration of the MCU. When this is to be selected, the push button or switch can be wired directly from the main power supply to the pin.

 

3. Sensors

Most sensors are similar to similar to a variable resistor. They change their internal resistance depending on what they sense. For example the resistance of a Light Dependant Resistors (LDR) reduces when light falls on the it.

Sensors such as LDR, photo resistors, temperature sensors, and other similar input devices are connected as follows which is similar to the wiring to the button

sensors

In this situation a potential divider is formed between the fixed resistor and the sensor. The voltage as a result of the potential divider is read by your MCU. Unlike a button, the sensor is a analogue device. It should be connected to a analogue pin on your MCU to receive the complete range of values.

It is possible to connect the sensor to a digital pin. If you do this you will only receive a High or a Low input depending on the state of the sensor. I advice you to to refer to the datasheet of the MCU to find out how much voltage is required by a digital pin to register as a High or Low voltage.

 

4. Light Emitting Diodes (LED)

LED’s are one of the basic output devices. They are diodes which allow current to flow in only one direction. Before connecting an LED you must know how much voltage is needed by the LED for optimal glow and the rated current.

LED’s are connected via a resistor as shown in the figure below. The resistor that needs to be added in series with LED is to limit the current flowing through the LED. This is needed because of the LED’s I-V curve. According to the I-V curve, after a certain voltage drop the LED will allow almost infinite current to flow through it. This will draw all the current from your MCU and cause the batteries to drain much quickly. It may also blow out your LED.

LED

The resistance of the resistor to be added can be calculated as follows.

  • Reduce the voltage drop over the LED (Ex. 2.2V) from the supply voltage (Ex. 5V) to find the voltage drop over the Resistor (5 – 2.2 = 2.8V)
  • Using Ohms law (V = IR) calculate how much resistance is needed to draw a current less than the rated current of the LED (Ex. 20mA). Remember than in a series circuit the same current flows through all the connected components (R = (2.8/0.02)Ω).

7 segment displays are connected similar to LEDs. They have an input pin which requires a positive voltage and 8 output pins which are connected to the cathode of each the LEDs on the segments.

Bi-colour LEDs are also similar. It contains three pins where one of the pins are the power supply and the other two are the cathodes for each colour.

Multiple LED’s can be connected in many ways: Two LEDs can be connected as follows where one LED will light up and the other one will switch off depending on the output of the MCU pin

Bicolour

If you need to control many LEDs with only a few pins on your MCU please read about Multiplexing and Charlieplexing. I will explain these circuits on another part of this tutorial.

 

On a Final Note

This is only the first part of the Basic Micro controller unit connections tutorial. Other parts will uploaded soon

If you are someone who is always working with electronic circuits, I have found a very useful Mobile app named “ElectroDroid” by lero . There is a free and pro version. You can use it to look up resistor colour codes and SMD values, calculate theoretical values for different circuits and many more.

If you thing this post needs more improvement please let me know by commenting below. If you think this post is useful, bookmark it or share it with someone who might need it.

Thank you for reading.

Tuesday, 2 April 2013

Lap Timer

SAM_7979

I built this circuit to test the time taken for a line following buggy to complete one lap in a track that I created. Myself and my friend used this circuit to measure the best time taken.
The circuit consists of
  • 2 push buttons to select which user is racing next
  • LCD display to show the best time and the current time while the timer is running
  • A power supply consisting of a 9V battery connected to two voltage dividers that step down the voltage to 5V and 3.3V.
  • A sensor circuit fabricated by my friend which outputs a logic high when the sensor detects any object in front of it at a limited range.

SAM_7968

SAM_7971

To get started, I built the circuit with an Arduino Uno R3. After successfully making basic connections to the arduino and debugging my code I decided the make the circuit with a MSP430 to make it smaller and more portable.
The MSP430 operates at 3.3V but the LCD display needs more than that to record a logic high. To overcome this problem AND gates were used to increase the output to the LCD display connections increase to 4.5V.

SAM_7978

If you want to create a similar circuit with an arduino all you have to do is the following.
  • Read and be familiarised with the “Liquid Crystal” library that comes with the Arduino software.
  • Make connections to the LCD display as shown in the library.
  • Fix two switches and wire it to the arduino.
  • Get a basic IR emitter and a receiver (It is easier to get a TCRT5000). Then wire the receiver same as the switches. Instead of connecting it straight to the arduino, connect it to a comparator and use a voltage regulator to control the output signal.
  • If necessary use a Voltage regulator to drop the voltage from your source to 5V.

You can write your own program. but here is a copy of my program.
 

 Here is a demonstration

Monday, 28 January 2013

Line Following Buggy Sensor Prototype

UoM Buggy Prototype 28Jan2013 (4)
As a second year student at the University of Manchester my team and I had to create a line following buggy. To demonstrate to the lecturers the basics of detecting the line and applying the correct duty cycle for the PWM I made a simple sensor prototype.