Tuesday 6 January 2015

Fleet Management System

Sorry it took me a long time to post this, this is actually our thesis, The Fleet management System. It composes of all the tutorial I made with GSM and GPS modules. This is the summation of all the projects I made along with my thesis partner Areo joseph Paolo Bartolome. 

Introduction:

This research basically focuses on the development of a system that monitors vehicles in Mindanao area and its fuel consumption. More specifically, the system will:
1.      Secure the Global Positioning System (GPS) device installed in the vehicle.
1.1              The driver cannot disable and manipulate the GPS device.
1.2              The ignition of the vehicle will be disabled if the F.M.S. device is removed improperly.
1.3              The registered owner can enable and disable the GPS through the use of the GSM.
1.4              The registered owner can disable the vehicle’s power through the system with a delay of 30 seconds.
1.5              The device will be powered from the vehicle’s battery.
2.      Transmit information from its current location to the monitoring station. The device can do the following:
2.1              Locates the vehicle’s position within Mindanao area by the use of the GPS module.
2.2              Transmits data to the monitoring station by the use of the GSM module.
2.3              Transmits security status information of the vehicle.
2.4              Sends the collected data in real-time.
3.      Receive the collected information from the transmitter to the monitoring station. The device can do the following:
3.1              Receives the vehicle’s location through the use of the GSM module.
3.2              Stores the received data in a database.
3.3              Calculates the distance travelled by the vehicle.
4.      Secure an access user code only for the registered owner.
4.1              Registered vehicle can be monitored only by the registered owner.
4.2              Registered owner can access the system through an internet connection.
4.3              Vehicle information will be secured with a unique password for each of the registered owner.
5.      Displays the collected data in the system.
5.1              Vehicle’s location will be displayed on an electronic map in line with Google Earth map.
5.2              Displays the calculation of fuel consumption, travelled distance, and vehicle’s status.
5.3              Receive and stores the data.


Circuit Image:





Fleet Management Video:



Sunday 19 January 2014

Gizduino (Arduino Clone) & GSM Shield Integration Test (Receive SMS)

Hello There! This topic is about my integration test between the GSM/GPRS Shield with the Gizduino for my research proposal. Gizduino is basically and Arduino Clone that I bought from E-gizmo. (Gizduino, an Arduino clone)


The type of Gizduino I used is the v4.0 which is basically the latest KIT they have as of January 2014. The type of microcontroller it comprises is ATmega 168 and ATmega 328, but for this project, I bought the ATmega 328 since it has a 

higher RAM.

The image shown below is the Gizduino (LEFT) and the GSM/GPRS Shield (RIGHT).




In the next image, I mounted the GSM/GPRS Shield to the Gizduino.




In order for this to work, I downloaded an Arduino Sketch Software. The Arduino Software is free, open source, and available for Windows, Mac OS and Linux. You can download the Arduino IDE from their website.



The image shown below is the Arduino Sketch Environment.



Here is the link for learning more about the Arduino Sketch Environment

Here is the program code I have made:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
char number[]="ur cellphone number here";
char message[180];
char pos;
char *p;

void setup()                      //declaring inputs and outputs
{
 Serial.begin(9600);              //initiate gizduino witha baud rate of 9600
 pinMode(7, OUTPUT);              //output for turning LED ON or OFF

 if (gsm.begin(9600))             //condition if gsm is initialized
 Serial.println("\nstatus=READY");     //displays "ready" on the serial monitor if gsm is ready
 else Serial.println("\nstatus=IDLE"); //otherwise displays "idle" on the serial monitor if gsm is not found
};

void loop()     //looping of the program
{
       pos=sms.IsSMSPresent(SMS_UNREAD);  //save to variable if there is an SMS
       Serial.println((int)pos);          //display position number (a.k.a index) of the message
       if((int)pos>0&&(int)pos<=20)       //if message from 0-20 is found
              {                   
               Serial.print("Message Received, INBOX=");  //display an output on the serial monitor
               Serial.println((int)pos);                  //display the position/index of the message
               message[0]='\0';                           //display '0' if no messages found
               sms.GetSMS((int)pos,number,message,180);   //get position/index, number of sender, and text message
               Serial.println(message);                   //display the text on serial monitor
               if(strstr(message, "ON")) digitalWrite(7,HIGH);   //if message 'ON' is received, LED is ON
               if(strstr(message, "OFF")) digitalWrite(7,LOW);   //if message 'OFF' is received, LED is OFF
               sms.DeleteSMS((int)pos);                          //after reading, delete SMS
                }
 delay(5000);                             //delay of 5seconds per loop
};

NOTE:
-->But before you would be able to run this program, download the GSM_Library and paste it in the Arduino libraries located on your Arduino folder in order to have this program running successfully.

-->Also, be sure to set the mode of the GSM/GPRS Shield to USART, and not UART. There is a hardware switch located on the top of the GSM/GPRS Shield Board.

Once the program is uploaded, you are good to GO!

A video shown below is the sample actual presentation of the implemented program I made.
(This was my first time to use an Arduino Kit and Arduino Sketch Environment)





The next image shown below is the combined circuit of the GSM/GPRS Shield and the Gizduino with their own regulated power supply from a 12VDC input into a 5VDC and a 9VDC output. The 5VDC source would be plugged into the GSM/GPRS Shield and the 9VDC source would be plugged into the Gizduino. 

GSM/GPRS Shield and Gizduino Circuit combined

Powered ON image of the GSM/GPRS Shield and Gizduino Circuit combined

The regulator transistors that were used are the LM7809 and the LM350. LM7809 is a 1A/9V regulator for the Gizduino source, since the Gizduino must have an input from 8VDC-10VDC. The GSM/GPRS Shield is powered by the LM350. The LM350 is an adjustable voltage regulator from 3VDC-33VDC of 3A. I created a circuit in such a way that I am able to produce an output of only 5VDC for the GSM/GPRS Shield. (You can check the LM350 pdf for the circuit and its formula for the desired output voltage you would prefer to have: LM350 Datasheet)

Here is an actual video footage in testing this combined circuit:



Project made by: Kirk Benedict P. Macaraeg

Thursday 5 December 2013

GPS Shield with PIC16F877A

Hello there! Here is another integration test for my research proposal (Fleet Management System) that composes of a GPS Shield. In this project, I have integrated the GPS Shield with the PIC16F877A and a 2x16 LCD. The information from the GPS Satellite, specifically the latitude and the longitude, would be captured and will be displayed on the 2X16 LCD.

The image shown below is the GPS Shield module that I used for my project. You may be able to purchase this module at http://www.e-gizmo.com/KIT/gps%20shield.html for 1,385 pesos.


An image below that is shown is the circuit diagram for the connection of the devices which are the GPS Shield, the MCU PIC16F877A and lastly the 2x16 LCD.



As I said earlier, I used a "2x16" LCD and the image shown here is a"2x14" LCD. This is because i used proteus for circuit design and simulation and the 15 and 16 are neglected due to the built in function of the device. In actual, the pin 15 is the anode and the 16 is the cathode. The purpose of pin 15 and 16 is that it turns on the LED/light background of the LCD. To attain this, simply connect pin 15 of the LCD to the 5VDC source and the pin 16 to the GND.

As for the TX and RX connection, only connect the Rx of the GPS to the Rx of the PIC16F877A, We will neglect the TX since we would only retrieve the information of the latitude and longitude. 

Here is the program code I have made for this project:
NOTE: The programming software i used is the MikroC PIC Pro. In order for this to work, you need to download the MikroC PIC Pro and download the NMEA library function in order for you to be able to utilize some functions used for the GPS Shield. The NMEA library can be downloaded here : http://www.libstock.com/projects/view/695/nmea-library


/*---------------------------FLEET MANAGEMENT SYSTEM-------------------------
         MikroC Programming by Kirk
----------------------------------------------------------------------------*/

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections



char txt5[] = "GPS with PIC877A";
char txt6[] = "F.M.S.";





// Variables
int i = 0;
int received = 0;
char DataType[] = "GPXXX";
char NMEA[] = "$xxxxx,xxxxxxxxx,xxxx.xxx,x,xxxxx.xxx,x,x,xx,x.x,xxx.x,x,xx.x,x,,*xx";
char receive;
// End Variables

void main(){

  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,1,txt5);                 // Write text in first row
  Lcd_Out(2,6,txt6);                 //displays txt5
  Delay_ms(5000);                    //displays txt6
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Delay_ms(250);


  UART1_Init(9600);         // Initialize UART for GPS board connectivity
 //LCD Stuff
 LCD_Out(1,1, "Lat:                 ");
 LCD_Out(2,1, "Lon:                 ");

 LCD_Chr(1, 7, 0x20);  //Degree Character
 //LCD_Chr(2, 8, 0xB0);  //Degree Character
 LCD_Chr(2, 8, 0x20);  //' Character
 LCD_Chr(2, 11, 0x2E);  //' Character

 //End of LCD

  while(1) {
  if (UART1_Data_Ready() == 1) {
   receive = UART1_Read();
   if (receive == '$')  // Check if sentence begins.
   {
        received = 0;
        do{
          if (UART1_Data_Ready() == 1)
          {
           UART1_Read_Text(DataType, ",", 10);  // Capture GPXXX word
           received = 1;
          }
        } while(received == 0);
        // If it is GPGGA Data, then acquire it.
        if ((DataType[2] == 'G') && (DataType[3] == 'G') && (DataType[4] == 'A'))
        {
          received = 0;
          do{
            if (UART1_Data_Ready() == 1)
            {
             UART1_Read_Text(NMEA, "*", 100);   // Stop at *XX checksum data
             received = 1;
            }
          } while(received == 0);
          // Fill LCD with relevant data     */
          // Latitude
          LCD_Chr(1, 5, NMEA[11]);
          LCD_Chr(1, 6, NMEA[12]);

          LCD_Chr(1, 8, NMEA[13]);
          LCD_Chr(1, 9, NMEA[14]);

          LCD_Chr(1, 10, NMEA[15]);
          LCD_Chr(1, 11, NMEA[16]);
          LCD_Chr(1, 12, NMEA[17]);
          LCD_Chr(1, 13, NMEA[18]);
          LCD_Chr(1, 14, NMEA[19]);
          //LCD_Chr(1, 15, NMEA[20]);
          LCD_Chr(1, 16, NMEA[21]);

          // Longitude
          LCD_Chr(2, 5, NMEA[23]);
          LCD_Chr(2, 6, NMEA[24]);
          LCD_Chr(2, 7, NMEA[25]);

          LCD_Chr(2, 9, NMEA[26]);
          LCD_Chr(2, 10, NMEA[27]);

          LCD_Chr(2, 12, NMEA[29]);
          LCD_Chr(2, 13, NMEA[30]);
          LCD_Chr(2, 14, NMEA[31]);
          LCD_Chr(2, 15, NMEA[32]);
          LCD_Chr(2, 16, NMEA[34]);

          //LCD_Chr(2, 15, NMEA[35]);
          }
           receive = "x";
   }
   }
   }
   }

Here are some images of this project and its actual video footage:








Project made by: Kirk Benedict P. Macaraeg

GSM Shield SIM900D with PIC16F877A

Hi there!..So this is my partial project for my research proposal on how I integrated my GSM Shield module, specifically the SIM900D, with the PIC16F877A microcontroller unit. In this project, I only constructed a sending process function by using a push-button. Therefore, every time I would press the push-button, a fixed message would be sent to a specific recipient. This is only a basic construction of understanding the GSM Shield function and its AT Commands.

The image that is shown below is the GSM Shield SIM900D that I used for my project. You can purchase this at http://www.e-gizmo.com/KIT/gsm%20shield.html for about 1,995.00 pesos.



Features and Specifications of GSM/GPRS Shield:
 • Industry proven SIMCOM SIM900D Module 
• Buffered UART provides additional layer of protection
• Fused power input
• On board LDO voltage regulator
• UART/SUART switch selectable port (gizDuino)
• On board manual power switch
• SIM Card Holder


Here is the circuit I made by integrating the PIC16F877A and the GSM Shield:




Be sure to connect the Tx of the GSM Shield to the Tx of the PIC and the Rx of the GSM Shield to the Rx of the PIC. Take note also that the GSM needs to be powered by a 1.5A and 5VDC supply and its ground must be COMMON to the ground of the circuit.

For the PIC16F877A programming code, I used a programming language which is the "MikroC Pro for PIC". MikroC has an awesome and numerous features of built-in libraries along with examples of small programs in order for the user to simply understand the functions. Here is my program code: (REMEMBER: This is only a sending process, it does not consist of a receiving capability yet.)



/*---------------------------FLEET MANAGEMENT SYSTEM-------------------------
      MikroC Programming by Kirk Macaraeg
-------------------------------------------------------------------------------------------*/

void GSM_Init(void);

void GSM_send(void);
void GSM_receive(void);

void main(void) {


TRISD=0b00000010;     //RD1 is an input

PORTD=0x00;                //The rest of RD pins are output

UART1_Init(9600);     //Initialize and establish communication at 9600 bps

Delay_ms(250);
UART1_Write_Text("AT+CMGD=1");  //Delete mesage sotred in inbox1
UART1_Write(0x0D);              //<CR>

while(1)

{

if(PORTD.F1==0)           //if pushbutton is pressed

{
  PORTD.F0=0;               //LED OFF

  GSM_Init();                   //calls GSM_Init function

  GSM_send();                 //calls GSM_send function

  PORTD.F0=1;                //LED1 blinks 3 times

  Delay_ms(250);

  PORTD.F0=0;

  Delay_ms(250);

  PORTD.F0=1;

  Delay_ms(250);

  PORTD.F0=0;
  Delay_ms(250);

  PORTD.F0=1;

  Delay_ms(250);

  PORTD.F0=0;

  Delay_ms(250);
  }


 }

}
/*----------------------------------------------------------------------
                      GSM INITIALIZING PROCESS
----------------------------------------------------------------------*/

void GSM_Init(void)

{
  UART1_Write_Text("AT\r");
  UART1_Write_Text("AT+CMGF=1");      //Text Mode
  UART1_Write(0x0D);                                //<CR>
  Delay_ms(250);
  UART1_Write_Text("AT+CMEE=2");      //Write Mode
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(250);
  UART1_Write_Text("AT+CFUN=1");      //Full Phone Functionality
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(250);
}

/*----------------------------------------------------------------------

                       GSM SENDING PROCESS
----------------------------------------------------------------------*/

void GSM_send(void)

{
  UART1_Write_Text("AT+CMGS=\"09429185691\"");    //send SMS to this number
  UART1_Write(0x0D);                              //<CR>
  Delay_ms(250);
  UART1_Write_Text("F.M.S. GSM with PIC Testing\r");  //message to be sent
  UART1_Write(0x1A);                                  //<CTRL+Z>
  Delay_ms(250);

}


Here is an actual video of what I have made:





Project made by: Kirk Benedict P. Macaraeg

Friday 11 October 2013

Robotic Arm (Gripper) [Using servo motor with 555 timer]

One of the requirements for the 1st semester in our Robotics subject is to create a robotic arm or either a gripper. Our group decided to create a robotic arm but we didn't have enough time and resources to create a robotic arm, instead we made a gripper/end-effector. Our gripper is controlled by a servo motor. The servo motor is driven by a 555 timer. We connected two tact-switch for the gripping functionality of the gripper.

So what is a servo motor and how was it controlled by the 555 timer?


A Servo motor is a small device that incorporates a three wire DC motor, a gear train, a potentiometer, an integrated circuit, and an output shaft bearing. Of the three wires that stick out from the motor casing, one is for power, one is for ground, and one is a control input line. The shaft of the servo can be positioned to specific angular positions by sending a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. If the coded signal changes, then the angular position of the shaft changes.


Here is an image of a servo-motor:

This is a special kind of motor, often used as the "muscles" of a robot. A servomotor takes a stream of pulses, where the width of each pulse controls the absolute position of the servo. This allows for precise positioning of motor turns. To do this, we're going to use a 555 timer in "Astable" mode - this will run it as an oscillator.



Here is the circuit diagram used for controlling the servo motor:





The two switches controls the rotation of the servo. The circuit is powered by a 7V DC source.



Here are some images of our Robotic Arm [Gripper]:










The output of our gripper was not well-designed due to limitation of resources and time. But at least we pulled out something like this. All of the parts from the gripper are recycled parts as well as the servo motor. The servo motor was found in a garbage can, believe it or not. LOL (-_~)

Here is a unit test video of our Gripper:

Project Made By:
Kirk Benedict P. Macaraeg
Jonald B. Sarmiento
Lindsey Baguio

Wednesday 2 October 2013

SUMOBOT


This is basically our project on our mechatronics subject at NDDU. We were tasked to create a sumobot for the final semester. This was an awesome experience to have especially in designing and building a sumobot. It was very challenging to create such thing our from you imagination. So here are the steps of how I assembled my sumobot.

First step: CREATING THE SUMOBOT BUMPER

(Front View)

3D View

Bottom View

Side View

Pictures which are shown above are my dimensions for the bumper design for pushing other sumobot out from the battle arena.

Second Step: CIRCUIT DESIGN

SUMOBOT CIRCUIT DESIGN

The image shown above is my personal circuit design. I utilized a PIC16F877A microcontroller. There were 4 CNY70 sensors that were implemented. 3 sensors for sensing the opponent and the other sensor for sensing the arena track in order for my sumobot to avoid in getting out of the arena. 

Program code:
#include <pic.h>
#include "delay.h"

__CONFIG(HS & WDTDIS & PWRTDIS & UNPROTECT & LVPDIS);

#define LeftCol RB0
#define BackCol RB1
#define RightCol RB2
#define FrontLine RB3
#define Forward 0x05
#define Left 0x06
#define Right 0x09
#define Backward 0x0A
#define Stop 0x00
#define Full 0b11111001
#define Reduce 0b11000111



void PWMInit(void);

void main()
{
TRISB=0xFF;
TRISA=0x00;
PORTB=0x00;
ADCON1=0x06;
PWMInit();
capture_init();
TRISC=0x00;
RC1=1;

while(1)
{

if(FrontLine==1)
{
if(LeftCol==1)
{
PORTA=Left;CCPR2L=Full;
}
else if(RightCol==1)
{
PORTA=Right;CCPR2L=Full;
}
else if(BackCol==1)
{
PORTA=Backward;CCPR2L=Full;
}
else if(LeftCol==0 && RightCol==0 && BackCol==0)
{
PORTA=Forward;CCPR2L=Full;
}
}
else if(FrontLine==0)
{

PORTA=Backward;
DelayMs(250);
DelayMs(250);
PORTA=Stop;
DelayMs(250);
PORTA=Right;
DelayMs(250);
DelayMs(250);
DelayMs(250);
PORTA=Stop;
DelayMs(250);
PORTA=Forward;
DelayMs(250);
DelayMs(250);
}
}
}

//Initialize CCP1 & CCP2 for PWM Operation
void PWMInit(void)
{
TMR2 = 0x00; //Clear TMR2 & CPP related registers
T2CON = 0x00;
CCP2CON = 0x00;
PR2 = 249; //Set PWM freq = 5Khz
CCPR2L = Full; //Set PWM2 Duty Cycle
TRISC2 =0; //Enable PWM1 output pin
TRISC1 = 0; //Enable PWM2 output pin
T2CKPS1 = 0; //Prescaler = 4
T2CKPS0 = 1;
CCP1CON-0x0C; //CCP1 in PWM mode
CCP2CON = 0x0C; //CCP2 in PWM mode
TMR2ON = 1; //Enable TMR2. PWM signal is generated.
return;
}

Third Step: TESTING & TROUBLESHOOTING

Well, as an electronics engineering student, one of the most challenging and fun thing to do is testing the unit and troubleshooting if there may seem to be no full functionality of the unit. Troubleshooting enhances one's skill in order to accomplish the desired goal. It may seem tiring but the accomplishment is worth striving for. So never give up if you may have messed up in creating you sumobot or if the result may not be fully functional, because as an ECE, we should be patient and persistent in troubleshooting things. =)


HERE ARE SOME IMAGES OF MY SUMOBOT:



Here is the sample vid


THE RESULT?
I won with my SUMOBOT for the Championship!..  =)