Epics@GSI Webhome

CAN bus implementation on HADControl

Introduction

The objective of this project is the implementation of a software on the HADCon(trol) board's AVR micro controller. This software enables the control of AVR micro controller's CANbus Interface using an (ASCII based) Application Programming Interface (API). Integrated via streamDevice driver into EPICS the control of CANbus devices will be possible within EPICS.

Hardware

Hardware component

The HADControl is a board which has been developped at the GSI. It consists of the following components:
  • AVR micro controller
  • ETRAX SoC
  • CAN connector
  • RJ45 10MBit/s Ethernet
  • JTAG interface
The HADControl board provides a CAN interface and a TCP/IP interface. This involves the communication of the two units SoC and microcontroller over an internal serial interface.

Hardware montage

The HADControl Board needs a minimal input voltage of 5V. The CAN cable is inserted in CAN connector. The CAN cable connects the board with the controlled device. At both ends of the cable should be a 120 Ohm resistor to be completed.The AVR ICEmkII debug device is connected to the board's JTAG port.

Hardware setup

How is hardware setup installed?
  • Micro controller setup
The CAN_API-Slave is the program for the execution of the commands from micro controller to CAN devices via CAN bus.

Open a console

$> cd hadcon/CAN_API-Slave
$> make
$> make program

  • ETRAX Setup
The CAN_API-Master is the program for sending commands from micro controller to SoC via serial interface. The execution of the program consist of two parts.

Open the first console

$> cd devboard_R2-10
$> source init_env
$> cd apps/API-Master
$> make
$> gcc-cris -mlinux API-Master.c -o API-Master
$> lftp root:pass@etrax-number:/mnt/flash
$> put API-Master
$> lcd put CAN_API-Script.sh

Open the second console

$> telnet etrax-number
$> cd mnt/flash
$> ./ _API-Master "command"

  • Example of Etrax-number: etrax243

  • Example of command: “SEND 304 0 1 8“

Software

Before you start, you'll need

  • Compiler & Cross Compiler
A compiler is a computer program that transforms the source code written in a computer language into another computer language. The most common reason for transform source code is to create an executable program. A cross compiler is a compiler capable of creating a code for a platform other than the one on which the compiler runs. Cross compiler tools are generally found in use to generate executables for embedded system or multiple platforms. The CRIS architecture is the cross compiler for SoC.
  • SDK
A Software Development Kit(SDK)is a set of development tools that allows a software engineer to create applications for a certain software package, a hardware platform and a computer system. SDK also frequently includes a sample code and supporting technical information or other supporting documentation to clarify points from the primary reference material.

μC

A micro controller is a small computer on a single integrated circuit consisting of a relatively simple CPU combined with support functions such as a crystal oscillator, timers, serial and analog I/O etc.

The micro-controller on the HADControl board is AT90CAN128, this is an AVR micro controller of ATMEL. He is an 8 Bit micro controller with many interfaces other CAN and serial interfaces. This micro controller consists of 128 kBytes FLASH, 4 kBytes RAM and 4 kBytes EEPROM.

ETRAX

The ETRAX SoC (Ethernet Token Ring Axis System on Chip) is a Central Processing Unit(CPU) of the company AXIS communication,with, 4 MB FLASH, 10/100 MBits/s Ethernet and four serial ports with high speed. The SoC(CPU)can be adressed via TCP/IP. The communication between EPICS and HADControl-Board or SoC is over TCP/IP.

API

The implemented API is CAN_API and is addressed and read via the serial interface between the microcontroller and CPU. The API consists of two parts, one is the API–Master. This API-Master is a program that uses the API and knows the protocol. It runs on the CPU, and has to send mainly the commands over a serial interface from the CPU to the microcontroller.The second part is a API-Slave, this runs of the microcontroller and processes the commands and CAN data arriving at the CPU.

  • Implementation of CAN_API-Slave
The implementation of CAN_API-Slave must be loaded and run in the microcontroller. This has two main roles. One is that it be receives commands from the CPU for ationinterpret and implementation. On the other hand the arriving data of CAN devices are packed in a CAN_API structure and manages at the CPU .

  • Implementation of CAN_API-Master
The implementation of CAN_API-Master must be charged and must run in the CPU. The program is for the communication between the CPU and the microcontroller via serial interface.The program is independent of EPICS.

EPICS

EPICS stand for Experimental Physics and Industrial Control System. The EPICS is an control system with following components:
  • It is a control system architecture: A client/server model with an efficient communication protocol(channel access) for passing data.

  • A Software Toolkit: A collection of software tools collaboratively developed which can be integrated to provide a comprehensive and scalable.

  • Input Output Control Server: A computer running iocCore, a set of EPICS routines used to define process variables and implement real-time control algorithms. The iocCore uses database records to define process variables and their behaviour.

EPICS standalone

Open a console and to log on linux computer

$> telnet etrax-number
$> cd mnt/flash
$> cd /home
$> cd hadaq/EPICS/epics_apps/streamTest/iocBoot/iocstreamTest
$> ../../bin/linux-cris_v10/streamTest st.cmd
$> dbl

With the help of dbl gives different PV in action

Open a new console

$> caput axis:off.PROC 1
off is the name of a PV in action.

With the help of camonitor command, you can view the result.

$> camonitor Debug

EPICS stream

STREAM is a general EPICS Device Support for devices with a“ Byte Stream“. It controls the sending and receiving of strings, including non-printable characters and null bytes. An example of this type of communication is the serial communication. STREAM Device uses the interface of the ASYNdriver, the ASYNdriver performs the low-level support for this communication. It supports all standard record types of EPICS. ASYNdriver is the EPICS Device support for asynchronous communication.

Preliminary code

For the current version, go to :ext:hadaq@lxi003.gsi.de:/misc/hadesprojects/daq/cvsroot/hadcon

How to use the CAN_API-Script

The CAN_API-Script contains some commands. Now is the command a name and no longer a string. You need no longer the CAN_API-Master to run but the CAN_API-Script. Open a new console and call a terminal emulator.

$> xterm -e bin/trb etrax043
Run the script on the the terminal emulator.

$> ./CAN_API-Script.sh IDstat
IDstat is a name that contains the string: IDstat = "SEND 4 0 1 8". To show the other name of command open the script CAN_API-Script.sh.

The CAN_API-Script.pdf is a summary of commands with a brief description and examples of responses expected. For more information open the file CAN_API-Script.pdf.

Instructions

check the settings of the serial communication

If the program doesn't respond during testing, switch off and follow instruction below.

1- Open a new console
2- Enter ==trb etrax-number==
3- Enter stty -F /dev/ttyS1 to have the Baud rate of the serial interface
4- If the Baud rate is not equal 115200, adjust these values with ==stty–F /dev/ttyS1 115200==

Settings for communication via CAN bus

Be soldered for communication via the CAN bus must have a 120Ohm resistance at the JCAN1 plug of HadControl boards. The resistor is located between pin 1 and pin 2.

Diploma Thesis Linda Fouedjio

For more information about the project can be found in my Diploma thesis

As a result of this work Linda Fouedjio graduated with a diploma in Electrical Engineering and Information Technology at the University of Applied Science in Darmstadt.


-- LindaFouedjio - 17 november 2009

Topic attachments
I Attachment Action Size Date Who Comment
CAN_API-Master.tartar CAN_API-Master.tar manage 80.0 K 2009-03-03 - 15:53 LindaFouedjio Source code in the SoC to run
CAN_API-Script.pdfpdf CAN_API-Script.pdf manage 42.4 K 2009-11-17 - 12:58 LindaFouedjio Script of commands for testing the implemented CAN_API
CAN_API-Script.shsh CAN_API-Script.sh manage 2.7 K 2009-09-16 - 09:24 LindaFouedjio Script of commands for testing the implemented CAN_API
CAN_API-Slave.tar.gzgz CAN_API-Slave.tar.gz manage 391.1 K 2010-08-16 - 11:07 LindaFouedjio Source code in the microcontroller to run
HadControlEpicsCANbus.pdfpdf HadControlEpicsCANbus.pdf manage 2066.6 K 2009-05-06 - 13:44 LindaFouedjio Diploma thesis
Topic revision: r42 - 2011-02-28, PeterZumbruch
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)