Difference between revisions of "Kladky s EV3"

From RoboWiki
Jump to: navigation, search
m (Software)
m (Software)
Line 40: Line 40:
 
         LCD.drawInt(currPower, 5, 5);
 
         LCD.drawInt(currPower, 5, 5);
 
         Delay.msDelay(20000);
 
         Delay.msDelay(20000);
break;
+
        break;
 
       }
 
       }
 
       if(draha == last) {
 
       if(draha == last) {

Revision as of 20:52, 16 June 2016

Project objective

Cieľom nášho prjektu bolo vytvorenie stavebnice, ktorá umožňuje meranie sily motora potrebnej na zdvihnutie telesa za pomoci kladky, alebo konfigúrácie kladiek. Daľšou úlohou bolo naprogramovanie programu, ktorý toto meranie riadi v zariadení EV3 v systéme Lejos.

Hardware

Pre účely tohto projektu sme použili EV3 zariadenie, EV3 Large servo motor a EV3 svetelný senzor. Súčasti hardvéru sme umiestnili do stvebnice.

Stavebnica.jpg Ev3.jpg Ev3ss.jpg Ev3lsm.jpg Ev3pohladH.jpg

Software

Náš projekt je napísaný v Jave pre systém Lejos. Použili sme prostredie Eclipse a verziu JRE 1.6

Pri programovaní sme použili Lejos dokumentáciu [1].

Ukážka zdrojového kódu:

public static void meraj() {

  EncoderMotor em = new UnregulatedMotor(MotorPort.A);
  EV3ColorSensor cs = new EV3ColorSensor(SensorPort.S1);
  SensorMode sm = cs.getRedMode();	
  int maxPower = 100;
  int currPower = 5;
  int draha = 5;
  int last = 0;
  int senzorAktive = -1;	
  em.setPower(currPower);
  em.forward();
  while(true){
     em.setPower(currPower);
     draha = em.getTachoCount();
     Delay.msDelay(1000);
     LCD.drawInt(draha, 5, 5);
     senzorAktive = ziskajDataZoSenzoru(cs);
     if (senzorAktive != -1) {
        LCD.clear();
        em.stop();
        LCD.drawString("SILA ZDVIHU: ", 1, 4);
        LCD.drawInt(currPower, 5, 5);
        Delay.msDelay(20000);
        break;
     }
     if(draha == last) {
        if(currPower < maxPower) {

currPower += 5; } if(currPower == maxPower) { em.stop(); LCD.drawString("MOTOR NEMA POTREBNU SILU", 1, 5); Delay.msDelay(5000); break; }

     }
     last = draha;
     LCD.drawInt(last, 5, 4);
  }

}