CoDeSys
Siemens S7-1200 viide Siemens LOGO! viide Automatiseerimise viide Mehhatroonikaseadmete viide Pneumoautomaatika viide
Joonis
Joonis

7.7 Ülesanne: Massiivi liikmete bitimustrite nihutamine

Süsteemi „Nuppud ja lambid” kirjeldus

Süsteemus on 3 nuppu (S1 - Start, S2 - Stop, S3 - Reset) ja 3 indikaatorlampi (H1 - roheline, H2 - kollane, H3 - punane).

Ülesande püstitus

Koostada programm, mis nihutab massiivi liikme bitimustrit paremale või vasakule. Massiiv koosneb 2...200 (määrab õppejõud) liikmest. Ülesandes tuleb kasutada sobivat andmetüüpi massiivi deklareerimisel. Kõigil massiivi liikmetel peab olema vähemalt esimene bitt aktiivne (väärtus 1). Õppejõud valib millised ja kui palju bitte on aktiivsed ühes massiivi liikmes.

Kõik massiivi liikmete bitimustreid tuleb nihutada 1...4 biti võrra (määrab õppejõud) vasakule kui vajutada START nuppu. Kui mõned bitid nihutatakse mingi massiivi liikme bitimustrist välja (üle vasaku ääre), siis tuleb need panna tagasi massiivi liikme bitimustrisse paremale poole. Üle bitimustri ääre nihkuvad bitid tuleb panna samas järjekorras tagasi teisele poole bitimustrisse kuidas need väljusid bitimustrist. Sama funktsioon kehtib ka RESET nupu jaoks, ainult et see nihutab massiivi liikme bitimustrit paremale.

Nuppude hoidmisel ei tohi toimuda mitut bitimustri nihkumist.

Massiiv ei ole seotud ühegi füüsilise väljundiga. Ülesande korrektset täitmist kontrollitakse Login vaates massiivi liikmete väärtusi jälgides. Testimiseks on vaja aktiveerida iga massiivi liikme bitimustris mingid bitid. Seejärel programm sisse laadida ja kontroller taaskäivitada.


Soovitatav lugemismaterjal

Ülesande lahendamiseks tutvuda järgmiste peatükkidega.

CoDeSys animatsioon

Alla laetav animatsioon virtuaalsele PLC-le "CODESYS Control WIN V3". See võimaldab testida PLC programmi arvutis ilma reaalse riistvarata.

7.7 Exercise: Shifting bit patterns of the array members

Description of the buttons and lights

The MFS stand has three buttons (S1 – Start button, S2 – Stop button, S4 – Reset button) and 3 indicator lights (lamps) (H1 – Green light, H2 – Yellow light, H3 – Red light).

Description of the exercise

Write a program that shifts bit patterns of an array member to right or left. The array has to consist of 2...200 (says the tutor/teacher) members and an optimal data type for the task has to be used. In all array members at least the first bit has to be active (status 1/on). The tutor/teacher can choose which and how many bits are active in one array member.

All array member bit patterns have to be shifted to left by 1...4 bits (says the tutor/teacher) when pressing the START button. If some bits are shifted over the left side of the array member bit pattern, then these must be put into the other (right) side of the array member bit pattern. Bits moving over the side must be placed straight to the others side of the bit pattern, as they moved over the bit pattern side (no randomising of bit values). The same function applies to the RESET button. The only difference is that RESET button will shift the array member bit patterns to the right.

There should be no double shifting of bit patterns when holding the buttons.

The array is not related to any physical output. The correct execution of the task can be checked in the Login view by observing the array member values. For testing purposes, it is necessary to activate random bits in different array members. Then download the program and restart the controller (PLC).


CoDeSys animation

Animation for virtual PLC "CODESYS Control WIN V3". Download it and solve the exercise on the PC without the real equipment.

Creative Commons Licence
"CoDeSys" is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License .