DOC PREVIEW
SJSU ME 106 - Embedded Programming

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Embedded ProgrammingLearning ObjectivesMechatronics Concept MapProcedural vs. Embedded ProgrammingEvent Driven Program StructureRequirements for Events and ServicesEvent Checkers for Discrete EventsCode to Check for Discrete EventsEvents involving an analog quantityEvent Checkers for Events Involving Analog QuantitiesEvent Detection with HysteresisCode to Check for Events With Analog QuantitiesMain body of Events & Services CodeEmbedded ProgrammingB. Furman09MAY2011Learning ObjectivesDistinguish between procedural programming and embedded programmingExplain the Events and Services embedded programming frameworkExplain what an Event isExplain what a Service isExplain the key rule and its two corollariesDescribe how an event checking routine works forDiscrete quantitiesAnalog quantitiesDevelop code for:an event checking routinea servicean event driven systemMechatronics Concept MapController(Hardware & Software)System toControlSensorSignalConditioningPowerInterfaceActuatorUserInterfacePowerSourceBJ Furman 22JAN11ME 106ME 154ME 157ME 195ME 120ME 297AME 106ME 120ME 106ME 190ME 187ME 110ME 136ME 154ME 157ME 182ME 189ME 195ME 106ME 120ME 106 INTEGRATIONProcedural vs. Embedded ProgrammingProceduralME 30/CmpE 46Computation and analysis programsMostly sequentialStart  …  EndKnown inputs and outputsProgram is in controlPredictable operation and timingEmbeddedME 106Inputs and outputs can occur at any time, in any order and are not predictableInputs can come from multiple sourcesSensors, user inputs, or internal (timer, ADC, etc.)May handle simultaneous inputs and outputsProgram never endsEvent Driven Program StructureProgramming task divides into: Checking for eventsServicing events when they occurEventA detectable change or transition in something of interestButton press (before: not pressed, after: pressed)ADC complete flag bit setServiceAn action taken in response to an eventRequirements for Events and ServicesThe occurrence of events must be checked for continuously and oftenServices must execute quickly and must be non-blockingEx. Determine if a switch has closedBlocking code:while(digitalRead(pin) == HIGH);Event Checkers for Discrete EventsEx. Check that a switch has closedPseudocodeIF switch is closed AND switch was open last time, THENSwitchClosed event has occurredELSESwitchClosed event has not occurredNeed to keep track of the state of the switch (i.e., maintain its history)Use a state variableWill need to be declared as a static local variable in the function that checks for the eventNeed to retain the value between successive calls to the event checking functionCode to Check for Discrete EventsEvents involving an analog quantityhttp://www.soe.ucsc.edu/classes/cmpe118/Winter08/LectureNotes/EventDrivenProg.pdfA single-valued threshold will likely result in “chatter” when the quantify of interest is near the thresholdEvent Checkers for Events Involving Analog QuantitiesFiltering the signal may helpAdd hysteresis in the event checkerMake the criteria for when the event occurs a variable instead of a fixed valueInitially threshold is set to an upper valueAs soon as the signal crosses the threshold, the threshold is dropped to a lower valuePseudocode:Set threshold to high valueIF var is greater than or equal to the threshold, THENEvent has happenedSet threshold to lower valueELSEEvent has not happenedEvent Detection with Hysteresishttp://www.soe.ucsc.edu/classes/cmpe118/Winter08/LectureNotes/EventDrivenProg.pdfCode to Check for Events With Analog QuantitiesMain body of Events & Services


View Full Document

SJSU ME 106 - Embedded Programming

Download Embedded Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Embedded Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Embedded Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?