Research Article
Frequency-Based Control Strategy for Compact Electromagnetic Tuned Mass Damper
| //Connecting libraries: | #include <avr/io.h> | #include <avr/interrupt.h> | //Pin definition: | //Acceleration Input: | const int Acc_1 = A2; | const int Acc_2 = A1; | //Control output: | const int SWITCH1 = 4; | //Variables: | float f = 0; //frequency of the system excitation; | int VA_1; //the first measured acceleration; | int VA_2; //the second measured acceleration; | unsigned int timerValue; //timer value; //Start the code: | void setup() { cli(); //cancell general interupptions pinMode(SWITCH1, OUTPUT); // setting the timer 1: | TCCR1A = 0; | TCCR1B = 0; | TCCR1B |= (1 << CS10); | TCCR1B |= (0 << CS11); | TCCR1B |= (1 << CS12); //start up the timer } | void loop() { VA_1 = analogRead(Acc_1); //reading accelerator sensor data; VA_2 = analogRead(Acc_2); //reading accelerator sensor data; if (VA_1 > 440 && VA_2 ≤ 440){ TCCR1B |= (0 << CS10); TCCR1B |= (0 << CS11); TCCR1B |= (0 << CS12); //stop the timer timerValue = (unsigned int)TCNT1L | ((unsigned int)TCNT1H << 8); //reading the timer; f = 1/((float)(timerValue) 0.000064); //deriving the frequency; TCNT1H = 0; //resetting the timer; TCNT1L = 0; TCCR1B |= (1 << CS10); TCCR1B |= (1 << CS12); //set the resolution of the timer with a divider 1024; //FBC control law: if (f ≥ 8.2 && f ≤ 10){ digitalWrite(SWITCH1,LOW); //set the maximum damping of the TMD; } else { digitalWrite(SWITCH1,HIGH); //set the minimum damping of the TMD; } } VA_1 = 0; VA_2 = 0; } |
|