Treść książki

Przejdź do opcji czytnikaPrzejdź do nawigacjiPrzejdź do informacjiPrzejdź do stopki
Chapter1
ExerciseL1:PCsequentialcontrol
Thisexercisecoverstopicsrelatedtostatemachinesandtheirimplementationinthe
C/C++language.MoorestatemachineandMealystatemachinearediscussed.Athe-
oreticalnotationisintroduced,clarifyingthedifferencebetweenthesetwotypesofstate
machines.Animplementationofanexamplestatemachineinbothversionsdiscussedis
presented,aswellastheirimplementationintheC/C++language.
Afterreviewingthecontentofthischapter,studentswillbeableto:
ExplainthedifferencebetweenaMoorestatemachineandaMealystatemachine;
Designastatemachinethatperformsasimpletask;
Understandhowaprogramimplementedaccordingtoagivenstatemachineworks;
Indicatewaystointroducetimingdependenciesintostatemachines;
Designastatemachinethatcyclicallyswitchesbetweentwostates;
ImplementaprogrambaseonastatemachineintheC/C++language.
1.1
Introduction
Thecommunicationbetweenprogrammablecontrollersandtheenvironmentinwhich
theyoperateisachievedthroughanalogordigitalsignalmeasurements.Analogsignals
arevoltagesorcurrentsdirectlyproportionaltothemeasuredquantity,suchastemper-
ature.Digitalsignalsarevoltagesrepresentingthepresenceorabsenceofspecificinform-
ation/quantities,suchasthepresenceofanitem.PLCs,or:dedicatedmeasuringcircuits,
candirectlyperformthesemeasurementsandcanbeusedtotransmitinformationabout
measurementstothecontrollerdigitally.
Signalscanalsobedividedintocontinuousanddiscretesignals.Ananalogsignalis
asignalthatcantakeanyvaluewithinaspecificrange,suchastemperaturemeasured
inwholedegrees.Meanwhile,discretesignalstakeoneofthepredeterminedvalues.For
example,acolorsensorrecognizeswhethertheobserveddetailisred,blue,white,orcannot
bedetermined.Inthiscase,thevaluesarepredetermined,andtherearenointermediate
valuessuchaspurple.Inpractice,discretesignalsareusuallybinary,i.e.,theytakeone
ofonlytwovalues.Typically,thesevaluesarerepresentedasalogicalvalue(true/false)
oradigitalvalue(1/0).
Althoughtheaboveconsiderationsregardmeasurements,theyareapplicabletoma-
nipulatedcontrolsignals.Itis,therefore,worthsupplementingthelistofexamplesof
thesesignalswiththefollowingitems:ananalogcontrolsignalcontrollingtheoutputofa
heaterorpump,adigital,andatthesametime,discrete(binary)signalactivatinganelec-
tromagneticactuator,acontinuoussignalcontrollingthepositionofaservomechanism.
9