본문 바로가기

Eelektronika

PWM Arduino Uno

반응형

itutorial - It has the ability to operate DC motors at lower speeds Pulse Width Modulation (PWM) on the Arduino board microcontroller, namely setting the comparison or ratio tall And low (cycle) I really love you.

How to use PWM to operate a DC motor?

It will be easier to answer the question above if you use the analogy of an LED flame. This is what makes me happy at home divert There are many different types of LED lights, and they also feature different LED lights with different lights at the same time. It will be difficult to use an LED screen to display the same colors as an LED display. This also applies to DC motors where when the signal is square it has a condition tall Longer or longer than the condition low then the dc motor will rotate faster than the square PWM signal that has the condition low longer in comparison tall.

PWM and pad frequencies are different grid line follower I do not know what to do try try (trial) because the author uses a Tamiya DC motor and does not know the detailed specifications of the Tamiya DC motor. There is no need to worry about anything other than this, and this also happens. grid line follower This is what you want and desire Video 1 day grid line follower walking quite hello.

Use this technical explanation regarding setting up Arduino PWM via register tuning Timer/Counter.

Setup Timer/Counter 1 10 bit fast PWM.

Designing grid line follower This page focuses on the use of registers timer/counter 1 Where timer/counter it is a register timer which can count from 0 to 16 bits and can be used as a Fast PWM or PWM True Phase 8, 9 or 10bit.

And this tent has many types of tents that can be installed using PWM so they can be used for a long time. cycle So the rotational speed of the dc motor can change so that grid line follower This may be the reason why it has nothing to do with it, but it also has the same control over it. The materials and images below are taken from the materials data sheet ATmega328P microcontroller IC.

Figure 1. Fast PWM timing diagram mode

Image Caption 1:
  1. TCNTn: register Timer/Counter which is used to count from 0 to maximum (depending on the bit ward off used) then from the maximum count down to 0 continuously and repeatedly. I don't need to eat anything timer activated.
  2. OCRnx: Is a register and is used to change cycleThe value in this register is compared with the TCNTn value, the result of which will change cycle Output pad or output on the OCnx pin or terminal.
  3. OCnx: List Compare Output They also have different options for registering TCNTn and OCRnx. OCnx is directly related to the pin or PWM terminal (PWM output).

PWM pins or terminals output used in the network grid line follower This uses pins 9 and 10 on the Arduino Uno because these pins work in 8, 9 and 10 bit PWM mode. By using this pin you can have many options if you want to change the PWM mode used. Timer/Counter 1 The register has several modes for using PWM as follows:

  1. PWM True Phase 8, 9 or 10bit
  2. Fast PWM 8,9, or 10bit
  3. Correct PWM Phase and Frequency
  4. PWM True Phase
  5. Fast PWM

PWM and other devices grid line follower this is using Fast PWM 10 bit. Maybe if you can use different modes according to the suitability of the dc motor you are using.


It doesn't work in this mode Fast PWM10 bits can use the data shown in Table 1 taken from data sheet ATMega328P.

Table 1. PWM mode descriptionPWM description mode

To set the PWM according to the data in table 1, you need to adjust the TCCR1 register as shown in Figures 2 and 3 below:

Register TCCR1A
Figure 2. Register TCCR1A

Register TCCR1B
Figure 3. Register TCCR1B

Data tab 2 below is used to change the TCCR1A register on the COM1A or COM1B bit which aims to select whether the PWM mode is reversernot flipping Or disconnect the OCA1A or OC1B port so that the PWM wave does not come out of the Arduino PWM pin.

Table 2. Configuration Fast PWM Output Mode
Configure Fast PWM Output Mode
Table 3. Hours choose a little

Clock tab select bit

To configure fast 10 bit PWM And also has a TCCR1A register and TCCR1B adjustment register. For this you need to change the bits in each register according to the data options in tables 1, 2, 3 including Figure 2 and Figure 3 above.


Example of the value of each bit in the TCCR1A register:
  • bit 0: WGM10 is 1
  • bit 1: WGM11 is 1
  • bit 2: Value 0
  • bit 3: Value 0
  • bit 4: COM1B0 is 0
  • bit 5: COM1B1 is 1
  • bit 6: COM1A0 is 0
  • bit 7: COM1A1 is 1

So the TCCR1A value can be written as:

TCCR1A = 0b10100011 or TCCR1A = 0xA3

Example of the value of each bit in the TCCR1B register:
  • bit 0: CS10 is worth 0
  • bit 1: CS11 is 0
  • bit 2: CS12 is 1
  • bit 3: WGM12 is 1
  • bit 4: WGM13 is 0
  • bit 5: Value 0
  • bit 6: ICES1 is 0
  • bit 7: ICNC1 is 1

So the TCCR1B value can be written as follows:

TCCR1B = 0b00001100 or TCCR1B = 0x0C

Make sure to register TCCR1A and TCCR1B together:
  1. The bit value of WGM10, WGM11 is 1 and WGM12 is 1 and WGM13 is 0. Fast PWM mode 10 bit.
  2. The bit value COM1B1, COM1A1 is 1 and COM1B0, COM1A0 is 0, meaning it is using mode not flipping. This is what you are trying to do reverserAnd there are motorbikes that get the opposite speed, where if you want them to be fast they end up slow, and vice versa.
  3. In the TCCR1B register, the CS10, CS11, CS12 bits are 0, 0 and 1, which means that the PWM frequency is the speed frequency. clock crystal oscillator divided by 256 (clkio/256).

Because the setup uses 10bit fast PWM No need to use PWM is:


Using a frequency of around 61 Hz, the Tamiya dc motor can work well as shown in Video 1.


After knowing the configuration 10bit fast PWMthe thing that needs to be done is to give the initial speed on line follower Members now have the option of OCR1A and OCR1B on 0 to 1023 (10 bits).

Don't forget to talk about what you need to know, if you have any problems, you don't need to worry. Fast PWM simply write the values ​​from the TCCR1A and TCCR1B registers as in the following example:

void main()
{
// 10bit fast PWM
TCCR1A = 0b10100011 ;
TCCR1B = 0b00001100 ;
OCR1A = 500 ; //duty cycle below almost 50% (DC motor rotates slowly)
OCR1B = 500 ; //duty cycle below almost 50% (DC motor rotates slowly)
}

Project Materials Grid Line Follower :
  1. Grid Line Follower Working Concept
  2. How Arduino Uno's PWM works for regulating dc motor speed
  3. Interrupt timer For line sensor reading
  4. Line Sensor Reading Program Code
  5. Mechanics and movement Grid Line Follower
  6. Complete Code Grid Line Follower
  7. PCB and Grid Line Follower Circuit
반응형

'Eelektronika' 카테고리의 다른 글

Op-amps  (0) 2024.04.26
Rectifier diode  (0) 2024.04.26
JFET (Junction Field Effect Transistor)  (0) 2024.04.26
N-MOSFET Amplifier Common Source  (0) 2024.04.26
Install Sloeber IDE on Windows  (0) 2024.04.26