1 / 12

Emblinux

Emblinux. DC-MOTOR. 利用 tftp 把 host 和 target 連接 Run kernel Run rootfs. 拷貝 driver 到 linux 中 用 make 得到 ko 檔 ( 驅動 ) 在用 /usr/local/arm/3.4.1/bin/arm-linux-gcc –o xx_test xx_test.c 可得 xx_test( 測試檔 ). Dc motor. 如同 pwm 一樣用 duty cycle 控制轉速 程式如下 ( 在附件 ) dc_motor.c dc_motor_test.c.

mercury
Download Presentation

Emblinux

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 TCMPB0 TCNTB0 PWM 0 TOUT0 Control Logic 0 Dead zones generator 1/16 1/32 1/64 1/128 TCLK0 Dead Zone PCLK 8-bit prescaler TCMPB1 TCNTB1 TOUT1 PWM 1 TCMPB2 TCNTB2 Dead Zone PWM 2 TOUT2 • TCNTB: Time counter buffer register for clock period • TCMPB: Time compare buffer register for PWM pulse width TCMPB3 TCNTB3 1/16 1/32 1/64 1/128 TCLK0 PWM 3 TOUT3 8-bit prescaler TCNTB4 Control Logic 4 No pin

  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 5V Duty cycle Average value Pulse width μP 25% 1.25 PWM 50% 2.5 75% 3.75

  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)

More Related