S17: CamBot

From Embedded Systems Learning Academy
Revision as of 08:46, 25 May 2017 by Proj user16 (talk | contribs) (References)

Jump to: navigation, search

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

CamBot

Abstract

The project aims to build a motorized camera holding bot that helps the photographers to create moving time-lapses across a landscape.The photographers can program the bot to move in a sequence of desired directions and capture the time-lapse. CamBot can slowly move over time to capture the time-lapse and also slowly change angles.

Objectives & Introduction

The project explores the GPIO and UART drivers in LPC1758 platform. CamBot is driven with the help of DC Motors whose PWM Signals are given by LPC1758. Since stepper motor moves in precise repeatable steps, it is best suited for applications requiring precise positioning. Precise increments of movement also allow for excellent control of rotational speed for process automation and robotics. Normal DC motors do not have much torque at low speeds. The sequence of directions for the CamBot is provided by a Bluetooth Application which sends the commands for specific movements.

Team Members & Responsibilities

  • Spoorthi Mysore Shivakumar
  • Goutam Madhukeshwar Hegde
  • Chethan Palangotu Keshava
  • Aajna Karki

Schedule

Team Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 03/14/2017 03/21/2017
  • Project proposal submission.
  • Dividing module ownership among the team members.
  • Decide on components required.
Completed 03/21/2017
2 03/21/2017 03/28/2017
  • Brainstorm on the hardware and software design.
  • List the interfaces and order the components.
Completed 03/28/2017
3 03/29/2017 04/04/2017
  • Study the datasheets of the components and understand the pin connections.
  • Prepare pinout diagrams and prepare the hardware design
  • Prepare the software design flow of each of the modules.
Completed 04/04/2017
4 04/05/2017 04/12/2017
  • Design the PCB and place order for fabrication.
Completed 04/12/2017
5 04/13/2017 04/18/2017
  • Interface Stepper Motor with SJOne Board and get the functionality working.
  • Implement a basic Android application.
  • Implement UART driver for interfacing the Bluetooth module with the SJOne board.
Completed 04/18/2017
6 04/19/2017 04/25/2017
  • Interface DC Motor with SJOne Board and get the functionality working.
  • Check of communication between Android application and SJOne board.
  • Implement the control of the camera via Bluetooth.
Completed 04/25/2017
7 04/26/2017 05/02/2017
  • Build the robot with all interfaces integrated.
  • Complete the development and testing of all modules stand-alone.
Completed 05/02/2017
8 05/03/2017 05/09/2017
  • Integrate all the modules and test for functionality as a unit.
  • Ensure that the motor responds to the commands provided by the application accurately.
Completed 05/09/2017
9 05/10/2017 05/15/2017
  • Final testing and debugging phase.
  • Update project report and prepare for demo.
Completed 05/15/2017

Parts List & Cost

Item# Part Name Vendor Cost $
1 SJOne Board From Preet 80$
2 PCB Fabrication 4PCB 66$
3 Bluetooth Module Sparkfun 25$
4 Chassis Amazon 15$
5 Battery - 1000mAh Amazon 14$
6 Motor Wheel Couplers Amazon 10$
7 Corner Braces Amazon 6$
8 Lipo Battery Charger Amazon 12$
9 Motor Drive Shield Amazon 5.5$
10 Stepper motor Amazon 13$
11 IR Reflective Sensor Amazon 7$

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

This section includes schematics and hardware interface of the components used in the project

PCB Design

Eagle software is used for PCB design. The steps involved in the PCB design process are discussed below.


1. PCB Schematic Design: In the first step, we need to design a circuit using components available in Eagle library.Here two important things to keep in mind are:

1. The Electrical Characteristics: Based on our requirement of voltage or current rating, we select the components which are suitable for our board.For example, if we want to connect a switch to conduct 5A current, we should not select a switch with 2A current rating from the library because the copper width for 2A switch will not be able to conduct 5A current.

2. Components Selection: We need to carefully select the components here because each component has specific dimension as defined in their library.So once we convert this schematic into board layout, the size of the pads printed on the board depends on the component selection.We can't change the size if we select the library components.But there is a way we create our custom components with required electrical characteristics and dimensions.For our design, we used most of the parts from the Sparkfun library as it is very reliable and some of the parts which are not available in the library are created manually using Eagle.

PCB Schematics

2. PCB board layout:

PCB board layout involves mainly placing components in the layout and routing them together.we can manual routing or auto routing to connect components together with copper lines.But sometimes auto routing does not work or it will not be able to route all the connectors in an efficient manner.So manual routing is the best way where we will be able to plan and do the routing. In our project, the main challenges faced while PCB design is placing connectors and components in the appropriate place.Since we used a motor driver shield, which has 14 pin male connectors on the one side and 12 pin male connectors on the other side, it was very important that we measure proper dimension to fit this board on female connectors placed on PCB.We used dimension tool of the eagle to fix the accurate placement of connectors.

The other challenge involved in the PCB design is routing the 34 pin connector for connecting SJ-one board to PCB.We decided to leave out extra 34 pin connector corresponding to SJ-one board because it can be used for any additional features added to our project.

PCB Board


  • PCB without Components
  • PCB with Components
  • PCB with Motor Driver

Hardware Interface

The hardware components used in this project include:

  • Motor Shield
  • Stepper Motor
  • DC Motor
  • Bluetooth module.


Motor Shield

The Arduino motor shield is used in this project. It comprises of two L293D dual H-bridge motor driver ICs. It has four digital inputs which are in pairs. Each pair controls a motor. The operation can be explained with an example. If pin 7 is set low and pin 2 is set high, motor 1 is turned on. Reversing the inputs will reverse the motor. In order to conserve pins, the motor driver IC pins are wired to the outputs of 74HCT595N IC which is an 8-bit shift register. The data is fed in serially into this IC which then outputs the data in the parallel form.

The inputs to the shift register consists of:

  • DIR_EN: Enable Input (Active Low)
  • DIR_SER: Data Input
  • DIR_CLK: Rising edge results in shifting in of the input data bit
  • DIR_LATCH: Rising edge results in internal bits to be moved out as parallel data
Motor Shield Schematic


Motor Shield and SJOne Interface
Motor Shield Pin SJOne Pin
4 (CLK) P2.4
7 (EN) P2.5
8 (DATA) P2.6
12 (LATCH) P2.7


Stepper Motor

Stepper motor is used to obtain the rotation of the phone for capturing a time-lapse.

Stepper motors consist of a rotor and stationary electromagnets around the rotor. The movement of the rotor is controlled by energizing the electromagnets in a particular sequence as required. The movement of the rotor occurs since the rotor is attracted towards the electromagnets. In this project, we use the NEMA 17 stepper motor which has a precision of 200 steps per revolution. Based on the angle required, the stepper motor can be configured to take the required number of steps in the provided direction.

Stepper Motor Functionality


Stepper Motor and Motor Shield Interface
Stepper Motor Motor Shield
2A and 2B M2
3A and 3B M3
SJOne PWM for Stepper Motor
Stepper Motor SJOne Pins
2A and 2B P2.0 (PWM1)
3A and 3B P2.3 (PWM4)


DC Motor

DC motor is used in this project to move the robot forward and backward. Two DC motors are used each connected to a wheel.

The DC motor converts electrical energy to mechanical energy. It consists of a current carrying conductor placed in an electromagnetic field. When current is passed through the conductor, a mechanical force is generated due to the electromagnetic effect.

DC Motor Functionality
DC Motor and Motor Shield Interface
DC Motor Motor Shield
DC Motor 1 M1
DC Motor 2 M4
SJOne PWM for DC Motor
DC Motor SJOne Pins
DC Motor 1 P2.1 (PWM2)
DC Motor 2 P2.2 (PWM3)

Bluetooth Module

RN42XV Bluetooth Module

RN42XV is built around Microchip's RN42 low power Bluetooth module. Some features of this module are as follows

  • Based on the popular 2 x 10 (2mm) socket footprint.
  • Voltage range: (3-3.6)Volts
  • Current range: 26 μA sleep, 3 mA connected, 30 mA transmit.
  • UART data connection interface.
  • Sustained data rates: 240 Kbps (slave), 300 Kbps (master)
  • Transmission range up to 60 feet (20 m) distance, +4 dBm output transmitter, -80 dBm typical receive sensitivity.
  • FHSS/GFSK modulation, 79 channels at 1-MHz intervals.

The bluetooth module uses simple UART communication protocol for sending/receiving data from the Micro-controller board. We are using UART2 to communicate with the Bluetooth module.

Hardware Interface of Bluetooth Module

Software Design

FlowChart

The software design consists of 3 tasks:

  • Bluetooth Task
  • Stepper Motor Task
  • DC Motor Task

The Bluetooth task is of high priority since the user data needs to be received and acted upon. The Stepper Motor and the DC Motor tasks are run with medium priority.

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

Motor Shield Software Implementation

The shift register in the motor shield requires 4 inputs. They are configured using SJOne GPIOs as below:

GPIO MOTORLATCH(P2_7);
GPIO MOTORDATA(P2_6);
GPIO MOTORCLK(P2_4);
GPIO MOTORENABLE(P2_5);

MOTORLATCH.setAsOutput();
MOTORENABLE.setAsOutput();
MOTORDATA.setAsOutput();
MOTORCLK.setAsOutput();

Latch enabling is required every time a data is set since it controls the data moving into the shift register and the parallel data being sent out of the motor shield. This functionality of latching motor state data is implemented as follows:

for(i=0; i<8; i++)
{
     setMotorClockLow();
     
     if(latch_state & (1 << (7-i))
     {
           setMotorDataHigh();
     }
     else
     {
           setMotorDataLow();
     }
     setMotorClkHigh();
}
setMotorLatchHigh();


Stepper Motor Task Implementation

PWM Initialization:

PWMs 1 and 4 are used for Stepper Motor.

GPIO PWM1(P2_0);
GPIO PWM4(P2_3);

PWM1.setAsOutput();
PWM4.setAsOutput();

The Stepper motor coils are energized in the following sequence based on the command received from the application:

Latching for clockwise direction:

latch_state |= (1 << MOTOR3_A) | (1 << MOTOR2_A); 
latch_state |= (1 << MOTOR2_A) | (1 << MOTOR3_B); 
latch_state |= (1 << MOTOR3_B) | (1 << MOTOR2_B); 
latch_state |= (1 << MOTOR2_B) | (1 << MOTOR3_A); 

This sequence results in a clockwise rotation. The reverse of this sequence results in an anti-clockwise rotation.


DC Motor Task Implementation

PWM Initialization:

PWMs 2 and 3 are used for DC Motor.

GPIO PWM2(P2_1);
GPIO PWM3(P2_2);

PWM2.setAsOutput();
PWM3.setAsOutput();

The DC motor is activated based on the command received from the application:

Latching for forward direction:

latch_state |= (1 << MOTOR1_A);
latch_state &= ~(1 << MOTOR1_B);

latch_state |= (1 << MOTOR4_A);
latch_state &= ~(1 << MOTOR4_B);

This sequence results in a forward motion. The reverse of this sequence results in a backward motion.

Bluetooth Task Implementation

The bluetooth task initializes UART2 for the communication with Zigbee Bluetooth module with the baud rate of 115200. It waits for a byte from UART2 in its run() function (which is always run in a loop as long as the task is running). The byte it receives can be decoded from the enumeration datatype declared to represent the commands from the app. Below is the definition of the Bluetooth task used along with the enum datatype.

class bluetooth_task : public scheduler_task
{
private:
	Uart2 &Bluetooth_uart_2;
	static const int Rx_Q_Size = 3;
	static const int Tx_Q_Size = 3;
	static const int Baud_Rate_Bluetooth_Uart2 = 115200;
	char buff;
public:
	bluetooth_task(uint8_t priority) :
		scheduler_task("Bluetooth Task", 2000, priority),Bluetooth_uart_2(Uart2::getInstance())
        {
		Bluetooth_uart_2.init(Baud_Rate_Bluetooth_Uart2,Rx_Q_Size,Tx_Q_Size);
		buff = 0;
        }

	bool init(void);
	bool run(void *p);
};

enum command
{
   init,
   start,
   stop,
   clockwise,
   anticlockwise,
   angle30,
   angle60,
   angle90,
   angle120,
   angle150,
   angle180,
   forward,
   backward,

};

Android App Implementation

Android Application UI

The android application to control our CamBot is a simple one screen application. The screenshot showing the button layout (UI) is given on the right. The table with the button descriptions is given below:

Button Functionality
TURN ON Turn on the Bluetooth on the mobile
TURN OFF Turn off the Bluetooth on the mobile
GET VISIBLE Makes your mobile device visible to other Bluetooth devices
LIST DEVICES Lists all the Bluetooth devices paired with the mobile. You can click on any of the listed devices to connect to it
START After giving appropriate commands and parameters, pressing this button will set the cambot in motion
STOP This stops the motion of the CamBot
ANTICLOCKWISE Press this button to set the direction of rotation of the camera holder stepper motor to anticlockwise direction
CLOCKWISE Press this button to set the direction of rotation of the camera holder stepper motor to clockwise direction
FORWARD Press this button to set the direction of movement of the dc motor to forward direction
BACKWARD Press this button to set the direction of movement of the dc motor to backward direction
SET ANGLE First select appropriate angle for the above discussed stepper motor using the list to the left of this button. Then press this button to set the angle of rotation of the stepper motor

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

Issue #1

Problem connecting the android app with Zigbee bluetooth module via Bluetooth. The app was initialising connection but was not able to finish the connection process and get connected.

Solution: The RFComm socket was not getting created properly. Even when the RFComm socket gets created, it was not created with the accurate device UUID that needed to be setup. After manually setting up the device UUID and then creating the RFComm socket, you can start the Bluetooth connection with that socket object and then it would successfully connect with the Bluetooth module.

Issue #2

We tried integrating the Sunfounder line follower module that works on I2C interface. We faced an issue where the module was getting discovered but read and write was failing. On further debugging, we observed that the I2C was getting disabled in the software.

Solution: We changed the module to TCRt5000

Issue #3

We faced issue with the mechanical camera mount of the stepper motor. A small mismatch between the coupler used to connect the stepper motor shaft and the camera mount resulted in amplification of the vibration. This caused a lot of vibration on the camera mount when the stepper motor was activated.

Solution

The coupler placement was adjusted for minimal shakiness. Also, the mechanical mount had a lot of distinct moving parts. We replaced it with a camera mount with less moving parts for stability.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

https://www.youtube.com/watch?v=Wxr-8NMwPrs

Project Source Code

https://gitlab.com/aajna.karki/cmpe244_CamBot

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

[1] Preetpal Kang's lecture notes of CMPE 244, Computer Engineering, San Jose State University, Feb-May 2017
[2] https://docs.google.com/document/d/1OdGS0QHKCdbrbAs_x62gmfSx_UdUPFPgZjwZnVDVHDg/preview
[3] http://www.vishay.com/docs/83760/tcrt5000.pdf
[4] https://developer.android.com/training/basics/firstapp/building-ui.html
[5] https://www.tutorialspoint.com/android/android_bluetooth.htm