Speaking Taxi meter

Speech assisted Taxi Meter

Project by Pranav Pralhad Sawant and Aditya Shrikant Kadam

Purpose and idea behind this project

In India, people most often use the public transport while going around places and Taxis are the most common medium. The fare of the Taxi is based on the duration of the journey which indirectly depends upon the distance covered. The Taxi union of India decides the distance fare ratio and thus the fare is calculated. However, the current meters used in India are mechanical and can be manipulated to read a different meter value than the real ones. Also, some taxi drivers even end up demanding more money from the visually impaired people, as they are not able to read the meter values and often end up paying more. This is also the case with the foreign tourists visiting India. Although, the tourists can read the meter value, they do not have access to the meter fare ratio and have to blindly pay what the taxi driver asks for. Moreover, when it comes to change in fare regulations, all the taxi meters need to be sometimes re-calibrated which is a very time consuming process, with the meters being mechanical. Our project aims to address these issues by making the meter mechanism completely automated by taking advantage of the vast expanding internet and embedded systems domain.

Modules used for accomplishing aims

  • DC motor : To replicate a rotating wheel of the taxi
  • IR sensor : To calculate the Number of revolutions of the wheel.
  • MBED chip : For integration of all the involved peripherals and logic implementation.
  • MicroSD card : For storing converted voice reading.
  • VS1053 : A mp3 encoder module necessary for encoding the mp3, in our case the text converted voice fare.
  • Audio Jack : A jack for facilitating connection to speakers.
  • Ethernet : To send a text (fare) to google translate service and get back a mp3 file(text to speech) containing the audio format of the fare.
  • LCD : To display the meter reading and the corresponding fare.

Block Diagram

600

Image

500

Video Demonstration

Connections

MBEDVS1053Headphone jack
3.3VVout
Micn
15RST
16DREQ
GPIO2
GPIO3
17Bsync
TX
RX
GndGnd
RightRSH
GbufGND
LeftTSH
GPIO1
GPIO0
6SO
5SI
7SCK
14CS


MicroSDMBED
CS8
DI11
VCC3.3V
SCK13
GNDGND
DO12


NetworkingMBED
P1TD1
P2TD-
P7RD+
P8RD-
P33.3V
P63.3V
GS1GND
GS2GND


LCDMBED
GND0V
VCC5V
VO1k resistor OV
RS10
RW0V
E18
D0
D1
D2
D3
D424
D523
D622
D721


IR sensorMBED
VCC5V
GND0V
Analog Signal19


SwitchesMBED
Switch1internal PullUp p9
Switch2internal PullUp p20
Switch3internal PullUp p30
Switch4internal PullUp p29


MBEDDual H BridgeDC MotorBattery
VMOT+
GNDGND-
VOUTVCC
P25PWMB
P26BIN2
P27BIN1
VOUT/STNDBY
B02BLACK
B01RED

Working

There are three switches for the meter.

  • Meter On
  • Meter off
  • Tell me the fare
    When the meter is turned on , the IR sensor close to the wheel starts measuring the number of revolutions of the wheel by using a base point on the wheel.Once the taxi covers the intended distance of the journey, the meter is switched off to stop counting the revolutions now. Now, based on the no of revolutions, the distance is calculated by using the formula : noOfRevolutions X circumferenceOfWheel. Now, based on the distance, the fare is calculated and the same is displayed on the LCD screen. The text format of the fare is then sent to the google text to speech conversion service via ethernet,which returns a mp3 file of the text converted speech. This mp3 file is then read out loud using the VS1053 encoder and audio jack module. Also, an additional switch is provided to replay the fare if the passenger wishes to. Thus, with this project we aim to make the complete meter an automated device.

Code

#include "mbed.h"
#include "VS1002.h"
#include "TextLCD.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
#include "DebounceIn.h"
#include "Motor.h"
#include <string>
#include<stdlib.h>
#define PI 3.14
#define DIAMETER 0.076                                    
#define MINIMUM_FARE 11
#define FARE_PER_KM 10

TextLCD fareDisplay(p10, p18, p24, p23, p22, p21 );
VS1002 audioDriver(p11, p12, p13, p8, "sd",
           p5, p6, p7, p14, p15,
           p16, p17, p20);
EthernetNetIf ethernet;                 
HTTPClient http;                   
AnalogIn sensorReading(p19);
DebounceIn setup(p9);
DebounceIn startMeter(p20);
DebounceIn stopMeter(p30);
DebounceIn playFare(p29);
Motor m(p25, p26, p27); 

void initializeAudioDriver()
{
#ifndef FS_ONLY
    audioDriver._RST = 1;
    audioDriver.cs_high();                                   
    audioDriver.sci_initialise();                            
    audioDriver.sci_write(0x00,(SM_SDINEW+SM_STREAM+SM_DIFF));
    audioDriver.sci_write(0x03, 0x9800);
    audioDriver.sdi_initialise();
#endif
}

float calculateFare(int noOfRevolutions)
{
    float distanceinKM;    
    distanceinKM = noOfRevolutions*PI*DIAMETER;//For Demo purposes we do not divide by 1000 as would be in real scenario.
    float fare;
    if(distanceinKM>1)
    fare = MINIMUM_FARE + FARE_PER_KM*(distanceinKM - 1); // Formula can be changed as per required or can be taken dynamically from a web server
    else
    fare = MINIMUM_FARE;
    return fare;
}


void convertFareToSpeech(float fare)
{
    string ttsURL=" http://translate.google.com/translate_tts?tl=en&q=Your+Fare+is+;+";
    char strFare[100];
    sprintf(strFare,"%d",(int)fare);
    ttsURL+=strFare; 
    ttsURL+="+Rupees+.+Thank+you+for+the+ride+.+Have+a+Nice+Day+.";
    //printf("%s\n",ttsURL);
    HTTPFile audioOutput("/sd/Fare.mp3");
    HTTPResult result = http.get(ttsURL.c_str(),&audioOutput);
    if(result!=HTTP_OK)
    {
          printf("Error during speech convrsion!! Error Number : %d\n", result);
    }
    else
    printf("Done\n");
    audioDriver.play_song("/sd/Fare.mp3");
    
}

void initialize_system()
{    
    setup.mode(PullUp);
    wait(0.001);
    startMeter.mode(PullUp);
    wait(0.001);
    stopMeter.mode(PullUp);
    wait(0.001);
    playFare.mode(PullUp);
    wait(0.001);
    wait(2);
    fareDisplay.printf("PRESS SETUP");
    printf("Press setup to continue.....\n");
}

int main()
{ 
    bool flag = false;
    int noOfRevolutions =0;
    float fare;
    bool isMeterStopped=false;
    
    initialize_system();
    
    while(setup==1){wait(0.1);}
    while(setup == 0){wait(0.1);}
    fareDisplay.cls();
    fareDisplay.printf("INITIALIZING...");

    initializeAudioDriver();        
    EthernetErr error = ethernet.setup();
    if(error)
    {
        printf("Error in correction. Error number: %d.\n", error);
        return -1;
    }
    printf(" Connection established\n");
    
    while(1)
    {
        fareDisplay.cls();
        fareDisplay.printf("START METER");
        printf("Press start to continue.....\n");
        while(startMeter==1){wait(0.1);}
        while(startMeter==0){wait(0.1);}
        int new_val = 0;
        int old_val =0;
        fareDisplay.cls();
        fareDisplay.printf("METER STARTED");
        {        
            m.speed(0.15); 
        }
        while(!isMeterStopped)
        {
            if(sensorReading>0.5)
            {
                flag=true;
                wait(0.1);
            }
            if(flag)
            {
                if(sensorReading<0.4)
                {
                    flag=false;
                    noOfRevolutions++;                     
                }
            }
            new_val = stopMeter;
            if ((new_val==0) && (old_val==1))
            {        
               isMeterStopped = true;
               fareDisplay.cls();
               fareDisplay.printf("METER STOPPED !!");           
               m.speed(0);
            }   
             old_val=new_val; 
             wait(0.1);
        }
        
         if(isMeterStopped)
         {
            isMeterStopped = false;
            fare = calculateFare(noOfRevolutions);
            fareDisplay.cls();
            fareDisplay.printf("The Fare is: %d",(int)fare);
            printf("The no of revolutions is: %d\n; The Fare is: %d\n",(int)noOfRevolutions,(int)fare);
            convertFareToSpeech(fare);
         }   
         bool isExit =false;
         while(1)
         {         
            while(playFare==1)
            {
                new_val = stopMeter;    
                if ((new_val==0) && (old_val==1))
                {  
                  isExit = true;      
                  break;
                }   
                 old_val=new_val; 
                 wait(0.2);
             }
            while(playFare==0){wait(0.1);}
            if(isExit)
            break;
            audioDriver.play_song("/sd/Fare.mp3");
            
         }
     }  
}


Import programLab3_VoiceMeter

12Oct2012MBEDLab3Project

Information

There was a VS1053 chip issue we found while implementing this project. Some VS1053 chips exhibit abnormal behavior and don't play the mp3 file at all. We checked the sparkfun site and found the same was mentioned there, as well in some forums. There is no software workaround for this and we had to use another working chip for the same. The hardware workaround if one has to implement,has been mentioned on sparkfun site(https://www.sparkfun.com/products/8954).

References

http://mbed.org/cookbook/MP3-Player
http://mbed.org/users/benglish6/notebook/universal-translator/
http://www.vsdsp-forum.com/phpbb/viewtopic.php?f=10&t=71


All wikipages