K, Anbazhagan - Tricky Circuit projects with programmed Level handson_ Programmed Staircase Lights, IR Remote, Tune or Sound Generator, Movement Detector, Vehicle Tracking, Line Follower Robot ETC.., .pdf
K, Anbazhagan - Tricky Circuit projects with programmed Level handson_ Programmed Staircase Lights, IR Remote, Tune or Sound Generator, Movement Detector, Vehicle Tracking, Line Follower Robot ETC.., .pdf
K, Anbazhagan - Tricky Circuit projects with programmed Level handson_ Programmed Staircase Lights, IR Remote, Tune or Sound Generator, Movement Detector, Vehicle Tracking, Line Follower Robot ETC.., .pdf
PROJECTS WITH
PROGRAMMED LEVEL
HANDSON
Programmed Staircase Lights, IR Remote, Tune or
Sound Generator, Movement Detector, Vehicle
Tracking, Line Follower Robot, Controlling
Brightness of LED etc...,
Anbazhagan K
Copyright © 2020 Anbazhagan K
The characters and events portrayed in this book are fictitious. Any similarity to real persons, living
or dead, is coincidental and not intended by the author.
No part of this book may be reproduced, or stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, or otherwise, without express written
permission of the publisher.
CONTENTS
Title Page
Copyright
Acknowledgments
Introduction
1. PDA Charger Circuit
2. Programmed Staircase Lights utilizing PIR Sensor along with Relay
3. IR Remote Tester Circuit
4. Tune or Sound Generator Circuit
5. PIR Sensor Based Motion Detector/Sensor Circuit
6. Water Level Indicator Alarm
7. Interfacing HC-05 Bluetooth Module with MSP430 Launchpad to control
a LED
8. Movement Detector Using MSP430 Launchpad and PIR Sensor
9. Vehicle Tracking and Accident Alert System utilizing MSP430
Launchpad and GPS Module
10. Line Follower Robot Using MSP430 LaunchPad
11. I2C correspondence with MSP430 Launchpad
12. Sending Email Using MSP430 Launchpad and ESP8266
13. RFID Interfacing with MSP430 Launchpad
14. Interfacing RTC module (DS3231) with MSP430: Digital Clock
15. Interfacing Stepper Motor with MSP430G2
16. Beginning with MSP430 utilizing Code Composer Studio-Blinking a
LED
17. Interfacing Servo Motor with MSP430G2
18. Heartbeat width Modulation (PWM) utilizing MSP430G2: Controlling
Brightness of LED
19. Step by step instructions to utilize ADC in MSP430G2 - Measuring
Analog Voltage
20. Interfacing LCD with MSP430G2 LaunchPad
Thank you
ACKNOWLEDGMENTS
The writer might want to recognize the diligent work of the article group in
assembling this book. He might likewise want to recognize the diligent
work of the Raspberry Pi Foundation and the Arduino bunch for assembling
items and networks that help to make the Internet of Things increasingly
open to the overall population. Yahoo for the democratization of
innovation!
INTRODUCTION
2. Amendment
Amendment is the way bring closer expelling the negative piece of the
Alternate Current (AC), thus creating the fractional DC. This can be
accomplished by utilizing 4 diodes. Diodes just permit current to stream
one way. In first half pattern of AC diode D2 along with D3 are forward
one-sided and D1 along with D4 are turned around one-sided, and in the
subsequent half cycle (negative half) Diode D1 along with D4 are forward
one-sided and D2 along with D3 are switched one-sided. This Combination
changes over the negative half cycle into positive.
A full wave connect rectifier segment is accessible in the market, which
comprise that mix of 4 diode inside. Here we have utilized this segment.
3. Filtration
4. Voltage Regulation
You must be highly cautious while building this circuit, as AC mains 220V
is included here.
2. PROGRAMMED
STAIRCASE LIGHTS
UTILIZING PIR SENSOR
ALONG WITH RELAY
This programmed flight of stairs light circuit switch on the flight of stairs
lights consequently when somebody enters on the steps and gets off after
few time. There are 2 significant parts in this circuit, 1st is PIR Sensor
(Passive Infrared Sensor) along with 2nd is Relay.
PIR Sensor
Hand-off
Circuit Explanation
This programmed flight of stairs light circuit can be handily clarified. At
whatever point PIR sensor distinguishes anyone development, its OUTPUT
pin turns out to be HIGH, which applies the activating voltage to the base of
the transistor, transistor jump ON, and current began coursing through the
loop. Loop in Relay gets energies and make electromagnetic field, which
draws in the switch and COM and NO get associated. This permits an a lot
bigger current (220v AC) to stream, which turns ON the BULB. You can
increment or reduction the Bulb ON term by setting up PIR sensor.
3. IR REMOTE TESTER
CIRCUIT
We are particularly acquainted with our TVs, DVDs, MP3 players, music
frameworks along with many other gadget that are constrained by utilizing
IR Remote. There are numerous sorts of remote controls accessible for
various gadgets however a big part of them take a shot at around 38KHz
Frequency signal. In some cases we face a normal problem identified with
IR TV or other gadget remote control that in the event that it is working or
not. We check on various occasions to discover if the remote is functioning
or not. We are gonna to do an IR Remote analyzer circuit utilizing
TSOP1738 IR Receiver sensor circuit. This Thin small outline package
1738 sensor can detect 38Khz Frequency flag and can distinguish any IR
signal.
Parts Required
TSOP1738
1K resistor
Jumper wires
Bread board
Battery Connector
Ringer
Driven
Television Remote
When TSOP1738 sensor gets IR heartbeats or sign its yield pin goes LOW
along with become HIGH once more when sign is lost. As a matter of
course yield pin stays in HIGH state. A TSOP1738 sensor is appeared in the
underneath picture.
Circuit Diagram and Explanation
As appeared in the above IR remote manage analyzer circuit, we have
associated a signal and a yellow LED for sign. LM7805 Voltage controller
is additionally included to the circuit for giving 5 volt voltage supply to the
circuit, and a 9 volt battery is used for driving the circuit. Pin number 1 of
LM7805 is associated with battery's Positive terminal and pin second is
associated with ground terminal of battery. Pin 2 of Thin small outline
package 1738 is straightforwardly combined with pin number 3 of LM7805
and first number is combined with ground. Ringer is associated with pin
number three of TSOP1738 trough a 1K opposition and yellow LED's
negative terminal is associated with a similar terminal trough 150 ohm
resistor.
In the wake of driving up the circuit when we press any catch of IR Remote
then remote sends some IR beats of around 38Khz recurrence. These
heartbeats are gotten by TSOP1738 sensor and as examined above, it gives
a LOW sign. We utilizes this LOW yield sign to initiate the bell and LED.
So by getting LOW yield sign of TSOP1738 Buzzer begins signaling and
LED begin shining, which demonstrates that the remote control is working
accurately. In the event that this IR remote analyzer circuit doesn't react
with the remote control's catch squeezes, it demonstrates that the remote
control isn't working appropriately. (Additionally check this TV remote
manage jammer circuit)
4. TUNE OR SOUND
GENERATOR CIRCUIT
A great deal of toys have a tune tones in them. Be that as it may, how do
these tones produce? Here we have planned a straightforward tone
generator circuit utilizing just a solitary tune generator IC.
Circuit Components
BT66T-19L
1K Resistor
Breadboard
Bell
Press Button
Circuit Components
Driven
Battery (5-9V)
Circuit Components
4 - BC547 transistors
6 - 220 ohm resistors
1 – Buzzer
Breadboard
Circuit Diagram
We can think about this entire circuit as 4 little circuits, every one for
demonstrating/disturbing, when a specific level (A,B,C,D) of water have
been reached.
At the point when water level compasses to point A, circuit with RED LED
and transistor Q1 gets finished and RED LED gleams. Correspondingly
when water level compasses to point B, circuit with YELLOW LED and
transistor Q2 gets finished and Yellow LED sparkles, same goes with point
C. Lastly when tank gets full (Point D), circuit with bell gets finished and
ringer begins blaring.
Working
Here we are utilizing transistor (of NPN type) as a Switch. At first there is
no voltage given to the base of the Transistor Q1 along with the transistor is
in OFF state along with no current is coursing through gatherer and
producer along with Light Emitting Diode is OFF (See beneath chart to
comprehend Transistor Pin structure).
At the point when the water level scopes to Point An in the tank, the +ve
side of the battery gets associated with the base of the Transistor Q1 across
the water. So when a +ve voltage has been given to the base of the
Transistor Q1, it gets into ON state and current beginnings spilling out of
authority to producer. Also, RED LED gleams.
You can view resistors (R1, R2, R3) at the base of every transistor, which is
utilized to constrain the most extreme Base current. For the most part a
transistor gets its ON state completely when a voltage of 0.7 V is given to
the base. There are likewise resistors (R4, R5, R6) with every one of the
LEDs, to drop the voltage across LEDs, in any case LED may explode.
Same marvel occurs when water level ranges to Point B. When water level
scopes to Point B, a positive voltage gets applied to the Transistor Q2, it
kicks ON and momentum off moving through YELLOW LED, and LED
gleams. With same standard, GREEN LED shine when water level
compasses to Point C.And at long last Buzzer signals when water level
scopes to D.
Note that Left most wire in the tank must be lengthier than other four wires
in the tanks, since this is the wire which is associated with positive voltage.
7. INTERFACING HC-05
BLUETOOTH MODULE
WITH MSP430
LAUNCHPAD TO
CONTROL A LED
While a ton of remote advancements have been presented in past decade,
yet Bluetooth is as yet the most well known tech for short range remote
correspondence. In implanted frameworks HC-05/06 is the most well
known Bluetooth Module. We recently utilized this Bluetooth module in
numerous undertakings to manage home machines, robots and so forth and
interfaced it with other microcontroller:
In case you're new to MSP430, at that point you can begin with Getting
Started with MSP430G2 utilizing Energia IDE instructional exercise and
can follow all the MSP430 Tutorials here.
Materials Required
TI-MSP430 Launchpad
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
Next in if-else articulation we are checking the information sent from the
telephone. In the event that it is 1, at that point turn the LED on by utilizing
digitalWrite(LED, HIGH); and print message on the application that LED is
turned on by utilizing Serial.write() work. Furthermore, in case it is 2, at
that point turn the Light Emitting Diode off by utilizing digitalWrite(LED,
LOW); and print the message on the application that Light Emitting Diode
is OFF by utilizing Serial.write() work.
void loop() {
if (Serial.available())
{
char data_received;
data_received = Serial.read();
if (data_received == '1')
digitalWrite(LED, HIGH);
digitalWrite(LED, LOW);
At last transfer the code into MSP430 utilizing Energia IDE, and download
and introduce the Bluetooth Terminal application on your advanced mobile
phone. The application will look like appearing underneath:
Presently turn on the Bluetooth in your advanced cell and interface with
Bluetooth module by choosing HC-06 from the rundown of accessible
gadgets. Utilize the secret phrase 0000 or 1234 to interface. After
association, a window will open titled with gadget name and associated
composed underneath it. This window will resemble the figure underneath:
PIR Sensor along with Global System for Mobile Based Security
System
Materials Required
PIR Sensor Module
TI-MSP430 Launchpad
Driven
Ringer
Breadboard
Jumper wires
The PIR sensor represents Passive Infrared sensor which can identify
numerous degrees of radiations. As it is notable that each article discharges
some radiation and more sizzling materials produce a greater number of
radiations than different materials. That is the reason this sensor can
identify human/creature nearness since they are more sweltering than
different materials in encompassing. The module comprises a pyroelectric
sensor, which distinguishes the nearness of human/creature body. Also,
there is one Fresnel Lens appended to the sensor, which builds the scope of
the sensor. The pin-out for PIR sensor module is given underneath:
This module is customizable for example the affectability and time trigger
can be balanced by pivoting the handles of two potentiometers on the load
up.
There are 2 methods of working: Retriggering (H) mode and non-
Retriggering (I) mode.
In retriggering or H mode, the yield remains high as long as the movement
is happening. What's more, in non-retriggering or I mode, the yield remains
high at that point turns low after the trigger time and this procedure
proceeds insofar as movement is proceeded. Most applications use H mode
and we're likewise going to utilize this mode as it were. The PIR sensor
takes a shot at 5V to 12V force supply. Be that as it may, it can likewise be
fueled by 3.3V pins of the MSP430.
To get familiar with PIR sensor, follow the connection and furthermore
figure out how PIR sensor can be utilized with Arduino, Raspberry Pi along
with different microcontrollers for different applications:
The code is straightforward. Here we are gonna to flicker the LED and
blare the ringer consistently when any movement gets identified by PIR
sensor.
In arrangement work, we announce that the pin 8 will be utilized as
information pin since it is bringing the yield from PIR module and the pin 6
will be utilized as a yield pin as it is associated with LED and bell.
void setup()
pinMode(8, INPUT);
pinMode(6, OUTPUT);
}
Next on the up and up work, right off the bat we check for the yield from
PIR module whether it is high or not. Presently in case the yield from PIR
module is high, at that point, it implies that some development is
recognized. So to demonstrate this, we turn the pin 6 low and high with a
period postponement of 100 milli seconds, so constant glimmering and
humming can be experienced.
void loop()
If(digitalRead(8) == HIGH)
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
}
At last transfer the code to MSP430 utilizing Energia IDE and force the
board and sit tight for about a moment. The PIR sensor module sets aside
some effort to align. Following a moment, move your deliver front of
sensor, and it works. In the wake of evacuating your hand the blazing and
humming will stop. You can likewise have a go at changing the affectability
and time trigger utilizing the two potentiometers present on the PIR sensor.
Code
void setup()
{
pinMode(8, INPUT);
pinMode(6, OUTPUT);
}
void loop()
{
If(digitalRead(8) == HIGH)
{
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
}
}
9. VEHICLE TRACKING
AND ACCIDENT ALERT
SYSTEM UTILIZING
MSP430 LAUNCHPAD
AND GPS MODULE
In past instructional exercises, we have found out about How to interface
GPS module with Computer and how to Track vehicle utilizing Global
System for Mobile along with Global Positioning System. We likewise
assembled Vehicle Accident Alert System utilizing Arduino and
accelerometer. We are again constructing a similar undertaking yet this time
a MSP430 launchpad and a vibration sensor will be utilized to identify
vehicle mishap. So this undertaking will likewise tell about interfacing a
vibration sensor with MSP430.
Here Vibration sensor module identifies the vibration of vehicle along with
imparts a sign to MSP430 Launchpad. At that point MSP430 brings
information from GPS module and send it to client Mobile Phone by means
of SMS utilizing GSM module. A LED will likewise shine as Accident
Alert sign, this LED can be supplanted by some caution. Area of the mishap
is sent as Google Map interface, got from the scope and longitude from the
GPS module.
Parts Required
MSP430 Launchpad
GSM Module
GPS Module
16x2 LCD
Force Supply
Interfacing Wires
10 K-POT
Breadboard or PCB
5v power supply
Prior to going into Project, we will talk about GPS, GSM and Vibration
Sensor. Likewise in case you are new to MSP430, at that point start with
LED flicker utilizing MSP430 Tutorial.
GPS represents Global Positioning System and used to identify the Latitude
along with Longitude of any area on the Earth, with precise UTC time
(Universal Time Coordinated). GPS module is utilized to follow the area of
mishap in our venture. This gadget gets the directions from the satellite for
every single second, with time along with date. We have recently removed
$GPGGA string in Vehicle Tracking System to discover the Latitude and
Longitude Coordinates.
GPS module transmits the data identified with following situation
continuously, and it sends such a significant number of information in
NMEA design (see the screen capture underneath). NMEA group comprises
a few sentences, wherein we just need one sentence. This sentence begins
from $GPGGA and contains the directions, time and other helpful data.
This GPGGA is alluded to Global Positioning System Fix Data. Find out
about NMEA sentences and perusing GPS information here.
We can separate arrange from $GPGGA string by including the commas in
the string. Assume you discover $GPGGA string and stores it in a cluster, at
that point Latitude can be found after two commas and Longitude can be
found after four commas. Presently, this scope and longitude can be placed
in different clusters.
The following is the $GPGGA String, alongside its depiction:
$GPGGA,104534.000,7791.0381,N,06727.4434,E,1,08,0.9,510.4,M,43.
9,M,,*47
$GPGGA,HHMMSS.SSS,latitude,N,longitude,E,FQ,NOS,HDP,altitude,
M,height,M,,checksum data
Identifier Description
Longitude Longitude(Coordinate)
M Meter
Height Height
AT Commands
AT implies ATTENTION. This order is utilized to control the GSM module.
There are a few orders for calling and informing that we have utilized in a
significant number of our past GSM ventures with Arduino. For testing
GSM Module we utilized AT order. In the wake of accepting AT Command
GSM Module react with OK. It implies GSM module is working fine. The
following is some AT orders we utilized here in this task:
ATE0 For reverberation off
AT+CNMI=2,2,0,0,0 <ENTER> Auto opened message Receiving. (No
compelling reason to open message)
ATD<Mobile Number>; <ENTER> making a call
(ATD+919610126059;\r\n)
AT+CMGF=1 <ENTER> Selecting Text mode
AT+CMGS="Mobile Number" <ENTER> Assigning beneficiary's portable
number
>>Now we can compose our message
>>After composing a message
Ctrl+Z sends message order (26 in decimal).
ENTER=0x0d in HEX
(To get familiar with GSM module, Check our different GSM ventures with
different microcontrollers here)
Programming for this venture is simple aside from the GPS part. Complete
code is given toward the finish of the undertaking. To compose or arrange
the code in MSP430 we have utilized Energia IDE which is Arduino good.
A large portion of Arduino IDE capacity can be used straightforwardly in
this Energia IDE.
So above all else we have incorporated a necessary libraries and proclaimed
pin and factors.
#include <SoftwareSerial.h>
float logitude=0;
int i=0;
Given capacity is utilized for perusing vibration sensor signal. This capacity
will channel little or bogus vibrations also.
#define count_max 25
char count_low=0,count_high = 0;
do
delay(1);
if (digitalRead(pin) == HIGH)
count_high++;
count_low = 0;
}
else
count_high = 0;
count_low++;
return LOW;
else
return HIGH;
void loop()
if(SensorRead(vibrationSensor) == HIGH)
{
digitalWrite(led, HIGH);
gpsEvent();
Send();
digitalWrite(led, LOW);
delay(2000);
Given Function is liable for getting GPS strings from GPS module, remove
the directions from them and convert them in degree-decimal organization.
void gpsEvent()
char gpsString[55];
char test[]="RMC";
i=0;
while(1)
{
char inChar = (char)Serial.read();
i++;
if (i < 4)
i=0;
int degree=0;
degree=gpsString[16]-48;
degree*=10;
degree+=gpsString[17]-48;
int minut_int=0;
minut_int=gpsString[18]-48;
minut_int*=10;
minut_int+=gpsString[19]-48;
int minut_dec=0;
minut_dec+= (gpsString[21]-48)*10000;
minut_dec+= (gpsString[22]-48)*1000;
minut_dec+= (gpsString[23]-48)*100;
minut_dec+= (gpsString[24]-48)*10;
minut_dec+= (gpsString[25]-48);
Lastly, Send() work is utilized to send the Short Message Service to the
client number that is embedded in this piece of the code.
void Send()
GSM.print("AT+CMGS=");
GSM.print('"');
GSM.println('"');
delay(500);
// GSM.print("Latitude:");
// GSM.println(latitude);
GSM.println("Accident Happned");
delay(500);
// GSM.print(" longitude:");
// GSM.println(logitude);
GSM.print("http://maps.google.com/maps?
&z=15&mrt=yp&t=k&q=");
GSM.print(latitude,6);
GSM.print("+");
GSM.print(logitude,6);
GSM.write(26);
delay(4000);
Code
#include <SoftwareSerial.h>
SoftwareSerial GSM(P1_6, P1_7); // RX, TX
float latitude=0;
float logitude=0;
#define led P1_0
const int vibrationSensor=PUSH2;
int i=0;
#define count_max 25
char SensorRead(int pin) // read sw with debounce
{
char count_low=0,count_high = 0;
do
{
delay(1);
if (digitalRead(pin) == HIGH)
{
count_high++;
count_low = 0;
}
else
{
count_high = 0;
count_low++;
}
}while(count_low< count_max && count_high < count_max);
if (count_low >= count_max)
return LOW;
else
return HIGH;
}
void setup()
{
GSM.begin(9600);
Serial.begin(9600);
GSM.println("AT");
delay(1000);
GSM.println("ATE0");
delay(1000);
GSM.println("AT+CMGF=1");
pinMode(led , OUTPUT);
digitalWrite(led, LOW);
pinMode(vibrationSensor, INPUT_PULLUP);
}
void loop()
{
if(SensorRead(vibrationSensor) == HIGH)
{
digitalWrite(led, HIGH);
gpsEvent();
Send();
digitalWrite(led, LOW);
delay(2000);
}
}
void gpsEvent()
{
char gpsString[55];
char test[]="RMC";
i=0;
while(1)
{
while (Serial.available()) //Serial incomming data from GPS
{
char inChar = (char)Serial.read();
gpsString[i]=inChar; //store incomming data from GPS to
temparary string str[]
i++;
if (i < 4)
{
if(gpsString[i-1] != test[i-1]) //check for right string
i=0;
}
if(i>50)
{
int degree=0;
degree=gpsString[16]-48;
degree*=10;
degree+=gpsString[17]-48;
int minut_int=0;
minut_int=gpsString[18]-48;
minut_int*=10;
minut_int+=gpsString[19]-48;
int minut_dec=0;
minut_dec+= (gpsString[21]-48)*10000;
minut_dec+= (gpsString[22]-48)*1000;
minut_dec+= (gpsString[23]-48)*100;
minut_dec+= (gpsString[24]-48)*10;
minut_dec+= (gpsString[25]-48);
float minut= ((float)minut_int + ((float)minut_dec/100000.0))/60.0;
latitude= ((float)degree + minut);
degree=0;
degree=gpsString[30]-48;
degree*=10;
degree+=gpsString[31]-48;
minut_int=0;
minut_int=gpsString[32]-48;
minut_int*=10;
minut_int+=gpsString[33]-48;
minut_dec=0;
minut_dec+= (gpsString[35]-48)*10000;
minut_dec+= (gpsString[36]-48)*1000;
minut_dec+= (gpsString[37]-48)*100;
minut_dec+= (gpsString[38]-48)*10;
minut_dec+= (gpsString[39]-48);
minut= ((float)minut_int + ((float)minut_dec/100000.0))/60.0;
logitude= ((float)degree + minut);
i=0;
Serial.flush();
return;
}
}
}
}
void Send()
{
GSM.print("AT+CMGS=");
GSM.print('"');
GSM.print("984****009"); // enter your Mobile number
GSM.println('"');
delay(500);
// GSM.print("Latitude:");
// GSM.println(latitude);
GSM.println("Accident Happned");
delay(500);
// GSM.print(" longitude:");
// GSM.println(logitude);
GSM.println("Click On link to see Location");
GSM.print(" http://maps.google.com/maps?&z=15&mrt=yp&t=k&q= ");
GSM.print(latitude,6);
GSM.print("+");
GSM.print(logitude,6);
GSM.write(26);
delay(4000);
}
10. LINE FOLLOWER
ROBOT USING MSP430
LAUNCHPAD
Line supporter robot is one of the well known mechanical technology
ventures among understudies and novices on account of its effortlessness. It
follows a line, either dark or white, contingent upon how you program your
microcontroller. Here we make a line devotee robot utilizing MSP430
launchpad from Texas Instruments, which follows the dark line. On the off
chance that you are new to MSP430 launchpad, if it's not too much trouble
read our Getting gazed with MSP430 Tutorial.
Materials Required
Interfacing wires
IR sensor Modules
Chasis, wheel, crazy ride
Energia IDE
Idea of line adherent is identified with light. We have utilized the conduct of
light at highly contrasting surface. At the point when light fall on a white
surface it will practically full reflects and if there should be an occurrence
of dark surface light is consumed by dark surface. This clarified conduct of
light is utilized in this line adherent robot.
In this MSP430 based line supporter robot we have utilized IR Transmitters
and IR recipients likewise called photograph diodes. They are utilized for
sending along with getting light. IR transmits infrared lights. At the point
when infrared beams falls on white surface, it's reflected back along with
got by photodiodes which creates some voltage changes. At the point when
IR light falls on a dark surface, light is retain by the dark surface and no
beams are reflected back, subsequently photograph diode doesn't get any
light otherwise beams. To Learn increasingly about IR sensors, follow the
connection.
Here in this MSP430 based line adherent robot when sensor detects white
surface then MSP gets 1 as info and when detects dark line MSP gets 0 as
information.
Circuit Explanation
We can isolate the entire line devotee robot into different areas like sensor
segment, control segment and driver segment.
int pins[4]={P1_5,P2_0,P2_1,P2_2};
//#define activeLowMode
#ifdef activeLowMode
int res[4]={forward,left,right,stop};
#else
int res[4]={stop,right,left,forward};
#endif
void setup()
for(int i=0;i<4;i++)
pinMode(pins[i], OUTPUT);
pinMode(l_sensor, INPUT);
pinMode(r_sensor, INPUT);
}
void loop()
for(int i=0;i<4;i++)
There are four conditions in this line adherent that we read by utilizing
MSP430 Launchpad. We have utilized two sensors specifically the left
sensor and the correct sensor.
Input Output
Movement Of
Left Right Robot
Left Motor Right Motor
Sensor Sensor
LM LM
LS RS RM1 RM2
1 2
0 0 0 0 0 0 Stop
0 1 1 0 0 0 Turn Right
1 0 0 0 1 0 Turn Left
1 1 1 0 1 0 Forward
#include <Wire.h>
void setup() {
Wire.begin();
byte val = 0;
In circle work, we will begin transmission to the i2c slave gadget (for this
situation Digital potentiometer IC) by indicating the gadget address which
is given in the datasheet of the IC.
void loop() {
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
Thusly, line bytes for example information you need to send to the IC for
transmission with the compose() work.
delay(500);
Code
#include <Wire.h>
byte val = 0;
void setup() {
Wire.begin();
}
void loop() {
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
Wire.write(byte(0x00)); // sends instruction byte
Wire.write(val); // sends potentiometer value byte
Wire.endTransmission(); // stop transmitting
val++; // increment value
if (val == 64) { // if reached 64th position (max)
val = 0; // start over from lowest value
}
delay(500);
}
12. SENDING EMAIL
USING MSP430
LAUNCHPAD AND
ESP8266
We are moving towards the World of Internet of Things (IoT), an
innovation which is going to assume a significant job in the purchaser along
with mechanical hardware. Sending an Email from any Microcontroller or
Embedded framework is essential thing which is required in IoT. Here we
make a demo IoT venture where we use ESP8266 along with MSP430
Launchpad to send an email upon fire identification.
Parts Required
MSP430 Launchpad
Fire Sensor
Interfacing wires
16x2 LCD
In this undertaking, a 16x2 Liquid Crystal Display is used for showing the
status of Wi-Fi Connection and Fire location messages. Here an email will
be sent at any point framework distinguishes any fire close to it.
To get the hang of sending email with ESP8266 utilizing other
microcontroller, experience underneath instructional exercises:
#include<LiquidCrystal.h>
#include <SoftwareSerial.h>
char str[40];
int i=0;
while (1)
i = 0;
ESP.println(cmd);
Serial.print("-->");
Serial.println(cmd);
Serial.print("<--");
delay(t);
serialEvent1();
// Serial.println(str);
if (strstr(str, res))
return;
delay(1000);
ESP.begin(9600);
Serial.begin(9600);
pinMode(fireSensor, INPUT);
lcd.begin(16,2);
lcd.setCursor(0,1);
lcd.print("By MSP430");
delay(2000);
lcd.clear();
lcd.print("Hello_world");
delay(2000);
lcd.clear();
lcd.print("Finding ESP8266");
lcd.setCursor(0,1);
lcd.print("Please Wait...");
lcd.print("Connecting WiFi");
Serial.println("Connecting Wifi....");
else
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Sending Email");
//lcd.print("Configuring Email..");
ESP.println("AT+CIPMUX=1");
delay(1000);
ESP.println("AT+CIPSERVER=1,80");
delay(2000);
ESP.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",
2525");
delay(2000);
ESP.println("AT+CIPSEND=4,180");
delay(2000);
ESP.println("EHLO 192.168.1.123");
ESP.println("AUTH LOGIN");
ESP.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");
ESP.println(" tu934yt89ert83=");
ESP.println("MAIL FROM:<[email protected]>");
ESP.println("RCPT To:<[email protected]>");
ESP.println("DATA");
// ESP.println("Testing Success.");
ESP.println(".");
Note: Many email servers won't acknowledge email from the IP addresses
gave by obscure server.
We need to enter recepient email, sender email and secret word in
base64encoded group, which we have changed over in past area utilizing
https://www.base64encode.org/site.
Check the total clarification.
Code
#include<LiquidCrystal.h>
LiquidCrystal lcd(P2_4, P2_3, P1_5, P2_0, P2_1, P2_2);
#include <SoftwareSerial.h>
SoftwareSerial ESP(P1_3, P1_4); // RX, TX
#define fireSensor P2_5
char str[40];
int i=0;
void connect_wifi(char *cmd, char *res, int t)
{
while (1)
{
for (int i = 0; i < 40; i++)
str[i] = NULL;
i = 0;
ESP.println(cmd);
Serial.print("-->");
Serial.println(cmd);
Serial.print("<--");
delay(t);
serialEvent1();
// Serial.println(str);
if (strstr(str, res))
return;
delay(1000);
}
}
void setup()
{
ESP.begin(9600);
Serial.begin(9600);
pinMode(fireSensor, INPUT);
lcd.begin(16,2);
lcd.print("Email Alert ");
lcd.setCursor(0,1);
lcd.print("By MSP430");
delay(2000);
lcd.clear();
lcd.print("Hello_world");
delay(2000);
lcd.clear();
lcd.print("Finding ESP8266");
lcd.setCursor(0,1);
lcd.print("Please Wait...");
connect_wifi("AT", "OK", 1000);
connect_wifi("ATE0", "OK", 1000);
connect_wifi("AT+CWMODE=3", "OK", 1000);
connect_wifi("AT+CWQAP", "OK", 1000);
lcd.clear();
lcd.print("Connecting WiFi");
Serial.println("Connecting Wifi....");
connect_wifi("AT+CWJAP=\"Redmi\",\"arishkhan\"","CONNECTED",
7000);
lcd.clear();
lcd.print("WIFI Connected...");
Serial.println("Wifi Connected");
ESP.println("AT+CIFSR");
delay(5000);
}
void loop()
{
if(digitalRead(fireSensor))
{
lcd.setCursor(0,0);
lcd.print("No Fire ");
}
else
{
lcd.clear();
lcd.print("Fire Alert ");
lcd.setCursor(0,1);
lcd.print("Sending Email");
//lcd.print("Configuring Email..");
ESP.println("AT+CIPMUX=1");
delay(1000);
ESP.println("AT+CIPSERVER=1,80");
delay(2000);
ESP.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",2525");
delay(2000);
ESP.println("AT+CIPSEND=4,180");
delay(2000);
ESP.println("EHLO 192.168.1.123");
ESP.println("AUTH LOGIN");
ESP.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");
ESP.println(" tu934yt89ert83=");
ESP.println("MAIL FROM:< [email protected] >");
ESP.println("RCPT To:< [email protected] >");
ESP.println("DATA");
// ESP.println("Testing Success.");
ESP.println("Fire Alert from Arduino");
ESP.println(".");
delay(2000);
ESP.println("AT+CIPSEND=6");
delay(1000);
ESP.println("QUIT");
delay(1000);
lcd.clear();
lcd.print("Email Sent...");
delay(2000);
lcd.clear();
}
}
void serialEvent1()
{
int ln=ESP.available();
if(ln>0)
{
for(int i=0;i<ln;i++)
{
char ch=ESP.read();
str[i]=ch;
Serial.print(ch);
delay(1);
}
}
}
13. RFID INTERFACING
WITH MSP430
LAUNCHPAD
In this instructional exercise we plan a framework to peruse the RFID cards
utilizing MSP430 and RFID Reader. RFID represents Radio Frequency
Identification. Each card has a special ID and this settles on it an ideal
decision for some validation applications, as in workplaces, shopping
centers and in numerous different spots where just the individual with
approval card is permitted to enter inside. RFID is utilized in shopping
centers to prevent a burglary from occurring, where the item will be labeled
with RFID chip and on the off chance that anybody leaves the structure
with the RFID chip an alert is raised naturally thus the robbery is halted.
The RFID tag is planned as little as grain of sand. The RFID verification
frameworks are anything but difficult to structure and are modest in cost. A
few schools and universities these days use RFID as participation register.
Materials Required
1. MSP430 Launchpad
2. EM-18 (RFID peruser module)
3. 16*2 LCD
4. Potentiometer
5. Breadboard
6. Jumper wires
Each RFID card has a one of a kind ID implanted in it and a RFID peruser
is utilized to peruse the RFID card no. EM-18 RFID peruser works at 125
KHz and it accompanies an on-chip radio wire and it very well may be
fueled with 5V power supply. It gives sequential yield along weigand yield.
The range is around 8-12cm. sequential correspondence parameters are
9600bps, 8 information bits, 1 stop bit. This remote RF Identification is
utilized in numerous frameworks like
Security frameworks,
We will utilize Hardware UART of MSP430 in this way, ensure RXD and
TXD jumpers on the board are on HW UART mode. At that point associate
Tx of EM-18 to RXD(P1.1) of MSP430.
Before going to assist we have to comprehend about the sequential
correspondence. The RFID module here sends information to the controller
in sequential. It has other method of correspondence however for simple
correspondence we are picking RS232. The RS232 pin of module is
associated with RXD pin of MSP430.
The information sent by the RFID module goes as:
Presently for setting up an association between RFID peruser and MSP430,
we have to empower the sequential correspondence in MSP430. The
sequential correspondence empowering in MSP430 should be possible by
utilizing a solitary order.
Serial.begin(9600);
data = Serial.read();
We will compose our code in Energia IDE. It is same as Arduino IDE along
with simple to utilize. Complete code is given toward the finish of this
venture, here we are clarifying not many pieces of it.
In the 1st place, incorporate library for LCD show and pronounce singe
cluster to store RFID number.
#include <LiquidCrystal.h>
char input[12];
In arrangement work, empower LCD and sequential correspondence by
characterizing Baud pace of 9600.
void setup()
lcd.begin(16, 2);
Serial.begin(9600);
...
..
Serial.print(input[count]);
lcd.print(input[count]);
delay(300);
count++;
if (count==12)
lcd.print(" ");
This is the manner by which we can peruse and show the RFID number on
LCD utilizing MSP430 Launchpad. Presently you can additionally expand
this extend and can manufacture Attendance framework, casting a ballot
framework, security framework and so on.
Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5);
char input[12];
int count = 0;
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print("Welcome..");
delay(3000);
lcd.clear();
lcd.print("Place Card to");
lcd.setCursor(0, 1);
lcd.print("scan");
}
void loop()
{
if(Serial.available()==0){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Place Card to scan");
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
}
if(Serial.available()>0){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("RFID No. ->");
lcd.setCursor(0, 1);
delay(30);
}
while(Serial.available() && count < 12) // Read 12 characters and
store them in input array
{
input[count] = Serial.read(); //storing 12 characters
Serial.print(input[count]);
lcd.print(input[count]);
delay(300);
count++;
if (count==12)
{
lcd.print(" ");
count = 0; // once 12 characters are read get to start and wait for
second ID
lcd.setCursor(0, 1); //move courser to start
}
}
delay(3000);
}
14. INTERFACING RTC
MODULE (DS3231) WITH
MSP430: DIGITAL CLOCK
In this instructional exercise we will make a Digital Clock by interfacing
RTC module DS3231 with MSP430 and show the time along with date on
16x2 Liquid Crystal Display. The MSP-EXP430G2 is a Development Tool
a.k.a LaunchPad gave by the Texas Instruments to learn and rehearse on the
best way to utilize their Microcontrollers. This board falls under the
MSP430 Value Line classification where we can program all the MSP430
arrangement Microcontrollers. On the off chance that you are new to MSP,
at that point check our beginning with MSP430 instructional exercise.
Materials Required:
MSP430
POT - 10k
Associating wires
Breadboard
What is RTC??
Note: When utilizing this module just because you need to set the date
along with time. You can likewise utilize RTC IC DS1307, we have
recently utilized DS1307 with Arduino.
Interfacing the DS3231 RTC with MSP430:
Circuit chart for MSP430 Microcontroller based Digital Clock is given
underneath. As told before the DS3231 works with the assistance of I2C
correspondence so it will have a Serial Clock (SCL) and a Serial Data
(SDA) pin which must be associated with the I2C nails to our MSP430
which is the pin 9(PIN 2.1,SCL) along with pin 10 (PIN 2.2,SDA).
MSP430 gives 3.3V Vcc yet we need 5V to interface it with LCD and RTC
module. In this way, we will utilize a hack, there is a jumper accessible
named as TP1 close to USB link connector. You can take 5V from that
point.
Circuit Diagram:
#include <Wire.h>
At that point we have included RTClib.h library for RTC clock along with
LiquidCrystal.h for LCD capacities.
#include "RTClib.h"
#include <LiquidCrystal.h>
RTC_DS3231 rtc;
At that point make a variety of size 7 and store every one of the seven days
with name in it.
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
In void arrangement(), we have instated the interface to the LCD screen and
RTC and indicated the measurements (width and stature) of the showcase,
start() should be called before some other library orders.
void setup () {
lcd.begin(16, 2);
lcd.setCursor(3,0);
lcd.print("RTC Clock");
delay(3000);
lcd.clear();
rtc.begin();
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
void loop () {
lcd.clear();
lcd.setCursor(3,0);
lcd.print(now.day(), DEC);
lcd.print("/");….
…….
Code
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
LiquidCrystal lcd(8 ,6, 7,11,12,13);
void setup () {
lcd.begin(16, 2);
lcd.setCursor(3,0);
lcd.print("RTC Clock");
delay(3000);
lcd.clear();
rtc.begin();
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop () {
DateTime now = rtc.now();
lcd.clear();
lcd.setCursor(3,0);
Serial.print(now.year(), DEC);
Serial.print('/');
lcd.print(now.day(), DEC);
lcd.print("/");
lcd.print(now.month(), DEC);
lcd.print("/");
lcd.print(now.year(), DEC);
lcd.setCursor(1,5);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(",");
lcd.print(now.hour(), DEC);
lcd.print(":");
lcd.print(now.minute(), DEC);
lcd.print(":");
lcd.print(now.second(), DEC);
delay(1000);
}
15. INTERFACING
STEPPER MOTOR WITH
MSP430G2
In this instructional exercise we will Interface Stepper Motor utilizing
MSP430. The MSP-EXP430G2 is a Development Tool a.k.a LaunchPad
gave by the Texas Instruments to learn and rehearse on the most proficient
method to utilize their Microcontrollers. This board falls under the MSP430
Value Line classification where we can program all the MSP430
arrangement Microcontrollers. In the event that you are new to MSP, at that
point check our beginning with MSP430 instructional exercise.
Stepper Motor:
To check which wire is focused tapped or which is signal wire, you need to
look at obstruction of wires happening to the engine. In this way, those
wires, which are associated with a similar loop, has high obstruction esteem
when contrasted with opposition of focused tapped.
In above chart, on the off chance that we have checked obstruction
estimation of Blue and Yellow wires and opposition between them is more
than the incentive among Yellow and Red or Blue along with Red. In this
way, Red is focused Tapped wire.
We have beforehand interfaced Stepper Motor with different
Microcontrollers:
Most stepper engines will work just with the assistance of a driver module.
This is on the grounds that the controller module (For our situation MSP)
won't have the option to give enough current from its I/O pins for the
engine to work. So we will utilize an outer module like ULN2003 module
as stepper engine driver. There are a numerous kinds of driver module and
the rating of one will change dependent on the sort of engine utilized. The
essential guideline for all driver modules will be to source/sink enough ebb
and flow for the engine to work.
In this venture, we will utilize ULN2003 engine driver IC. Pin chart of IC is
given underneath:
We will utilize 4 info and 4 yield port if IC.
Materials Required:
MSP430
ULN2003 IC
Wires
Breadboard
Circuit Diagram:
In above graph, RED wire of stepper isn't associated with PIN5 of IC .It
must be associated with 5V. Shading code of your Stepper engine might be
unique in relation to the hues given in the circuit chart. In this way,
interface the wires in case of checking the right sign wires.
We will compose our code utilizing Energia IDE. It is same as Arduino IDE
and simple to utilize. Test code for driving the stepper can similarly be
found in model menu of Arduino IDE.
Pin Coils
Step
Energized Energized
Step
6 and 7 A and B
1
Step
7 and 8 B and C
2
Step
8 and 9 C and D
3
Step
9 and 6 D and A
4
Here, we will compose the MSP430 stepper engine code . The total
program can be found toward the finish of the instructional exercise barely
any significant lines are clarified underneath.
The quantity of steps per insurgency for our stepper engine was determined
to be 32; henceforth we enter that as appeared in the line underneath
Since we are utilizing the Stepper library, we can set the speed of the engine
utilizing the beneath line. The speed can run between 0 to 200 for 35BYJ46
stepper engines.
Mystepper.setSpeed(200);
Presently, to make the engine move one stage we can utilize the
accompanying line.
myStepper.step(STEPS);
Code
#include <Stepper.h>
const int STEPS = 32; // change this to fit the number of steps per
revolution
// for your motor
// initialize the stepper library on pins 6 through 9 or you can use any pins
on MSP430:
Stepper myStepper(STEPS, 6,7,8,9);
void setup() {
// set the speed at 200rpm or as you want:
myStepper.setSpeed(200);
}
void loop() {
myStepper.step(STEPS);
}
16. BEGINNING WITH
MSP430 UTILIZING CODE
COMPOSER STUDIO-
BLINKING A LED
The MSP-EXP430G2 is a Growth Tool a.k.a LaunchPad gave by the Texas
Instruments to learn and rehearse on the best way to utilize their
Microcontrollers. This board falls under the MSP430 Value Line class
where we can program all the MSP430 arrangement Microcontrollers.
Figuring out how to utilize TI Microcontrollers would be a powerful device
up in our sleeve since TI is extremely immense and has a wide verity of
MCU's to browse at a less serious cost.
We previously secured definite article on utilizing Energia IDE with
MSP430. Here we will find out about Code Composer Studio along with
how it is utilized to program MSP430. This instructional exercise is
composed for very fledglings and no equipment is required with the
exception of the MSP430 board and a PC. Toward the finish of this
instructional exercise we will have the option to Blink the installed LED of
MSP430.
It is possible that you can install entire programming utilizing web installer
or download arrangement/disconnected installer. This product is very
substantial around 1GB along these lines, you have to hold up until it
completed the process of downloading.
In case of installing the product, open it and introduce.
At the point when you click on arrangement, much the same as some other
programming you will be approached to concur terms along with conditions
along with to choose the establishment envelope. After that you require to
pick sheets for which you require to download documents. For our situation
we are utilizing MSP430 MCU, click on first choice. You can download
more than 1 board records.
In this way, how about we investigate the principal window that we will
view.
This is a straightforward interface where you can view Getting started menu
in which you can begin to make your venture, close to beginning there is a
Resource Explorer. This is a wonderful component of this product where
you can discover everything about a TI item like datasheets,
documentations, along with etc. There is no compelling reason to discover
datasheets on web, simply click on asset traveler and snap on the gadget
which you need to investigate after that you can see everything about the
item.
Making first Project in Code Composer Studio: Blink a LED:
Making Project in CCS:
Stage 1:- Click on File - > New - > CCS venture. As demonstrated as
follows
Stage 2:- Next, you require to pick MSP board that you are utilizing. I am
utilizing MSP430G2553 in this way, I will pick this as appeared.
Offer name to your task and snap on finish.
When you click on finish, another window will open with certain lines code
previously composed into it.
Composing Code in CCS:
How about we see the shape of the code that is now given. First line is our
header document which relies upon the variation that we pick while making
the undertaking. As I told I am utilizing MSP430G2553, so I'll rename the
header record to
#include<msp430g2553.h>
Next line is the fundamental capacity. In the primary capacity you will view
instatement of Watchdog clock. MSP430 along with other TI based
microcontroller has extraordinary kind of clock which is known as
Watchdog clock . Work of this clock is to rset the microcontroller when it
starts to hanging or quit giving reaction. In our code, we won't use
Watchdog clock since it is over the learner's viewpoint. At the point when
we ON the Microcontroller, guard dog clock is ON as a matter of course so
we require to OFF this clock by composing this line
P1DIR = 0x01;
Next, we require to set the specific pin of specific port as high or low. For
this reason we require to utilize P1OUT register, 1 for high while 0 for low.
At first, I do the LED ON by setting BIT0 as 1 different stays zero.
P1OUT=0b00000001 ;
P1OUT = 0x01; // in hexadecimal
Unsigned int i;
To start with, we will make PIN0 HIGH and give some defer utilizing FOR
circle after that do the PIN LOW. In this way, we get flickering impact. We
compose program this way:
You can compose this code in another manner too. You can utilize
BITWISE administrator to lessen lines of code. There are OR, and XOR
bitwise administrators accessible. You can utilize XOR administrator (^) .
XOR activity gives 1 when the 2 bits are equivalent like 1 and 1, 0 and 0
.We compose it like this
P1OUT ^= 0x01;
which implies P1OUT = P1OUT xor 0b00000001;
In this way, at first we introduce P1OUT as 0b00000001, in the event that
we take xor activity with 0b00000001, yield will be 0b00000000 methods
our LED will be OFF. After this we put for circle for defer reason.
while (1)
Complete program for CCS is given toward the finish of the page. So our
code is prepared to consume in MSP430. In this way, interface MSP with
your PC utilizing USB link.
Presently, we require to incorporate/form our code, for this snap on Project
- > Build All. Check the report of aggregation in the comfort box at the base
of the window. It will show "Fabricate Finished".
It's a great opportunity to transfer the program. Snap on Run - > Debug. In
the wake of tapping on troubleshoot, you will get a window identified with
power sparing, simply click on continue. In investigate choice go to Run-
>Resume. On the off chance that your alternatives are blanked out, no
compelling reason to stress, go to View->Debug and afterward again go to
Run->Resume.
When you fixed the code, your program is transferred in the MSP. An easy
route path is to just tap the play/stop like catch on the screen. The
investigate screen will resemble, as given underneath
Whenever LED isn't squinting at that point Reset the board or associate the
USB again.
SO this is the means by which you can compose a basic program in Code
Composer Studio to squint a LED utilizing MSP430.
Code
#include <msp430g2553.h> // header file that depends upon your board
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
P1DIR = 0X01; //Declare PIN0 OF PORT 1 AS OUTPUT
P1OUT = 0X01; //MAKE PIN0 HIGH INITIALLY
unsigned int i; //Delay variable
while(1)
{
P1OUT ^=0X01; ////toggle the bits
for(i=0;i<20000;i++){ // delay till you make LED LOW HIGH
}
}
return 0;
}
17. INTERFACING SERVO
MOTOR WITH MSP430G2
In this instructional exercise we will find out about Servo Motor and How
to interface Servo with MSP430. The MSP-EXP430G2 is a Development
Tool a.k.a LaunchPad gave by the Texas Instruments to learn and rehearse
on the most proficient method to utilize their Microcontrollers. This board
falls under the MSP430 Value Line class where we can program all the
MSP430 arrangement Microcontrollers. On the off chance that you are new
to MSP, at that point check our beginning with MSP430 instructional
exercise.
For the pole to be moved to 12o clock the ON time of sign must be 1.5ms
and OFF time ought to be 16.5ms. This proportion is decoded by control
framework in servo and it alters the position dependent on it. This PWM in
here is created by utilizing MSP430. Become familiar with creating PWM
with MSP430 here.
Before Connecting Servo to MSP430, you can test your servo with the
assistance of this Servo Motor Tester Circuit. Likewise check our beneath
Servo activities:
Servo Motor Manage utilizing Arduino
Materials Required:
MSP430
SG90 servo
Male-Female wires
void loop()
{
for(angle = 0; angle< 180; angle++) // goes from 0 degrees to 180
degrees
{ // in steps of 1 degree
Sg90servo.write(angle); // tell servo to go to position in variable
'angle’
delay(20); // waits 20ms for the servo to reach the position
}
for(angle = 180;angle>=1; angle--) // goes from 180 degrees to 0
degrees
{
Sg90servo.write(angle); // tell servo to go to position in variable
'angle'
delay(20); // waits 20ms for the servo to reach the position
}
}
18. HEARTBEAT WIDTH
MODULATION (PWM)
UTILIZING MSP430G2:
CONTROLLING
BRIGHTNESS OF LED
This instructional exercise is a piece of arrangement of MSP430G2
LaunchPad instructional exercises in which we are figuring out how to
utilize the MSP430G2 LaunchPad from Texas Instruments. So far we have
taken in the nuts and bolts of the board and have secured how to peruse
simple voltage, interface LCD with MSP430G2 and so on. Presently we
continue with the subsequent stage of finding out about PWM in
MSP430G2. We will do that by controlling the splendor of a LED by
fluctuating the potentiometer. So the potentiometer will be joined to a
simple pin of the MSP430 to peruse its simple voltage, thus it is prescribed
to know experience the ADC instructional exercise before continuing.
The level of time wherein the PWM signal stays HIGH (on schedule) is
called as obligation cycle. In case the sign is consistently ON it is in 100%
obligation cycle and in case it is constantly off it is 0% obligation cycle.
Obligation Cycle =Turn ON schedule/(Turn ON time + Turn OFF time)
Recurrence of a PWM:
The recurrence of a PWM signal decides how quick a PWM finishes one
period. One Period is finished ON along with OFF of a PWM signal as
appeared in the above figure. In our instructional exercise the recurrence be
500Hz as it is the default esteem set by the Energia IDE.
There is plenty of uses for PWM flags continuously, yet to give you a
thought the PWM sign can be utilized to control servo Motors and can
likewise be changed over to Analog voltage which can control the brilliance
of the splendor of a LED. We should gain proficiency with somewhat about
how that should be possible.
Here are not many PWM models with other Microcontroller:
So what essentially occurs here is that when the when the Pulse Width
Modulation signal is high the capacitor energizes however the resistor and
when the Pulse Width Modulation signal goes low the capacitor releases
through the put away charge. In this way we will consistently have a steady
voltage at the yield which will be corresponding to the PWM obligation
cycle.
In the diagram appeared over, the Yellow shaded one is the Pulse Width
Modulation signal and the blue shading one is the yield simple voltage. As
should be obvious the yield wave won't be an unadulterated DC wave yet it
should work for our application. In case you need unadulterated DC wave
for other kind of use you should plan an exchanging circuit.
Circuit Diagram:
The circuit chart is quite straightforward; it simply has a potentiometer and
a Resistor and capacitor to frame a RC circuit and the Led itself. The
potentiometer is utilized to give a simple voltage dependent on which the
Pulse Width Modulation signal obligation cycle can be managed. The yield
of the pot is associated with Pin P1.0 which can peruse simple voltages. At
that point we require to deliver a PWM signal, which should be possible by
utilizing the pin P1.2, this Pulse Width Modulation signal is then sent to the
RC channel circuit to change over the Pulse Width Modulation signal into
Analog Voltage which is then given to the Light Emitting Diode.
It is essential to comprehend that not all pin on the MSP board can peruse
simple voltage or can produce PWM pins. The particular pins which can do
the particular assignments are appeared in the figure beneath. Continuously
utilize this as a direction to choose your pins for programming.
Collect the total circuit as appeared above, you can utilize a breadboard and
scarcely any jumper wires and effectively make the associations. When the
associations are done my board looked like as demonstrated as follows.
Programming the MSP for PWM signal:
When the equipment is prepared we can begin with our programming. The
primary thing in a program is to pronounce the pins that we are gonna to
utilize. Here we are gonna to utilize the pin number 4 (P1.2) as our yield pin
since it can create PWM. So we make a variable and relegate the pin name
with the goal that it's anything but difficult to allude to it later in the
program. Complete program is given toward the end.
int PWMpin = 4; //We are using the 4th pin on the MSP module as
PWM pin
Next we come into the arrangement work. Whatever code is composed here
will be executed just a single time, here we pronounce that we are utilizing
this fourth pin as a yield pin since PWM is yield usefulness. Note that we
have utilized the variable PWMpin here rather than the number 4 with the
goal that the code looks progressively important
void setup() {
pinMode(PWMpin,OUTPUT); //The PEMpin is set as Outptut
At long last we get into the circle work. Whatever we compose here gets
executed over along with over. In this program we require to peruse the
simple voltage and create a PWM signal appropriately and this needs to
happen over along with over. So first we should begin by perusing the
simple voltage from the pin A0 since we have associated with
potentiometer to it.
Here we are perusing the worth utilizing the AanalogRead work, this
capacity will restore an incentive from 0-1024 dependent on the estimation
of voltage applied to the pin. We at that point store this incentive to a
variable called "val" as demonstrated as follows
When you have comprehended the equipment and code, the time has come
to have a great time with the working of the circuit. Transfer the code to the
MSP430G2 board and turn the potentiometer handle. As you turn the
handle the voltage on pin 2 will change which will be perused by the
microcontroller and as indicated by the voltage the PWM signs will be
created on pin 4. The more noteworthy the voltage, the more prominent will
be the obligation cycle and the other way around.
This PWM signal at that point gets changed over into simple voltage to
sparkle a LED. The brilliance of the LED is straightforwardly
corresponding to the PWM signal obligation cycle. Aside from the LED on
the breadboard you can likewise see the smd LED (red shading) changing
its splendor like the breadboard drove. This is LED is likewise associated
with a similar pin, yet it doesn't have a RC organize so it is really
glimmering extremely quick. You can shake the board in a dim space to
check its glimmering nature.
That is in support of now people, we have figured out how to utilize PWM
flags on MSP430G2 board, in our next instructional exercise we will figure
out the fact that it is so natural to control a servo engine utilizing the
equivalent PWM signals.
Code
int PWMpin = 4; //We are using the 4th pin on the MSP module as PWM
pin
void setup() {
pinMode(PWMpin,OUTPUT); //The PEMpin is set as Outptut
}
void loop() {
int val = analogRead(A0); // read the ADC value from pin A0
val = map(val, 0, 1023, 0, 255); //The ADC will give a value of 0-1023
convert it to 0-255
analogWrite(PWMpin,val); //Write that value to the PWM pin.
}
19. STEP BY STEP
INSTRUCTIONS TO
UTILIZE ADC IN
MSP430G2 - MEASURING
ANALOG VOLTAGE
One basic element that is utilized in pretty much every installed application
is the ADC module. These Analog to computerized Converters can peruse
voltage from simple sensors like Temperature sensor, Tilt sensor, Current
sensor, Flex sensor and substantially more. So in this instructional exercise
we will figure out how to utilize ADC in MSP430G2 to peruse Analog
voltages utilizing the Energia IDE. We will interface a little potentiometer
to MSP board along with supply a differing voltage to an Analog pin, read
the voltage along with show it on the Serial Monitor.
Trust me, it would barely take ten min to interface and program the
MSP430G2 to peruse Analog voltage. Yet, let us invest some energy in
understanding the ADC module in the MSP board so we will have the
option to utilize it adequately in the entirety of our up and coming ventures.
A microcontroller is a computerized gadget, which means it can see just 1's
and 0's. Be that as it may, in genuine world, nearly everything like
temperature, moistness, wind speed, and so on are simple in nature. So as to
connect with these simple modifies, the microcontroller utilizes a module
called Analog-to-Digital Converter. There are a wide range of sorts of ADC
modules accessible, the one utilized in our MSP is the SAR 8 channel 10-
piece ADC.
Progressive Approximation (SAR) ADC: The SAR ADC works with the
assistance of a comparator and some rationale discussions. This sort of
ADC utilizes a reference voltage (which is variable) and contrasts the
information voltage along with the reference voltage utilizing a comparator
and distinction, which will be an advanced yield, is spared from the Most
noteworthy piece (MSB). The speed of the correlation relies upon the Clock
recurrence (Fosc) on which the MSP is working.
10-piece Resolution: This ADC is a 8 channel 10 piece ADC. Here the
term 8 channel suggests that there are 8 ADC pins utilizing which we can
quantify simple voltage. The term 10-piece infers the goals of the ADC. 10-
piece implies 2 to the intensity of ten (210) which is 1024. This is the
quantity of test ventures for our ADC, so the scope of our ADC esteems
will be from 0 to 1023. The worth will increment from 0 to 1023 dependent
on the estimation of voltage per step, which can be determined utilizing the
underneath recipe
Note: By default in Energia the reference voltage will be set to Vcc (~3v),
you can shift the reference voltage by utilizing the analogReference()
alternative.
Likewise check how to interface ADC with different Microcontrollers:
Circuit Diagram:
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
Next, we incorporate the header document for the LCD show. This calls the
library which contains the code on how the MSP ought to speak with the
LCD. This library will be introduced in the Energia IDE as a matter of
course so you need not trouble including it. Likewise ensure the capacity
Liquid Crystal is called with the pin names that we simply characterized
previously.
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know
how we have connected the LCD
At long last, inside our boundless circle() work, we begin perusing the
voltage provided to the A7 pin. As we talked about as of now the
microcontroller is a computerized gadget and it can't peruse voltages level
straightforwardly. Utilizing SAR strategy the voltage level is mapped from
0 to 1024. These qualities are known as the ADC esteems, to get this ADC
esteem just utilize the accompanying line
For our situation we definitely realize that the ADC goals of our
microcontroller is 1024. The ADC esteem is additionally found in the past
line and put away the variable called val. The reference voltage is
equivalent to the voltage at which the microcontroller is working. At the
point when the MSP430 board is controlled by means of USB link then the
working voltage is 3.6V. You can likewise gauge the working voltage by
using a multimeter over the Vcc and ground nail to the load up. So the
above recipe fits into our case as demonstrated as follows
float voltage = (float(val)/1024) * 3.6; //formulae to convert the
ADC value to voltage
You may be mistaken for the line glide (val). This is utilized to modifies the
variable "val" from int information type to "drift" information type. This
transformation is required on the grounds that just in case we get the
aftereffect of val/1024 in drift we can duplicate it 3.6. In case the worth is
gotten in whole number it will consistently be 0 and the outcome will
likewise be zero. When we have determined the ADC worth and voltage, all
that is left is to show the outcome on the Liquid Crystal Display screen
which should be possible by utilizing the accompanying lines
lcd.print("ADC Val:");
lcd.print("Voltage:");
Here we have shown the estimation of ADC in the principal line and the
estimation of Voltage in the subsequent line. At long last we give a
postponement of 100 plant seconds and clear the LCD screen. This was the
worth will get refreshed for each 100 mils.
At last, we come down to the pleasant part, which is trying our program and
messing with it. Simply make the associations as appeared in the circuit
outline. I have utilized a little breadboard to make my associations and
utilized jumper wires to interface the breadboard to MSP430. When the
associations are done mine resembled this underneath.
At that point transfer the program which is offered underneath to the
MSP430 board through the Energia IDE. You must have the option to see
the introduction message on the LCD, if not change the difference of the
LCD utilizing the potentiometer until you view clear words. Likewise, have
a go at squeezing the reset button. In the event that things fill in true to
form, at that point you ought to have the option to see the accompanying
screen.
Presently shift the potentiometer and you ought to likewise observe the
voltage showed in the LCD getting fluctuated. Allow us to confirm in the
event that we are estimating the voltage effectively to do that, utilization a
multimeter to quantify the voltage over the focal point of the POT and the
ground. The voltage showed on the multimeter ought to be near the worth
shown on the LCD as appeared in the image beneath.
That is it, we have figured out how to quantify simple voltage utilizing
ADC of MSP430 board. Presently we can interface numerous simple
sensors with our load up to peruse ongoing parameters. Expectation you
comprehended the instructional exercise and delighted in learning it. We
should do up for lost time in another instructional exercise of MSP430 with
another new theme.
Code
/*
* Reading Analog Voltage with MSP430 using Energia
*/
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#include <LiquidCrystal.h> //This librarey is insatlled by default along with
IDE
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how
we have connected the LCD
void setup() {
lcd.begin(16, 2); //We are using a 16*2 LCD display
lcd.setCursor (0,0); //Place the cursor at 1st row 1st column
lcd.print("MSP430G2553"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row
lcd.print("-Hello_world"); //Display a intro message
}
20. INTERFACING LCD
WITH MSP430G2
LAUNCHPAD
This is the third instructional exercise in the arrangement of instructional
exercises where we are figuring out how to program the MSP430G2
LaunchPad utilizing the Energia IDE. In our past instructional exercise, we
find out how to manage the Digital Input and Output nails to our MSP
board. In this instructional exercise, we will find out how to interface a
LCD with the board so we can show valuable data.
The LCD that we are utilizing in this task is the most usually utilized 16×2
Dot grid LCD show a.k.an Alphanumeric Displays. A large portion of us
would have gone over this either through open PCOs or different hardware
ventures. A presentation like this will come in exceptionally helpful for our
future instructional exercises to show information and other troubleshooting
data. Interfacing this Liquid Crystal Display with MSP430 is simple,
because of the library accessible. So we should make a plunge!!
Materials Required:
Associating wires
Energia IDE
As told before the Energia IDE gives an excellent library which makes the
interfacing a bit of cake and consequently it's not compulsory to know
anything about the showcase module. Be that as it may, would didn't it be
intriguing to show what we are utilizing!!
The name 16×2 infers that the showcase has 16 Columns and 2 Rows,
which together (16*2) structures 32 boxes. One single box would look like
this in the image underneath
A solitary box has 40 pixels (specks) with a lattice request of 5 Rows and 8
sections, these 40 pixels together structures one character. So also, 32
characters can be shown utilizing all the containers. Presently lets
investigate the pinouts.
The LCD has a sum of 16 Pins, as appeared above, they are divided into
four gatherings like as follows
Source Pins (1, 2 along with 3): These pins source the force and
differentiation level for the showcase
Control Pins (4, 5 along with 6): These pins sets/controls the registers in
the LCD interfacing IC (more this can be found in connect beneath)
Information/Command Pins (7 to 14): These pins give the information of
what data ought to be shown on the LCD.
Driven pins (15 and 16): These pins are utilized to sparkle the backdrop
illumination of LCD if necessary (discretionary).
Out of all these 16 pins, just 10 pins are to be utilized obligatory for the best
possible working of the LCD in the event that you need to find out about
these LCD show bounce to this LCD article.
The total circuit chart to interface a 16×2 Dot network LCD show with
MSP430G2 is demonstrated as follows.
Note: Do not associate loads that may devour more than 50mA to this 5V
pin s it may broil your USB port.
In case you are not keen on binding basically utilize any +5V controlled
stock and force the LCD, considering all, ensure you associate the ground
of your capacity supply to the ground of the MSP board.
When you are finished with the +5V pin interfacing different pins are
practically direct. Since our equipment is prepared, how about we proceed
onward to the product part.
You can infer that we have associated the LCD in accordance with the
accompanying table
Vss Ground
R/W Ground
Pin 3 of
Enable
MSP
Pin 4 of
D4
MSP
Pin 5 of
D5
MSP
Pin 6 of
D6
MSP
Pin 7 of
D7
MSP
In view of this current how about we begin characterizing the LCD pins
utilized in our program. We will name each stick with a progressively
significant name so we can utilize it effectively later.
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#include <LiquidCrystal.h>
The subsequent stage is to specify the pins to which the LCD is associated
with, as we have just named it utilizing the #define we can now basically
make reference to the names of the LCD pins. Ensure a similar request is
followed.
Presently let us move into the void arrangement() work. There are such a
large number of sorts of LCD shows differing in size and nature, the one
that we are utilizing is 16*2 so how about we indicate that in our program
lcd.begin(16, 2);
lcd.setCursor (0,0);
lcd.clear();
So the total void arrangement() capacity would look something like this.
void setup() {
Next, inside our void circle() work, we should keep augmenting a number
for each 500ms and show the number in the LCD. This number tests and is
instated to 1 as demonstrated as follows
delay(500);
Increasing a variable should be possible by test++, the rest all are as of now
clarified. The total code inside the void circle is demonstrated as follows
void loop() {
delay(500);
test++;
When your equipment and code is prepared, basically associate your board
the PC and transfer the code as we did in instructional exercise one. When
the code is transferred you should see the presentation demonstrating the
accompanying.
Following two seconds, the showcase screen will change from arrangement
to circle and begin augmenting the variable and show on the screen as
demonstrated the underneath picture.
Feel free to have a go at changing what's being shown on the LCD and play
with it. Expectation you comprehended the instructional exercise and got
the hang of something valuable structure it.
Code
/*
* Interfacing 16*2 LCD with MSP430G2553 in 4-bit mode using Energia
*/
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#include <LiquidCrystal.h> //This librarey is insatlled by default along with
IDE
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how
we have connected the LCD
void setup() {
lcd.begin(16, 2); //We are using a 16*2 LCD display
lcd.setCursor (0,0); //Place the cursor at 1st row 1st column
lcd.print("MSP430G2553"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row
lcd.print("-Hello_world"); //Display a intro message
delay(2000); //Wait for display to show info
lcd.clear(); //Then clean it
}
int test =1;
void loop() {
lcd.print("LCD with MSP"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to column 0, line 1
lcd.print(test); //Display a intro message
delay(500);
lcd.clear(); //Then clean it
test++;
}
THANK YOU