Embedded CAN intelligent node based on PIC microcontroller and its communication with PC

Publisher:RadiantWhisperLatest update time:2011-12-06 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This paper introduces the hardware and software design of embedded CAN intelligent node based on PIC16F874 single chip microcomputer, and uses PCL-841 CAN interface card to realize communication between embedded CAN intelligent node and PC, completes the real-time acquisition, reliable transmission and real-time display of voltage, current, temperature and other signals, and realizes the control of pulse width of PWM wave output of embedded CAN intelligent node by PC.

Introduction

CAN bus is a serial data communication protocol. Its communication interface integrates the physical layer and data link layer functions of CAN protocol, which can complete the framing of data. One of the biggest features of CAN protocol is that it abolishes the traditional station address coding and replaces it with communication data block coding. This method can make the number of nodes in the network theoretically unlimited, and different nodes can receive the same data at the same time.
This paper introduces the embedded CAN intelligent node, and uses PC and embedded CAN intelligent node to form a CAN communication system, which completes the real-time acquisition, reliable transmission and real-time display of voltage, current, temperature and other signals, and realizes the control of the pulse width of the PWM wave output of the embedded CAN intelligent node by the PC.

Design of embedded CAN intelligent node based on PIC microcontroller

The embedded CAN intelligent node uses PIC16F874 microcontroller as embedded microcontroller, MCP2510 as CAN controller, PCA82C250 as CAN transceiver, and has field/remote control function. According to user needs, the embedded CAN intelligent node can complete the real-time acquisition, reliable transmission and real-time display of various signals by connecting corresponding sensors, and the PWM wave output can be used to control the corresponding load. The embedded CAN intelligent node can realize circuit protection, field configuration, automatic adjustment, fault diagnosis alarm, status detection and other functions through external circuits, and complete the drive and intelligent control of electrical appliances such as motors, valves, and pumps.

Hardware Design

Microchip's PIC16F874 microcontroller uses RISC instruction system, Harvard bus structure, low power consumption, high speed. It integrates ADC, serial peripheral interface (SPI) and flash program memory, etc., and has functions such as PWM output and LCD drive. PIC16F874 can achieve seamless connection with CAN controller MCP2510 through SPI interface. PIC16F874 has rich I/O resources, with five I/O ports A, B, C, D, and E. Each I/O port has some special functions in addition to basic uses.

CAN communication module

The CAN communication module of the embedded CAN intelligent node consists of CAN controller MCP2510 and CAN transceiver PCA82C250. MCP2510 can complete all functions of the physical layer and data link layer of the CAN bus, support high-speed SPI interface (the maximum data transmission rate can reach 5MB/s), and support CAN2.0A/CAN2.0B protocol. CAN transceiver PCA82C250 is the interface between CAN controller and physical bus, providing differential transmission capability for physical bus and differential reception capability for CAN controller. At the same time, it can increase communication distance and improve the anti-interference capability of embedded CAN intelligent node.

PIC16F874 is connected to CAN controller MCP2510 through SPI, its serial data input (SDI) pin is connected to MCP2510's SO pin, its serial data output (SDO) pin is connected to MCP2510's SI pin, and its serial clock (SCK) pin is connected to MCP2510's SCK pin. The reset signal and chip select signal of MCP2510 are provided by RA5 and RA2 of microcontroller A port, and the interrupt signal and receive buffer full interrupt signal of MCP2510 are output to RB0 and RB5 of microcontroller B port.

The SPI interface works in active mode by setting the SPI interface status register and control register of PIC16F874. The timing of communication between PIC16F874 and MCP2510 is very important. When sending data, first send the write instruction, then send the register address, and finally send the data. When MCP2510 receives data from the bus, an interrupt will be generated, and the microcontroller responds to the interrupt. When reading data, first send the read instruction, then send the register address, and the data will be automatically written into the buffer of the microcontroller SPI interface.

Display module

The embedded CAN intelligent node uses the OCMJ4χ8 display module, which can display Chinese characters, ASCII codes, etc. All its settings and initialization work can be automatically completed when powered on.
The data lines DB0~DB7 of the OCMJ4χ8 display module are connected to the D port of the microcontroller, and the request (REQ) pin and the response (BUSY) pin are connected to the RB4 of the B port and the RE2 of the E port of the microcontroller respectively. The RT1 and RT2 pins of the display module are connected to external adjustable resistors to adjust the brightness of the LCD.

The interface protocol of the display module is a request/response (REQ/BUSY) handshake mode. When busy is high, it means that the display module is busy; when busy is low, it means that the display module is idle and waiting to receive commands. The microcontroller first sends commands or data to the display module, and then sends a request signal to request the display module to process. The display module sets busy to a high level and processes the command or data. After the processing is completed, it sets busy to a low level.

Analog acquisition module

RA0, RA1, and RA3 of port A of PIC16F874 microcontroller are used for analog input. The main function of the analog acquisition module of the embedded CAN intelligent node is to convert the current signal to be collected into a voltage signal through a current transformer, and to convert the temperature signal to be collected into a voltage signal through a temperature sensor AD590.

Switching input/output modules

The embedded CAN intelligent node provides 4 switch inputs and 7 switch outputs through I/O expansion. The switch input is used for circuit protection, fault alarm, status detection, etc. As long as the controlled object has the corresponding detection element, it can be connected to the corresponding interface. The switch output is used to drive the relay. It can determine whether to connect the contactor to control the motor, valve, pump and other electrical actuators according to the load size. According to the needs of the user, this part of the circuit can be changed accordingly.

Reference address:Embedded CAN intelligent node based on PIC microcontroller and its communication with PC

Previous article:CAN bus expansion technology based on dsPIC30F6011 microcontroller
Next article:Application of single chip microcomputer in permanent magnet brushless DC motor drive system of electric golf cart

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号