Implementation of Step Motor Control under Embedded Linux Based on S3C2440

Similar documents
The Design of CAN Bus Communication System Based on MCP2515 and S3C2440 Jinmei Liu, Junhong Wang, Donghui Sun

Timing Measurement (Linux) Introduction Timekeeping Architecture Related System Calls

The Design of the Embedded WEB Server Based on ENC28J60

Study of Smart Home System based on Zigbee Wireless Sensor System. Jie Huang 1

The IIC interface based on ATmega8 realizes the applications of PS/2 keyboard/mouse in the system

Research on Technologies in Smart Substation

Research and Design of Universal Proportional Valve Controller

Research on Embedded CNC Device Based on ARM and FPGA

Tomasz Włostowski Beams Department Controls Group Hardware and Timing Section. Developing hard real-time systems using FPGAs and soft CPU cores

Speech Recognition Based on Efficient DTW Algorithm and Its DSP Implementation

General Purpose Programmable Peripheral Devices. Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

The Design of Embedded MCU Network Measure and Control System

Research on Device Control System Design Based on Stepping Motor Wu Dongyan 1, Xu Wen 1, Wang Mingge 2, Jiang Ruochong 1, Jiang Lifeng 1

Runtime Power Management on SuperH Mobile

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

Operating systems for embedded systems. Embedded Operating Systems

Design and Development of a High Speed Sorting System Based on Machine Vision Guiding

7.4 Simple example of Linux drivers

DSP-Based Parallel Processing Model of Image Rotation

A Rapid Automatic Image Registration Method Based on Improved SIFT

Operating systems for embedded systems

DEVELOPMENT OF USER FRIENDLY DATA ACQUISITION AND ACTUATION SYSTEM ON EMBEDDED PLATFORM

The Four Layers Elevator Control System Design Based on S7-200 PLC Xianjie Feng

World Scientific Research Journal (WSRJ) ISSN: Design and Implementation of Stepper Motor Control System Based on 52 MCU

Data Processing System to Network Supported Collaborative Design

Based on a Single Chip Microcomputer to Realize Electronic Clock Design and Analysis

Interrupts Peter Rounce

In this tutorial, we will discuss the architecture, pin diagram and other key concepts of microprocessors.

Applied mechanics and applied technology in fuel injection pump bench. Rotational speed measurement system design based on CPLD

Research on Device Control System Design Based on Stepping Motor. Zhongyong Tian

I.CH Brushless DC Motor Driver

Wireless Remote Water Meter Design of Automatic Meter Reading System

Research on software development platform based on SSH framework structure

Improvement of the Communication Protocol Conversion Equipment Based on Embedded Multi-MCU and μc/os-ii

Interrupts in Zynq Systems

Product Technical Brief S3C2412 Rev 2.2, Apr. 2006

Embedded Linux kernel and driver development training 5-day session

User Manual. KE-Relay or KD-Relay Profibus DPV0 Communication Module. Page 1 / 18. KE-PROFI-DP0 Version (NE_NC-KE-PROFI-DP0_MAN_01_10_FN04)

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

Product Technical Brief S3C2440X Series Rev 2.0, Oct. 2003

The 8255A: Programmable Peripheral Interface

Research on Sine Dynamic Torque Measuring System

Available online at ScienceDirect. Procedia Engineering 111 (2015 )

Laboratory Exercise 4

Design and Simulation of Temperature Data Acquisition System based on Proteus. Jinghui Su

The Research about Embedded Soft PLC Running System Based on ARM

Shared Address Space I/O: A Novel I/O Approach for System-on-a-Chip Networking

Emulating Dual SPI Using FlexIO

16-BIT TIMER AND EVENT COUNTER

SquareWear Programming Reference 1.0 Oct 10, 2012

Research on the Application of Digital Images Based on the Computer Graphics. Jing Li 1, Bin Hu 2

C09: Process Synchronization

Design of New Oscillograph based on FPGA

Effective Utilization of a Microcontroller Port for Optimisation of Hardware

International Conference on Information Sciences, Machinery, Materials and Energy (ICISMME 2015)

Product Technical Brief S3C2413 Rev 2.2, Apr. 2006

Automating with STEP 7 in STL

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Operation manual. HDOM-Profibus-V0. More options please visit;

Drowsy Power Management. Matthew Lentz James Litton Bobby Bhattacharjee University of Maryland

Unit 2 : Computer and Operating System Structure

Interrupts Peter Rounce - room 6.18

Positioning Controller

Preliminary Research on Distributed Cluster Monitoring of G/S Model

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

Citation for the original published paper (version of record):

A new Class of Priority-based Weighted Fair Scheduling Algorithm

ARM 11 Based Industrial Dust Cleaner Using High Voltage Pulse Power Supply

Me Stepper Driver. Overview

Microcontroller and Embedded Systems:

Remote Keyless Entry In a Body Controller Unit Application

Evaluation of uclinux and PREEMPT_RT for Machine Control System

Design of the Refueling Card Information Transmission System Based On DTMF

Research and design on boxing-teaching robot of embedded system and pressure sensor

OS Structure. Hardware protection & privilege levels Control transfer to and from the operating system

Product Technical Brief S3C2416 May 2008

Hardware design of a submerged buoy system based on electromagnetic inductive coupling

ARM Processors for Embedded Applications

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

An SPI interface for the 65(C)02 family of microprocessors

STEPPER MOTOR DRIVES SOME FACTORS THAT WILL HELP DETERMINE PROPER SELECTION

Multi-core microcontroller design with Cortex-M processors and CoreSight SoC

Using FlexIO to emulate communications and timing peripherals

1.Overview of X7083/X7043/X7023

Design And Implementation Of USART IP Soft Core Based On DMA Mode

8254 is a programmable interval timer. Which is widely used in clock driven digital circuits. with out timer there will not be proper synchronization

Development of a Rapid Design System for Aerial Work Truck Subframe with UG Secondary Development Framework

The Design and Realization of Visual Education System for Bridge Structure Analysis

Synchronization Time Division Multiplexing Bus Communication Method Using Serial Communication Interface

Main Points of the Computer Organization and System Software Module

Design and Simulation Based on Pro/E for a Hydraulic Lift Platform in Scissors Type

Applications of wireless sensor network in the agriculture environment monitoring

Design of Coal Mine Power Supply Monitoring System

Hello and welcome to this Renesas Interactive module that covers the Independent watchdog timer found on RX MCUs.

DSP/BIOS Kernel Scalable, Real-Time Kernel TM. for TMS320 DSPs. Product Bulletin

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

The Design of Embedded Remote Intelligent Automotive Monitoring System based on GSM. Lijun Gao

Available online at ScienceDirect. Procedia Computer Science 87 (2016 )

Digital Signal Processor

Transcription:

Available online at www.sciencedirect.com Energy Procedia 16 (2012) 1541 1546 2012 International Conference on Future Energy, Environment, and Materials Implementation of Step Motor Control under Embedded Linux Based on S3C2440 Wang Shuai 1, Zhang Heng 2, Tan Han-qing 2, Jiang Lin-ying 2 1 College of information science and Engineering, Northeastern University, Shenyang, China, 110819 2 Software College, Northeastern University, Shenyang, China, 110819 Abstract This document mainly outlines the procedures on implementation of control of S3C2440 based embedded Linux stepping motor. Such discussion is focused on hardware design method, driving program compilation and application program compilation. It also introduces the concept of stepping motor control and analyzes structure, compilation procedure and improvement of stepping motor driving program in embedded system. Application of S3C2440 and Linux 2.6.30 based driving program can realize various controls by ARM processor of stepping motor in embedded Linux system. 2011 Published by Elsevier B.V. Selection and/or peer-review under responsibility of International Materials Science Society. 2011 Published by Elsevier Ltd. Selection and/or peer-review under responsibility of [name organizer] Open access under CC BY-NC-ND license. Keywords:Stepping motor, Linux 2.6.30, ARM processor, embedded system. 1. Introduction Linux is a kind of open source code operating system that is widely adopted, which kernel may support a lot of processor architectures, including Soc embedded platform, such as ARM, StrongARM, MIPS, XScale, etc. In real application, modification to each module in Linux kernel can reach the requirement of embedded application. Step motor is widely applied in various automatic control system due to its advantage of good control performance, accurate positioning, anti-interference, strong ability and high open-loop control accuracy. It is an open-loop control element which transfers pulse signal into angular displacement or linear displacement. In order to acquire various required operating characteristics, it is necessary to research and improve the drive program and its implementation principle. This article will focus on the introduction to its implementation method on ARM processor. 1876-6102 2011 Published by Elsevier B.V. Selection and/or peer-review under responsibility of International Materials Science Society. Open access under CC BY-NC-ND license. doi:10.1016/j.egypro.2012.01.241

1542 Wang Shuai et al. / Energy Procedia 16 (2012) 1541 1546 2. Introduction to the project background This project focuses on the implementation of a kind of embedded entrance guard device which combines RFID device and is master controlled by ARM. Thus, investigation is proceeded, in which ARM/Linux controls step motor to implement open and close of door. This project faces the practical application, having specific requirements on timeliness and stability. However, its control method is basically the same, which has reference value. This article mainly focuses on the introduction to the improvement and comment on its specific implementation method and traditional implementation method. 3. Design of relevant hardware system A. Brief introduction to the micro-processor 32 bits micro-processor S3C2440A produced by Samsung provides a small-size micro-controller solution to the handheld device and ordinary application, of low price, low power consumption and high performance. 32 bits micro-controller of ARM920T processor core of ARM is integrated inside S3C2440A processor, which has abundant resource and a maximum master frequency of 400MHz. On the basis of abundant resource of processor, relevant configuration and expansion are proceeded. B. Introduction to the step motor Rotating speed, stop position of the step motor are only determined by the frequency and pulse count of pulse signal under the condition of non-overloading, i.e. one pulse signal being put on the motor, the motor rotating over a step angle. Only with the control system consisted by double ring pulse signal and power drive circuit can the step motor be used. C. Brief introduction to the control system of step motor System controlling the step motor can be divided into three ends: step motor, motor drive circuit, transmitting end of control signal. Since special driver is commonly adopted as the drive circuit of step motor, design emphasis of this system is the transmitting end of control signal which provides pulse signal to have the step motor producing angle displacement and universal I/O signal to support the motor changing its rotating direction. TOUT1 of S3C2440A can be selected as the transmitting end of pulse signal, and common I/O terminal GPG13 as the transmitting end of changing signal. According to the project characteristic itself, control method should be manual speed regulation, i.e. electrical levels control of four interrupt pins of S3C2440A being implemented by four buttons. Buttons K1, K2, K3, K4 are defined to control interrupt pins EINT1, EINT4, EINT2, EINT0 respectively.

Wang Shuai et al. / Energy Procedia 16 (2012) 1541 1546 1543 4. Linux drive program A. Brief introduction to the drive program Version of the operating system adopted in this article is Linux 2.6.30. Device drive program is materially a group of function sets for completing various tasks, which are called by virtual file system to implement the operation of read and write on device. Therefore, device drive program shielded implementation details on hardware to application program so that the application program can be applied to operate external device as operating ordinary files. Definition the drive program of motor driver (motor drive in brief) is signal sending to the transmitting end of pulse signal TOUT1 and the transmitting end of changing signal GPG13. Button drive program will monitor the signal change of the four interrupt pins. Since motor device and button device are direct read and write device that required no buffering, they are all character devices. Linux kernel will enter the specific device file functions through file_operations structure. This section of functions are provided by device drive program, applying for various operation to hardware device. File_operations structure is defined in /include/linux/fs.h of kernel source tree, usually only several interface functions in file_operations can be implemented when drive program being written. New characters in which class list, device directory, device file are established under the directory of /sys/class, and purpose of controlling hardware can be reached by visiting device file through order line under the character interface terminal, are added in advanced version of Linux-2.6. For example, device file of LED light under /sys is /sys/class/xxx_class/xxx_device/xxx, LED light can be lightened or turned off only by inputting echo0>/sys/class/xxx_class/xxx_device/xxx.however, for more complex control, advantage of new characters is not distinct. Therefore, new characters are not completely implemented in motor drive and button drive. B. Implementation of motor drive and button drive under S3C2440A Implementation of file_operations structure of motor drive is as below: static struct file_operations motor_fops = {.owner = THIS_MODULE,.open = motor_open,.ioctl = motor_ioctl,.release = motor_release, Open and release operation is usually essential, motor_open() and motor_release() are for openning and closing down motor device respectively. Specially, opening is setting terminal GPG13 as output terminal and adding spin lock, because control to the motor must be serial; closing down is lock releasing materially. Motor_ioctl operation is transferring rotating speed data from customer process into pulse interval to

1544 Wang Shuai et al. / Energy Procedia 16 (2012) 1541 1546 reach the purpose of controlling the rotating speed of step motor. At the same time, direction parameter from customer process controls rotating direction of the motor. There are two parameters in motor_ioctl: cmd and arg. Cmd controls positive and negative rotation of the motor (0 to positive rotation,1 to negative rotation,2 to stay still) and arg is a parameter indicating rotating speed of the motor from customer process. Function motor_set_freq controls rotating speed of the motor, which adopts internal counter of S3C2440A, incoming parameter freq is rotating speed, i.e. arg parameter of motor_ioctl function, its process is as below: 1) Setting GPB1 to TOUT1, i.e. pulse generating terminal. 2) Setting timer configuration register0 (TCFG0) to 49. 3) Setting timer configuration register 1 (TCFG1) to 0x0011 (S3C2410_TCFG1_MUX0_DIV16), i.e. 1/16. 4) Acquiring clock frequency of pclk from platform clock queue of system through the functions clk_get and clk_get_rate defined in include/linux/clk.h. 5) Interval is pclk/50/16/freq acquired in (4), setting this value into timer count buffer register (TCNTB(1)). 6) Setting duty ratio 50%, setting half of the value obtained in (5) into timer comparison buffer register (TCMPB(1)). 7) Closing dead zone, automatically reloading, closing phase inverter, renewing TCNTB1 and TCMPB1, starting timer 1, i.e. timer control register(tcon). 8) Resetting TCON, clearing manual renew position of timer 1. Only by resetting GPB1 to common I/O terminal and setting to low level, pulse signal will stop. Core data structure and required variables for motor drive is as follows: struct motor_dev { struct cdev cdev; struct semaphore motor_lock; struct motor_dev *devp; static dev_t devno; static struct class *motor_class; struct device *d_p; Process of loading function for motor drive under advanced version of Linux-2.6 is as follows: 1) Call alloc_chrdev_region to get dynamic device driver number. 2) Call class_create, create class categories in /sys/class directory. 3) Distribute motor_devstruct and call cdev_init bond cdev struct under motor_dev with file_operations in the driver. 4) Registrate cdev to the core. 5) Call the class categories under /sys/class, create device directory. 6) Initialise the semaphore under motor_dev; Name the written drive program as motor.c. C. Drive of button device The great difference between button drive and motor drive is that button drive is drive program of interrupt device. Therefore, button driven has the following characteristics: 1) Button drive will set the common I/O terminal in use to interrupt port and set the interrupt handling program. 2) Button drive should support polling operation from application program such as select, etc. Therefore, there are following modifications for button drive comparing with motor drive: 1) Since there are four buttons, each button device should be initialized. They use the same primary device number, and different sub-device number.

Wang Shuai et al. / Energy Procedia 16 (2012) 1541 1546 1545 2) For each button device, a wait queue head and a flag variable should be added in its button_dev device structure. Loading function of drive program initializes the wait queue head for each button device. 3) File_operations structure of button drive will implement: static struct file_operations buttons_fops = {.owner = THIS_MODULE,.open = buttons_open,.release = buttons_release,.poll = buttons_poll, Open and release operation is essential, open operation sets the common I/O port used by buttons to interrupt port and makes the interrupt port be resource register (to prevent being used by other program), and at the same time register the interrupt handling program (adopting request_irq, and transferring button_dev device structure to the interrupt handling program). Release operation will release interrupt resource (disable_irq and free_irq). The interrupt handling program only does two kinds of things: setting the flag variable in button_dev and waking up the process from the waiting queue. Purpose of poll operation is to support the select polling operation. Poll operation calls poll_wait function to make the process go into sleeping till waking up(wake_up)operation of the interrupt handling program. Kernel data structure of buttons drive is as follows: struct button_resource { int irq;// interrupt number corresponding to common I/O port int pin;//common I/O port int pin_setting;//interrupt port corresponding to common I/O port struct buttons_dev { struct cdev cdev; struct button_resource resource; volatile int flag_press; wait_queue_head_t button_wait; struct buttons_dev *devp; Initializing the four buttons to: struct button_resource b_resources[] = { {IRQ_EINT1,S3C2410_GPF1,S3C2410_GPF1_EINT1, 0}, {IRQ_EINT4,S3C2410_GPF4,S3C2410_GPF4_EINT4, 1}, {IRQ_EINT2,S3C2410_GPF2,S3C2410_GPF2_EINT2, 2}, {IRQ_EINT0,S3C2410_GPF0,S3C2410_GPF0_EINT0, 3}, Naming the above written drive program as buttons.c. After verification, the above drive program can operate perfectly on motor, can implement functions such as switching control, manual speed regulation, prompting of LED light, etc. 5. Test the driver module in application program First, define functional keys: K3: acceleration; K4: deceleration. When in static state or running in reverse direction, press K1 to turn in positive direction. When in static state or running in positive direction, press K2 to turn in reverse direction. When running in positive direction, press K1 to come to

1546 Wang Shuai et al. / Energy Procedia 16 (2012) 1541 1546 standstill. When running in reverse direction, press K2 to come to standstill. Application program can fulfill main functions as below: 1) Bring the system into snooze mode by SELECT system. Once wakeup, FD_ISSET macron can be used to determine interrupted processing program of press button equipment from which such wakeup operation comes. 2) Define symbolic vector flag: 0, 1, 2 and 3 for pressed K1, K2, K3 and K4. 4 stands for standstill. Initial value is 4. Flag indicates lat pressed key. Depending on flag value and currently pressed key as defined in (1), use specified function of the key to operate ioctl to control speed and direction of motor rotation. Compiled application program is named contro.c. Transmit through NFS the drive modes motor.ko and buttons.ko which are compiled in parallel and application program control to the directory of the lib of S3C2440A based object machine. Add insmod motor.ko insmod buttons.ko control& to startup script /etc/rc.d/rcs. Restart the system to realize manual speed adjustment. 6. Conclusion and expectation In practical control system, implementation of control to step motor is not the final purpose. It is only one part of the system. Since step motor is widely applied in control field, and embedded system has the characteristics of portable and compact, combination of these can greatly simplify complexity of the system. For example, controller requires reading in some data from some peripheral device, and controls the controlled device like motor according to these data, and sends signal to display device and PC terminal, and people also hope that the controlled device can be directly operated and controlled. Obviously, these will greatly increase complexity of the system. And more importantly, increasing of complexity is non-linear, a central control program may be required on the terminal of micro-controller following the increasing of device and tasks, to control the dispatching of each device and task. So, partition of system-level software and application-level software in embedded software is natural. Under embedded Linux system, development of drive program of step motor is implemented by character device thought. At present, only open-loop approach is adopted to control step motor for driver system of entrance guard system. In order to meet the requirement under more complex condition, we can adopt the control approaches of partition and closed loop to step motor, to achieve more complex function. Control method of driver module is also applicable, through partly modification. Application of specified kernel for embedded system can greatly simplify the implementation complexity of system and enable a great extendibility to the system.