Project in progress
Android Guided Vehicle

Android Guided Vehicle © LGPL

A customizable vehicle which makes path decisions based on the commands given using an Android app for material movement in industries.

  • 3,487 views
  • 0 comments
  • 7 respects

Components and supplies

35942 ind frdm k82 %20freescale%20freedom%20development%20platform 365x255 no%20title v1 tws
NXP Kinetis Freedom Board with FlexIO
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
wheels (generic)
any pair of wheels which will fit in the chassis and the motor
×1
09670 01
SparkFun Dual H-Bridge motor drivers L298
×1
DC motor (generic)
×1
HC-SR04 Ultrasonic Distance Measuring Sensor Module
×1
11026 02
Jumper wires (generic)
×20
Digital IR transceiver module
×1

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)
09507 01
Soldering iron (generic)
plier and screwdriver

Apps and online services

About this project

Android guided vehicle is a project I have done for Flex Your Mind with Kinetis FlexIO contest. I made used of the NXP Freedom K82F Development Board which I was awarded and I've developed an Android app which sends the destination and direction to the Freedom Board (vehicle) via Bluetooth.

What is AGV (Automatic Guided Vehicle)

It is a mobile robot that follows markers or wires in the floor, or uses vision, magnets, or lasers for navigation. They are most often used in industrial applications to move materials around a manufacturing facility or warehouse. Application of the automatic guided vehicle has broadened during the late 20th century. the navigation is based on wiring, guide tapes, laser target navigation, vison guidance, nature targeting etc and the steering control, traffic control, path decisions are made using various complex algorithms and as a result the complexity and cost of the AGV is increased.

Getting Started to FRDM-K82F and Kinetis SDK (KSDK)

  • Download the Kinetis Design studio IDE and install it

Using Demo Apps

  • Browse to the SDK 'examples' folder of your SDK installation and select your board, the FRDM-K82F (<SDK_Install_Directory>/examples/frdmk82f).
  • Import any of the demo_app by using kinetis design studio (KDS).
  • Build the project.
  • Then by clicking the 'debug' icon in the bar enter into the debug configuration
  • Click the Debug button, it will upload the code to the FRDM board
  • It shows a prompt message and you are done .

Introduction

My motive is to make a small Android Guided Vehicle which performs the similar tasks of an AGV but the process involved in path decision, traffic control, controlling is simpler and cost required in building the vehicle is less and when it comes to the programming and electronic hardware requirement it's much simpler and reasonable accuracy can be obtained.

Black lines are painted as a replacement for magnetic tapes, reflective tapes, lasers, wires etc.. We can consider this Android Guided Vehicle as an intelligent line follower which also receives commands from the user or controller

The AGV's available in market are very expensive and it can be used efficiently only in big industries and it also requires proper installation of navigation systems. But our Android guided vehicle is less expensive when compared and can be used in smaller industries and in places where less transport of materials are involved

Role of NXP Freedom K82F Development Board

  • The Freedom Board controls Right, Left, Forward and Backward movement of the car by sending signals to the L298 motor driver.
  • I’ve added a Bluetooth module (HC-05) which is connected to the Freedom Board via UART interface, this HC-05 module receives data from the smartphone app.
  • IR transceiver pairs are connected to GPIO/Digital pins of the board so that the black line drawn on the ground can be sensed

The Android APP

The path for moving the materials is selected by the operator using the android app ie. the starting and ending points are sent to the vehicle as a pair of strings via bluetooth and each point is represented using a string as shown in the blocks

App Inventor is a cloud-based tool, which means you can build apps right in your web browser.

http://appinventor.mit.edu/explore/get-started.html

I've also uploaded the .aia file along with the .apk for this android app

Application

  • Repetitive movement of materials over a distance
  • Regular delivery of stable loads
  • Finished product handling
  • trailer loading

Code

work_in_progressC/C++
code to receive data via uart and send command to motor driver using GPIO
#include "board.h"
#include "fsl_flexio_uart_driver.h"
#include "fsl_clock_manager.h"
#include "fsl_lpuart_driver.h"
#include "fsl_debug_console.h"
// Standard C Included Files
#include <stdio.h>
// SDK Included Files
#include "board.h"
#include "gpio_pins.h"
#include "fsl_debug_console.h"


//GPIO

// Variables


volatile bool isButtonPress = false;

// Code

/*
 * Uses a switch to run a motor
 *
 * This function toogles motor when press the switch.
 */
int main(void)
{
    // Define gpio input pin config structure SW.
    gpio_input_pin_user_config_t inputPin[] = {
        {
            .pinName                       = BOARD_SW_GPIO,
            .config.isPullEnable           = true,
#if FSL_FEATURE_PORT_HAS_PULL_SELECTION
            .config.pullSelect             = kPortPullUp,
#endif
#if FSL_FEATURE_PORT_HAS_PASSIVE_FILTER
            .config.isPassiveFilterEnabled = false,
#endif
#if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
            .config.isDigitalFilterEnabled = false,
#endif
            .config.interrupt              = kPortIntFallingEdge,
        },
        {
            .pinName = GPIO_PINS_OUT_OF_RANGE,
        }
    };

    // Define gpio output pin config structure LED1.
    gpio_output_pin_user_config_t outputPin[] = {
        {
            .pinName              = kGpioM1,
            .config.outputLogic   = 0,
#if FSL_FEATURE_PORT_HAS_SLEW_RATE
            .config.slewRate      = kPortFastSlewRate,
#endif
#if FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
            .config.driveStrength = kPortHighDriveStrength,
#endif
        },
        {
            .pinName = GPIO_PINS_OUT_OF_RANGE,
        }
    };

    // Init hardware
    hardware_init();

    // Print a note to terminal.
    PRINTF("\r\n Press %s to turn on/off a motor\r\n",BOARD_SW_NAME);

    // Init motor, Switch.
    GPIO_DRV_Init(inputPin, outputPin);
    // Turn motor on.
    GPIO_DRV_ClearPinOutput(kGpioM1);

    while(1)
    {
        if(isButtonPress)
        {
            PRINTF(" %s is pressed \r\n",BOARD_SW_NAME);
            // Reset state of button.
            isButtonPress=false;
        }
    }
}

/*!
 * @brief Interrupt service fuction of switch.
 *
 * This function toogles motor
 */
void BOARD_SW_IRQ_HANDLER(void)
{
    // Clear external interrupt flag.
    GPIO_DRV_ClearPinIntFlag(BOARD_SW_GPIO);
    // Change state of button.
    isButtonPress = true;
    // Toggle motor
    GPIO_DRV_TogglePinOutput(kGpioM1);
}


//  Variables

static uint32_t s_flexioInstance;
flexio_uart_state_t uartState;
#define DATA_LENGTH         65
const uint8_t txBuff[] = "This data to transfer between FlexIO simulated UART and LPUART";
uint8_t rxBuff[DATA_LENGTH] = {0};
#if defined TWR_K80F150M || defined TWR_K81F150M || defined FRDM_K82F
#define COMM_UART_INSTANCE    0
#else
#define COMM_UART_INSTANCE    1
#endif

//  Codes


bool flexio_uart_compare(uint8_t *txBuff, uint8_t *rxBuff, uint32_t count)
{
    uint32_t i;
    /* Comapre source and sink data*/
    for (i = 0; i < count ; i++)
    {
        if (txBuff[i] != rxBuff[i])
        {
            return false;
        }
    }
    return true;
}
/*!
 * @brief reset a buffer.
 * @param source The pointer to the buffer
 * @param size of the buffer
 */
void flexio_uart_reset_buffer(uint8_t *txBuff, uint32_t count)
{
    uint32_t i;
    /* Comapre source and sink data*/
    for (i = 0; i < count ; i++)
    {
        txBuff[i] = 0;
    }
}
/*!
 * @brief Check send/receive blocking functionality
 *
 */
int main(void)
{
    lpuart_state_t lpuartStatePtr;
    s_flexioInstance = 0;
    /* Fill in FlexIO config data */
    flexio_user_config_t userConfig =
    {
        .useInt = true,
        .onDozeEnable = false,
        .onDebugEnable = true,
        .fastAccessEnable = false
    };

    // Enable clock for PORTs, setup board clock source, config pin
    hardware_init();

    // Call OSA_Init to setup LP Timer for timeout
    OSA_Init();

    FLEXIO_DRV_Init(s_flexioInstance,&userConfig);
    FLEXIO_DRV_Start(s_flexioInstance);

    /* Fill in FlexIO UART config data */
    flexio_uart_userconfig_t uartConfig;
    uartConfig.bitCounter = kFlexIOUart8BitsPerChar;
    uartConfig.baudRate = 115200;
    uartConfig.uartMode = flexioUART_TxRx;
    uartConfig.txConfig.pinIdx = 5;
    uartConfig.txConfig.shifterIdx = 0;
    uartConfig.txConfig.timerIdx = 0;
    uartConfig.rxConfig.pinIdx = 4;
    uartConfig.rxConfig.shifterIdx = 1;
    uartConfig.rxConfig.timerIdx = 1;

    // Fill in lpuart config data
    lpuart_user_config_t lpuartConfig = {
        .clockSource     = BOARD_LPUART_CLOCK_SOURCE,
        .bitCountPerChar = kLpuart8BitsPerChar,
        .parityMode      = kLpuartParityDisabled,
        .stopBitCount    = kLpuartOneStopBit,
        .baudRate        = 115200
    };

    /* init the FlexIO simulated UART module with base address and config structure*/
    FLEXIO_UART_DRV_Init(s_flexioInstance, &uartState, &uartConfig);
    // Initialize the lpuart module with instance number and config structure
    LPUART_DRV_Init(COMM_UART_INSTANCE, &lpuartStatePtr, &lpuartConfig);
    // Inform to start blocking example
    PRINTF("\r\n++++++++++++++++ FLEXIO UART Send/Receive Example Start +++++++++++++++++\r\n");
    PRINTF("\r\n1. FlexIO simulated UART send a buffer \
            \r\n2. LPUART receives data from FlexIO simulated UART.\
            \r\n3. Compare rxBuff and txBuff to see result.\
            \r\n4. LPUART send a buffer\
            \r\n5. FlexIO simulated UART receives data from LPUART.\
            \r\n6. Compare rxBuff and txBuff to see result.\r\n");
    PRINTF("\r\n============================================================\r\n");
    PRINTF("\r\nPress any key to start transfer:\r\n\r\n");
    while(true)
    {
        GETCHAR();
       // FlexIO UART sends data to LPUART

        FLEXIO_UART_DRV_SendData(&uartState, txBuff, DATA_LENGTH);
        LPUART_DRV_ReceiveDataBlocking(COMM_UART_INSTANCE, rxBuff, DATA_LENGTH, 1000U);
        if(flexio_uart_compare((uint8_t*)txBuff, rxBuff, DATA_LENGTH) != true)
        {
            PRINTF("\r\nFailure transfer from FlexIO simualted UART to LPUART");
            break;
        }
        PRINTF("Transfer from FlexIO simulated UART to LPUART successfully\r\n");

        flexio_uart_reset_buffer(rxBuff,DATA_LENGTH);
        // FlexIO UART receives data from LPUART
        LPUART_DRV_SendData(COMM_UART_INSTANCE, txBuff, DATA_LENGTH);
        FLEXIO_UART_DRV_ReceiveDataBlocking(&uartState, rxBuff, DATA_LENGTH,1000U);
        if(flexio_uart_compare((uint8_t*)txBuff, rxBuff, DATA_LENGTH) != true)
        {
            PRINTF("\r\nFailure FlexIO simulated UART receive from FlexIO LPUART");
            break;
        }
        PRINTF("FlexIO simulated UART receive from FlexIO LPUART successfully\r\n");
    }

    return 0;
}
Arduino codeC/C++
Initially for setting the delay, calibrating the IR sensors and for connecting the DC motors in right polarity I made use of Arduino since its user friendly and easier to Debug
int M1T1= 5;
int M1T2 =6;
int M2T1= 9;
int M2T2 = 10;
void setup() 
{
  Serial.begin(9600);
  pinMode(M1T1, OUTPUT);
  pinMode(M1T2, OUTPUT);
  pinMode(M2T1, OUTPUT);
  pinMode(M2T2, OUTPUT);
 
}
void loop() 
{
  int S1 = digitalRead(A0);
  int S2 = digitalRead(A1);
  int S3 = digitalRead(A2);
  int S4 = digitalRead(A3);
  int S5 = digitalRead(A4);
  

  if(S1==HIGH && S5== HIGH)
  {

    if(S2==HIGH && S3==LOW && S4==HIGH) // FRONT
    {
      analogWrite(M1T1,220);
      analogWrite(M1T2,0);
      analogWrite(M2T1,22
      );
      analogWrite(M2T2,0);
      delay(15);   }
      
      if(S2==LOW && S3==LOW && S4==LOW) // FRONT
    {
      analogWrite(M1T1,220);
      analogWrite(M1T2,0);
      analogWrite(M2T1,220);
      analogWrite(M2T2,0);
      delay(20);   }
      
      
    if(S2==LOW && S3==LOW && S4==HIGH) // Slight Left 
    {
      analogWrite(M1T1,130); 
      analogWrite(M1T2,0);
      analogWrite(M2T1,170);
      analogWrite(M2T2,0);
      delay(25);
    }
    if(S2==HIGH && S3==LOW && S4==LOW) // Slight Right
    {
      analogWrite(M1T1,170); 
      analogWrite(M1T2,0);
      analogWrite(M2T1,130); 
      analogWrite(M2T2,0);
      delay(25);
    } 

  }

  else if(S1==LOW && S5== HIGH) //Full LEFT
  {
    analogWrite(M1T1,180);
    analogWrite(M1T2,0);
    analogWrite(M2T1,0);
    analogWrite(M2T2,140);
    delay(30);
  }

  else if(S1==HIGH && S5== LOW) //Full Right
  {
    analogWrite(M1T1,0);
    analogWrite(M1T2,140);
    analogWrite(M2T1,180);
    analogWrite(M2T2,0);
    delay(30);
  }


}
App,flow,code
It contains Android-Guided-Vehicle(.aia and .apk), flow diagram of the Uart and GPIO code

Schematics

Power Supply
Input to the freedom board is given via P5-9V_VIN pin
and the IR sensors are powered from the pin P5V_USB ( Nominal 5 V supplied to the I/O headers (J3 pin10) )

When 3.3 V power is supplied directly through the Freedom platform
compatibility header J3, please enable protection diode D7 by opening J18 shorting header.
Ps
Bluetooth
An optional header (J24) on the FRDM-K82F supports communication with an add-on Bluetooth interface over a UART.
Bt
Overall Interface
make the connections accordingly
Schematics

Comments

Similar projects you might like

Android Apps Controlled Arduino Robot Car

by Team platinum

  • 3,594 views
  • 0 comments
  • 16 respects

Gesture Drive: Accelerate with Freedom

Project tutorial by Shahariar

  • 2,833 views
  • 0 comments
  • 12 respects

Two Mode Robot Controlling through Android and Windowsphone8

Project tutorial by Anas Siddiqui

  • 16,314 views
  • 9 comments
  • 48 respects

BE∆ST: Bluetooth Vehicle Final Designed Chassis

Project showcase by Matthew Chiang

  • 2,711 views
  • 0 comments
  • 15 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,849 views
  • 17 comments
  • 75 respects

Android Arduino RC Car

Project tutorial by RAFI RASHEED T C

  • 15,340 views
  • 2 comments
  • 38 respects
Add projectSign up / Login