Finite State Machines in Microcontrollers

lecture 3 finite state machines n.w
1 / 15
Embed
Share

Explore the concept of finite state machines in microcontrollers, their types, and implementations. Learn how FSMs with binary logic and memory elements operate in systems like the ATMega168 microcontroller.

  • Finite State Machines
  • Microcontrollers
  • FSM Implementation
  • Binary Logic
  • Memory Elements

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lecture 3 Finite State Machines Definition: A system which has a finite number of states that can be encoded in binary form The system remembers what state it is in called the Present State (PS) Transitions between the states are governed by (usually) deterministic rules These rules operate upon the input and the PS and cause the FSM to transition to the Next State (NS). At the following time step, the NS becomes the PS. 1/8

  2. The ATmega168 microcontroller, or any other microprocessor functions as a (complex) Finite State Machine Details are different depending on the processor architecture: Number of states Sequence of state transitions Delay between transitions (CPU clock) 2/8

  3. ATMega168 Micro-controller (mostly) complete diag. 3/8

  4. 4/8

  5. Arduino Board Design 5/8

  6. There are other, Simpler Finite State Machines we can study in more detail 6/8

  7. Example: Odd Parity Checker Input: String of 0101001011010 . Objective: Assert output 1 whenever input bit stream has odd number of 1's Three things matter: 1. Present State i.e. system needs to remember its state 2. Input 3. Next State Output is indicated by Using binary logic, need memory elements: 2 states 1 bit binary 3 states 2 bit binary 4 states 2 bit binary State Diagram

  8. Basic 1-bit memory element: D register D Q D CLEAR CLOCK 8/8

  9. Implementation 1 of parity checker: Next State is calculated based on Input and Present State Output is equal to the present state of the system Present State Even Even Odd Odd Input 0 1 0 1 Next State Even Odd Odd Even Output 0 0 1 1 Symbolic State Transition Table State Diagram Encoded State Transition Table Use the FSM State Table to deduce the Boolean Logic function of Next State= f (Present State, Input) 9/8

  10. Combinational Logic: NS = PS XOR Input Combinational Logic: NS = PS XOR Input Implementation 1: Output = PS NS Input D Q PS=Output CLK Q R Reset

  11. Implementation 2 of parity checker : Next State is calculated based on Input and Present State Output is equal to the next state of the system Present State Even Even Odd Odd Input 0 1 0 1 Next State Even Odd Odd Even Output 0 1 1 0 Symbolic State Transition Table Present State 0 0 1 1 Input 0 1 0 1 Next State 0 1 1 0 Output 0 1 1 0 State Diagram Encoded State Transition Table Use the FSM State Table to deduce the Boolean Logic function of Next State= f (Present State, Input) (Mealy FSM) 11/8

  12. Combinational Logic: NS = PS XOR Input Combinational Logic: NS = PS XOR Input Implementation 1: Output = PS Implementation 2: Output = (PS xor I) = NS NS NS=Output Input Input D Q D Q PS=Output PS CLK CLK Q Q R R Reset Reset Timing Behavior: Input 1 0 0 1 1 0 1 0 1 1 1 0

  13. State Register 1. Moore Machine Present State X i Combinational Logic for Next State Outputs are function of the present state Zk Inputs Outputs Outputs change synchronously with state changes Clock state feedback Remember: CLK must enter the Memory element used to store states of the system! 2. Mealy Machine Z X k i Combinational Logic for Outputs and Next State Outputs Inputs Outputs depend on state AND inputs Present State Input change causes an immediate output change State Feedback State Register Clock Asynchronous outputs 13/8

  14. Moore-Mealy difference 14/8

  15. Moore-Mealy trade-offs But Mealy FSM responds immediately (asynchronously) to Input Susceptible to Input Glitches in a complex FSM. CLK (which synchronizes change of state) may get delayed in propagating change of state through the memory registers. 15/8

Related


More Related Content