Design of electronic control throttle based on ARM-Linux of Samsung S3C2410

Publisher:平凡梦想Latest update time:2014-03-18 Source: elecfansKeywords:S3C2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  introduction

  The cruise control system (CCS) was developed in the 1960s and is also known as a constant speed driving system. When the cruise control system is working, the ECU determines the operating status of the car based on the signals sent by various sensors, and automatically adjusts the throttle opening through the actuator to keep the car's driving speed consistent with the set speed. When the car is driving on a good road for a long time, the driver starts the cruise control system and sets the driving speed. The driver does not need to operate the accelerator pedal. The cruise control system can automatically maintain the set driving speed, which not only reduces the driver's labor intensity, but also uses advanced electronic control technology to control the throttle opening, which is more accurate than the driver operating the throttle, and the car's fuel economy and emission pollution can also be improved.

  1 System Principle

  1.1 Principle of electronic throttle control

  During operation, the driver issues a speed control command, the throttle opening sensor collects the engine speed parameters, and inputs the signal into the electronic control unit; the electronic control unit compares the control signal with the feedback throttle position signal, and drives the actuator to change the throttle opening according to the comparison result, so that the actual opening is consistent with the control opening, thereby realizing automatic control of the vehicle speed.

  1.2 Servo control principle

  A servo is a position (angle) servo drive suitable for systems where the angle needs to be constantly changed and maintained. The S3003 servo has three pins, namely the power supply Vcc, the ground GND and the control line Signal. The control signal enters the signal modulation chip through the Signal channel to obtain a DC bias voltage [2]. It has a reference circuit inside that generates a reference signal with a period of 20 ms and a width of 1-5 ms. The DC bias voltage obtained is compared with the voltage of the potentiometer to obtain a voltage difference output. Finally, the positive and negative outputs of the voltage difference are sent to the motor driver chip to determine the forward and reverse rotation of the motor. When the motor speed is constant, the potentiometer is driven to rotate through the cascade reduction gear, so that the voltage difference is 0 and the motor stops rotating.

  The input of the control line is a periodic square wave pulse signal with adjustable width. The period of the square wave pulse signal is 20 ms (i.e. the frequency is 50 Hz). When the pulse width of the square wave changes, the angle of the servo changes, and the angle change is proportional to the pulse width. The relationship between the output shaft angle and the input pulse width is shown in Figure 1.

  Relationship between servo output angle and input pulse width

  Figure 1 Relationship between servo output angle and input pulse width

  2 System Design

  This system uses Samsung's S3C2410 and Futaba's S3003 servo as controller and actuator respectively, uses Linux operating system, and the experimental platform is the engine experimental platform of Jinan Hengxin Co., Ltd. [page]

  System Process

  Figure 2 System flow

  2.1 System Design Process

  The system flow is shown in Figure 2. The controller S3C2410 completes various initialization tasks, receives the cmd command from the operator, and performs a series of processing according to the cmd value, including stopping the actuator, rotating the actuator by a certain angle, etc. Then, the equivalent cmd value is calculated through the throttle opening sensor and the speed sensor, and compared with the cmd to decide whether to make the next cmd judgment or adjust the actuator angle.

  2.2 Setting the Linux system clock frequency

  In order to reduce electromagnetic interference and reduce the requirements for inter-board wiring, the frequency of the crystal oscillator connected to the chip is usually very low, and the system clock is increased by the PLL of the clock control logic [3]. The S3C2410A manual of Samsung Company lists several recommended clock frequencies. Here we choose the configuration of output clock frequency FCLK=202?80 MHz, that is, in the PLL control register: MDIV=161 (0xa1), PDIV=3, SDIV=1.

  Set it in board/smdk2410/smdk2410.c of UBoot:

  #define M_MDIV 0xA1

  #define M_PDIV 0x3

  #define M_SDIV 0x1

  int board_init(void){

  …

  /* configure MPLL */

  clk_power?﹥MPLLCON = ((M_MDIV ﹤﹤ 12) + (M_PDIV ﹤﹤ 4) + M_SDIV);

  …

  }

  Set the ratio of FCLK, HCLK, PCLK in cpu/arm920t/start.S of UBoot:

  /* FCLK:HCLK:PCLK = 4:2:1*/

  ldrr0, =CLKDIVN

  mov r1, #3

  strr1, [r0]

  From the above program, we can see that FCLK=202.80 MHz, HCLK=101?40 MHz, PCLK=50.70 MHz, and the clock used by the PWM module of S3C2410 is PCLK, so the input clock of PWM is 50.7 MHz.

  2.3 Writing the Servo Driver

  2.3.1 Using udev to dynamically create device nodes

  The Linux 2.6 series kernel uses udev to manage device nodes in the /dev directory. It is also used to replace the functions of devfs and hotplug, which means that it has to handle the /dev directory and all user space behaviors when adding/removing hardware, including loading firmware. udev relies on sysfs to export all device information to user space, and /sbin/hotplug to notify it when devices are added or removed [4].

  In order for udev to work properly, a device driver must export the major and minor device numbers of the device controlled by the driver to user space through sysfs. udev searches for a file named dev in the /class/ directory tree in sysfs so that when the kernel calls it through the /sbin/hotplug interface, it can obtain the major and minor device numbers assigned to a specific device [5]. A device driver only needs to use the class_create interface to create this file for each device it controls. [page]

  The class structure is created using the class_create function. This code creates a directory under /sys/class in sysfs, and creates a new "pwm" class in the directory to accommodate all the attributes of the driver exported through sysfs. One of the attributes is the dev file entry, which is created by class_device_create() - it triggers the user space udev daemon to create the /dev/pwm device node. The code is as follows:

  static struct class *pwm_class;

  pwm_class = class_create(THIS_MODULE, "pwm");

  if(IS_ERR(pwm_class)){

  printk(KERN_ERR "Error creating pwm class.\\ ");

  goto error;

  }

  When the driver discovers a device and has assigned a minor number, the driver calls the class_device_create function:

  class_device_create(pwm_class, NULL, MKDEV(device_major, 0), NULL, "pwm");

  This code creates a subdirectory pwmN under /sys/class/pwm, where N is the minor device number of the device. In this directory, a file dev is created, and with this udev can create a device node for the device in the /dev directory.

  When the device is detached from the driver, it is also detached from the assigned minor device number. At this time, the class_device_destroy (struct class *cls, dev_t devt) function needs to be called to delete the device's entry in sysfs:

  class_device_destroy(pwm_class, MKDEV(device_major, 0)).

  2.3.2 Configuring PWM output frequency

  First use the system function provided by the Linux system to obtain the clock pclk:

  clk_p = clk_get(NULL, "pclk");

  pclk = clk_get_rate(clk_p);

  From the S3C2410 data sheet, we know that after the prescaler and clock divider, the input clock frequency of timer 0 is calculated as clkin= (pclk/{prescaler0+1}/divider value); and then divided by the 16-bit timer 0 count register TCNTB0 and timer 0 compare counter TCMPB0 (their values ​​are represented by tcnt and tcmp respectively), so that a suitable PWM waveform signal can be obtained from pin Tout0, with a period of T=tcnt/clkin and a high level period of Th=tcmp/clkin.

  Given that pclk = 50.7 MHz, let

  MAX=(prescale0+1)×(divider value)(1)

  Then clkin=pclk/MAX; we can take tcnt=pclk/date; and because tcnt is 16 bits, tcnt≤65 535, so 507 in pclk can be directly eliminated; and the system requires a period of T=20 ms, so we first extract the coefficient 50, that is:

  tcnt=pclk/(date×50)=1 014 000/date(2)

  It turns out that MAX=date≥16, the value range of prescaler0 is 0 to 255, and the possible values ​​of divider value are 1, 2, 4, and 16.

  The required PWM waveform period is 20 ms, the positive level width is 0.5 to 2.5 ms, 20 ms/0.5 ms=40, so:

  tcmp=tcnt/40+(cmd-1)×tcnt/(40×N)(3)

  Where tcmp and tcnt are both integers; N is the subdivision coefficient, which means that when cmd is increased by 1, the servo will rotate (45/N)°; cmd is the control parameter to be input, which is used to control the angle of the servo.

  According to equations (1) to (3), and the principle that tcmp and tcnt should be integers as much as possible to reduce errors, MAX=date= can be 16, 20, or 25.

  3 Experimental results analysis

  Theoretically, the larger the subdivision coefficient N is, the more accurate the actuator's action will be, but too large a subdivision coefficient will cause the actuator's command to respond more slowly to cmd. Therefore, the value of N should be considered comprehensively based on the distance from the actuator to the throttle valve. Taking the subdivision coefficient N=5, that is, using the formula: tcmp=tcnt(cmd+4)/200, the minimum angle is (45/5)=9, which is sufficient to meet the needs of the experiment.

  By using the experimental method, experiments were conducted on MAX=date=16, 20, and 25 respectively, and an oscilloscope was used to observe the value of MAX=date based on the rounding characteristics of the register. The results are listed in Tables 1 to 3. Among them, cmd is the input command, err is the error, Wh is the high level width, and ~Wh is the actual high level width.

  Table 1 Results when MAX=date=16, tcnt=63375, clkin=3168750

  Table 1 Results when MAX=date=16,tcnt=63375, clkin=3168750

  Table 2 Results when MAX=date=20, tcnt=50700, clkin=2535000

  Table 2 Results when MAX=date=20,tcnt=50700, clkin=2535000

  Table 3 Results when MAX=date=25, tcnt=40560, clkin=2028000

  Table 3 Results when MAX=date=25,tcnt=40560, clkin=2028000

  From the above data, we can see that the error is the smallest when MAX=date=20. From formula (4), we can see that prescale0+1=20, 10, 5 correspond to divider value=1, 2, 4.

  Conclusion

  The high frequency generated by the ARM phase-locked loop can be used to obtain a more precise PWM wave, thereby achieving more precise control of the servo to achieve the purpose of precise throttle control. This paper implements the control of the servo angle of 9 from both theoretical and practical aspects. To obtain a more detailed angle, just increase the value of N. For example, if N=15, the minimum control angle that can be obtained is (45/15)=3; if N=45, the minimum control angle that can be obtained is (45/45)=1.

Keywords:S3C2410 Reference address:Design of electronic control throttle based on ARM-Linux of Samsung S3C2410

Previous article:Photonics technology will be widely used in automotive applications
Next article:Video Moving Vehicle Detection System Based on DM6446

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号