Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
cs:sw:01-mervis:advanced-modes-of-digital-inputs-hidden [2020/01/17 07:22]
avsetula created
cs:sw:01-mervis:advanced-modes-of-digital-inputs-hidden [2024/03/14 10:00] (current)
kcerny typos
Line 1: Line 1:
-FIXME - překlad +====== ​Digitální vstupyfunkce DebounceCounter a Direct Switch ​====== 
-====== ​Digital inputsdebouncecounter and direct switch ​====== +<WRAP group 100%> 
- +<WRAP half column 81%> 
-The digital inputs on UniPi controllers have interesting "​add-ons"​which help accuracy and responsiveness of the regulationThese add-ons are configured in the CPU of the input/output backplane board in UniPiso they are SW independent and therefor very fast.+Digitální vstupy na kontrolérech Unipi jsou vybaveny užitečnými přídavnými funkcemikteré umožňují zvýšit odezvu a přesnost regulaceTyto funkce jsou řízeny mikroprocesorem samotné I/O desky a jsou tak nezávislé na řídicím softwarucož výrazně zvyšuje jejich rychlost odezvy 
 +</​WRAP>​ 
 +<WRAP half column 15%> 
 +;;# 
 +<​html><​span class="​dev-tag dev-patron">​Patron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-neuron">​Neuron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-axon">​Axon</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-extens">​Extension</​span></​html>​ 
 +;;# 
 +</​WRAP>​ 
 +</​WRAP>​
  
 ===== Debounce ===== ===== Debounce =====
- +Funkce ​**Debounce** je navržena pro vykrývání nepřesností,​ se kterými se typicky setkáte při přepínání stavu digitálního vstupuTyto chyby obvykle vznikají v případěchžje vstup spínán mechanickým prvkem (napřpřepínač)Signál generovaný při stisknutí ​puštění spínače může vypadat např. takto
-The **debounce** functionality is for catching glitches which typically occur when changing states on digital inputThose happen mostly when the digital input is operated by some mechanical element, e.gmomentary switch. The signal generted upon pressing and releasing ​momentary switch can look like this:+
  
 {{ :​en:​sw:​01-mervis:​digital-inputs-01-debounce.jpg?​direct&​400 |}} {{ :​en:​sw:​01-mervis:​digital-inputs-01-debounce.jpg?​direct&​400 |}}
  
-To "​debounce"​ these glitches, you have to slow down the reaction on changing states of the inputOn HW level, you could achieve this with employing a RC element for exampleTo make your life easier, you can set this "​slowing down" on SW level.+Pro odstranění těchto odchylek by normálně bylo nutné zpomalit reakci vstupu na změnu stavuNa úrovni hardwaru lze tohoto docílit například zapojením ​RC prvkuPro usnadnění práce ale můžeme toto zpomalení provést i na úrovni softwaru
  
-The functionality looks for changes on a digital inputIf the change is less then defined ​debounce ​timeit will be ignoredOnce the change exceeds the debounce timethen the event is passed to the Mervis.+Funkce Debounce detekuje změnu na digitálním vstupuPokud je signál kratší než předdefinovaný ​debounce ​časje ignorovánZměna je předána řídicímu SW až tehdypokud je délka změny delší než definovaný interval
  
 <WRAP center round info 60%> <WRAP center round info 60%>
-By default, all digital inputs are equipped with 5ms debounce ​time+Z výroby jsou všechny digitální vstupy na jednotkách Unipi nastaveny na debounce ​interval 5 ms.
 </​WRAP>​ </​WRAP>​
  
-Let's seehow the debounce ​can be configured in Mervis. ​The configuration is done per device inputso double click on the UniPi'​s controller nameIn the **Main window**, the tab with all controller'​s registers will apearUnder the **Name**, you have a search box, where by entering ​"​DI_" ​you will be presented with the list of digital inputs, or more preciselytheir registers.+Nyní se podívejmejak lze debounce ​konfigurovat v Mervis ​IDENastavení se provádí přes vstupy zařízenídvojitě proto klikněte na název vašeho kontroléru Unipi pod Modbus TCP kanálemNa **hlavním panelu** se objeví záložka se všemi registry kontroléruPod kolonkou ​**Název** naleznete vyhledávací řádekdo kterého zadejte ​"​DI_"​. Zobrazí se seznam všech dostupných digitálních vstupůči přesněji řečeno jejich datových bodů
  
 {{ :​en:​sw:​01-mervis:​digital-inputs-02-list-of-inputs.png?​direct |}} {{ :​en:​sw:​01-mervis:​digital-inputs-02-list-of-inputs.png?​direct |}}
  
-Select the desired digital inputfor which you want to set the debouncingIn the **Properties panel** you can see all the options you can set on this registerThe option we are interested in right now is the **Debounce**. Value of this option is number of miliseconds of deboucing period.+Ze seznamu vyberte vstupkterý chcete konfigurovatV panelu ​**Vlastnosti** jsou zobrazeny všechny možnosti nastavení daného registruNás zajímá kolonka ​**Debounce**, jejiž hodnota určuje délku debounce intervalu v milisekundách
  
 {{ :​en:​sw:​01-mervis:​digital-inputs-03-debounce-time.png?​direct |}} {{ :​en:​sw:​01-mervis:​digital-inputs-03-debounce-time.png?​direct |}}
  
-We just changed the configuration of the PLC moduleswhich is not applicable by simply uploading the solutionTo save the configuration,​ follow the [[en:​sw:​01-mervis:​unipi-configure-module-hidden|UniPi Configure Module]] tutorial.+Zadání Vámi žádané hodnoty je změnou konfigurace modulu ​PLC, kterou nelze aplikovat nahráním sestavyPro uložení konfigurace modulu se řiďte návodem ​[[en:​sw:​01-mervis:​unipi-configure-module-hidden|Unipi konfigurace modulu]]. 
  
 <WRAP center round tip 60%> <WRAP center round tip 60%>
- If you are about to set options on multiple registersyou can do it at once and **Configure module** afterwards+Pokud měníte nastavení více registrůmůžete všechny změny uložit najednou později.
 </​WRAP>​ </​WRAP>​
  
-===== Counter ====== +===== Čítač (Counter======
-Another interesting functionality of **digital inputs** is the **counter**. It is a software independent,​ high-speed counter of rising edges of changing signal on digital input. In simple words, it can count short pulses very precisely.+
  
-The speed of Mervis ​programs is not enough for detecting quick changes of digital inputs in traditional way (with the "​Pulse ​counter ​(BD30)" FUPLA box for example). If you have [[https://​en.wikipedia.org/​wiki/​Slot_car|slot car track]] and you want to count the number of passes of slot carsyou wouldn'​t be able to detect it, since the length of pulses from the "​pass"​ sensors will be in units of miliseconds. Speed of the slot car is up to 80kmph and with length of the car about 10cm is the pass of whole car above the sensor about 4.5ms+Druhou zajímavou funkcí **digitálních vstupů** je **čítač**. Jde o vysokorychlostní počítadlo náběžných hran signálů pro změnu stavu digitálního vstupu, které je (stejně jako funkce Debounce) nezávislé na řídicím softwaru. Jednoduše řečeno, čítač dokáže velmi přesně sčítat i velmi krátké pulzy.  
 + 
 +Programy vytvářené v Mervis ​IDE nejsou dostatečně rychlé pro detekci rychlých změn digitálních vstupů ​(např. pomocí funkčního bloku "​Pulse ​Counter ​(BD30). ​Pokud například vlastníte autodráhu ​chcete počítat průjezdy autíček cílovou čárousamotný Mervis IDE nebude schopný je detekovat - při rychlosti až 100 km/h a délce autíčka cca 10 cm trvá průjezd přes senzor sotva 4,5 ms
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-The HW counter depends on the **Debounce** settingsTherefor the **Debounce** ​has to be set to lower valuethan is the expected length of the pulses to count.+Hardwarový čítač je závislý na nastavení intervalu funkce debounceInterval funkce ​**Debounce** ​je třeba nastavit na kratší dobunež je očekávaná délka sledovaných pulzů
 </​WRAP>​ </​WRAP>​
  
 +Čítačem jsou standardně vybaveny všechny **digitální vstupy** a pro jeho používání není třeba žádných nastavení. Výstupem čítače je globální proměnná - například vstupu ''​Neuron_L523_DI_1.01''​ odpovídá proměnná ''​Neuron_L523_CNT_1.01''​.
  
-Each **digital input** is equipped with **counter** and you don't need to set anything to use it. The counter is available through global variable. For the input named ''​Neuron_L503_DI_1.01''​ we have counter variable named ''​Neuron_L503_CNT_1.01''​. +Jako důkaz nízké rychlosti softwarového čítače si prohlédněte následující ​program ​běžící v režimu ladění
- +
-To demonstrate how slow is the software counting, look at this program ​in debugging mode:+
  
 {{ :​en:​sw:​01-mervis:​digital-inputs-08-sw-counter-vs-hw-counter.png?​direct |}} {{ :​en:​sw:​01-mervis:​digital-inputs-08-sw-counter-vs-hw-counter.png?​direct |}}
  
-As you can seewe are counting the rising edge events on the ''​Neuron_L503_DI_1.01'' ​through ​''​Pulse counter (BD30)'' ​function blockand reading the HW counter of the same input via the ''​Neuron_L503_CNT_1.01''​ variable. Afterwardswe compare those two variables in ''​eq''​ function block, and if they are equal, we will turn the ''​X1''​ LED on the controller ''​ON''​Once the two counters are not equalthe LED will be ''​OFF''​.+Jak můžete vidětprogram detekuje náběžné hrany na vstupu ​''​Neuron_L523_DI_1.01'' ​pomocí bloku ''​Pulse counter (BD30)'', ​a zároveň na stejném vstupu pulzy počítá pomocí hardwarového čítačePokud mají čítače stejnou hodnotuna kontroléru se rozsvítí dioda X1. Pokud čítače nejsou shodnédioda zůstane zhasnuta
  
-The debugging started with both counter values at 0. We connected a momentary switch to the ''​DI1.1'' ​input and start pressing the switch very quicklyAs you can seethe software counter detected only 10 pressesbut the hardware counter detected ​54.+V okamžiku spuštění ladění jsou oba čítače na hodnotě ​0. Ke vstupu ​''​DI1.1'' ​připojíme kontaktní spínač a začneme jej co nejrychleji stiskávatJak vidítesoftwarový čítač zachytil pouze 10 pulzůzatímco hardwarový celých ​54. 
  
 <WRAP center round tip 60%> <WRAP center round tip 60%>
-The counter variables are read onlytherefor you cannot set or reset them directly from program or the variable browser in debugging modeYou can set or reset the variables via "​set" ​variable. For the ''​Neuron_L503_CNT_1.01'' ​the set variable is called ​''​Neuron_L503_CNT_1.01_set''​.+Čítačové proměnné jsou pouze pro čtenínelze je proto nastavovat či resetovat přímo v programu či skrze prohlížeč proměnných v módu laděníTyto proměnné se nastavují pomocí proměnné ​"​set"​; u čítače ​''​Neuron_L523_CNT_1.01'' ​má tato proměnná název ​''​Neuron_L523_CNT_1.01_set''​.
 </​WRAP>​ </​WRAP>​
  
 ===== Direct switch =====  ===== Direct switch ===== 
-Last extra functionality (but not least) is the direct switchAs we discoveredthe software detection of changes is far from being instantaneous. And there are applicationswhere even 20ms delay can cause problems, or represent some discomfort at least. Typical example is a switch controlling a light. What we expect from the behaviour is the instant change of the lighting upon pressing the switchThatas demonstrated aboveis not possible to achieve in the software by simple wiring the DI to DO.+V neposlední řadě jsou jednotky Unipi vybaveny funkcí Direct SwitchJak jsme zjistili výšesoftwarová detekce změn není dostatečně rychlá - v některých projektech přitom způsobí problémy zpoždění už 20 msjako například u spínačů osvětleníU nich očekáváme okamžitou reakci světla na stisknutí vypínačena předchozích řádcích ale vidímeže pouhým propojením digitálního vstupu s výstupem tohoto cíle nedosáhneme
  
-The direct switch is the configuration of digital input in a way it will directly control digital or relay output of the same nameThe wiring of the input and output is fixed cannot be changedonly turned on or offOn Group 1, the DIs are wired to DOsOn other Groups, the DIs are wired to ROs.+Direct Switch oproti tomu umožňuje nastavit digitální vstup tak, aby ovládal určený digitální či reléový výstup přímo skrze fyzické propojeníTo je pevné ​nelze jej měnitlze jej pouze zapínat a vypínatV I/O skupině ​jsou na jednotkách Unipi digitální vstupy propojeny s digitálními výstupyU skupin 2 a 3 pak jsou digitální vstupy napojeny na reléové výstupy
  
 <WRAP center round info 60%> <WRAP center round info 60%>
-On Neuron ​L503, the direct switch (DS) on DI1.1 is wired to DO1.1. ​The DS on DI3.14 ​is wired to RO3.14+U modelu ​Neuron ​L523 je vstup DI1.1 propojen s DO1.1. DI3.14 ​je pak propojen s RO3.14.
 </​WRAP>​ </​WRAP>​
  
- +Konfigurace Direct Switch se provádí stejně jako u **Debounce**. ​**levém panelu** dvojitě klikněte na název vašeho kontroléru Unipi pod Modbus TCP kanálem**hlavním panelu** vyhledejte příslušný DIklikněte na nej a v panelu ​**Vlastnosti** vyhledejte kolonku ​**Direct ​Switch**. 
-The settings is done in the same way we did with the **Debounce**. ​Double click on the name of the UniPi module on the **Left panel**, search for the desired DI in the **Main window**, click on it and in the **Properties panel** look for the option called ​**Direct ​switch**.+
  
 {{ :​en:​sw:​01-mervis:​digital-inputs-09-direct-switch.png?​direct |}} {{ :​en:​sw:​01-mervis:​digital-inputs-09-direct-switch.png?​direct |}}
  
-As you can seethe option has dropdown ​menu with different modes.+Jak můžete viděttato možnost má rozbalovací ​menu obsahující různé módy funkce
  
-  * **Disabled**: the direct switch is disabled +  * **Blokování**: funkce je vypnuta 
-  * **Copy**: The status of the DI is copied to the DO/RO. So when the DI is ''​TRUE'', ​the DO is ''​TRUE'' ​and when the DI is ''​FALSE''​ the DO is also ''​FALSE''​ +  * **Kopírovat**: Stav DI je přenášen na DO či RO. Pokud se DI přepne na ''​TRUE'', ​stav DO se rovněž změní na ''​TRUE''​. To samé platí i při změně stavu na ''​FALSE''​ 
-  * **Copy (Invert)**: Same as above but invertedWhen the DI is ''​TRUE'' ​the DO is ''​FALSE'' ​and vice versa+  * **Kopírovat inverzně**: Stejný princip jako u předchozího módu, avšak inverzně, tjpokud je DI ve stavu ''​TRUE''​DO se přepne do stavu ''​FALSE'' ​a naopak.  
-  * **Toggle**: This mode toggles the DO on the rising edge of the DI. Handy for controlling a light with momentary switch for example+  * **Přepnout**: Tento mód přepne ​DO při detekci náběžné hrany na DI. Tato funkce je praktická například pro ovládání světel digitálním spínačem. ​
  
-After setting the configuration,​ you need tu download it to the moduleSee the [[#debounce|debounce]] section.+Po dokončení konfigurace je nutné ji stáhnout do kontroléruViz návod ​[[cs:​sw:​01-mervis:​unipi-configure-module-hidden|]]. 
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-The **Direct ​switch** depends on the **Debounce** ​settingsIn order to have instant changeyou need to set the **Debounce** ​to value which doesn'​t deny the purpose of the **Direct ​switch** and yet to valuewhich doesn'​t deny the purpose of the **Debouncing**. The 5-10ms ​should be OK.+Funkce ​**Direct ​Switch** je rovněž závislá na nastavení ​**Debounce**. ​Aby změna na výstupu nastala okamžitěje nutné ​**Debounce** ​nastavit na takovou hodnotu, která nezabrání požadované funkci ​**Direct ​Switch**, ale zároveň nepopře smysl funkce ​**Debounce**. Interval ​5-10ms ​by měl v tomto případě stačit
 </​WRAP>​ </​WRAP>​
-