Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROJEKTOVANJE I IZRADA VIŠEKANALNOG KONTROLERA ZA PROGRAMIBILNI LED IZVOR DIPLOMSKI RAD IZ FIZIČKE ELEKTRONIKE.

Similar presentations


Presentation on theme: "PROJEKTOVANJE I IZRADA VIŠEKANALNOG KONTROLERA ZA PROGRAMIBILNI LED IZVOR DIPLOMSKI RAD IZ FIZIČKE ELEKTRONIKE."— Presentation transcript:

1 PROJEKTOVANJE I IZRADA VIŠEKANALNOG KONTROLERA ZA PROGRAMIBILNI LED IZVOR DIPLOMSKI RAD IZ FIZIČKE ELEKTRONIKE

2 UVOD Spektralno modulisani LED izvori sa različitim spektralnim doprinosima, namenjeni kalibraciji optičkih detektora. Podesiti doprinose pojedinačnih LED u ukupnom spektru. Podešavanje pomoću odgovarajuće struje. Dobijanje željenog spektra pomoću LED različitih karakteristika. Za kalibraciju optičkih radijacionih pirometara, spektar će imati oblik Plankovog zakona zračenja. Sumiranje unutar integrišuće sfere.

3 Zadatak

4 PWM Tehnika dobijanja analognih rezultata digitalno. 1 – 5V, 0 – 0V. Simuliramo napone u rasponu od 0V do 5V menjajući odnos signal-pauza. Velika frekvencija  stabilni napon.

5 BLOK ŠEMA URE Đ AJA Arduino daje najviše 40mA  moramo da povećamo struju  strujni izvori za svaki kanal.

6 ARDUINO ATMega 16MHz 15 pina za PWM USB kontroler Napajanje zasebno ili preko USB

7 PWM LED TESTER

8 LED PANEL I NIZ LED ZA TESTIRANJE DIP ZIF Kontaktna letvica 1x15 Kontaktna letvica 2x15 sa jumper-ima 5mm LED 20mA (u praksi 40mA) 2.1V pad napona 3 diode u red i 7 paralelno  250mA i 6.3V

9 STRUJNI IZVORI

10 POTENCIOMETRI

11 PCB

12 KUĆIŠTE I RASPORED KOMPONENATA

13

14 PROGRAMIRANJE Kontrola odnosa signal-pauza preko računara za svaki kanal zasebno. Baud Rate = 9600b/s. Određivanje COM porta Unos vrednosti za PWM u % Između 0 i 100 Prijava greške Pretvaranje u 8-bit Kreiranje stringa sa deliteljima String u Int Int u String Slanje na COM port Mapiranje pinova Menjanje frekvencije Čitanje sa serijskog Deljenje stringa String u int PWM

15 ARDUINO PWM analogWrite(pin, vrednost) Podrazumevane PWM frekvencije: 490Hz i 976Hz Menjamo vrednosti 5 tajmera. Prescaler 1 daje najveću frekvencu: 31.25kHz i 62.5kHz int myEraser = 7; // 111 se koristi za brisanje // postavljamo prescaler za timer 1 na 0 TCCR1B &= ~myEraser; // upisujemo novu vrednost int myPrescaler = 1; TCCR1B |= myPrescaler; // upisujemo prescaler

16 Provera na osciloskopu: desno pinovi 4 i 13, levo ostali pinovi.

17 ARDUINO - PROGRAMIRANJE char inputBuffer[100]; // For incoming serial data String s; int pwm[15]; // 0 – 255 String pod; int ledPin[] = {2,3,4,5,6,7,44,45,46,8,9,10,11,12,13}; // maps Arduino pins void setup() { Serial.begin(9600); // Opens serial port, sets data rate to 9600 bit/s. int myEraser = 7; // sets integer that erases timers TCCR0B &= ~myEraser; // erase timer 0 TCCR1B &= ~myEraser; // erase timer 1 TCCR2B &= ~myEraser; // erase timer 2 TCCR3B &= ~myEraser; // erase timer 3 TCCR4B &= ~myEraser; // erase timer 4 TCCR5B &= ~myEraser; // erase timer 5 // Write timers values int myPrescaler = 1; // chose max frequency // write into timers TCCR0B |= myPrescaler; // 62kHz, it affects timing functions by reducing them 62 times TCCR1B |= myPrescaler; // 31kHz TCCR2B |= myPrescaler; // 31kHz TCCR3B |= myPrescaler; // 31kHz TCCR4B |= myPrescaler; // 31kHz TCCR5B |= myPrescaler; // 31kHz } void loop() { if (Serial.available() > 0) { // writes while there is something to read from serial Serial.readBytes(inputBuffer, Serial.available()); // reads from serial into inputBuffer array Serial.print(inputBuffer); // writes what has been read from serial Serial.print("END"); // puts an END at the end of read string } delay(20000); // for default timer 0, enough is this value divided by 62 set it to 20k pod = String(inputBuffer); // PWM starts here, for all pins for (int x=0; x =parserCnt){ rFromIndex = rToIndex+1; rToIndex = s.indexOf(parser,rFromIndex); if(index == parserCnt){ if(rToIndex == 0 || rToIndex == -1){ return '\0'; } return s.substring(rFromIndex,rToIndex); } else{ parserCnt++; } } return rs; }

18 JAVA FORMA PWM LED br. poklapaju se sa onima na kućištu. Arduino Pin odgovaraju rednom br. PWM pina na boardu. Unosimo vrednosti od 0 do 100. Ukoliko unesemo vrednost van ovog opsega, izaći će prozor koji prijavljuje grešku. Pritiskom na dugme „Apply“, procenti se pretvaraju u 8-bitne vrednosti (od 0 do 255), što se i ispisuje za svaki pin. Tako đ e se šalje informacija na USB i ispisuje koji je COM port odredio operativni sistem za Arduino.

19 JAVA KOD package arduinoserialtest; import javax.swing.JOptionPane; import jssc.SerialPort; import jssc.SerialPortEvent; import jssc.SerialPortEventListener; import jssc.SerialPortException; import jssc.SerialPortList; public class NewJDialog extends javax.swing.JDialog { jssc.SerialPort serialPort; String izabraniPort = ""; String tmp=""; String primljeno=""; int percent[]; String percents[]; int bin[]; String bins[]; String percentInput; String zaSlanje = ""; public NewJDialog() { initComponents();} class SerialPortReader implements SerialPortEventListener { public void serialEvent(SerialPortEvent event) { if (event.getEventValue() == 0) { return;} //Read from serial until the END is received if (event.isRXCHAR()) {try { byte buffer[] = serialPort.readBytes(event.getEventValue()); tmp = tmp + new String(buffer); if (new String(buffer).indexOf("END") > -1) { primljeno = tmp.split("END")[0]; tmp = ""; //clear what has been read}} catch (SerialPortException ex) { // System.out.println(ex);}}}} private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try { // detect com port for Arduino String[] portNames = SerialPortList.getPortNames(); if (portNames == null) { System.out.println("sout"); //print if nothing is detected return;} // Print out working COM port for (int i = 0; i < portNames.length; i++) { // System.out.println("port: " + portNames[i].toString()); izabraniPort = portNames[i].toString(); comport.setText(izabraniPort); // write com port into textbox}} serialPort = new SerialPort(izabraniPort); serialPort.openPort(); serialPort.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, false, false); // speed is 9600 to match Arduino, false statements at the end exist so that Arduino does not get reset each time there is a read int mask = SerialPort.MASK_RXCHAR + SerialPort.MASK_CTS + SerialPort.MASK_DSR;//Prepare mask serialPort.setEventsMask(mask);//Set mask serialPort.addEventListener(new SerialPortReader()); // Catch port package arduinoserialtest; import javax.swing.JOptionPane; import jssc.SerialPort; import jssc.SerialPortEvent; import jssc.SerialPortEventListener; import jssc.SerialPortException; import jssc.SerialPortList; public class NewJDialog extends javax.swing.JDialog { jssc.SerialPort serialPort; String izabraniPort = ""; String tmp=""; String primljeno=""; int percent[]; String percents[]; int bin[]; String bins[]; String percentInput; String zaSlanje = ""; public NewJDialog() { initComponents();} class SerialPortReader implements SerialPortEventListener { public void serialEvent(SerialPortEvent event) { if (event.getEventValue() == 0) { return;} //Read from serial until the END is received if (event.isRXCHAR()) {try { byte buffer[] = serialPort.readBytes(event.getEventValue()); tmp = tmp + new String(buffer); if (new String(buffer).indexOf("END") > -1) { primljeno = tmp.split("END")[0]; tmp = ""; //clear what has been read}} catch (SerialPortException ex) { // System.out.println(ex);}}}} private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try { // detect com port for Arduino String[] portNames = SerialPortList.getPortNames(); if (portNames == null) { System.out.println("sout"); //print if nothing is detected return;} // Print out working COM port for (int i = 0; i < portNames.length; i++) { // System.out.println("port: " + portNames[i].toString()); izabraniPort = portNames[i].toString(); comport.setText(izabraniPort); // write com port into textbox}} serialPort = new SerialPort(izabraniPort); serialPort.openPort(); serialPort.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, false, false); // speed is 9600 to match Arduino, false statements at the end exist so that Arduino does not get reset each time there is a read int mask = SerialPort.MASK_RXCHAR + SerialPort.MASK_CTS + SerialPort.MASK_DSR;//Prepare mask serialPort.setEventsMask(mask);//Set mask serialPort.addEventListener(new SerialPortReader()); // Catch port

20 // Calculations percent = new int[16]; // define array length percents = new String[16]; // define array length bin = new int[16]; bins = new String[16]; // get string values from textboxes percents[1] = percentInput1.getText(); percents[2] = percentInput2.getText(); percents[3] = percentInput3.getText(); percents[4] = percentInput4.getText(); percents[5] = percentInput5.getText(); percents[6] = percentInput6.getText(); percents[7] = percentInput7.getText(); percents[8] = percentInput8.getText(); percents[9] = percentInput9.getText(); percents[10] = percentInput10.getText(); percents[11] = percentInput11.getText(); percents[12] = percentInput12.getText(); percents[13] = percentInput13.getText(); percents[14] = percentInput14.getText(); percents[15] = percentInput15.getText(); // Do for all 15 fields zaSlanje = ""; for (int x=1; x<=15; x++) { percent[x] = Integer.parseInt(percents[x]); // set int values bin[x] = (int) Math.round(2.55 * percent[x]); //convert percent to 8-bit value bins[x] = Integer.toString(bin[x]); //convert to string zaSlanje = zaSlanje + bins[x] + ","; // Check if values are withing percent range if (percent[x] 100) { // Error input report with message box System.out.println("Error"); NewJDialog.infoBox("Input values must be between 0 and 100", "Error"); } // System.out.println(zaSlanje + "\n"); //test weather it sends proper values // Display 8-bit values in label bitvalue1.setText(bins[1]); bitvalue2.setText(bins[2]); bitvalue3.setText(bins[3]); bitvalue4.setText(bins[4]); bitvalue5.setText(bins[5]); bitvalue6.setText(bins[6]); bitvalue7.setText(bins[7]); bitvalue8.setText(bins[8]); bitvalue9.setText(bins[9]); bitvalue10.setText(bins[10]); bitvalue11.setText(bins[11]); bitvalue12.setText(bins[12]); bitvalue13.setText(bins[13]); bitvalue14.setText(bins[14]); bitvalue15.setText(bins[15]); //serialPort.writeString(text.getText()); // Set String to send over // String zaSlanje = "100,0,100,0,100,0,100,0,100,0,100,0,100,0,100,"; serialPort.writeString(zaSlanje); System.out.println("Sending String" + zaSlanje); try { Thread.sleep(500); } catch (InterruptedException ex) { } // System.out.println("primljeno: " + primljeno); // print what is received over serial serialPort.closePort(); } catch (SerialPortException ex) { System.out.println("greska: " + ex); } // Calculations percent = new int[16]; // define array length percents = new String[16]; // define array length bin = new int[16]; bins = new String[16]; // get string values from textboxes percents[1] = percentInput1.getText(); percents[2] = percentInput2.getText(); percents[3] = percentInput3.getText(); percents[4] = percentInput4.getText(); percents[5] = percentInput5.getText(); percents[6] = percentInput6.getText(); percents[7] = percentInput7.getText(); percents[8] = percentInput8.getText(); percents[9] = percentInput9.getText(); percents[10] = percentInput10.getText(); percents[11] = percentInput11.getText(); percents[12] = percentInput12.getText(); percents[13] = percentInput13.getText(); percents[14] = percentInput14.getText(); percents[15] = percentInput15.getText(); // Do for all 15 fields zaSlanje = ""; for (int x=1; x<=15; x++) { percent[x] = Integer.parseInt(percents[x]); // set int values bin[x] = (int) Math.round(2.55 * percent[x]); //convert percent to 8-bit value bins[x] = Integer.toString(bin[x]); //convert to string zaSlanje = zaSlanje + bins[x] + ","; // Check if values are withing percent range if (percent[x] 100) { // Error input report with message box System.out.println("Error"); NewJDialog.infoBox("Input values must be between 0 and 100", "Error"); } // System.out.println(zaSlanje + "\n"); //test weather it sends proper values // Display 8-bit values in label bitvalue1.setText(bins[1]); bitvalue2.setText(bins[2]); bitvalue3.setText(bins[3]); bitvalue4.setText(bins[4]); bitvalue5.setText(bins[5]); bitvalue6.setText(bins[6]); bitvalue7.setText(bins[7]); bitvalue8.setText(bins[8]); bitvalue9.setText(bins[9]); bitvalue10.setText(bins[10]); bitvalue11.setText(bins[11]); bitvalue12.setText(bins[12]); bitvalue13.setText(bins[13]); bitvalue14.setText(bins[14]); bitvalue15.setText(bins[15]); //serialPort.writeString(text.getText()); // Set String to send over // String zaSlanje = "100,0,100,0,100,0,100,0,100,0,100,0,100,0,100,"; serialPort.writeString(zaSlanje); System.out.println("Sending String" + zaSlanje); try { Thread.sleep(500); } catch (InterruptedException ex) { } // System.out.println("primljeno: " + primljeno); // print what is received over serial serialPort.closePort(); } catch (SerialPortException ex) { System.out.println("greska: " + ex); }

21 POVEZIVANJE LED I MERENJE JAČINE STRUJE Moguće je priključiti po 3 LED na svakom kanalu. A – merenje struje, V – pada napona. Za tačnu amplitudu struje, podesiti signal na 1.

22


Download ppt "PROJEKTOVANJE I IZRADA VIŠEKANALNOG KONTROLERA ZA PROGRAMIBILNI LED IZVOR DIPLOMSKI RAD IZ FIZIČKE ELEKTRONIKE."

Similar presentations


Ads by Google