ของขวัญจากดิน #define UN (400.0) // motor rated voltage #define FN (50.0) // motor nominal frequency #define P (UN/FN) // associate Determining the ratio of voltage to nominal frequency #define T_PWM (0.000255) // PWM signal period - set by the prescaler in the counters #define T_MAX (4.0) // Specify the maximum output voltage period #define T_MIN (0.02) // minimum output voltage #define K_MAX floor (T_MAX/T_PWM) // number of period values for T_MAX #define K_MIN ceil (T_MIN/T_PWM) // number of period values for T_MIN volatile static unsigned int length_tab_sin; // variable containing the number of values in the full // period of the output voltage static unsigned int i = 0; // auxiliary variable volatile static unsigned int main_counter = 0; // variable in the interrupt // ^ every T_PWM period increasing its value by 1 static unsigned int next_value_sin = 0; // variable which value sin should be calculated static double t_param = 50; // parameter specifying the period of the output voltage static float t = T_PWM; // T_PWM static float omega_t; // pulsation of the output voltage multiplied by T_PWM static float t_out; // output voltage period static float U_o_param; // parameter specifying the size of the output voltage // ^ calculated on the basis of t_out and U_in static unsigned int ocr0a, ocr0b, ocr1a; // auxiliary variables to store obl. fillings static unsigned int ocr1b, ocr2a, ocr2b; // ^ static double sin_in; // variable containing the parameter of the function sin static double error = 1; // variable used to stop generating voltage when overloaded static unsigned int analog = 0; // variable containing the measured value static double U_in = 0; // variable holding the voltage measurement of the intermediate system static double U_rms_max; // maximum currently possible to generate the effective voltage value static bool a = 0; // logical variable for the implementation of two alternating measurements //void setup() //{ // Serial.begin(57600); //} int main() { io_init(); // initiate entry and exit timers_init(); // initialization of PWM meters adc_init(); // initialization of the ADC transducer while (1) // infinite loop with the main program { if (i == 185) // condition specifying the entry to the change function { // parameter of the discharge voltage, calling approx. 100ms chang_para(); // function to change the parameters of the output voltage i = 0; } next_value_sin = main_counter % length_tab_sin; // the next sine value to be calculated sin_in = omega_t*next_value_sin; // calculating the value to registers specifying the completion of the output signal / ocr0a = round(error * (U_o_param * (sin(sin_in) + 1) * 254 / 2) + 1); // pin ocr0b = ocr0a - 1; ocr1a = round (error * (U_o_param * (sin(sin_in - 2.09) + 1) * 254 / 2) + 1); // pin ocr1b = ocr1a - 1; ocr2a = round(error * (U_o_param * (sin(sin_in + 2.09) + 1) * 254 / 2) + 1); // pin ocr2b = ocr2a - 1; // updating values in registers / cli(); // prohibition on obsloge interruptions in case if // an interrupt occurred during the upgrade OCR0A = ocr0a; // pin OCR0B = ocr0b; // pin OCR1AL = ocr1a; // pin OCR1BL = ocr1b; // pin OCR2A = ocr2a; // pin OCR2B = ocr2b; // pin sei(); // allow for interruption obsloge i++; } } void adc_init() { ADCSRA |= _BV(ADEN); // start the transmitter ADCSRA |= _BV(ADPS2); // setting the prescaler ADCSRA |= _BV(ADPS1); // ^ ADCSRA |= _BV(ADPS0); // ^ ADMUX |= _BV(REFS0); // reference voltage set as power supply ADMUX |= ADMUX &= 0b11110000; // choose the ADC0 input for measurement } void timers_init() { cli(); // interrupt handler is forbidden // timer0 init TCCR0A |= _BV(COM0A1) | _BV(COM0B0) | _BV(COM0B1) | _BV(WGM00); TCCR0B |= _BV(CS01); // preskaler 8 | _BV(WGM02) TIMSK0 |= _BV (TOIE0); // flag from value 0 enabled // // timer1 init TCCR1A |= _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1) | _BV(WGM10); TCCR1B |= _BV (CS11); // preskaler 8 // | _BV(WGM02) // timer2 init TCCR2A |= _BV(COM2A1) | _BV(COM2B0) | _BV(COM2B1) | _BV(WGM20); TCCR2B |= _BV(CS21); // preskaler 8 | _BV(WGM02) // resetting counter values TCNT0 = 0; TCNT1L = 0; TCNT2 = 0; /* the counter counts in g3re to 255, then in d3 ?: / \ / \ / \ at the value of 255 there is an interruption at which it occurs voltage and current measurements */ sei(); // allow for interruption obsloge } void io_init() { pinMode(13, OUTPUT); // OC0A Arduino Mega2560 pin 13 pinMode(4, OUTPUT); // OC0B Arduino Mega2560 pin 4 pinMode(11, OUTPUT); // OC1A Arduino Mega2560 pin 11 pinMode(12, OUTPUT); // OC1B Arduino Mega2560 pin 12 pinMode(10, OUTPUT); // OC2A Arduino Mega2560 pin 10 pinMode(9, OUTPUT); // OC2B Arduino Mega2560 pin 9 pinMode(14, INPUT_PULLUP); // up Arduino Mega2560 14 pinMode(15, INPUT_PULLUP); // dn Arduino Mega2560 15 pinMode(16, OUTPUT); // Arduino Mega2560 16 } ISR(TIMER0_OVF_vect) // interrupt at 0 counter 0 { analog = ADC; if (a) { U_in = 0.0709 * analog; ADMUX |= _BV(MUX0); // choose the ADC1 input to measure the current } else { ADMUX |= ADMUX &= 0b11110000; // select the ADC0 input to measure the voltage if (analog > 579) { error = 0; // if the overload turn off the voltage generation digitalWrite(16, HIGH); // lighting the diode } } ADCSRA |= _BV(ADSC); // start reading the measurement a = a ^ 1; // the XOR gate negates the logical value a main_counter++; if (main_counter >= length_tab_sin) main_counter = 0; } void chang_para() { t_param = map(analogRead(3), 0, 102, 0, 100); U_rms_max = U_in * 0.62; // value 0.62 experimentally limited bool up; // logical variable, informs you that the button has been pressed to increase the frequency bool down; // logical variable, informs you that the button has been pressed to decrease the frequency up = digitalRead(14); // read: if you press the button, increase the frequency down = digitalRead(15); // read: if you press the button you will decrease the frequency if (!up) t_param--; // if you press the button to increase the frequency then you will decrease the period if (!down) t_param ++; // if the button you press decreases the frequency, it will increase the period if (t_param < 0) t_param = 0; // protection of exceeding the extreme values if (t_param > 100) t_param = 100; // ^ length_tab_sin = ceil((K_MAX - K_MIN) * t_param / 500 + K_MIN); // amount of values filled in one period t_out = T_PWM * length_tab_sin; // calculate the period of the output voltage omega_t = t * 2 * PI / t_out; // calculate the output voltage pulsation U_o_param = (P / t_out) / U_rms_max; // calculate the parameter determining the value of the output voltage if (t_out > 1) U_o_param = 0.5 * (18.5 / U_rms_max); // voltage at the output at low frequencies of 10v if (U_o_param > 1) U_o_param = 1; //protection of exceeding the extreme values error = 1; //if the overload turn off the voltage generation //digitalWrite(13, HIGH); //diode lighting //if the overload turn off the voltage generation digitalWrite(16, LOW); //diode lighting // Serial.println(t_param); }
//Arduino Atmega 1280 Atmega 2560 3 phase induction motor Variable Speed Controller //Code
// Complier By Arduino Version 101 Version 106 Software
//?????????????? AUTO RE RUN ????????????????? 5KB ????????????????? ??? -??? ??????? ?????? R //4K7 ??? ??+5Vdc ??????????? ?????????? + MAX ??? VR ??? R 1K-10 K ??? ???? A3 ??? //ATmega 168 ATmega 328 P
#include "arduino.h" //Store data in flash (program) memory instead of SRAM
#include "avr/pgmspace.h"
#include "avr/io.h"
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define UN (400.0)
#define FN (50.0)
#define P (UN/FN)
#define T_PWM (0.000255)
#define T_MAX (4.0)
#define T_MIN (0.02)
#define K_MAX floor(T_MAX/T_PWM)
#define K_MIN ceil(T_MIN/T_PWM)
volatile static unsigned int dlugosc_tab_sin; //okresie napiecia wyjsciowego
static unsigned int i = 0;
volatile static unsigned int licznik_glowny = 0;
static unsigned int next_value_sin = 0;
static double t_param=100;
static float t = T_PWM;
static float omega_t;
static float t_out;
static float U_o_param;
static unsigned int ocr0a, ocr0b, ocr1a;
static unsigned int ocr1b, ocr2a, ocr2b;
static unsigned int ocr3a, ocr3b, ocr3c;
static unsigned int ocr4a, ocr4b, ocr4c;//^
static unsigned int ocr5a, ocr5b, ocr5c;//
static double sin_in;
static double blad = 1;
static unsigned int analog=0;
static double U_in = 0;
static double U_rms_max;
static bool a=0;
int main()
{
io_init();
timers_init(); //inicjalizacja licznikow PWM
adc_init(); //inicjalizacja przetwornika ADC
while(1) //nieskonczona petla z programem glownym
{
if(i==185) //warunek okreslajacy wejscie do funkcji zmiany
{ //parametrow napiecia wysjciowego, wywolanie co okolo 100ms
zmien_predkosc(); //funkcja zmiany parametrow napiecia wyjsciowego
i=0;
}
next_value_sin = licznik_glowny%dlugosc_tab_sin; //kolejna wartoœ? sinusa do obliczenia
sin_in=omega_t*next_value_sin;
//obliczenie wartosci do rejestrow okreslajacych wypelnienie sygnalu wyjscioweg/
ocr0a = round(blad*(U_o_param*(sin(sin_in)+1)*254/2)+1);//pin D 13
ocr0b = ocr0a - 1;//pin D 4
ocr1a = round(blad*(U_o_param*(sin(sin_in-2.09)+1)*254/2)+1);//pin D 11
ocr1b = ocr1a - 1;//pin D 12
ocr2a = round(blad*(U_o_param*(sin(sin_in+2.09)+1)*254/2)+1);//pin D 10
ocr2b = ocr2a - 1;//pin D 9
ocr3a = round(blad*(U_o_param*(sin(sin_in)+1)*254/2)+1);//pin D 5
ocr3b = ocr0b;//ocr3a - 1;//pin D 2
ocr3c = round(blad*(U_o_param*(sin(sin_in-2.09)+1)*254/2)+1);//pin D 3
ocr4a = ocr2b;//ocr3c - 1;//pin D 6
ocr4b = round(blad*(U_o_param*(sin(sin_in+2.09)+1)*254/2)+1);//pin D 7
ocr4c = ocr1b ; //pin D 8
ocr5a = ocr0b;//round(blad*(U_o_param*(sin(sin_in)+1)*254/2)+1);//pin D 46
ocr5b = ocr1b;//round(blad*(U_o_param*(sin(sin_in+2.09)+1)*254/2)+1);//pin D 45
ocr5c = ocr2b;//round(blad*(U_o_param*(sin(sin_in-2.09)+1)*254/2)+1);//pin D 44
//uaktualnienie wartosci w rejestrach/
cli(); //zabronienie na obsloge przerwan na wypadek gdyby
//podczas uaktualniania wystapilo przerwanie
OCR0A = ocr0a; //pin 6
OCR0B = ocr0b; //pin 5
OCR1AL = ocr1a; //pin 9
OCR1BL = ocr1b; //pin 10
OCR2A = ocr2a; //pin 11
OCR2B = ocr2b; //pin 3
OCR3A = ocr3a; //pin 6
OCR3B = ocr3b; //pin 5
OCR3CL = ocr3c; //pin 3
OCR4AL = ocr4a; //pin 10
OCR4B = ocr4b; //pin 11
OCR4C = ocr4c; //pin 8
OCR5A = ocr5a; //pin 10
OCR5B = ocr5b; //pin 11
OCR5C = ocr5c; //pin 8
sei(); //zezwolenie na obsloge przerwan
i++;
}
}
void adc_init()
{
ADCSRA |= _BV(ADEN);//uruchomienie przetwornika
ADCSRA |= _BV(ADPS2);//ustawienie preskalera
ADCSRA |= _BV(ADPS1);//^
ADCSRA |= _BV(ADPS0);//^
ADMUX |= _BV(REFS0);// napiecie odniesienia ustawione jako napiecie zasilania
ADMUX |= ADMUX &= 0b11110000; //wybranie wejscia ADC0 do pomiaru
}
void timers_init()
{
cli(); // obsloga przerwan zabroniona
TCCR0A |= _BV(COM0A1) | _BV(COM0B0) | _BV(COM0B1) | _BV(WGM00);
TCCR0B |= _BV(CS01); //preskaler 8
TIMSK0 |= _BV(TOIE0); //flaga od wartosci 0 wlaczona
//timer1 init
TCCR1A |= _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1) | _BV(WGM10);
TCCR1B |= _BV(CS11); //preskaler 8
//timer2 init
TCCR2A |= _BV(COM2A1) | _BV(COM2B0) | _BV(COM2B1) | _BV(WGM20);
TCCR2B |= _BV(CS21); //preskaler 8
//timer3 init
TCCR3A |= _BV(COM3A1) | _BV(COM3B0) | _BV(COM3B1) | _BV(WGM30);
TCCR3B |= _BV(CS31);
TCCR3C |= _BV(COM3A1) | _BV(COM3B0) | _BV(COM3B1) | _BV(WGM33);
TCCR3C |= _BV(CS31);//;|(1 << CS00); //preskaler 8
cbi (TCCR3A, COM3C0);
sbi (TCCR3A, COM3C1);
//timer4 init
TCCR4A |= _BV(COM4A1) | _BV(COM4B0) | _BV(COM4B1) | _BV(WGM40);
TCCR4B |= _BV(CS41);
TCCR4C |= _BV(CS40); //preskaler 8
cbi (TCCR4A, COM4C0);
sbi (TCCR4A, COM4C1);
//timer5 init
TCCR5A |= _BV(COM5A1) | _BV(COM5B0) | _BV(COM5B1) | _BV(WGM50);
TCCR5B |= _BV(CS51); //preskaler 8
TCCR5C |= _BV(CS51);
cbi (TCCR5A, COM5C0);
sbi (TCCR5A, COM5C1);
//zerowanie wartosci licznik?w
TCNT0 = 0;
TCNT1L = 0;
TCNT2 = 0;
sei(); //zezwolenie na obsloge przerwan
}
void io_init()
{
pinMode(6, OUTPUT); //OC0A
pinMode(5, OUTPUT); //OC0B
pinMode(9, OUTPUT); //OC1A
pinMode(10, OUTPUT);//OC1B
pinMode(11, OUTPUT);//OC2A
pinMode(3, OUTPUT); //OC3C
pinMode(52, INPUT);
pinMode(53, INPUT);
pinMode(50, OUTPUT);
pinMode(2, OUTPUT); //OC3B
pinMode(4, OUTPUT); //OC0B
pinMode(7, OUTPUT); //OC1A
pinMode(8, OUTPUT);//OC4C
pinMode(12, OUTPUT);//OC2A
pinMode(13, OUTPUT); //OC2B
pinMode(44, OUTPUT);//OC4C
pinMode(45, OUTPUT);//OC2A
pinMode(46, OUTPUT); //OC2B
pinMode(A3, INPUT); //OC1A
pinMode(A4, OUTPUT);//OC1B
pinMode(A5, OUTPUT);//OC2A
pinMode(A6, OUTPUT); //OC3C
pinMode(A1, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A9, OUTPUT);
pinMode(A10, OUTPUT); //OC0A
pinMode(A11, OUTPUT); //OC0B
pinMode(A12, OUTPUT); //OC1A
pinMode(A13, OUTPUT);//OC4C
pinMode(A14, OUTPUT);//OC2A
pinMode(A15, OUTPUT); //OC2B
}
ISR(TIMER0_OVF_vect) //przerwanie przy wartosci 0 licznika0
{
analog = ADC;
if(a)
{
U_in = 0.0709*analog;
ADMUX |= _BV(MUX0); //wybranie wejscia ADC1 do pomiaru pradu
}
else
{
ADMUX |= ADMUX &= 0b11110000; //wybranie wejscia ADC0 do pomiaru napiecia
if(analog>579)
{
blad = 0; //jezeli przeciazenie wylaczenie generacji napiecia
digitalWrite(50, HIGH); //zapalenie diody
}
}
ADCSRA |= _BV(ADSC);//start odczytywania pomiaru
a=a^1; //bramka XOR neguje wartosc logiczna a
licznik_glowny++;
if(licznik_glowny>=dlugosc_tab_sin) licznik_glowny = 0;
}
void zmien_predkosc()
{
t_param = map(analogRead(3),0,1023,0,100);
U_rms_max = U_in*0.62;
bool up;
bool down;
up = digitalRead(52);
down = digitalRead(53);
if(up==1) t_param--;
if(down==1) t_param++;
if(t_param<0) t_param=0;
if(t_param>100) t_param=100;//^
dlugosc_tab_sin = ceil((K_MAX-K_MIN)*t_param/500+K_MIN);//ilosc wartosci wypelnien w jednym okresie
t_out = T_PWM*dlugosc_tab_sin; //obliczenie okresu napiecia wyjsciowego
omega_t = t*2*PI/t_out; //obliczenie pulsacji napiecia wyjsciowego
U_o_param = (P/t_out)/U_rms_max; //obliczenie parametru okreslajacego wielkosc napiecia wyjsciowego
if(t_out>1) U_o_param = 0.5*(18.5/U_rms_max); //napi?cie na wyjsciu przy niskiej czestotliwosci 10V
if(U_o_param>1) U_o_param=1;
//zabezpieczenie przekroczenia wartosci skrajnych
blad = 1; //jezeli przeciazenie wylaczenie generacji napiecia
digitalWrite(50, LOW); //zapalenie diody
}?
#การเข้าผลสมาบัติ#อารมณ์พระนิพพาน#จึงมุ่งสู่พุทธภูมิ#เธออย่าได้กล่าวคำหยาบต่อใครๆ#วิมุตติความหลุดพ้น#สามแดนโลกธาตุ#หาที่จะหยั่งเท้าลงไม่ได้เลย#จิตใจที่แห้งสนิทจึงจะหลุดพ้น#ความหลุดพ้น #การเข้าผลสมาบัติ#เป็นการเข้าอยู่ในอารมณ์พระนิพพาน#ที่ได้มาจากอริยผลญาณ #อันบังเกิดแล้วแก่ตน #เพื่อเสวยโลกุตตรสุข #ซึ่งเป็นความสงบสุขที่พึงเห็น #ประจักษ์ได้ในปัจจุบัน #พระนิพพาน ที่เป็นอารมณ์ของผลสมาบัตินั้นมีชื่อ ๓ ชื่อหรือมี ๓ อาการคือ ๑. #อนิมิตตนิพพาน หมายถึงว่า ผู้ที่ก้าวขึ้นสู่มัคคผลนั้น เพราะเห็นความ ไม่เที่ยง อันปราศจากนิมิตเครื่องหมาย คือ อนิจจัง โดยบุญญาธิการแต่ปางก่อน แรงด้วยสีล เมื่อเข้าผลสมาบัติก็คงมีอนิมิตตนิพพาน เป็นอารมณ์
๒. #อัปปณิหิตนิพพาน หมายถึงว่า ผู้ที่ก้าวขึ้นสู่มัคคผลนั้น เพราะเห็นความ ทนอยู่ไม่ได้ ต้องเปลี่ยนแปรไป อันหาเป็น ปณิธิ ที่ตั้งไม่ได้ คือทุกขัง โดยบุญญาธิ การแต่ปางก่อนแรงด้วยสมาธิ เมื่อเข้าผลสมาบัติ ก็คงมี อัปปณิหิตนิพพาน เป็น อารมณ์
๓. #ญตนิพพาน หมายถึงว่า ผู้ที่ก้าวขึ้นสู่มัคคผลนั้น เพราะเห็นความ ไม่ใช่ตัวตน บังคับบัญชาไม่ได้ อันเป็นความว่างเปล่า คืออนัตตา โดยบุญญาธิการ แต่ปางก่อนแรงด้วยปัญญา เมื่อเข้าผลสมาบัติ ก็คงมี สุญญตนิพพาน เป็นอารมณ์
#บุคคลที่เข้าผลสมาบัติได้ต้องเป็นพระอริยบุคคล คือเป็น พระโสดาบัน พระ สกทาคามี พระอนาคามี หรือ พระอรหันต์ ส่วนปุถุชนจะเข้าผลสมาบัติไม่ได้เลย เป็นอันขาด
#พระอริยเจ้าที่จะเข้าผลสมาบัติ ก็เข้าได้เฉพาะอริยผลที่ตนได้ ที่ตนถึงครั้ง สุดท้ายเท่านั้น แม้อริยผลที่ตนได้และผ่านพ้นมาแล้วก็ไม่สามารถจะเข้าได้ กล่าวคือ
#พระโสดาบัน ก็เข้าผลสมาบัติได้แต่ โสดาปัตติผล
#พระสกทาคามี ก็เข้าผลสมาบัติได้แต่ สกทาคามีผล เท่านั้น จะเข้าโสดา ปัตติผล ซึ่งถึงแม้ว่าตนจะเคยได้เคยผ่านเคยพ้นมาแล้ว ก็หาได้ไม่
#พระอนาคามี ก็เข้าผลสมาบัติได้แต่เฉพาะ อนาคามีผล
#พระอรหันต์ ก็เข้าผลสมาบัติได้แต่ อรหัตตผลโดยเฉพาะเช่นกัน
#พระอริยบุคคล ผู้จะเข้าผลสมาบัติ กิจเบื้องต้นก็จะต้องตั้งความปรารถนาว่า จะเข้าผลสมาบัติเป็นเวลา .... (ตามความประสงค์ที่จะเข้าอยู่สักกี่ชั่วโมง หรือกี่วัน) ขอให้ผลจิตที่เคยปรากฏมาแล้วนั้น จงบังเกิดขึ้นตามความปรารถนานี้เถิด
#ขณะที่ตั้งความปรารถนา(อธิษฐาน) นี้ กามจิตอันเป็นมหากุสลญาณสัมปยุตต สำหรับพระอริยเบื้องต่ำ ๓ หรือ กามจิตอันเป็นมหากิริยาญาณสัมปยุตต สำหรับ พระอรหันต์ก็เกิด มีวิถีจิตซึ่งเรียกว่า #อธิฏฐานวิถี ดังนี้
น ท มโน ช ช ช ช ช ช ช
#ต่อจากอธิฏฐานวิถี #ก็เจริญวิปัสสนาภาวนา #ไตรลักษณ์แห่งรูปนามเป็น อารมณ์
#เริ่มแต่อุทยัพพยญาณเป็นต้นไป #ผลจิตก็จะเกิด วิถีจิตนี้ชื่อว่า ผลสมา บัติวิถี มีวิถีดังนี้
น ท มโน อนุโลม อนุโลม อนุโลม อนุโลม ผล ผล ผล ฯลฯ ฯลฯ อนุโลม ๔ ขณะ #สำหรับมันทบุคคล หรืออนุโลม ๓ ขณะ #สำหรับติกขบุคคล ต่อจากอนุโลม #ผลจิตก็เกิดเรื่อยไปเป็นจำนวนมากมาย ไม่สามารถที่จะประมาณได้ #จนครบกำหนดเวลาที่ตนปรารถนาไว้ #ผลจิตจึงจะหยุดเกิด แล้วก็เป็นภวังคจิตต่อไป ตาม
อนึ่ง #จิตในผลสมาบัติวิถีนี้ ไม่เรียกว่า บริกรรม อุปจาระ อนุโลม โคตรภู เหมือนอย่างในมัคควิถี แต่เรียก #อย่างเดียวทั้ง ๔ ขณะ เพราะผลสมาบัติวิถี นี้ #ไม่ได้ทำการประหารกิเลส เหมือนอย่างในมัคควิถี เป็นแต่จิต ๔ ดวงนี้เกิดขึ้น #เพื่ออนุโลมให้จิตถึงพระนิพพาน หรือให้แนบแน่นในอารมณ์พระนิพพาน
ความคิดเห็น
แสดงความคิดเห็น