Download presentation
Presentation is loading. Please wait.
Published byOliver Robbins Modified over 9 years ago
1
Emblinux DC-MOTOR
2
利用 tftp 把 host 和 target 連接 Run kernel Run rootfs
3
拷貝 driver 到 linux 中 用 make 得到 ko 檔 ( 驅動 ) 在用 /usr/local/arm/3.4.1/bin/arm-linux-gcc – o xx_test xx_test.c 可得 xx_test( 測試檔 )
4
Dc motor 如同 pwm 一樣用 duty cycle 控制轉速 程式如下 ( 在附件 ) dc_motor.c dc_motor_test.c
5
PWM and timer in Samsung S3C2410X TCNTB: Time counter buffer register for clock period TCMPB: Time compare buffer register for PWM pulse width TOUT1 Dead Zone Control Logic 0 Dead zones generator TCMPB0 TCNTB0 TOUT0 Dead Zone 1/16 1/32 1/64 1/128 TCLK0 8-bit prescaler PCLK TCMPB1 TCNTB1 1/16 1/32 1/64 1/128 TCLK0 8-bit prescaler TOUT2 Control Logic 4 TCNTB4 No pin TOUT3 PWM 1 PWM 0 PWM 2 PWM 3 TCMPB2 TCNTB2 TCMPB3 TCNTB3
6
HL Chan, EE, CGU Interfacing 6 Pulse-width modulation (PWM) DC motor control: Rotation speed proportional to input voltage level – DC-to-DC converter – Digital-to-analog converter – PWM (use average voltage) Use pulse width as control command to output device Pulse width Duty cycle 50% 75% 25% 5V μP PWM Average value 2.5 3.75 1.25
7
DC motor connection
8
GPIO registers
9
set_pwm3 函數:完成對直流馬達的脈波比調節。參 數 hiratio 為占空百分比( 0~100 ) static void set_pwm3(unsigned char hiratio) { unsigned long tcnt; printk("hiratio = %d",hiratio); tcnt =( 96000000 )/( FREQ_PWM1 *16 ); __raw_writel(((tcnt*(hiratio))/100), S3C2410_TCMPB(3)); }
10
dcm_ioctl 函數:透過呼叫 set_pwm3 函數,傳送不同 的脈波比參數,對直流馬達的速度進行 10 級調節 static int dcm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch(cmd) { case DC_IOCTL_START: set_pwm3(DUTY); break; case DC_IOCTL_STOP: set_pwm3(0); printk("off\n"); break; case DC_IOCTL_SPEED_UP: DUTY +=STEP; if (DUTY>MAX_VAL) DUTY=MAX_VAL; set_pwm3(DUTY); break; case DC_IOCTL_SPEED_DOWN: DUTY -=STEP; if (DUTY<0) DUTY=0; set_pwm3(DUTY); printk("PWM_IOCTL_SPEED_DOWN\n"); break; default : break; } return 0; }
11
對 dcm_ioctl 的參數初始化 #define MAX_VAL 90 static int DUTY = 50; static int STEP=10;
12
作業 不要透過 uart 而改變馬達轉速 (DUTY:0~100)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.