Difference between revisions of "Kladky s EV3"
m (→Software) |
m |
||
Line 58: | Line 58: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | ==Zdrojový kód== | ||
+ | |||
+ | The relay code is compiled under Python 3.5, and using the pySerial library. | ||
+ | |||
+ | You can download pySerial trough pip with the | ||
+ | <code>pip install pyserial</code> | ||
+ | command, or get it from the [https://pypi.python.org/pypi/pyserial official site] and install it [https://pythonhosted.org/pyserial/pyserial.html#from-source-tar-gz-or-checkout manually]. | ||
+ | |||
+ | For the robots you require ChibiStudio Preview 12 and stm32flash for downloading. | ||
+ | For tutorial go to [http://dai.fmph.uniba.sk/courses/pphw/tatra_tutorial.html]. | ||
+ | |||
+ | Zipped folder containing the [[Media:Project_source_code.zip|project source code]]. |
Revision as of 20:01, 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.
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
The relay code is compiled under Python 3.5, and using the pySerial library.
You can download pySerial trough pip with the
pip install pyserial
command, or get it from the official site and install it manually.
For the robots you require ChibiStudio Preview 12 and stm32flash for downloading. For tutorial go to [2].
Zipped folder containing the project source code.