{"format":"espplc-ir","version":3,"uid":"c0a1c0canzonci01","name":"Canzoncina dei relè","blocks":[{"id":"main","type":"main","number":0,"name":"Main","segments":[{"id":1,"order":0,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Call","fc":10}]},"outputs":[]}],"title":"Canzoncina","comment":"Quinta di Beethoven, Jingle Bells, \"Shave and a haircut — two bits\" sui relè Q0 e Q1. I0: da capo. M30 = 1: silenzio"}]},{"id":"startup","type":"startup","number":0,"name":"StartUp","segments":[{"id":1,"order":0,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW10"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW15"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW16"}}]},"outputs":[]}],"title":"Da capo","comment":"Dopo un Download o un passaggio in RUN la musica riparte dall'inizio"}]},{"id":"fc10","type":"fc","number":10,"name":"Canzoncina","segments":[{"id":1,"order":0,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Parallel","branches":[{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"I","idx":0}},{"type":"Trig","edge":"P","mem":{"ns":"E","idx":0}}]},{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":31}},{"type":"Trig","edge":"P","mem":{"ns":"E","idx":1}}]}]},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW10"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW15"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW16"}}]},"outputs":[]}],"title":"Da capo","comment":"Pulsante I0 o M31 forzato da Online: si ricomincia dal primo passo"},{"id":2,"order":1,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Compare","cmp":">=","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":0}},{"type":"Compare","cmp":"<","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":80}},{"type":"Contact","negated":true,"op":{"ns":"M","idx":20}},{"type":"Timer","kind":"TON","op":{"ns":"T","idx":1},"pt":75}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"M","idx":20}}}]}],"title":"Tempo Quinta","comment":"Passi 0..79: un passo ogni 75 ms (timer che si riarma da solo)"},{"id":3,"order":2,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Compare","cmp":">=","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":80}},{"type":"Compare","cmp":"<","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":224}},{"type":"Contact","negated":true,"op":{"ns":"M","idx":21}},{"type":"Timer","kind":"TON","op":{"ns":"T","idx":2},"pt":70}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"M","idx":21}}}]}],"title":"Tempo Jingle","comment":"Passi 80..223: un passo ogni 70 ms (timer che si riarma da solo)"},{"id":4,"order":3,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Compare","cmp":">=","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":224}},{"type":"Compare","cmp":"<","a":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":272}},{"type":"Contact","negated":true,"op":{"ns":"M","idx":22}},{"type":"Timer","kind":"TON","op":{"ns":"T","idx":3},"pt":95}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"M","idx":22}}}]}],"title":"Tempo Saluto","comment":"Passi 224..271: un passo ogni 95 ms (timer che si riarma da solo)"},{"id":5,"order":4,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Parallel","branches":[{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":20}}]},{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":21}}]},{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":22}}]}]}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"M","idx":24}}}]}],"title":"Passo","comment":"Un impulso a ogni passo, qualunque sia la parte"},{"id":6,"order":5,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":0}},{"type":"Box","box":"MOVE","a":{"k":256},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":340},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":1}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":2}},{"type":"Box","box":"MOVE","a":{"k":256},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":340},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":3}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":4}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":5}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":273},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":6}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":273},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":7}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":16657},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":8}},{"type":"Box","box":"MOVE","a":{"k":4369},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":1},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":9}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":16657},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":10}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":20753},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":11}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":4369},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":12}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":257},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":13}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":14}},{"type":"Box","box":"MOVE","a":{"k":4097},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":4433},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":15}},{"type":"Box","box":"MOVE","a":{"k":272},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":272},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]},{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":0}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":16}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW13"}},{"type":"Box","box":"MOVE","a":{"k":0},"out":{"ns":"DB","db":1,"f":"MW14"}}]},"outputs":[]}],"title":"Spartito","comment":"A inizio battuta: i 16 passi della battuta per Q0 (MW13) e Q1 (MW14), un bit per passo"},{"id":7,"order":6,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Box","box":"MOD","a":{"ns":"DB","db":1,"f":"MW13"},"out":{"ns":"DB","db":1,"f":"MW15"},"b":{"k":2}},{"type":"Box","box":"DIV","a":{"ns":"DB","db":1,"f":"MW13"},"out":{"ns":"DB","db":1,"f":"MW13"},"b":{"k":2}},{"type":"Box","box":"MOD","a":{"ns":"DB","db":1,"f":"MW14"},"out":{"ns":"DB","db":1,"f":"MW16"},"b":{"k":2}},{"type":"Box","box":"DIV","a":{"ns":"DB","db":1,"f":"MW14"},"out":{"ns":"DB","db":1,"f":"MW14"},"b":{"k":2}}]},"outputs":[]}],"title":"Colpo del passo","comment":"Bit più basso = colpo di questo passo (MOD 2), poi la battuta scorre di un passo (DIV 2)"},{"id":8,"order":7,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Box","box":"ADD","a":{"ns":"DB","db":1,"f":"MW10"},"out":{"ns":"DB","db":1,"f":"MW10"},"b":{"k":1}}]},"outputs":[]}],"title":"Avanti","comment":"Passo successivo"},{"id":9,"order":8,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Box","box":"DIV","a":{"ns":"DB","db":1,"f":"MW10"},"out":{"ns":"DB","db":1,"f":"MW11"},"b":{"k":16}},{"type":"Box","box":"MOD","a":{"ns":"DB","db":1,"f":"MW10"},"out":{"ns":"DB","db":1,"f":"MW12"},"b":{"k":16}}]},"outputs":[]}],"title":"Battuta","comment":"Battuta = passo / 16, posizione = passo MOD 16"},{"id":10,"order":9,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":false,"op":{"ns":"M","idx":24}},{"type":"Timer","kind":"TP","op":{"ns":"T","idx":5},"pt":45}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"M","idx":27}}}]}],"title":"Durata del colpo","comment":"Relè acceso 45 ms a ogni passo con il colpo"},{"id":11,"order":10,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":true,"op":{"ns":"M","idx":30}},{"type":"Contact","negated":false,"op":{"ns":"M","idx":27}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW15"},"b":{"k":1}}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"O","idx":0}}}]}],"title":"Relè 1 (mano sinistra)","comment":"Q0. M30 = 1 silenzia"},{"id":12,"order":11,"language":"LD","rungs":[{"series":{"type":"Series","items":[{"type":"Contact","negated":true,"op":{"ns":"M","idx":30}},{"type":"Contact","negated":false,"op":{"ns":"M","idx":27}},{"type":"Compare","cmp":"==","a":{"ns":"DB","db":1,"f":"MW16"},"b":{"k":1}}]},"outputs":[{"series":{"type":"Series","items":[]},"coil":{"kind":"coil","op":{"ns":"O","idx":1}}}]}],"title":"Relè 2 (mano destra)","comment":"Q1. M30 = 1 silenzia"}]}],"dbs":[{"number":1,"name":"Merker","retain":true,"fields":[{"name":"MW10","type":"WORD"},{"name":"MW11","type":"WORD"},{"name":"MW12","type":"WORD"},{"name":"MW13","type":"WORD"},{"name":"MW14","type":"WORD"},{"name":"MW15","type":"WORD"},{"name":"MW16","type":"WORD"}]}]}