development system - enertec … · the development system is fitted with: ... :: fig 4_[compiler]...
Post on 15-Jun-2020
9 Views
Preview:
TRANSCRIPT
REFRIGERATION &AIR CONDITIONING DIVISION System manual
MAKING MODERN LIVING POSSIBLE
Development SystemMCX unit controller
RS8FA1022 © Danfoss A/S (DE-BDP), November 2007
_INDEX1] Generaloverview 3 1.1] Functionlibrariesandapplicationsoftware 3 1.2] Compiler 4 1.3] Uploadingtheapplication 4 1.4] Simulator 5 1.5] MCXVirtualMachine 52] Anexampleofhowtocreateanapplicationstep-by-step 5 2.1] Arrangementofthedevelopmentenvironment 5 2.2] Creationoftheapplication 5 2.3] Programcompiling 6 2.4] Programuploading 7 2.5] Programexecution 73] Syntaxoftheprogramminglanguage 7 3.1] Variabledeclaration 7 3.2] Initializationofvariables 7 3.3] Functiondeclaration 8 3.4] Parameterspassing 8 3.5] Parameterssaving 8 3.6] Conditionalcompiling 9 3.7] Controlstructures 9 3.8] Basicdatatypes 104] Functionlibrary 10 4.1] Input/Output 11 4.2] Stringmanipulation 15 4.3] RS485Communication 16 4.4] CANbuscommunication 17 4.5] Timermanagement 17 4.6] Applicationandcontrolleridentification 18 4.7] Systeminformation 19 4.8] Userinterface 195] Howtocreateyourownlibrary 20
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
1] GeneraloverviewThe MCX development systemallows you to realize your ownapplication software for MCXprogrammablecontrollers.
You can find all the developmentsystem items inside theMCXDevPack.zipfiletheyconsistsof:
alibraryofbasicfunctions(MCXLib.libandDisplayLib.lib)acommandlinecompiler(nvmcc.exe)aprogramforuploadingtheapplicationsoftwareintothecontroller(nupload.exe)asimulationsoftware
1.1] Functionlibrariesandapplicationsoftware
TheapplicationsoftwareiswritteninaC-likeprogramminglanguage.Itisdifferentfromthestandardassomefunctionalitythatispotentiallydangerous in an embeddedhardware product (e.g. pointerusage),havebeenremoved.
This document describes thoseparts of the standard C that aresupportedandanydissimilaritiesfromthestandardarehighlighted.
Youcanuseanytexteditortowriteyoursoftware,butitissuggestedtouseeditorslikeEclipsewhichenablessyntaxevidence,on-linehelpandintegrationwiththeMCXcompileranduploadertools.
Thedevelopmentsystemisfittedwith:
aneasydemoprogramtobeusedasthedemoplatformformakingyourownapplicationsomelibrariesofbasicfunctions,describedatparagraph2Functionlibrary.Thesefunctions,usedbythedeveloperinsidehissoftware,allowtoeasilyinterfacewithallthecontrollerhardwaredevices,suchasdigitalandanaloginputsandoutputs,serialcommunicationports,CANbuscommunicationport,LED,buzzer,display,keyboardetc.
Standard application softwarefor managing the main HVACRapplications are already developedand available on demand. Theycanbeusedwithoutanychangeorcustomizedaccordingtoownneeds.Furtherinformationavailablewiththeapplicationsoftware.
»
»
»
»
»»
MCXLib
BIOSCANopen
CANbus
Modbus
RS485
Flash
EEPROM
Display
Keyboard
uploading(nupload .exe uploader )
compiling(nvmcc.exe compiler )
Application software
Object code
MCX programmable control
Virtual Machine
Object code
Fig1_[Generaloverview]
Fig2_[Functionslibrariesandapplicationsoftware]
Fig3_[Functionslibrariesandapplicationsoftware]
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
1.2] CompilerBasedupontheapplicationwritteninC,thecompilercreatesafile(objectcode)whichcanbeexecutedbytheprogrammablecontroller.
Thecompilerconsistsofthenvmcc.exeprogramthatrequiresthecompletenameofthefiletobecompiledasaparameter.ItcanbeexecutedfromtheWindows®commandprompt.
Beingacommandlinetool,itcanbeusedinsidebatchfilestoautomatecompiling.
Thecommandlineoptionsarecompatiblewithgcc(oneamongthemostusedCcompilers)andthusitcaneasilyfitinsidethirdpartysoftware(e.g.editorslikeEclipse,maketools,etc.)
Thecompletecommandsyntaxis:
nvmcc<file_name.c>
The result is saved in a file having the samenameofthesourcefilebutwiththeadditionof.oextension.
Possibleerrorsaredetected,signalingthenameofthesourcefilewheretheyaregenerated,thelinenumberanddescription.
Example
EXEX
compilingNVMCC test .c
errors ?
NO
YES
test .c
test .c.o errors signal<file_name >:<raw _number >:<description >
Fig4_[Compiler]
nvmcctest.c
compilesthetest.cfilesandproducesthetest.c.ofilethatcanbeexecutedbytheprogrammablecontroller.
1.3]UploadingtheapplicationYoucanuploadtheapplicationtotheprogrammablecontrollerbyconnectingyourPCtotheRS485serialinterfaceofthedevicethroughaUSB-RS485(orRS232-RS485)converter.
ToinstalltherecommendedUSB-RS485converterseetheInstallationGuideofthisproduct.
Followingsuccessful installationof the interface, theNUPLOADcommand includingspecificationofCOMportandobjectfilename(*.o)canbeexecuted.
ThecommandcanbeexecutedfromtheWindows®commandprompt,afterconnectingandpoweringonthecontroller.
Thecompletecommandsyntaxis:
nupload–comN[-console]<file_name.o>
Theoptional“console”parameterconfiguresthenuploadprogramtoshowthecharacterscomingfromtheseriallineandtosendwhatiswrittentotheserialline(asHyperTerminal®does).
Example
EXEXIftheRS485converterisconnected
totheCOM2ofyourPC,thecommandtouploadthetest.c.oprogramisthefollowing:
nupload–com2test.c.o
OnMCX08orhighermodels,loadingtheapplicationisanabsolutelysafeprocedure,becausethealreadyexistingapplicationsoftwareisnotoverwrittenuntilreceivingthenewonewithsuccess.
Note
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
1.4] SimulatorAsoftwaresimulatorisavailableinorderto:
simulatetheapplicationonaPCwithouttheneedofaphysicaldevicemakeafastdebug,integrateexternaldebugtoolsforamoreaccuratesimulation,keeptrackofeachchangetotheinputandoutputstatustoenablethechancetorepeatautomaticallythetestprocess.
TostartthesimulatoryouhavetorunthecommandNSimulatorfollowedbythebinaryfileoftheapplicationyouwanttosimulate.
ThecommandcanbeexecutedfromtheWindows®commandpromptandyoudoNOTneedtoconnectandpowerupthephysicaldevice.
Thecompletecommandsyntaxis:NSimulator–load<file_name.o>-session1
1.5] MCXVirtualMachineOnceuploadedintothedevice,theprogramisexecutedbyasoftwarevirtualmachinewhichabstractstheapplicationsoftwarefromphysicalhardware.
Thishasthefollowingadvantages:
ThecompilerproducesanuniqueobjectcodethatcanrunoneveryMCXprogrammablecontroller(currentandfutureonesaswell);theapplicationcanrecognizethemodelwhichitrunningonandadaptitselfaccordingtotheavailablehardwareresources.Easysoftwaremanagementandmaintenance.Thedevelopedapplicationsoftwaredoesn’tdependonthemicroprocessorused;itcouldbechangedinthefuture,keepingintouchwiththetechnologyevolution,withouttheneedtochangetheapplicationsoftware.Thevirtualmachinewilltakecareoftheadaptationissues.
ThevirtualmachineisthusanintermediarybetweentheapplicationsoftwareandtheBIOS,thatisthepartofsoftwaretightlyboundtothehardwareandthattakescareofthelowlevelmanagementofthemicroprocessorresources.
2] Anexampleofhowtocreateanapplicationstep-by-stepThefollowingexampleshowshowtocreateanapplicationthatvisualizesthecontrollerdatathroughtheserialline,thattogglesrelay1every1secondandwritesaparametervalueonthedisplay.
Itconsistsofthefollowingsteps:
ArrangementofthedevelopmentenvironmentCreationoftheapplicationProgramcompilingProgramuploadingProgramexecution
2.1] ArrangementofthedevelopmentenvironmentAdescriptionof thedevelopmentenvironmentfilescanbe found in the ‘Readme.html’file.To install thedevelopmentenvironment,runthe‘Setup.exe’fileandfollowtheon-screeninstructions.
2.2] CreationoftheapplicationCreateintheworkingfolderthedemo.cfilewhichrealizesthefollowingsmallsampleapplication.
//---------------------------//MCXDemo//---------------------------
#include“demolib.c”
»
»»»
»
»»
»»»»»
Fig5_[Simulator]
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
//thisstructurecontainsallparametersofthisapplicationstructTParams:publicTStdParams{//TODO:DeclarehereparameterstobestoredintoEEPROM
longSetpoint=250; //25.0};
//declareEEpromparameterspersistentTParamsParams;
//thisistheinitializationprocedure,andwillbecalledonce,atstartupvoidApp_Init(){
//TODO:Addhereinitializationcode//(itwillbeexecutedonlyonceafterpower-on)IO.SetAIType(1,ioTypeNTC);//configureAnalogInput1asNTC};
//thisisthecontrolloopprocedure,andwillbecalledcontinuouslyvoidApp_Run(){//TODO:AddhereyouralgorithmIO.SetDO(1,1);//setdigitaloutput1Sleep(1000);//wait1000ms(1second)IO.SetDO(1,0);//resetdigitaloutput1Sleep(1000);//wait1000ms(1second)
dsp.ClearDisplay();//cleardisplaydsp.DrawTextCR(1,2,”thisisatest”);//drawalabelatcolumn1,row2dsp.DrawValueCR(1,4,”Setpoint:“,Params.Setpoint,5,1);//drawalabelandavalueatcolumn1,row4,with5digitsand1decimal
};
Youcanmodifyandadaptittoyourneeds.
The App_Init() function is called only at power up. Here you can insert the initialization code of youralgorithm.
TheApp_Run()functioniscontinuouslycalled.Hereyoucaninsertthealgorithmcode.
2.3] ProgramcompilingRunthecommandpromptandgointotheexamplefolder.Beforecompiling,savethefileontheharddiskandtype:
nvmccdemo.c
TheresultwillbelikethisFig6:
Fig6_[Programcompiling]Note
Inthiswayyouhavegeneratedthedemo.c.ofile,consistingofthebinarycodetouploadintothecontroller.
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
2.4] ProgramuploadingAtthecommandprompt,type:
nupload–com2–consoledemo.c.o
com2:istheserialportwheretheUSB-485converterisconnectedtoconsole:configuresthenuploadprogramtoactasaterminalemulator
Attheendoftheuploadingprocess,thenewapplicationisrun.
HereishowthescreenshouldlooklikeaftertypingthecommandFig7:
2.5] ProgramexecutionProgramexecutionisautomaticafterloading.
Thesampleprogramshowssomeinformationonthecontroller(seeparagraph4.6Applicationandcontrolleridentification),togglesrelay1every1secondandshowsthesetpointvalueonthedisplay.
3] SyntaxoftheprogramminglanguageThesyntaxoftheMCXprogramminglanguageisderivedfromthestandardClanguage.
3.1] VariabledeclarationTodeclareavariableyouhavetodeclareitstypefollowedbyitsname.
Arrayscanbedeclaredusingsquarebracketsafterthevariablenamecontainingthemaximumnumberofelements.Thereisnolimittothemaximumnumberofelements.
Thearrayindexrangesfrom0tothemaximumnumberofitems-1.
»
»
Fig7_[Programuploading]
Example
EXEXlongMyVar;
shortMyArray[100];
longMyNewVar=5;
3.2] InitializationofvariablesVariablesarealwaysinitialized(exceptthoseofpersistenttype–see3.5Parameterssaving).Theyareinitializedwith0ifnovalueisspecified.
Onlyconstantsvaluesareallowedintheinitializingphase.Youcannotusecomplexexpressions.Onlythemainalgebraicfunctionsareallowed(addition,subtraction,multiplication,division)
RS8FA1028 © Danfoss A/S (DE-BDP), November 2007
3.3] FunctiondeclarationTodeclare the variable type returnedby the function, followedby thenameof the function itself andbyparametersbetweenroundbrackets.Thenfollowthefunctionbodyenclosedbetweencurlybraces.
Functionprototypesand.hfilesarenotnecessary;thecompilercanautomaticallyrecognizefunctionseveniftheyaredeclaredafterbeingused.
Example
EXEXlongMyFunction(shortParam1,charParam2){
returnParam1*Param2;
};
AvariablenamedRetValisautomaticallydefinedineveryfunction.Thisvariablestoresthereturnvalueanditcanbeassignedandreusedinsidethefunction.
Thereturninstructioncanbeomitted;attheendofthefunctionthevaluestoredintheRetValvariableisautomaticallyreturned.
3.4] ParameterspassingParameterscanbepassedbyvalueorbyreference(usingthe&characterafterthetypeandbeforethenameoftheparameter).
forparameterspassedbyreference,changesmadetotheirvalueinsidethefunctionaremaintainedoutsidethefunction(asinstandardC).
Example
EXEXvoidTest(long&a){a++;};
longk=5;Test(k);//kwillbe6
3.5] ParameterssavingItispossibletodefinevariablesthatmaintaintheirvalueevenafterpoweringoffthecontroller.Youcanusethepersistentkeywordtodeclare that thevariablevalue isstored innon-volatilememory(EEPROM).Thestorageprocessismanagedautomaticallyandyoucanusethevariableasanormalvariableinsidethecode.Notethatthereadandwritetimecanchangeaccordingtothehardwareusedandthattheaccesstimecanbelongerthananormalvariable.
TheInitParamsmethodoftheTStdParamsclassinitializeparametersusingtheirdefaultvalues:
Example
EXEXstructTParams:publicTStdParams{
wordNodeID=1;//defaultvalueis1byteRemote485;};
persistentTParamsParams;...//itloadsdefaultparameters,ifnecessaryif(Params.InitParams()<0){//defaultparametersarerestored//addherefurtherinitializations};
...//parametersusageCom1.NodeID=Params.NodeID;
Note
EverytimeyoumodifytheTParamsstructure(foraddingordeletinganewvariabledeclaration),thedefaultvaluesarere-loaded.
RS8FA102� © Danfoss A/S (DE-BDP), November 2007
3.6] ConditionalcompilingThefollowingdirectivesforconditionalcompilingaresupported,asinstandardC:
#define#undef#ifdef#else#endif#include
Thedefinedirectivewithparametersisnotsupported.
3.7] ControlstructuresThefollowingcontrolsstructuresoftheprogramflowaresupported,asinstandardC:
if,elsewhilefor
Thefollowingconstructs/commands/declarationsarenotsupported.
switch,caseenumdo/while?operatorpointers(ofanytype)Parameterscanbepassedtofunctionsbyreference(see3.4Parameterspassing).
declarationofvoidparameters
»»»»»»
»»»
»»»»»»
Example
EXEX//NOTsupported:
voidtest(void){
...
}
//supported:
voidtest(){
...
}
RS8FA10210 © Danfoss A/S (DE-BDP), November 2007
3.8] BasicdatatypesThesupportedbasicdatatypesarethefollowing:
voidsignedcharunsignedchar(byte)signedshortunsignedshort(word)signedintunsignedint(word)signedlong
Moreoverthefollowingtypesaresupported:
StringObject
Stringsofcharacters,normallydeclaredasarraysofcharacters instandardC,mustbedeclaredbeingofStringtype.AllthesetypessupportnormaloperationsallowedinstandardC,asaddition,division,modulo,multiplication,AND,OR,exclusiveORandbitshift:
OPERATOR OPERATION
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
=Assignation(N.B.unlikestandardC,itdoesn’treturnanyvalue)
! BitwiseAND
& BitwiseOR
| BitwiseExclusiveOR
^ LogicalNOT
&& LogicalAND
|| LogicalOR
<< Leftshift
< Lessthan
> Greaterthan
<= Lessthanorequalto
>= Greaterthanorequalto
== Equalto
!= Notequalto
++ Pre/postincrement
-- Pre/postdecrement
»»»»»»»»»
»»
ForallthefunctionssupportedbytheStringtyperefertothelibrarydocumentation-4.2]Stringmanipulation.
Note
Tab1_[Basicdatatypes]
4] FunctionlibraryHere’salistofthemainfunctionsavailableinthestandardlibrariesMCXLibandDisplayLibprovidedwiththedevelopmentsystem.Thesearethefunctionsyouneedtoknowtowriteyourownapplicationsoftware.Their detailed description is inside the “Index.html” file, provided with the develoment system in“bin\NVMTools\doc”.
It’simportanttorememberthatnotallthefunctionsaresupportedbyallthedevicesand,iftheyare,theycanhavesomelimitationaccordingtothehardwarefeaturesofthedevice.Forexamplethenumberofanaloginputsorthecapabilitytochangetheirtype(NTC,4-20mA,…)throughsoftwaredependsonthedevicecharacteristics.
Theavailablefunctionsandfieldsaredescribedbytheirname,whichiscasesensitive.
Functionsthatdonotspecifyareturnparameter(indicatedbeforethefunctionnameasinstandardC)donotreturnanyvalue.
RS8FA10211 © Danfoss A/S (DE-BDP), November 2007
Parameterswithoutanyspecifieddata typeandstartingwith the i lowercase letterareof long type (e.g.iIndex).
Limitsforthedatatypesareasfollow:
TYPE MINIMUM MAXIMUM
char -127 +127
short -32767 +32767
long -2147483647 +2147483647
byte 0 254
word 0 65534
Tab2_[Functionlibrary]
Note
Iftheparameterhasmorerestrictivelimitsitwillbeexplicitlyindicatedinthefunctiondescription.
4.1] Input/OutputTheIOobjectallowsyoutohaveaccesstoallthefunctionsrelatedtotheinputandoutputoftheprogrammablecontroller.Theyallowtosettheinputandoutputtype,toreadaninputandwriteanoutput.
IO.Init()InitializestheIOobject.
longIO.GetAI(iIndex)ReadsthevalueoftheiIndexanaloginput(from1tothenumberofanaloginputsofthecontroller),eventuallyconvertedinto°C,ifitisaNTCorPT1000input,orin0-1000percentageifitisa0-1V,0-10V,0-5V,4-20mA,0-20mAinput.
Belowtableliststhevaluesreturnedbytheinputmanagementfunctionsaccordingtotheinputtypes.
BeforeusinganinputitisnecessarytosetitstypewiththeIO.SetAIType()function.
ANALOGUEINPUTTYPEUSEDWITHIO.SETAITYPE()
VALUERETURNEDBYIO.GETAI() EXAMPLE
ioTypeNTC 1/10°C Ifthereadtemperatureis12.5°C,thereturnedvalueis125
ioTypePT1000 1/10°C Ifthereadtemperatureis12.5°C,thereturnedvalueis125
ioType0_20mA ‰ Ifthereadcurrentis5mA,thereturnedvalueis250(25.0%)
ioType4_20mA ‰ Ifthereadcurrentis5mA,thereturnedvalueis63(6.3%)
ioType0_1V ‰ Ifthereadvoltageis0.5V,thereturnedvalueis500(50.0%)
ioType0_5V ‰ Ifthereadvoltageis0.5V,thereturnedvalueis100(10.0%)
ioType0_10V ‰ Ifthereadvoltageis0.5V,thereturnedvalueis50(5.0%)
ioTypeDIGIN 0,1Ifthecontactisclosed,thereturnedvalueis0.Otherwiseitreturnsavaluedifferentfrom0(N.B.itcouldbedifferentfrom1)
longIO.GetFilteredAI()SimilartoIO.GetAI(),butreturnvalueisfilteredaccordingtoIO.AIFiltersettings.TochangethefilteractionuseIO.SetAIFilter(longiFilter):iFiltercanbe1=nofilter(fastresponse),16=default,50=veryslow.
Tab3_[InputOutput]
Example
EXEXIO.SetFilter(16); //setdefaultfilter
val=IO.GetFilteredAI(1)//getvaluefromanaloginput1
//Youcancheckprobeserrorusingyourprobevaluelimits.
if(val<-300||val>800)
//error:ntcprobevaluelowerthan-30.0°orhigherthan+80.0°
RS8FA10212 © Danfoss A/S (DE-BDP), November 2007
longIO.GetRawAI(iIndex)
Reads thenonconvertedvalueof the iIndexanalog input (from1 to thenumberofanalog inputsof thecontroller).IftheinputisconfiguredtobeNTCorPT1000,thereturnedvalueistheresistance(Ohm)readattheinput.
ANALOGUEINPUTTYPEUSEDWITHIO.SETAITYPE()
VALUERETURNEDBYIO.GETRAWAI() EXAMPLE
ioTypeNTC Ω Ifthereadresistanceis10kΩ,thereturnedvalueis10000
ioTypePT1000 Ω Ifthereadresistanceis10kΩ,thereturnedvalueis10000
ioType0_20mA μA Ifthereadcurrentis5mA,thereturnedvalueis5000
ioType4_20mA μA Ifthereadcurrentis5mA,thereturnedvalueis5000
ioType0_1V mV Ifthereadvoltageis0.5V,thereturnedvalueis500
ioType0_5V mV Ifthereadvoltageis0.5V,thereturnedvalueis500
ioType0_10V mV Ifthereadvoltageis0.5V,thereturnedvalueis500
ioTypeDIGIN 0,1Ifthecontactisclosed,thereturnedvalueis0.Otherwiseitreturnsavaluedifferentfrom0(N.B.itcouldbedifferentfrom1)
longIO.GetDI(iIndex)ReadsthevalueoftheiIndexdigitalinput(from1tothenumberofdigitalinputsofthecontroller).Returns0or1.
longIO.GetDO(iIndex)ReadsthevalueoftheiIndexdigitaloutput(from1tothenumberofdigitaloutputsofthecontroller).Returns0or1.
longIO.SetDO(iIndex,iValue)SetsthevalueoftheiIndexdigitaloutput(from1tothenumberofdigitaloutputsofthecontroller).Theoutputisde-energizedIfiValueis0,theoutputisde-energized.Otherwisetheoutputisenergized.
longIO.SetAIType(iIndex,ioType,iParam)SetsthevalueoftheiIndexanaloginput(from1tothenumberofanaloginputsofthecontroller).iParamisnotused.
SupportedtypesarelistedintheIO.GetAI()types.
longIO.SetAO(iIndex,iValue)SetsthevalueoftheiIndexanalogoutput(from1tothenumberofanalogoutputsofthecontroller).
Thevaluedependsontheoutputtype(setwithIO.SetAOType),anditisusuallyaproportionalvaluerangingfrom0to1000,correspondingtothe0.0%to100.0%outputvalues.
longIO.SetAOType(iIndex,ioType,iParam,iAdv)SetsthevalueoftheiIndexanalogoutput(from1tothenumberofanalogoutputsofthecontroller).
SupportedtypesarethesameasthoseusedbyIO.SetAITypeandthefollowing:
ioTypePPMioTypePWMioTypeFREQ
iParam,iValue(valuesettotheoutputwithIO.SetAO)andiAdvvalueshavethefollowingmeaning.
»»»
Tab4_[longIO.GetRawAI]
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
PPM
iParam iValue iAdv
It’stheONtimeoftheoutputaftertheimpulse.
From0to1000(0.0-100.0%).
Itshouldbesettoavaluegreaterthanthephasegapbetweenvoltageandcurrent.
Impulseanticipationfromzero-crossing.From0to1000(0.0-100.0%).
-iValue=0oriValue<iParamtheoutputstaysat0.
-iValue=500theoutputissetto1inthemiddleofthehalfwave.
-iValue=1000theoutputissetto1atthebeginningofthehalfway.Ineverycasetheoutputissetto0afterthemaximumtimesettledwithiParam.
Notused
PWMsynchronous
iParam iValue iAdv
iParam=0togetaPWMoutputsynchronouswiththefrequencyofthelinevoltage.
DutyCycle,thatisthepercentagebetweenthetimewithoutputat1andtheperiod.From0to1000(0.0-100.0%).
-iValue=0theoutputstaysalwaysat0.
-iValue=500theoutputstaysat0forhalfoftheperiodandat1fortheotherhalf.
iValue=1000theoutputstaysalwaysat1.
From0to1000(0.0-100.0%).
TheONPWMimpulseisinterruptedbeforezerocrossingaccordingtotheiAdvvalue.
Ittakescareofthephaseanticipationofcurrentagainstvoltagethattypicallyhappensonfans.
iValue (e.g. 70%)0
1
PWM
time
iParam
iValue (e.g. 70%)
0
1
Vac
iAdv
PWMsyncronous
zero crossing
time
NOTE.Minimum iValue = iAdvEffective duty cycle = iValue – iAdv iParam = 0
iValue (e.g. 70%)
iParam0
1
VacPPM
zero crossing
time
iValue (e.g. 70%)0
1
PWM
time
iParam
iValue (e.g. 70%)
0
1
Vac
iAdv
PWMsyncronous
zero crossing
time
NOTE.Minimum iValue = iAdvEffective duty cycle = iValue – iAdv iParam = 0
iValue (e.g. 70%)
iParam0
1
VacPPM
zero crossing
time
Fig8_[Analogoutput]PPM
Tab5_[PPM]
Tab6_[PWMsynchronous]
Fig9_[AnalogoutputPWMsynchronous]
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
PWM
iParam iValue iAdv
Itistheperiodtotallength,inHertz(iParam=2000isequaltoaperiodof500microseconds).
NOTE.Theavailablerangedependsonthehardwareused.
DutyCycle,thatisthepercentagebetweenthetimewithoutputat1andtheperiod.From0to1000(0.0-100.0%).
-iValue=0theoutputstaysalwaysat0.
-iValue=500theoutputstaysat0forhalfoftheperiodandat1fortheotherhalf.
iValue=1000theoutputstaysalwaysat1.
Notused
FREQ
iParam iValue iAdv
Notused OutputfrequencyinHertz(0tode-activate).
NOTE.Theavailablerangedependsontheusedhardwareasfollows:
-MCX06:100÷500Hz
-MCX08,MCX15,MCX20:20÷1000Hz
Notused
iValue (e.g. 70%)0
1
PWM
time
iParam
iValue (e.g. 70%)
0
1
Vac
iAdv
PWMsyncronous
zero crossing
time
NOTE.Minimum iValue = iAdvEffective duty cycle = iValue – iAdv iParam = 0
iValue (e.g. 70%)
iParam0
1
VacPPM
zero crossing
time
Tab7_[PWM]
Fig10_[AnalogoutputPWM]
Tab8_[FREQ]
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
4.2] StringmanipulationlongisEmpty()Returns0ifthestringisnotempty;differentfrom0otherwise.
operator[iIndex]
ReturnsthecharacteratiIndexposition(theindexstartsfrom0).
Example
EXEXStrings=“test”;
if(s[0]==“t”) //true
DoSomething;
operator=Assignsanewvaluetothestring.UnlikeinstandardC,thenewvalueiscopiedintotheoriginalstring,loosingthepreviouscontent.
AddFormatNum(iNum,iPad)
Appends the iNum number, converted into text, to the string. The number is right aligned on iPadcharacters.
longToInt()Convertsthestringtoanumber.
Example
EXEXx=“125”;
n=x.ToInt();
n==125
longAddSubStr(String&cSource,iStart,iLen)AddstothestringtheportionofcSource,startingfromiStartandiLencharacterslong.
operator+=(String&cSource)AddsthecSourcestringtothestring.
Example
EXEXx=“adding”;
x+=“test”;
x==“addingtest”
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
4.3] RS485CommunicationThe Com1 object allows you to access the RS485 serial port functions for setting the speed and othercommunicationparameters,forreadingandwritingcharactersandtextlines.
Com1.Init(iSpeed,iFlags)InitializesthecommunicationtotheiSpeedspeed(inbaud,e.g.9600,19200,…).
iFlagsissettocomSerFlag_8N1,anditsetsthecommunicationto8bitdata,noparity,1stopbit.
longCom1.CheckAndClearEvent(iEvent)Verifiesifacertaineventhasbeenactivatedontheserialline.
PossibleeventsintheiEventparameterare:
comEvRxChar:acharacterhasbeenreceivedcomEvRxLine:atextlineendedwithCR(+LF)hasbeenreceivedcomEvError:communicationerrorshavebeendetected
Com1.WriteStr(String&line)Sendsastringofcharactersovertheserialline.
Com1.WriteB(object&buff,longiSize)Sendsasequenceofbytesovertheserialline.
Com1.ReadLN(String&line)Readsarawofcharactersfromtheseriallineandsavesitinline,erasingitfromthereceivebuffer.
Com1.ClearBuffer()Clearsthereceiveandtransmitbuffers.
charCom1.RxQueue[iIndex]ReturnsthecharacterintheiIndexpositionofthereceivebuffer.Thefirstcharacterisat0position.
longCom1.RxQueue.LenReturnsthenumberofbytesofthereceivebuffer.
longCom1.RxQueue.MaxLenReturnsthemaximumcapacityoftheserialreceivebuffer.
longCom1.TxQueue.LenReturnsthenumberofbytesofthetransmitbufferwaitingtobesent.
longCom1.TxQueue.MaxLenReturnsthemaximumcapacityoftheserialtransmitbuffer.
longCom1.SetSuspend(iSuspend)Suspends(iSuspend=1)orre-establishes(iSuspend=0)sendingcharactersovertheserialline.
Modbuscommunication
shortCom1.IdentIdentificationnumberoftheModbusunit.
Messagesareacceptedonlyiftheyarrivewiththeiridentequaltothisorto0.
Thedefaultvalueis1;validvaluesrangesfrom0to127.
longCom1.TimeoutTimeoutinmillisecondsfromthereceptionofthelastcharacter.Whenthetimeoutiselapsed,thebufferisclearedandanewModbuspacketisexpected.
Thedefaultvalueis100ms.
Com1.Run()ManagestheModbusinputrequests.
Requestsforeachvariablearecomparedwithvariablesdeclaredinmodbusdecland,iftheycorrespond,ananswerisprovided.
modbusdecl(ModbusTable,RWflag,iModbusAddress,&iVariable)DeclaresanassociationbetweentheiVariablevariableandtheiModbusAddressaddress.
RWflagindicatesifthevariableisaread-onlyvariable(modbusR)oraread-and-writevariable(modbusRW).
AssociationsareheldintheModbusTabletable.
»»»
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
4.4] CANbuscommunicationTheCanobjectallowsyoutoaccessthecommunicationfunctionsoverCANbusforsendingmessagesandreceivingvariablesfromotherdevices.
exportvar(ExportTable,RWflag,iIndex,iSubIndex,&iVariable)DeclaresanassociationbetweentheiVariablevariableandtheiIndexandiSubIndexCANbusaddress.
RWflagindicatesifthevariableisaread-onlyvariable(co_canR)oraread-and-writevariable(co_canRW).
Can.NodeIDIdentificationnumberoftheCANbusunit(node).Validvaluesrangesfrom1to127.
Aftersettingthenode,youhavetore-initializecommunicationthroughthefollowingcommand:
Can.Init(Can.CurrSpeed(),0);
Can.SendMessage(shortiTarget,wordiIndex,byteiSubIndex,longiValue)SendstheiValuevaluetothevariablehavingiIndexindexandiSubIndexsub-indexoftheiTargetnode.
Can.RequestVar(shortiTarget,wordiIndex,byteiSubIndex,long&Dest)RequeststheiTargetnodeforthevalueofthevariablehavingiIndexindexandiSubIndexsub-index.ThevalueisstoredintotheDestvariablewhichmustbeglobal(itcan’tbeavariabledeclaredinsideafunction).
4.5] TimermanagementTTimertimer;Declaresatimer.
.Start()Startsatimer.
.Elapsedms()Returnsthenumberofmillisecondselapsedsincethetimerhasbeenstarted(withStart).Theresultrangesfrom0to20days.
.ElapsedSec()Returnsthenumberofsecondselapsedsincethetimerhasbeenstarted(withStart).Theresultrangesfrom0to60years.
Sleep(iMillisec)WaitsforiMillisecmillisecondsbeforestartingagaintheapplication.Inthisexampleatimer(toggle_timer)isusedtotoggleevery500msthefirstrelay.
Example
EXEXTTimertoggle_timer;
//...
//starttimer
toggle_timer.Start();
//...
//checkelapsedtime
if(toggle_timer.Elapsedms()>500){
//timeiselapsed
toggle_timer.Start(); //restarttimer
IO.SetDO(1,!IO.GetDO(1)); //togglerelay1
};
…
Note
Atimertoworkdoesn’tneedarealtimeclock(RTC)ontheMCXcontroller.
Example
EXEX//exportvariableontheCANnetworklongMyVar;...exportvar(ExportTable,co_canRW,0x2000,0x00,MyVar);...
//readvariablefromanotherdevicelongReceiveBuffer;//requestvariablewithindex0x2000,andsubindex0x00,fromdevicewithid1.ThenplacetheanswerintovariableReceiveBuffer.Can.RequestVar(1,0x2000,0x00,ReceiveBuffer);
RS8FA10218 © Danfoss A/S (DE-BDP), November 2007
4.6] ApplicationandcontrolleridentificationEachMCXcontroller isprovidedwith informationabout itself thatcanbereadby theapplication throughappropriatefunctions.
TSysDeviceInfodevinfo;Declaresavariablecontainingthefollowinginformation:
TYPE FIELDNAME DESCRIPTION USAGE
long ProductCode ProductCodeItcanbeusedtoautomaticallyconfiguretheapplicationaccordingtothehardwarewhereit’srunningon.
long SerialNumber SerialNumberofthedevice
Itisunivocallyassignedatproductiontimeforeachproductcode.
Theserialnumbertogetherwiththeproductcodeunivocallyidentifythecontroller.
long BiosDate BIOSDate(seconds)
ItisnormallyusedtoverifythattheBIOSisupdatedwhentheapplicationisstartedup.
word VendorID VendorID ItisunivocallyassignedbyfactoryonrequestanditiscontainedintheVendorID.datfile.
word AppID ApplicationCode
Itisdefinedinthesourcecodethroughthedefinestatement:
#definenvmcc_ApplicationID<AppID>.
ThevendorIDtogetherwiththeapplicationcodeunivocallyidentifytheapplication.Itcanbeusefulwhenyouhavetolookforthatapplicationinsideanetworkofconnectedcontrollers.
long AppDate ApplicationDate(seconds)
Dateofcompilationoftheapplication.Canbeusedtodisplayapplicationversionondisplay.
devinfo.GetInfo();Loadstheinformationaboutthecontrollerandtheapplicationintothedevinfovariable.
Tab9_[Applicationandcontrolleridentification]Example
EXEXTSysDeviceInfodevinfo;
devinfo.GetInfo();
if(devinfo.BiosDate<DateSerial(2005,11,8))
Com1.WriteStr(“Invalidbios!”);
DisplayDeviceInfoOnCom(TCom&Com1)Showstheinformationaboutthecontrollerandtheapplicationontheserialportindicatedasaparameter.
It’sadvisabletogivethiscommandatthebeginningoftheapplication(iftheserialcanbeusedinthisphase).Thisallowstovisualizeallthemaininformationabouttheapplication.
Example
EXEXDisplayDeviceInfoOnCom(Com1);
TSysDeviceInfodevinfo;TDateTimedt;//getsysteminformationdevinfo.GetInfo();//explodeapplicationdateintodatecomponentsdt.SetTime(devinfo.AppDate);dt.Explode();//showapplicationyeardsp.DrawValueCR(0,0,”App.Year:”,dt.Year,4);
RS8FA1021� © Danfoss A/S (DE-BDP), November 2007
Returnsthepressedkey,eventuallyreadfromthekeyboardqueue.
Keyrepetitionishandled.Ateachcyclethevariablestatesifthekeyispressed,onthebasisoftherepetitionrules.Thusifthekeyiskeptpressed,thefirstcalltoGetKey()returnsthekeycodeinkbd.Key.AfterfurthercallstoGetKey(),thekbd.Keywillbeequaltozerountiltherepetitiontimehaselapsed;thenitwillindicateagainthepressedkeyandthenagainzerountilthenextrepetition.Onthecontrary,inkbd.ActiveKeyyouwillalwaysfindthecodeofthepressedkey.
4.7] SysteminformationlongSys.MaxStackSizeHolds themaximumsizeof thestack in the lastexecutionof theapplication. It isused to verify the realmemoryrequirementsofyourapplication.
4.8] Userinterfacevoidkbd.GetKey()Readsthekeyboardstatus(itdetectwhichkeysarebeingpressed).
kbd.ActiveKeyReturnsthekeysthatarepressedwhentheGetKey()iscalled.Thesupportedkeysare:
KEY_OKKEY_ENTER(comeKEY_OK)KEY_ESCKEY_UPKEY_DOWNKEY_LEFTKEY_RIGHT
and can be added to obtain the combination of the keys simultaneously pressed (e.g.KEY_UP+KEY_DOWN).
kbd.ActiveTimeTime(ms)sincethecurrentkeycombination(ActiveKey)becameactiveandremainunchanged.
kbd.Key
»»»»»»»
Example
EXEXkbd.GetKey();
…
if((kbd.ActiveKey==KEY_OK+KEY_UP)&&(kbd.ActiveTime>=1000)){
//codetobeexecutedwhentheOKandUPkeysarepressedtogetherformorethan1second
}
//itincrementsordecrementsthevalvariableonthebasisofthepressingoftheUPandDOWNkeys
//keepingthekeyspressed,theincrementordecrementspeedwillincreaseprogressively
if(kbd.Key==KEY_DOWN)
val--;
elseif(kbd.Key==KEY_UP)
val++;
RS8FA10220 © Danfoss A/S (DE-BDP), November 2007
5] HowtocreateyourownlibraryTocreatethe“mylib.lib”library,writethemylib.csourcefile.
Thencreateamainfileincludingthelibrarywith.libextension:
#include“mylib.lib”
...
Whenthecompilerfindsthecorresponding(.c)fileforthatlibraryinthesamefolderofthemainfile,itmakesarebuild(ifnecessary)ofthesourcefileandcreatethenewlibrary.
Aftercompilingyouwillgetthemylib.libfileinthesamefolderofthemylib.cfile.Youcannowtakeawaythemylib.cfile.
voiddsp.ClearDisplay()Clearsthedisplay.
voiddsp.DrawLineXY(shortx1,shorty1,shortx2,shorty2)Drawsalinefromx1,y1tox2,y2.Coordinatesareinpixel.
voiddsp.DrawRect(shortx,shorty,shortw,shorth)Drawsarectanglehavingx,yorigin,widthwandheighth.
voiddsp.UpdateDisplay()Updates the display with the implemented changes. In most of the devices, changes to the display areperformedonatemporarybufferandthiscommandisnecessarytoupdatethedisplay.Thisisforavoidingvisualizationinconvenienceswhileyouaredrawinganewscreen.
voiddsp.DrawTextCR(shortiCol,shortiRow,String&cText)DrawsthetextstringcTextatiColcolumnandiRowraw.
voiddsp.DrawImage(shortx,shorty,longiImageID)Draws the indicated image starting from x,y coordinates. The images that are now supported are thefollowing:
imgALARM
imgSERVICE
imgCOMPR
imgICE
imgSUN
imgDEF
imgHEATER
imgFAN
imgPUMP
Tab10_[Images]
RS8FA10221 © Danfoss A/S (DE-BDP), November 2007
_FIGURESINDEXFig1_ [Generaloverview] 3Fig2_ [Functionslibrariesandapplicationsoftware] 3Fig3_ [Functionslibrariesandapplicationsoftware] 3Fig4_ [Compiler] 4Fig5_ [Simulator] 5Fig6_ [Programcompiling] 6Fig7_ [Programuploading] 7Fig8_ [Analogoutput]PPM 13Fig9_ [AnalogoutputPWMsynchronous] 13Fig10_ [AnalogoutputPWM] 14
_TABLESINDEXTab1_ [Basicdatatypes] 10Tab2_ [Functionlibrary] 11Tab3_ [InputOutput] 11Tab4_ [longIO.GetRawAI] 12Tab5_ [PPM] 13Tab6_ [PWMsynchronous] 13Tab7_ [PWM] 14Tab8_ [FREQ] 14Tab9_ [Applicationandcontrolleridentification] 18Tab10_ [Images] 20
Note
Preliminary23.08.07versione1.2
Danfoss can accept no responsibility for possible errors in catalogues, brochures and other printed material. Danfoss reserves the right to alter its products without notice. This also applies to products already on order provided that such alternations can be made without subsequential changes being necessary in specifications already agreed.All trademarks in this material are property of the respecitve companies. Danfoss and Danfoss logotype are trademarks of Danfoss A/S. All rights reserved.
RS8FA102 © Danfoss A/S (DE-BDP), November 2007
The Danfoss product range for therefrigeration and air conditioning industryDanfoss Refrigeration & Air Conditioning is
a worldwide manufacturer with a leading
position in industrial, commercial and
supermarket refrigeration as well as air
conditioning and climate solutions.
We focus on our core business of making
quality products, components and systems
that enhance performance and reduce
total life cycle costs – the key to major
savings.
We are offering a single source for one of the widest ranges of innovative refrigeration
and air conditioning components and systems in the world. And, we back technical
solutions with business solution to help your company reduce costs,
streamline processes and achieve your business goals.
Danfoss A/S • www.danfoss.com
Controls for Commercial Refrigeration
Controls forIndustrial Refrigeration
Industrial Automation Household Compressors Commercial Compressors
ThermostatsSub-Assemblies
Electronic Controls & Sensors
Brazed plate heat exchanger
top related