Model { Name "bike" Version 6.3 MdlSubVersion 0 GraphicalInterface { NumRootInports 0 NumRootOutports 0 ParameterArgumentNames "" ComputedModelVersion "1.118" NumModelReferences 0 NumTestPointedSignals 0 } SavedCharacterEncoding "windows-1252" SaveDefaultBlockParams on SampleTimeColors on LibraryLinkDisplay "none" WideLines off ShowLineDimensions off ShowPortDataTypes off ShowLoopsOnError on IgnoreBidirectionalLines off ShowStorageClass off ShowTestPointIcons on ShowViewerIcons on SortedOrder off ExecutionContextIcon off ShowLinearizationAnnotations on RecordCoverage off CovPath "/" CovSaveName "covdata" CovMetricSettings "dw" CovNameIncrementing off CovHtmlReporting on covSaveCumulativeToWorkspaceVar on CovSaveSingleToWorkspaceVar on CovCumulativeVarName "covCumulativeData" CovCumulativeReport off CovReportOnPause on ScopeRefreshTime 0.035000 OverrideScopeRefreshTime on DisableAllScopes off DataTypeOverride "UseLocalSettings" MinMaxOverflowLogging "UseLocalSettings" MinMaxOverflowArchiveMode "Overwrite" BlockNameDataTip off BlockParametersDataTip off BlockDescriptionStringDataTip off ToolBar on StatusBar on BrowserShowLibraryLinks off BrowserLookUnderMasks off Created "Mon Feb 27 13:59:19 2006" UpdateHistory "UpdateHistoryNever" ModifiedByFormat "%" LastModifiedBy "LAB USER" ModifiedDateFormat "%" LastModifiedDate "Tue Mar 07 19:44:45 2006" ModelVersionFormat "1.%" ConfigurationManager "None" LinearizationMsg "none" Profile off ParamWorkspaceSource "MATLABWorkspace" AccelSystemTargetFile "accel.tlc" AccelTemplateMakefile "accel_default_tmf" AccelMakeCommand "make_rtw" TryForcingSFcnDF off ExtModeBatchMode off ExtModeEnableFloating on ExtModeTrigType "manual" ExtModeTrigMode "normal" ExtModeTrigPort "1" ExtModeTrigElement "any" ExtModeTrigDuration 1000 ExtModeTrigDurationFloating "auto" ExtModeTrigHoldOff 0 ExtModeTrigDelay 0 ExtModeTrigDirection "rising" ExtModeTrigLevel 0 ExtModeArchiveMode "off" ExtModeAutoIncOneShot off ExtModeIncDirWhenArm off ExtModeAddSuffixToVar off ExtModeWriteAllDataToWs off ExtModeArmWhenConnect on ExtModeSkipDownloadWhenConnect off ExtModeLogAll on ExtModeAutoUpdateStatusClock on BufferReuse off StrictBusMsg "Warning" ProdHWDeviceType "32-bit Generic" ShowModelReferenceBlockVersion off ShowModelReferenceBlockIO off Array { Type "Handle" Dimension 1 Simulink.ConfigSet { $ObjectID 1 Version "1.1.0" Array { Type "Handle" Dimension 7 Simulink.SolverCC { $ObjectID 2 Version "1.1.0" StartTime "0.0" StopTime "180" AbsTol "auto" FixedStep "auto" InitialStep "auto" MaxNumMinSteps "-1" MaxOrder 5 ExtrapolationOrder 4 NumberNewtonIterations 1 MaxStep "auto" MinStep "auto" RelTol "1e-3" SolverMode "Auto" Solver "FixedStepDiscrete" SolverName "FixedStepDiscrete" ZeroCrossControl "UseLocalSettings" AlgebraicLoopSolver "TrustRegion" SolverResetMethod "Fast" PositivePriorityOrder off AutoInsertRateTranBlk off SampleTimeConstraint "Unconstrained" RateTranMode "Deterministic" } Simulink.DataIOCC { $ObjectID 3 Version "1.1.0" Decimation "1" ExternalInput "[t, u]" FinalStateName "xFinal" InitialState "xInitial" LimitDataPoints on MaxDataPoints "010000" LoadExternalInput off LoadInitialState off SaveFinalState off SaveFormat "Array" SaveOutput on SaveState off SignalLogging on InspectSignalLogs off SaveTime on StateSaveName "xout" TimeSaveName "tout" OutputSaveName "yout" SignalLoggingName "logsout" OutputOption "RefineOutputTimes" OutputTimes "[]" Refine "1" } Simulink.OptimizationCC { $ObjectID 4 Array { Type "Cell" Dimension 5 Cell "ZeroExternalMemoryAtStartup" Cell "ZeroInternalMemoryAtStartup" Cell "InitFltsAndDblsToZero" Cell "OptimizeModelRefInitCode" Cell "NoFixptDivByZeroProtection" PropName "DisabledProps" } Version "1.1.0" BlockReduction off BooleanDataType on ConditionallyExecuteInputs on InlineParams off InlineInvariantSignals off OptimizeBlockIOStorage off BufferReuse off EnforceIntegerDowncast on ExpressionFolding off FoldNonRolledExpr on LocalBlockOutputs off ParameterPooling on RollThreshold 5 SystemCodeInlineAuto off StateBitsets off DataBitsets off UseTempVars off ZeroExternalMemoryAtStartup on ZeroInternalMemoryAtStartup on InitFltsAndDblsToZero on NoFixptDivByZeroProtection off EfficientFloat2IntCast off OptimizeModelRefInitCode off LifeSpan "inf" BufferReusableBoundary on } Simulink.DebuggingCC { $ObjectID 5 Version "1.1.0" RTPrefix "error" ConsistencyChecking "none" ArrayBoundsChecking "none" SignalInfNanChecking "none" ReadBeforeWriteMsg "UseLocalSettings" WriteAfterWriteMsg "UseLocalSettings" WriteAfterReadMsg "UseLocalSettings" AlgebraicLoopMsg "warning" ArtificialAlgebraicLoopMsg "warning" CheckSSInitialOutputMsg on CheckExecutionContextPreStartOutputMsg off CheckExecutionContextRuntimeOutputMsg off SignalResolutionControl "TryResolveAllWithWarning" BlockPriorityViolationMsg "warning" MinStepSizeMsg "warning" SolverPrmCheckMsg "warning" InheritedTsInSrcMsg "warning" DiscreteInheritContinuousMsg "warning" MultiTaskDSMMsg "warning" MultiTaskRateTransMsg "error" SingleTaskRateTransMsg "none" TasksWithSamePriorityMsg "warning" SigSpecEnsureSampleTimeMsg "warning" CheckMatrixSingularityMsg "none" IntegerOverflowMsg "warning" Int32ToFloatConvMsg "warning" ParameterDowncastMsg "error" ParameterOverflowMsg "error" ParameterUnderflowMsg "none" ParameterPrecisionLossMsg "warning" UnderSpecifiedDataTypeMsg "none" UnnecessaryDatatypeConvMsg "none" VectorMatrixConversionMsg "none" InvalidFcnCallConnMsg "error" FcnCallInpInsideContextMsg "Use local settings" SignalLabelMismatchMsg "none" UnconnectedInputMsg "warning" UnconnectedOutputMsg "warning" UnconnectedLineMsg "warning" SFcnCompatibilityMsg "none" UniqueDataStoreMsg "none" BusObjectLabelMismatch "warning" RootOutportRequireBusObject "warning" AssertControl "UseLocalSettings" EnableOverflowDetection off ModelReferenceIOMsg "none" ModelReferenceVersionMismatchMessage "none" ModelReferenceIOMismatchMessage "none" ModelReferenceCSMismatchMessage "none" ModelReferenceSimTargetVerbose off UnknownTsInhSupMsg "warning" ModelReferenceDataLoggingMessage "warning" ModelReferenceSymbolNameMessage "warning" ModelReferenceExtraNoncontSigs "error" } Simulink.HardwareCC { $ObjectID 6 Version "1.1.0" ProdBitPerChar 8 ProdBitPerShort 16 ProdBitPerInt 32 ProdBitPerLong 32 ProdIntDivRoundTo "Undefined" ProdEndianess "Unspecified" ProdWordSize 32 ProdShiftRightIntArith on ProdHWDeviceType "32-bit Generic" TargetBitPerChar 8 TargetBitPerShort 16 TargetBitPerInt 32 TargetBitPerLong 32 TargetShiftRightIntArith on TargetIntDivRoundTo "Undefined" TargetEndianess "Unspecified" TargetWordSize 32 TargetTypeEmulationWarnSuppressLevel 0 TargetPreprocMaxBitsSint 32 TargetPreprocMaxBitsUint 32 TargetHWDeviceType "Specified" TargetUnknown off ProdEqTarget on } Simulink.ModelReferenceCC { $ObjectID 7 Version "1.1.0" UpdateModelReferenceTargets "IfOutOfDateOrStructuralChange" CheckModelReferenceTargetMessage "error" ModelReferenceNumInstancesAllowed "Multi" ModelReferencePassRootInputsByReference on ModelReferenceMinAlgLoopOccurrences off } Simulink.RTWCC { $BackupClass "Simulink.RTWCC" $ObjectID 8 Array { Type "Cell" Dimension 1 Cell "IncludeHyperlinkInReport" PropName "DisabledProps" } Version "1.1.0" SystemTargetFile "xpctarget.tlc" GenCodeOnly off MakeCommand "make_rtw" TemplateMakefile "xpc_default_tmf" Description "xPC Target" GenerateReport off SaveLog off RTWVerbose on RetainRTWFile off ProfileTLC off TLCDebug off TLCCoverage off TLCAssert off ProcessScriptMode "Default" ConfigurationMode "Optimized" ProcessScript "xpctarget_make_rtw_hook" ConfigAtBuild off IncludeHyperlinkInReport off LaunchReport off TargetLang "C" Array { Type "Handle" Dimension 2 Simulink.CodeAppCC { $ObjectID 9 Array { Type "Cell" Dimension 9 Cell "IgnoreCustomStorageClasses" Cell "InsertBlockDesc" Cell "SFDataObjDesc" Cell "SimulinkDataObjDesc" Cell "DefineNamingRule" Cell "SignalNamingRule" Cell "ParamNamingRule" Cell "InlinedPrmAccess" Cell "CustomSymbolStr" PropName "DisabledProps" } Version "1.1.0" ForceParamTrailComments off GenerateComments on IgnoreCustomStorageClasses on IncHierarchyInIds off MaxIdLength 31 PreserveName off PreserveNameWithParent off ShowEliminatedStatement off IncAutoGenComments off SimulinkDataObjDesc off SFDataObjDesc off IncDataTypeInIds off PrefixModelToSubsysFcnNames on CustomSymbolStr "$R$N$M" MangleLength 1 DefineNamingRule "None" ParamNamingRule "None" SignalNamingRule "None" InsertBlockDesc off SimulinkBlockComments on EnableCustomComments off InlinedPrmAccess "Literals" ReqsInCode off } xpctarget.xpcTargetCC { $BackupClass "Simulink.TargetCC" $ObjectID 10 Array { Type "Cell" Dimension 12 Cell "IncludeMdlTerminateFcn" Cell "CombineOutputUpdateFcns" Cell "SuppressErrorStatus" Cell "ERTCustomFileBanners" Cell "GenerateSampleERTMain" Cell "MultiInstanceERTCode" Cell "PurelyIntegerCode" Cell "SupportNonFinite" Cell "SupportComplex" Cell "SupportAbsoluteTime" Cell "SupportContinuousTime" Cell "SupportNonInlinedSFcns" PropName "DisabledProps" } Version "1.1.0" TargetFcnLib "ansi_tfl_tmw.mat" TargetLibSuffix "" TargetPreCompLibLocation "" GenFloatMathFcnCalls "ANSI_C" UtilityFuncGeneration "Auto" GenerateFullHeader on GenerateSampleERTMain off IsPILTarget off ModelReferenceCompliant on IncludeMdlTerminateFcn on CombineOutputUpdateFcns off SuppressErrorStatus off IncludeFileDelimiter "Auto" ERTCustomFileBanners off SupportAbsoluteTime on LogVarNameModifier "rt_" MatFileLogging on MultiInstanceERTCode off SupportNonFinite on SupportComplex on PurelyIntegerCode off SupportContinuousTime on SupportNonInlinedSFcns on RL32ModeModifier "Real-Time" ExtMode on ExtModeMexFile "ext_xpc" ExtModeArmWhenConnect off RL32LogTETModifier on RL32LogBufSizeModifier "100000" RL32IRQSourceModifier "Timer" xPCIRQSourceBoard "None/Other" xPCIOIRQSlot "-1" xpcDblBuff off xpcObjCom off xPCGenerateASAP2 off RL32ObjectName "tg" xPCisDownloadable on xPCisDefaultEnv on } PropName "Components" } } PropName "Components" } Name "Configuration" SimulationMode "external" CurrentDlgPage "Solver" } PropName "ConfigurationSets" } Simulink.ConfigSet { $PropName "ActiveConfigurationSet" $ObjectID 1 } BlockDefaults { Orientation "right" ForegroundColor "black" BackgroundColor "white" DropShadow off NamePlacement "normal" FontName "arial" FontSize 10 FontWeight "normal" FontAngle "normal" ShowName on } BlockParameterDefaults { Block { BlockType ActionPort InitializeStates "held" ActionType "unset" } Block { BlockType Constant Value "1" VectorParams1D on OutDataTypeMode "Inherit from 'Constant value'" OutDataType "sfix(16)" ConRadixGroup "Use specified scaling" OutScaling "2^0" SampleTime "inf" } Block { BlockType DataStoreMemory ReadBeforeWriteMsg "none" WriteAfterWriteMsg "none" WriteAfterReadMsg "none" StateMustResolveToSignalObject off ShowAdditionalParam off DataType "auto" OutDataType "sfix(16)" OutScaling "2^0" SignalType "auto" } Block { BlockType DataStoreRead } Block { BlockType DataStoreWrite } Block { BlockType DataTypeConversion OutDataTypeMode "Inherit via back propagation" OutDataType "sfix(16)" OutScaling "2^0" LockScale off ConvertRealWorld "Real World Value (RWV)" RndMeth "Zero" SaturateOnIntegerOverflow on SampleTime "-1" } Block { BlockType Demux Outputs "4" DisplayOption "none" BusSelectionMode off } Block { BlockType DigitalClock SampleTime "1" } Block { BlockType Gain Gain "1" Multiplication "Element-wise(K.*u)" ParameterDataTypeMode "Same as input" ParameterDataType "sfix(16)" ParameterScalingMode "Best Precision: Matrix-wise" ParameterScaling "2^0" OutDataTypeMode "Same as input" OutDataType "sfix(16)" OutScaling "2^0" LockScale off RndMeth "Floor" SaturateOnIntegerOverflow on SampleTime "-1" } Block { BlockType Ground } Block { BlockType If NumInputs "1" IfExpression "u1 > 0" ShowElse on ZeroCross on SampleTime "-1" } Block { BlockType Inport Port "1" UseBusObject off BusObject "BusObject" BusOutputAsStruct off PortDimensions "-1" SampleTime "-1" DataType "auto" OutDataType "sfix(16)" OutScaling "2^0" SignalType "auto" SamplingMode "auto" LatchByDelayingOutsideSignal off LatchByCopyingInsideSignal off Interpolate on } Block { BlockType Logic Operator "AND" Inputs "2" AllPortsSameDT on OutDataTypeMode "Logical (see Configuration Parameters: Optimiza" "tion)" LogicDataType "uint(8)" SampleTime "-1" } Block { BlockType Outport Port "1" UseBusObject off BusObject "BusObject" BusOutputAsStruct off PortDimensions "-1" SampleTime "-1" DataType "auto" OutDataType "sfix(16)" OutScaling "2^0" SignalType "auto" SamplingMode "auto" OutputWhenDisabled "held" InitialOutput "[]" } Block { BlockType Product Inputs "2" Multiplication "Element-wise(.*)" InputSameDT on OutDataTypeMode "Same as first input" OutDataType "sfix(16)" OutScaling "2^0" LockScale off RndMeth "Zero" SaturateOnIntegerOverflow on SampleTime "-1" } Block { BlockType RelationalOperator Operator ">=" InputSameDT on LogicOutDataTypeMode "Logical (see Configuration Parameters: Optimiza" "tion)" LogicDataType "uint(8)" ZeroCross on SampleTime "-1" } Block { BlockType "S-Function" FunctionName "system" SFunctionModules "''" PortCounts "[]" } Block { BlockType SubSystem ShowPortLabels on Permissions "ReadWrite" PermitHierarchicalResolution "All" SystemSampleTime "-1" RTWFcnNameOpts "Auto" RTWFileNameOpts "Auto" SimViewingDevice off DataTypeOverride "UseLocalSettings" MinMaxOverflowLogging "UseLocalSettings" } Block { BlockType Sum IconShape "rectangular" Inputs "++" InputSameDT on OutDataTypeMode "Same as first input" OutDataType "sfix(16)" OutScaling "2^0" LockScale off RndMeth "Floor" SaturateOnIntegerOverflow on SampleTime "-1" } Block { BlockType Terminator } Block { BlockType UnitDelay X0 "0" SampleTime "1" StateMustResolveToSignalObject off RTWStateStorageClass "Auto" } } AnnotationDefaults { HorizontalAlignment "center" VerticalAlignment "middle" ForegroundColor "black" BackgroundColor "white" DropShadow off FontName "arial" FontSize 10 FontWeight "normal" FontAngle "normal" } LineDefaults { FontName "arial" FontSize 9 FontWeight "normal" FontAngle "normal" } System { Name "bike" Location [374, 118, 1191, 708] Open on ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" ReportName "simulink-default.rpt" Block { BlockType Reference Name "2. pedal hall sensor\n3. switch" Ports [0, 2] Position [15, 37, 120, 88] SourceBlock "xpcsensoraylib/DI/Sensoray526 DI " SourceType "sensoray526-din" channel "[2 3]" sampletime "dt" baseaddress "0x2c0" } Block { BlockType DataStoreRead Name "Data Store\nRead" Position [205, 450, 235, 480] DataStoreName "dgear" SampleTime "dt" } Block { BlockType DataStoreRead Name "Data Store\nRead1" Position [65, 385, 95, 415] DataStoreName "pgear" SampleTime "dt" } Block { BlockType Gain Name "Gain" Position [335, 445, 365, 475] Gain "10" ParameterDataTypeMode "Inherit via internal rule" OutDataTypeMode "Inherit via internal rule" SaturateOnIntegerOverflow off SampleTime "dt" } Block { BlockType Sum Name "Subtract" Ports [2, 1] Position [280, 442, 310, 473] Inputs "-+" InputSameDT off OutDataTypeMode "Inherit via internal rule" OutScaling "2^-10" SaturateOnIntegerOverflow off } Block { BlockType If Name "decide to shift or not" Ports [5, 3] Position [345, 81, 445, 129] NumInputs "5" IfExpression "u1 > 60 & u2 ~= 6 & u3 > u4 & u5 == 0" ElseIfExpressions "u1 < 40 & u2 ~= 1 & u3 > u4 & u5 ==0" SampleTime "dt" } Block { BlockType Constant Name "delay\nconstant" Position [325, 160, 355, 190] Orientation "left" Value "3/dt" SampleTime "dt" } Block { BlockType Reference Name "delay counter" Ports [1, 1] Position [140, 150, 210, 210] SourceBlock "dspswit3/Counter" SourceType "Counter" Direction "Up" CountEvent "Free running" CounterSize "32 bits" MaxCount "255" InitialCount "0" Output "Count" HitValue "32" ResetInput on SamplesPerFrame "1" Ts "dt" CntDtype "double" HitDtype "Logical" } Block { BlockType DataStoreMemory Name "desired\ngear" Position [20, 500, 52, 530] DataStoreName "dgear" ReadBeforeWriteMsg "warning" WriteAfterWriteMsg "warning" WriteAfterReadMsg "warning" InitialValue "1" RTWStateStorageClass "Auto" VectorParams1D on ShowAdditionalParam off } Block { BlockType SubSystem Name "determine\ncurrent gear" Ports [2, 1] Position [140, 324, 210, 371] TreatAsAtomicUnit off MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off MaskType "Stateflow" MaskDescription "Embedded MATLAB block" MaskDisplay "disp('fcn');" MaskSelfModifiable on MaskIconFrame on MaskIconOpaque off MaskIconRotate "none" MaskIconUnits "autoscale" System { Name "determine\ncurrent gear" Location [257, 457, 812, 717] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "potV" Position [20, 101, 40, 119] IconDisplay "Port number" } Block { BlockType Inport Name "pgear" Position [20, 136, 40, 154] Port "2" IconDisplay "Port number" } Block { BlockType Demux Name " Demux " Ports [1, 1] Position [270, 160, 320, 200] Outputs "1" } Block { BlockType "S-Function" Name " SFunction " Tag "Stateflow S-Function bike 2" Ports [2, 2] Position [180, 100, 230, 160] FunctionName "sf_sfun" PortCounts "[2 2]" Port { PortNumber 2 Name "cgear" RTWStorageClass "Auto" DataLoggingNameMode "SignalName" } } Block { BlockType Terminator Name " Terminator " Position [460, 171, 480, 189] } Block { BlockType Outport Name "cgear" Position [460, 101, 480, 119] IconDisplay "Port number" BusOutputAsStruct off } Line { SrcBlock " SFunction " SrcPort 1 Points [0, 65] DstBlock " Demux " DstPort 1 } Line { SrcBlock " Demux " SrcPort 1 DstBlock " Terminator " DstPort 1 } Line { SrcBlock "potV" SrcPort 1 DstBlock " SFunction " DstPort 1 } Line { Name "cgear" Labels [0, 0] SrcBlock " SFunction " SrcPort 2 DstBlock "cgear" DstPort 1 } Line { SrcBlock "pgear" SrcPort 1 DstBlock " SFunction " DstPort 2 } } } Block { BlockType Reference Name "did shift occur?" Ports [1, 1] Position [55, 165, 115, 195] SourceBlock "simulink/Logic and Bit\nOperations/Detect\nChan" "ge" SourceType "Detect Change" ShowPortLabels on vinit "0" } Block { BlockType Terminator Name "future coasting\ncapability" Position [285, 15, 305, 35] } Block { BlockType SubSystem Name "pedaling" Ports [1, 2] Position [140, 28, 240, 92] TreatAsAtomicUnit off MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off System { Name "pedaling" Location [255, 558, 786, 815] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "Hall effect" Position [15, 53, 45, 67] IconDisplay "Port number" } Block { BlockType Constant Name "Constant" Position [370, 145, 400, 175] Value "60" SampleTime "dt" } Block { BlockType Reference Name "Counter" Ports [2, 1] Position [250, 15, 320, 75] SourceBlock "dspswit3/Counter" SourceType "Counter" Direction "Up" CountEvent "Non-zero sample" CounterSize "32 bits" MaxCount "255" InitialCount "0" Output "Count" HitValue "32" ResetInput on SamplesPerFrame "1" Ts "1" CntDtype "double" HitDtype "Logical" } Block { BlockType DigitalClock Name "Digital Clock" Position [165, 18, 230, 42] SampleTime "dt" } Block { BlockType Product Name "Divide1" Ports [2, 1] Position [440, 152, 470, 183] Inputs "*/" InputSameDT off OutDataTypeMode "Inherit via internal rule" OutScaling "2^-10" RndMeth "Floor" SaturateOnIntegerOverflow off SampleTime "dt" } Block { BlockType Reference Name "Edge\nDetector" Ports [1, 1] Position [90, 40, 140, 80] SourceBlock "dspswit3/Edge\nDetector" SourceType "Edge Detector" ShowPortLabels on } Block { BlockType Ground Name "Ground" Position [220, 185, 240, 205] } Block { BlockType If Name "If" Ports [1, 1] Position [180, 101, 280, 139] IfExpression "u1 == 1" ShowElse off SampleTime "dt" } Block { BlockType DataStoreMemory Name "time A" Position [120, 175, 152, 205] DataStoreName "tA" ReadBeforeWriteMsg "warning" WriteAfterWriteMsg "warning" WriteAfterReadMsg "warning" InitialValue "0" RTWStateStorageClass "Auto" VectorParams1D on ShowAdditionalParam off } Block { BlockType DataStoreMemory Name "time B" Position [165, 175, 197, 205] DataStoreName "tB" ReadBeforeWriteMsg "warning" WriteAfterWriteMsg "warning" WriteAfterReadMsg "warning" InitialValue "0" RTWStateStorageClass "Auto" VectorParams1D on ShowAdditionalParam off } Block { BlockType SubSystem Name "time b/t two pulses" Ports [1, 1, 0, 0, 0, 0, 0, 1] Position [275, 177, 345, 213] TreatAsAtomicUnit on MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off Port { PortNumber 1 Name "sec/rev" RTWStorageClass "Auto" DataLoggingNameMode "SignalName" } System { Name "time b/t two pulses" Location [791, 229, 1187, 507] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "In1" Position [15, 18, 45, 32] IconDisplay "Port number" } Block { BlockType ActionPort Name "Action Port" Position [170, 15, 229, 43] ActionType "then" } Block { BlockType DataStoreRead Name "Data Store\nRead" Position [100, 155, 130, 185] DataStoreName "tA" SampleTime "dt" } Block { BlockType DataStoreRead Name "Data Store\nRead1" Position [130, 215, 160, 245] DataStoreName "tA" SampleTime "dt" } Block { BlockType DataStoreWrite Name "Data Store\nWrite" Position [205, 75, 235, 105] DataStoreName "tB" SampleTime "dt" } Block { BlockType DataStoreWrite Name "Data Store\nWrite1" Position [315, 215, 345, 245] DataStoreName "tA" SampleTime "dt" } Block { BlockType DigitalClock Name "Digital Clock" Position [25, 78, 90, 102] SampleTime "dt" } Block { BlockType Sum Name "Subtract" Ports [2, 1] Position [180, 147, 210, 178] Inputs "+-" InputSameDT off OutDataTypeMode "Inherit via internal rule" OutScaling "2^-10" SaturateOnIntegerOverflow off SampleTime "dt" } Block { BlockType Sum Name "Sum" Ports [2, 1] Position [250, 215, 280, 245] ShowName off IconShape "round" Inputs "++|" InputSameDT off OutDataTypeMode "Inherit via internal rule" SaturateOnIntegerOverflow off } Block { BlockType Terminator Name "Terminator" Position [80, 15, 100, 35] } Block { BlockType Outport Name "time" Position [305, 143, 335, 157] IconDisplay "Port number" BusOutputAsStruct off } Line { SrcBlock "Digital Clock" SrcPort 1 Points [0, 0; 45, 0] Branch { DstBlock "Data Store\nWrite" DstPort 1 } Branch { Points [0, 65] DstBlock "Subtract" DstPort 1 } } Line { SrcBlock "Data Store\nRead" SrcPort 1 DstBlock "Subtract" DstPort 2 } Line { SrcBlock "Subtract" SrcPort 1 Points [35, 0; 0, -15; 15, 0] Branch { DstBlock "time" DstPort 1 } Branch { DstBlock "Sum" DstPort 1 } } Line { SrcBlock "In1" SrcPort 1 Points [0, 0] DstBlock "Terminator" DstPort 1 } Line { SrcBlock "Data Store\nRead1" SrcPort 1 DstBlock "Sum" DstPort 2 } Line { SrcBlock "Sum" SrcPort 1 DstBlock "Data Store\nWrite1" DstPort 1 } } } Block { BlockType Reference Name "window length\n(seconds)" Ports [1, 1] Position [345, 30, 375, 60] SourceBlock "simulink/Logic and Bit\nOperations/Compare" "\nTo Constant" SourceType "Compare To Constant" ShowPortLabels on relop "<" const "5/dt" LogicOutDataTypeMode "boolean" ZeroCross off } Block { BlockType Outport Name "Pedaling?" Position [430, 38, 460, 52] IconDisplay "Port number" BusOutputAsStruct off } Block { BlockType Outport Name "RPM" Position [495, 163, 525, 177] Port "2" IconDisplay "Port number" BusOutputAsStruct off } Line { SrcBlock "Counter" SrcPort 1 Points [0, 0] DstBlock "window length\n(seconds)" DstPort 1 } Line { SrcBlock "Digital Clock" SrcPort 1 DstBlock "Counter" DstPort 1 } Line { SrcBlock "Edge\nDetector" SrcPort 1 Points [0, 0; 10, 0] Branch { DstBlock "Counter" DstPort 2 } Branch { Points [0, 60] DstBlock "If" DstPort 1 } } Line { SrcBlock "Hall effect" SrcPort 1 Points [0, 0] DstBlock "Edge\nDetector" DstPort 1 } Line { SrcBlock "window length\n(seconds)" SrcPort 1 Points [0, 0] DstBlock "Pedaling?" DstPort 1 } Line { Name "sec/rev" Labels [0, 0] SrcBlock "time b/t two pulses" SrcPort 1 Points [75, 0] DstBlock "Divide1" DstPort 2 } Line { SrcBlock "Constant" SrcPort 1 Points [0, 0] DstBlock "Divide1" DstPort 1 } Line { SrcBlock "Ground" SrcPort 1 Points [0, 0] DstBlock "time b/t two pulses" DstPort 1 } Line { SrcBlock "If" SrcPort 1 Points [25, 0] DstBlock "time b/t two pulses" DstPort ifaction } Line { SrcBlock "Divide1" SrcPort 1 DstBlock "RPM" DstPort 1 } } } Block { BlockType Reference Name "potientiometer" Ports [0, 1] Position [15, 310, 120, 360] SourceBlock "xpcsensoraylib/A//D/Sensoray526 AD 1" SourceType "sensoray526-ain" channel "[1]" sampletime "dt" baseaddress1 "0x2c0" baseaddress2 "0" } Block { BlockType DataStoreMemory Name "previous\ngear" Position [80, 500, 112, 530] DataStoreName "pgear" ReadBeforeWriteMsg "warning" WriteAfterWriteMsg "warning" WriteAfterReadMsg "warning" InitialValue "6" RTWStateStorageClass "Auto" VectorParams1D on ShowAdditionalParam off } Block { BlockType SubSystem Name "set desired gear =\ncurrent gear" Ports [1, 0, 0, 0, 0, 0, 0, 1] Position [400, 262, 470, 298] TreatAsAtomicUnit on MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off System { Name "set desired gear =\ncurrent gear" Location [619, 640, 1064, 837] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "cgear" Position [75, 128, 105, 142] IconDisplay "Port number" } Block { BlockType ActionPort Name "Action Port" Position [155, 15, 214, 43] ActionType "else" } Block { BlockType DataStoreWrite Name "Data Store\nWrite" Position [170, 120, 200, 150] DataStoreName "dgear" SampleTime "-1" } Block { BlockType DataStoreWrite Name "Data Store\nWrite1" Position [170, 65, 200, 95] DataStoreName "pgear" SampleTime "-1" } Line { SrcBlock "cgear" SrcPort 1 Points [20, 0] Branch { DstBlock "Data Store\nWrite" DstPort 1 } Branch { Points [0, -55] DstBlock "Data Store\nWrite1" DstPort 1 } } } } Block { BlockType SubSystem Name "set desired gear =\ncurrent gear + 1" Ports [1, 0, 0, 0, 0, 0, 0, 1] Position [540, 37, 610, 73] TreatAsAtomicUnit on MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off System { Name "set desired gear =\ncurrent gear + 1" Location [723, 491, 1157, 802] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "cgear" Position [130, 138, 160, 152] IconDisplay "Port number" } Block { BlockType ActionPort Name "Action Port" Position [195, 15, 254, 43] ActionType "then" } Block { BlockType Sum Name "Add" Ports [2, 1] Position [215, 137, 245, 168] InputSameDT off OutDataTypeMode "Inherit via internal rule" OutScaling "2^-10" SaturateOnIntegerOverflow off } Block { BlockType Constant Name "Constant" Position [130, 180, 160, 210] SampleTime "dt" } Block { BlockType DataStoreWrite Name "Data Store\nWrite" Position [280, 140, 310, 170] DataStoreName "dgear" SampleTime "-1" } Block { BlockType DataStoreWrite Name "Data Store\nWrite1" Position [280, 80, 310, 110] DataStoreName "pgear" SampleTime "-1" } Line { SrcBlock "cgear" SrcPort 1 Points [0, 0; 20, 0] Branch { DstBlock "Add" DstPort 1 } Branch { Points [0, -50] DstBlock "Data Store\nWrite1" DstPort 1 } } Line { SrcBlock "Constant" SrcPort 1 Points [15, 0; 0, -35] DstBlock "Add" DstPort 2 } Line { SrcBlock "Add" SrcPort 1 Points [0, 0] DstBlock "Data Store\nWrite" DstPort 1 } } } Block { BlockType SubSystem Name "set desired gear =\ncurrent gear -1" Ports [1, 0, 0, 0, 0, 0, 0, 1] Position [530, 392, 600, 428] TreatAsAtomicUnit on MinAlgLoopOccurrences off RTWSystemCode "Auto" MaskHideContents off System { Name "set desired gear =\ncurrent gear -1" Location [342, 471, 840, 771] Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" PaperOrientation "landscape" PaperPositionMode "auto" PaperType "usletter" PaperUnits "inches" ZoomFactor "100" Block { BlockType Inport Name "cgear" Position [100, 138, 130, 152] IconDisplay "Port number" } Block { BlockType ActionPort Name "Action Port" Position [170, 15, 229, 43] ActionType "elseif" } Block { BlockType Sum Name "Add" Ports [2, 1] Position [185, 137, 215, 168] Inputs "+-" InputSameDT off OutDataTypeMode "Inherit via internal rule" OutScaling "2^-10" SaturateOnIntegerOverflow off } Block { BlockType Constant Name "Constant" Position [100, 180, 130, 210] SampleTime "dt" } Block { BlockType DataStoreWrite Name "Data Store\nWrite" Position [250, 140, 280, 170] DataStoreName "dgear" SampleTime "-1" } Block { BlockType DataStoreWrite Name "Data Store\nWrite1" Position [250, 60, 280, 90] DataStoreName "pgear" SampleTime "-1" } Line { SrcBlock "cgear" SrcPort 1 Points [20, 0] Branch { DstBlock "Add" DstPort 1 } Branch { Points [0, -70] DstBlock "Data Store\nWrite1" DstPort 1 } } Line { SrcBlock "Constant" SrcPort 1 Points [15, 0; 0, -35] DstBlock "Add" DstPort 2 } Line { SrcBlock "Add" SrcPort 1 DstBlock "Data Store\nWrite" DstPort 1 } } } Block { BlockType Reference Name "turn motor" Ports [1] Position [395, 435, 500, 485] SourceBlock "xpcsensoraylib/D//A/Sensoray526 DA " SourceType "sensoray526-aout" channel "[1]" reset "[0]" initial "[0]" sampletime "dt" baseaddress1 "0x2c0" baseaddress2 "0" } Line { SrcBlock "2. pedal hall sensor\n3. switch" SrcPort 1 DstBlock "pedaling" DstPort 1 } Line { SrcBlock "potientiometer" SrcPort 1 DstBlock "determine\ncurrent gear" DstPort 1 } Line { SrcBlock "determine\ncurrent gear" SrcPort 1 Points [10, 0] Branch { Points [30, 0] Branch { Points [60, 0] Branch { Points [-60, 0; 0, -255] DstBlock "decide to shift or not" DstPort 2 } Branch { Points [0, -70] DstBlock "set desired gear =\ncurrent gear" DstPort 1 } Branch { Points [155, 0] Branch { Points [40, 0; 0, -295] DstBlock "set desired gear =\ncurrent gear + 1" DstPort 1 } Branch { Points [0, 60] DstBlock "set desired gear =\ncurrent gear -1" DstPort 1 } } } Branch { Points [0, 100] DstBlock "Subtract" DstPort 1 } } Branch { Points [0, -85; -185, 0] DstBlock "did shift occur?" DstPort 1 } } Line { SrcBlock "decide to shift or not" SrcPort 3 Points [0, 127] DstBlock "set desired gear =\ncurrent gear" DstPort ifaction } Line { SrcBlock "decide to shift or not" SrcPort 1 Points [40, 0; 0, -68] DstBlock "set desired gear =\ncurrent gear + 1" DstPort ifaction } Line { SrcBlock "decide to shift or not" SrcPort 2 Points [40, 0; 0, 272] DstBlock "set desired gear =\ncurrent gear -1" DstPort ifaction } Line { SrcBlock "Data Store\nRead" SrcPort 1 DstBlock "Subtract" DstPort 2 } Line { SrcBlock "Subtract" SrcPort 1 Points [5, 0] DstBlock "Gain" DstPort 1 } Line { SrcBlock "Gain" SrcPort 1 Points [0, 0] DstBlock "turn motor" DstPort 1 } Line { SrcBlock "Data Store\nRead1" SrcPort 1 Points [25, 0] DstBlock "determine\ncurrent gear" DstPort 2 } Line { SrcBlock "pedaling" SrcPort 2 Points [40, 0; 0, 10] DstBlock "decide to shift or not" DstPort 1 } Line { SrcBlock "delay counter" SrcPort 1 Points [55, 0; 0, -75] DstBlock "decide to shift or not" DstPort 3 } Line { SrcBlock "delay\nconstant" SrcPort 1 Points [-5, 0; 0, -60] DstBlock "decide to shift or not" DstPort 4 } Line { SrcBlock "did shift occur?" SrcPort 1 DstBlock "delay counter" DstPort 1 } Line { SrcBlock "pedaling" SrcPort 1 Points [10, 0; 0, -20] DstBlock "future coasting\ncapability" DstPort 1 } Line { SrcBlock "2. pedal hall sensor\n3. switch" SrcPort 2 Points [10, 0; 0, 50] DstBlock "decide to shift or not" DstPort 5 } Annotation { Name "set dt = 0.01" Position [722, 21] UseDisplayTextAsClickCallback off FontSize 18 } } } # Finite State Machines # # Stateflow Version 6.2 (R14SP2) dated Aug 4 2005, 10:13:39 # # Stateflow { machine { id 1 name "bike" created "03-Mar-2006 21:50:48" isLibrary 0 firstTarget 10 sfVersion 62014000 } chart { id 2 name "determine\n" "current gear" windowPosition [281.813 329.45 200.25 189.75] viewLimits [0 156.75 0 153.75] screen [1 1 1280 1024 1.333333333333333] treeNode [0 3 0 0] firstTransition 5 firstJunction 4 viewObj 2 machine 1 decomposition CLUSTER_CHART type EML_CHART firstData 6 chartFileNumber 2 disableImplicitCasting 1 eml { name "fcn" } } state { id 3 labelString "eML_blk_kernel()" position [18 64.5 118 66] fontSize 12 chart 2 treeNode [2 0 0 0] superState SUBCHART subviewer 2 type FUNC_STATE decomposition CLUSTER_STATE eml { isEML 1 script "function cgear = fcn(potV, pgear)\n" "% This block supports an embeddable subset of the MATLAB la" "nguage.\n" "% See the help menu for details. \n" "\n" "cgear = potV;\n" "\n" "if potV < 2.94\n" " cgear = 6;\n" "elseif 4.35 < potV & potV < 4.51\n" " cgear = 5;\n" "elseif 5.53 < potV & potV < 5.68\n" " cgear = 4;\n" "elseif 6.50 < potV & potV < 6.85\n" " cgear = 3;\n" "elseif 7.58 < potV & potV < 7.98\n" " cgear = 2;\n" "elseif potV > 8.68\n" " cgear = 1;\n" "else\n" " cgear = pgear;\n" "end" editorLayout "100 M4x1[145 145 587 621]" fimathString "fimath(...\n" "'RoundMode', 'floor',...\n" "'OverflowMode', 'wrap',...\n" "'ProductMode', 'KeepLSB', 'ProductWordLength', 32,..." "\n" "'SumMode', 'KeepLSB', 'SumWordLength', 32,...\n" "'CastBeforeSum', false)" treatIntsAsFixpt 0 } } junction { id 4 position [23.5747 49.5747 7] chart 2 linkNode [2 0 0] subviewer 2 type CONNECTIVE_JUNCTION } transition { id 5 labelString "{eML_blk_kernel();}" labelPosition [32.125 19.875 102.544 14.964] fontSize 12 src { intersection [0 0 1 0 23.5747 14.625 0 0] } dst { id 4 intersection [7 0 -1 -1 23.5747 42.5747 0 0] } midPoint [23.5747 24.9468] chart 2 linkNode [2 0 0] dataLimits [21.175 25.975 14.625 42.575] subviewer 2 drawStyle SMART executionOrder 1 } data { id 6 name "potV" linkNode [2 0 7] scope INPUT_DATA machine 1 props { array { size "-1" } type { method SF_INHERITED_TYPE } complexity SF_COMPLEX_INHERITED } dataType "inherited" fixptType { slope 1 baseType SF_INT16_TYPE } complexity SF_COMPLEX_INHERITED } data { id 7 name "cgear" linkNode [2 6 8] scope OUTPUT_DATA machine 1 props { array { size "-1" } type { method SF_INHERITED_TYPE } complexity SF_COMPLEX_INHERITED } dataType "inherited" fixptType { slope 1 baseType SF_INT16_TYPE } complexity SF_COMPLEX_INHERITED } data { id 8 name "pgear" linkNode [2 7 0] scope INPUT_DATA machine 1 props { array { size "-1" } type { method SF_INHERITED_TYPE primitive SF_DOUBLE_TYPE isSigned 1 wordLength "16" } } dataType "inherited" } instance { id 9 name "determine\n" "current gear" machine 1 chart 2 } target { id 10 name "sfun" description "Default Simulink S-Function Target." machine 1 linkNode [1 0 11] } target { id 11 name "rtw" codeFlags " comments=1 statebitsets=1 databitsets=1 emitlogicalops=1 el" "seifdetection=1 constantfolding=1 redundantloadelimination=0" " preservenames=0 preservenameswithparent=0 exportcharts=0" machine 1 linkNode [1 10 0] } }