Giter Site home page Giter Site logo

team-pilot's Introduction

SEA:ME 2nd Project

Before start

Table of Contents

Complete Architecture

image

  • Simple project architecture
    • Receive sensor data from Arduino and transfer it to Raspberry Pi using CAN Bus
    • Raspberry Pi uses the DBus server to manage the data it receives and delivers the data it needs for each application

Basics knowledge of the Architecture

What is Arduino?

  • Micro Controller
    • Small electronic device that can easily handle various movements such as read data from sensors or use data to control motors.
    • C language (or C++) and Arduino IDE enable simple coding
    • Consists of Regulator, Circuit Element, GPIO
    • Peripherals allow direct control of external devices
    • More Information of Arduino

GPIO

  • General Purpose Input/Output
  • Uncommitted digital signal pin on an integrated circuit or electronic circuit board which may be used as an input or output, or both, and is controllable by software.

What is Raspberry Pi?

  • Micro Processor
    • Similar to Arduino, but called Processor because it can have various OSs
    • Unlike Arduino, there is no peripheral device and controls the device using an internal transistor
    • Powerful performance in computational processing, which is useful for complex computational processing such as video and graphics
    • Raspberry Pi official document

What is CAN(Controller Area Network)?

  • Standard communication protocol designed for vehicles to communicate with each other within a vehicle
  • ECUs in the vehicle communicate using the CAN protocol

Advantage

  • Multi-Master

    • All nodes are bus masters and whenever the bus is empty they can send information
  • Twisted Pair Wire

    • Strong against electrical noise due to electrically differentiated communication using two lines : CAN_H, CAN_L
    • Scalability. Only need to connect to two lines, No matter how many ECUs. image
  • Message-Oriented Protocol

    • Use ID based on message priority. Use them to distinguish messages
    • Multiple messages come in at the same time, carry out the priority ID message

ECU

  • Electronic Control Unit
  • Electronic control device used in a car

What is D-Bus?

  • System for IPC(Inter-Process Communication)

  • A bus system that enables various processes with different characteristics to communicate with each other

  • D-Bus is a service daemon that runs in the background that uses the bus daemon to communicate functions and communications between applications image

    • Two type of D-Bus daemon
      1. D-Bus System bus
        • Communicate with kernel and system-wide events
        • Any application is prevented from spoofing
      2. D-Bus Session bus
        • daemon attached to each user session
        • Used to communicate with other applications within the same system
        • Receive messages from the system bus

Check D-bus service in terminal
ps -ef | grep dbus-demon image
Separated by behind word

  • --system or --session

Key Terms and Concepts

  • Bus name(Service name)
    • Unique name for 1 connection
    • Automatically generated when connected to D-Bus daemon and can be set up by the user themselves
    • Names once used are non-reusable and must not be duplicated
  • Object path
    • D-bus is a Peer-to-Peer protocol in which all messages sent and received are source and purposeful
    • Address used to send and receive messages
      • Written like "/org/example/Test"
    • Multiple object paths can be assigned differently than a business name
    • Object provides one or more interfaces
  • Interface
    • Name of grouping Method and Signal
    • Interface is used as the namespace for each method
    • example
      <?xml version="1.0" ?>
      	<node name="/org/freedesktop/DBus/Example/Echo">
      		<interface name="org.freedesktop.DBus.EchoDemo">
      			<method name="HelloString">
      				<arg type="s" name="name" direction="in"/>
      				<arg type="s" name="greeting" direction="out"/>
      			</method>
      			<signal name="EchoCount">
      				<arg type="y" name="count"/>
      			</signal>
      		</interface>
      	</node>
      • Method
        • Can be called by another object
        • Can optionally have Input and Output
      • Signal
        • Kind of broadcast message. Send to one object to all objects registered with that signal
    • Message
      • Data passed between processes
      • Method Call Message
      • Method Return Message
      • Error Message
      • Signal Message
      • Header and Body

Prepare the materials

Pi RacerPro & Raspberry Pi Can Module MCP 2515 * 2 Arduino Nano(HIMALAYA
image image image
  • Basically, These materials can make communication. After connecting, you can connect Arduino with other modules(speed sensor, temperature sensor, etc) using Breadboard.

Make communication

Blueprint

Raspberry Pi <-> MCP2515 <-> MCP2515 <-> Arduino Nano <-> other modules

Raspberry Pi <-> MCP2515

image

Raspberry Pi MCP2515
GND[20] GND
GPIO25[22] INT
GPIO8[24] CS
GPIO10[19] SI
GPIO9[21] S0
GPIO11[23] SCK
5V VCC

  • VCC & 5V
    • You must find another 5Voltage socket in Pi Racer. Raspberry Pi 5V is already used for connecting Raspberry Pi & Pi Racer.

Arduino Nano <-> MCP2515

image image
Arduino Nano MCP2515
D2 INT
D13 SCK
D11 SI
D12 S0
D10 CS
GND GND
5V VCC
  • Use Breadboard to connect Arduino and MCP2515
  • Later, Sensors can be connected to Arduino with Breadboard

MCP2515 <-> MCP2515

MCP2515 MCP2515
CAN_H CAN_H
CAN_L CAN_L

Send & Receive Data

  • Raspberry-Pi and Arduino communication with CAN communicate library

Set Can

  1. Setting CAN interface on Raspberry Pi

    • Add the following line to your /boot/config.txt file:

       dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
       dtoverlay=spi-bcm2835-overlay
      • oscillator : should be set to the actual crystal frequency found on your MCP2515
      • interrupt : specifies the Raspberry PI GPIO pin number
    • Reboot your Raspberry Pi and Check this line

       [   20.248951] CAN device driver interface
       [   20.499256] mcp251x spi0.0 can0: MCP2515 successfully initialized.
      
  2. Bring up the CAN interfaces
    2-1. Manually bring up

    • Follow this command in terminal
      sudo /sbin/ip link set can0 up type can bitrate 500000
      • Check your CAN bus bitrate and write correct number

    2-2. Automatically bring up on boot

    • Edit your /etc/network/interfaces file and add this line
       auto can0
       iface can0 inet manual
       	pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on restart-ms 100
       	up /sbin/ifconfig can0 up
       	down /sbin/ifconfig can0 down
  • Check CAN module
    • Enter this command and check output
    image
  1. CAN-utils

    • CAN-utils is a collection of extremely useful debugging tools using the SocketCAN interface
    • list of applications
      • candump : Dump can packets โ€“ display, filter and log to disk.
      • canplayer : Replay CAN log files.
      • cansend : Send a single frame.
      • cangen : Generate random traffic.
      • canbusload : display the current CAN bus utilisation.
    • Install CAN utils
  2. CAN data send or receive with CAN utils

    • Make random data
      cangen can0
    • Receive can data and check in terminal
      candump can0
    image

Reference link

team-pilot's People

Contributors

skamo3 avatar pprajapa-42 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.