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

7.7 Ülesanne: Massiivi liikmete bitimustrite nihutamine

Juhtpaneeli kirjeldus

Juhtpaneelil on 3 nuppu (S1 - Start, S2 - Stop, S4 - Reset), üks võtmega lüliti (S3 - Auto/Man) ja 4 indikaatorlampi (H1, H2, H3, H4).

Ü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.

7.7 Exercise: Shifting bit patterns of the array members

Description of the control panel

The control panel has three buttons (S1 – Start button, S2 – Stop button, S4 – Reset button), one key switch (S3 – Auto/Man (in normal state, it is on Auto)) and 4 indicator lights (lamps) (H1 – Start light, H2 – Reset light, H3 – Light Q1, H4 – Light Q2).

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).

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