Stepper Motor 디바이스 드라이버

Slides:



Advertisements
Similar presentations
RT_FIFO, Device driver.
Advertisements

Lecture for Lab 3, Exp1 of EE505 (Developing Device Driver) T.A. Chulmin Kim CoreLab. Mar, 11, 2011 [XenSchedulerPaper_Hotcloud-commits] r21 - /
Computer System Laboratory
Programming Languages and Paradigms The C Programming Language.
Building and Running Modules Sarah Diesburg COP 5641.
FND 디바이스 드라이버 Lecture #13.
MSP430 Motor Controller Applications
CS 311 – Lecture 10 Outline Review open() and close() Difference between fopen() and open() File management system calls – read() – write() – lseek() –
Non-blocking I/O int flags; int fd; /* file descripter */ void main() { fd = open(“myfile.txt”, R_ONLY); if ((flags = fcntl(fd, F_GETFL, 0)) < 0) /* first.
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati. Writing/Registering to /proc Character Device Driver – Characteristics and functionality – Basic IO functions.
Stepper Motors Jason Wells. Background Brushless, synchronous electric motor Brushless, synchronous electric motor No feedback necessary (open loop) No.
Device Drivers In Linux © Gregory Kesden Fall 2000.
KyungHee Univ. 2-0 Chapter 8 Parallel Port Interfaces.
M. Muztaba Fuad Advanced Operating System Project Device Drivers.
POSIX: Files Introduction to Operating Systems: Discussion 1 Read Solaris System Interface Guide: Ch. 5.1 Basic File I/O.
Loadable Kernel Modules Dzintars Lepešs The University of Latvia.
Kernel module programming Nezer J. Zaidenberg. reference This guide is built on top of The Linux Kernel Module Programming Guide The guide is available.
Applied Control Systems Robotics & Robotic Control
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
Codec,battery,powermanager 커널 드라이버
Character LCD 디바이스 드라이버
2012 내장형 시스템 설계  Full Color LED 디바이스 구성  Full Color LED 디바이스 드라이버  Full Color LED JNI 라이브러리 작성  Full Color LED 안드로이드 App 구현  JNI 라이브러리.
OPERATING SYSTEMS 12 - FILES PIETER HARTEL 1. Files  Properties  Long term existence of data  Sharable between processes  Access control  Operations.
Instrumentation & Control Engg. Section Electrical Engineering Department Ahmedabad , Gujarat.
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
TEXT-LCD 디바이스 드라이버 Lecture #16.
UNIT 29 MCU Project 로봇 SW 교육원 조용수.
Kernel Modules. Kernel Module Pieces of code that can be loaded and unloaded into the kernel upon demand. Compiled as an independent program With appropriate.
Counter/Timer/PWM. incoming Lab. Counter counter is a device which stores the number of times a particular event or process has occurred synchronous/asynchronous.
Implementation of Embedded OS Lab3 Linux Kernel Modules.
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
K ERNEL D EVELOPMENT CSC585 Class Project Dawn Nelson December 2009.
11장 LDS2000 임베디드 실습.
Linux Device Driver 2009/04/08. Reference Book Another Reference Book Embedded Linux Primer: A Practical, Real-World Approach By Christopher Hallinan.
Internal Device Driver
Interfacing Device Drivers with the Kernel
Emblinux DC-MOTOR. 利用 tftp 把 host 和 target 連接 Run kernel Run rootfs.
1 1 Nov. 24, 2015 Kyu Ho Park Lecture 11 Time Handling,GPIO and I/O Systems.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
충북인력개발원 전자과 공학박사 강원찬 3. Timer & Counter &PWM. uP AVR (Atmega128) PWM1=OC1A(PB5) PWM2=OC1B(PB6) T0=T1(PD6) T1=T2(PD7)
망고100 보드로 놀아보자-14 디바이스 드라이버 작성 기초
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
1 4-Integrating Peripherals in Embedded Systems (cont.)
2 DHT11 Sensor VCC 3V 연결 GND GND 연결 Data GPIO 4 연결 Resistance10K.
OS interface: file and I/O system calls File operations in C/C++? –fopen(), fread(), fwrite(), fclose(), fseek() in C f.open(…), f.close(…) in C++ I/O.
2009/12/8 Report 報告學生 : 黃健瑋 指導教授 : 李正帆 1. Content seq_file structure proc file Data structure(not completed) 2.
1 Intro to Kernel Modules and /proc Sarah Diesburg CS 3430 Operating Systems.
Finish up OS topics Group plans. Today Finish up and review Linux device driver stuff – Walk example again – See how it all goes together – Discuss talking.
Chapter 3 Actuator Modeling
NAM S.B MDLAB. Electronic Engineering, Kangwon National University 1.
Lecture 3 Module Programming and Device Driver (Homework#1 included) Kyu Ho Park Sept. 15, 2015.
File table: a list of opened files Each entry contains: – Index: file descriptors – Pointer to the file in memory – Access mode File descriptor is a positive.
Embedded Linux Kernel Porting & Device Driver - 유柳 명明 환桓유柳 명明 환桓 [  ]
DIGITAL CONTROL 목 차 10. Dynamic model of DC servo motor Kyoung-Chul
 LED 를 직접 제어하는 디바이스 드라이버를 작성해 보자  Reminder: LED 는 SPI 를 통해 ARM7 과 연결된다. ◦ 그렇다면 고쳐야 하는 코드는 어디에 ?  linux-2.6.x/arch/arm/mach-nds/arm7 ◦ Hardware spec.
Device Driver_Skeleton
MOTORS.
Chapter 7-Android HAL 中国科学技术大学软件学院.
Lecture 3 Module Programming and Device Driver (Homework#1 included)
Linux Kernel Driver.
Scull device 사용 예 강서일( ) 최정욱( ).
פרטים נוספים בסילבוס של הקורס
Stepper Motors A stepper motor is a “pulse-driven” motor that changes the angular position of the rotor in “steps” Define β = the step angle (per input.
פרטים נוספים בסילבוס של הקורס
CSE 333 – Section 3 POSIX I/O Functions.
IT 318: M5 Motors: Questions IT M6.
Programming Language C Language.
Loadable Kernel Modules
Socket Programming with UDP
Presentation transcript:

Stepper Motor 디바이스 드라이버 Lecture #14

목 차 Stepper Motor구동 원리 Stepper Motor 디바이스 드라이버 Stepper Motor 응용 프로그램

Stepper Motor 개요 (1) 디지털 펄스를 기게적인 축 운동으로 변환시키는 디지털 엑추에이터 디지털 소스에서 펄스를 가하면 모터 축을 펄스의 주파수 및 펄스 수에 따라 정해 진 속도로 정해진 각도로 회전한다 AC servo 또는 DC servo motor에 비하여 정확한 각도 제어에 유리 하여 많이 사용 Stepper Motor, Stepping Motor, Pulse Motor 장점: 디지털 신호로 직접 open loop 제어를 할 수 있고 전반저긍로 간단하게 구동 회전속도는 펄스 신호의 주파수에 비례, 회전각도는 입력 펄스의 수에 비례 기동, 정지, 정-역회전, 변속이 용이하며 응답 특성도 양호 고토크, 고속 응답, 소형 경량, 미소각, 고정도, 저가격 단점: 고속 운전시 탈조가 쉽다 특정 주파수에서는 진공, 공진현상이 발생하기 쉽고 관성이 있는 부하에 약한다 펄스 비가 상승하면 토크가 저하하며 DC servo motor에 비해 효율이 떨어진다

Stepper Motor 개요 (2)

Stepper Motor 구조 및 동작 방식 Stepper Motor 구조 고정자(Stator) – 모터 내부의 장착된 코일, 모터의 위상(phase)을 결정, 전원 공급시 에 전자기력을 생성 회전자(Rotator) – 전자기력에 의해 회전하는 축, 회전축의 회전에 따라 역기전압이 발생, 입력 전압과 반대방향으로 서로 상쇄하여 전류 흐름을 제한 A. 4상 스텝 모터 B. 5상 스텝 모터

Stepper Motor 제어 (1) Stepper Motor 제어 포트의 물리 주소 0xC000000C Stepper Motor 제어 데이터 bit Bit 7 6 5 4 3 2 1 Stepper Motor nB B nA Step1 A Step2

Stepper Motor 제어 (2) Stepper Motor – Half Step Operation Stepper Motor – Full Step Operation Sequence Input Output A nA B nB 1 1(H) 0(L) 2 3 4 Sequence Input Output A nA B nB 1 1(H) 0(L) AB 2 nAB 3 nAnB 4 AnB

PXA255-FPGA – Stepper Motor 회로 구성(1)

PXA255-FPGA – Stepper Motor 회로 구성(2)

PXA255-FPGA – Stepper Motor 회로 구성(3)

PXA255-FPGA – Stepper Motor 회로 구성(4)

Stepper Motor Device Driver – 매크로/전역 변수 (stepmotor_driver.c) #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/version.h> #include <linux/delay.h> #include <linux/ioport.h> #include <asm-arm/io.h> #include <asm-arm/uaccess.h> #define IOM_STEP_MAJOR 269 // ioboard step device major number #define IOM_STEP_NAME "STEP" // ioboard step device name #define IOM_STEP_ADDRESS 0x0C00000C // pysical address #define A (unsigned short)(0x1) #define AB (unsigned short)(0x5) #define B (unsigned short)(0x4) #define _AB (unsigned short)(0x6) #define _A (unsigned short)(0x2) #define _A_B (unsigned short)(0xa) #define _B (unsigned short)(0x8) #define A_B (unsigned short)(0x9) //Global variable static int stepport_usage = 0; static unsigned short *iom_step_addr;

Stepper Motor Device Driver – 매크로/전역 변수 (stepmotor_driver.c) // define functions... ssize_t iom_step_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what); int iom_step_open(struct inode *minode, struct file *mfile); int iom_step_release(struct inode *minode, struct file *mfile); // define file_operations structure struct file_operations iom_step_fops = { open: iom_step_open, write: iom_step_write, release: iom_step_release, };

Stepper Motor Device Driver – open/release (stepmotor_driver.c) // when step device open ,call this function int iom_step_open(struct inode *minode, struct file *mfile) { if(stepport_usage != 0) return -EBUSY; stepport_usage = 1; return 0; } // when step device close ,call this function int iom_step_release(struct inode *minode, struct file *mfile) stepport_usage = 0;

Stepper Motor Device Driver – write (stepmotor_driver.c) // when write to step device ,call this function ssize_t iom_step_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned short speed; const char *tmp = gdata; if (copy_from_user(&speed, tmp, 2)) return -EFAULT; outw(A,iom_step_addr); udelay(speed); outw(B,iom_step_addr); outw(_A,iom_step_addr); outw(_B,iom_step_addr); return length; }

Stepper Motor Device Driver – init/cleanup (stepmotor_driver.c) int __init iom_step_init(void) { int result; result = register_chrdev(IOM_STEP_MAJOR, IOM_STEP_NAME, &iom_step_fops); if(result < 0) { printk(KERN_WARNING"Can't get any major\n"); return result; } iom_step_addr = ioremap(IOM_STEP_ADDRESS, 0x2); printk("init module, %s major number : %d\n", IOM_STEP_NAME,IOM_STEP_MAJOR); return 0; void __exit iom_step_exit(void) iounmap(iom_step_addr); if(unregister_chrdev(IOM_STEP_MAJOR, IOM_STEP_NAME)) printk(KERN_WARNING"%s DRIVER CLEANUP FALLED\n", IOM_STEP_NAME); module_init(iom_step_init); module_exit(iom_step_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Huins");

Stepper Motor Device Driver – 테스트 프로그램 (test_stepmotor.c) #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> int main(void) { int fd,id; unsigned int b_delay; unsigned short c = 0xffff; fd = open("/dev/STEP", O_WRONLY); if (fd < 0){ printf("Device Open Error\n"); exit(1); } while(1) { if(c < 0x1000) c = 0x1000; else c -= 0x100; write(fd, &c, 2); close(fd); return 0;

Stepper Motor Device Driver – Makefile #Makefile for a basic kernel module obj-m := stepmotor_driver.o KDIR :=/root/pxa255-pro3/kernel/linux-2.6.21 PWD :=$(shell pwd) all: driver app driver: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules app: arm-linux-gcc -o test_stepmotor test_stepmotor.c clean: rm -rf *.ko rm -rf *.mod.* rm -rf *.o rm -rf test_stepmotor rm -rf Module.symvers

Stepper Motor Device Driver – Testing 타겟보드를 부팅한 후 드라이버 모듈과 테스트 프로그램을 nfs 마운 트 디렉토리에 복사한 후에 아래와 같이 진행한다. # insmod ./stepmotor_driver.ko init module, STEP major number : 269 # mknod /dev/STEP c 269 0 # ./test_stepmotor