Difference between revisions of "Kladky s EV3"

From RoboWiki
Jump to: navigation, search
m
m (Video)
 
(24 intermediate revisions by the same user not shown)
Line 10: Line 10:
  
 
==Software==
 
==Software==
My project has two components. One is the program that runs on the robot. The another one is a relay, that handles the messaging between the bots, because the bluetooth chip cannot be set to Master mode to connect to another device. So that's why there is a need of a relay.
+
Náš projekt je napísaný v Jave pre systém Lejos. Použili sme prostredie Eclipse a verziu JRE 1.6
  
I have written this in Python 3.5, because of the ease of use of the language.
+
Pri programovaní sme použili Lejos dokumentáciu [http://www.lejos.org/ev3/docs/].
The program uses two threads where opens the serial bluetooth connections given by the user, and relays the incoming messages from one thread to another.
+
 
For the serial connection I have used the pySerial python library, so to compile the relay code you have to download, and install it from pip or [https://pythonhosted.org/pyserial/].
+
Ukážka zdrojového kódu:
 +
 
 +
Funkcia ktorá riadi beh stavebnice
 +
<code>
 +
  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);
 +
  }
 +
</code>
 +
 
 +
==Zdrojový kód==
 +
 
 +
Zdrojové kódy programu napísané v jazyku Java:
 +
 
 +
Pre programovanie EV3 v Lejose je potrebné nainštalovať do PC Lejos pre EV3 [https://sourceforge.net/projects/ev3.lejos.p/files/].
 +
 
 +
Dokumentácia je k dispozícii na [http://www.lejos.org/ev3/docs/].
 +
 
 +
 
 +
 
 +
Zipped folder containing the [[Media:Kladka.zip|project source code]].
 +
 
 +
==Zhrnutie==
 +
Podarilo sa nám vytvoriť program ktorý meria silu motora potrebnú pre zdvihnutie telesa s danou váhou. K dispozícii sú v stavebnici ľahko konfigurovateľné kladky, pomocou ktorých je možné merať silu motora potrebnú na zdvihnutie
 +
telesa pomocou danej konfigurácie kladiek.
 +
 
 +
==Video==
 +
<youtube>kqIT6wfY4hs</youtube>

Latest revision as of 21:11, 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:

Funkcia ktorá riadi beh stavebnice

  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);
 }

Zdrojový kód

Zdrojové kódy programu napísané v jazyku Java:

Pre programovanie EV3 v Lejose je potrebné nainštalovať do PC Lejos pre EV3 [2].

Dokumentácia je k dispozícii na [3].


Zipped folder containing the project source code.

Zhrnutie

Podarilo sa nám vytvoriť program ktorý meria silu motora potrebnú pre zdvihnutie telesa s danou váhou. K dispozícii sú v stavebnici ľahko konfigurovateľné kladky, pomocou ktorých je možné merať silu motora potrebnú na zdvihnutie telesa pomocou danej konfigurácie kladiek.

Video