본문 바로가기

Eelektronika

Timer interrupt with line sensor

반응형
Interrupt Timer very suitable for use in programs that work similar to perform multiple tasks where programs appear to be running simultaneously even though it is not like that. Analogy interrupt timer This is when a program has not finished registering interrupt timer Perform an interrupt to run it task This is the most important thing in the world and this program is an interrupt, this process is so fast that it seems as if the programs are working in unison.

Interrupt timer happens when compare matches between registering OCRnx and registering TCNTn. Moment compare matches There are also programs that contain subprograms that have different features vector interrupt the. And this method uses interrupt timer and PWM security simultaneously on the use of registers Timer/Counter the same one.

It's all about me Timer/Counter 2 To run program code written on vector interrupt. All sub programs are called via address bother You can use it to install similar sensors grid line follower. Timer/Counter2 in this project it works on 8 bits and setting Timer/Counter2 is more helpful than writing sub programs that are always called manually because if the main program is long enough, then the sub program cannot be called faster because it has to wait for everything task what was previously done has been completed.


Interrupt timer Very useful for checking sensor readings line followerExample: Checking the line sensor readings line follower walk along the white line, check the number of intersections passed (sensor opposing line).
Figure 1 shows the bits in the TCCR2A register.

Register TCCR2A
Figure 1. Register TCCR2A


Figure 2 shows the bits in the TCCR2B register

Register TCCR2B
Figure 2. Register TCCR2B


This project does not adjust the TCCR2A register because it does not enable PWM on this register, so all the WGMnx and COMnx bits in the TCCR2A register are ignored.


Use the pad to register TCCR2B with the pen on the CSnx bit pad based on tab 1 to determine the frequency timer. Table 1 Shows the setting options bit by bit to set select hour.

Table 1. Hours choose a little information


Hour select bit description



Setting the TCCR2B register on CS20 and CS21 bits by setting each bit with a value of 1 to get the frequency calculation klk/32. And this one has a different number of clk/8 types at once, clk/1, and the blog post only has one clk/32 pendulum, so there is no other way to use it and use sensors to guard against it. that is safe.


From the explanation above, psetup list timer TCCR2A and PWM timer can be reinstalled:


TCCR2B = 0b00000011;
Or it can be written as
TCCR2B = 0x03


After configuring the register timer TCCR2B can be used to register TIMSK2 (Register Interrupt Mask Timer/Counter2). Figure 3 shows the bits in the TIMSK2 register.

Register TIMSK2
Figure 3. TIMSK2 list


The author only activates the TOIE2 bit in the TIMSK2 register because it only uses Timer/Counter overflow interrupt2 Where ward off Always counts from 0 to 255 (works on 8 bits) once the maximum occurs overflowing And bother happened. A process that has no other way.


To run bother that has been set is by writing the command 'sei()'


Activate interrupt timer 2
Starting with the help of writing a program to activate bother timer 2:
TCCR2B =0b00000011; //Activates the timer with frequency clkio/32.
TIMSK2 = 0b00000001; //Activate mode Timer/Counter overflow interrupt2.
sei(); //Executes all bother you have been activated.


Write the sub program on vector interrupt
After configuring interrupt timer 2 mode. mode overflowingThe thing that needs to be done then is to write down the sub programs that are frequently called on vector interrupt. This program contains all the sub-programs that appear in the program vector interrupt Is a program for checking line sensors.


Writing programs on vector interrupt timer 2 This can be done with the help of someone else at home:
ISR(TIMER_OVF_vek) // Vector interrupt timer 2 mode. mode overflowing
{
dataSensor = readSensor();
temperature = digitalRead(sensor4);
if (temperature == 1)
{
if (flipflop == 0)
{
flipflop = 1 ;
counter++;
}
}
if(temperature == 0)
filpflop = 0
}


The aim of writing the program above is to make the sensor reading program network counter executed on interrupt timer so that sensor readings will always be carried out continuously when an interruption occurs timer And without having to wait for the main program to finish.


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
EOF
반응형

'Eelektronika' 카테고리의 다른 글

Study electronics  (0) 2024.04.26
Timer interrupt with line sensor  (0) 2024.04.26
Grid line follower working concept  (0) 2024.04.26
Kode program pembacaan sensor garis grid counter  (0) 2024.04.26
MOSFET  (3) 2024.04.26