Lab 4 servo motor
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Lab 4 – Servo Motor PowerPoint PPT Presentation


  • 57 Views
  • Uploaded on
  • Presentation posted in: General

Lab 4 – Servo Motor. Start Date: Week #6 Due date: Week #8. Overview of the timer system. See black book p. 66 TCNT Free running counter Prescaler sets relationship to ECLK (TMSK2) Main part of the timer subsystem Can be stopped while in wait or background debug mode (TSCR).

Download Presentation

Lab 4 – Servo Motor

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Lab 4 servo motor

Lab 4 – Servo Motor

Start Date: Week #6

Due date: Week #8


Overview of the timer system

Overview of the timer system

  • See black book p. 66

  • TCNT

    • Free running counter

    • Prescaler sets relationship to ECLK (TMSK2)

    • Main part of the timer subsystem

    • Can be stopped while in wait or background debug mode (TSCR)


Input capture output compare

Input capture/output compare

  • TIC / TOC

    • Set using TIOS register

  • Input capture

    • When an event is detected on pin x, the value of TCNT is latched into the 16-bit register TCx

    • The input event (rising edge, falling edge, both, none) is set in a register (TCTL3 and TCTL4)

    • Flag is set in TFLG1

    • Interrupt is generated if set in TMSK1


Input capture output compare1

Input capture/output compare

  • Output Compare

    • Successful output compare when the value in TCNT equals the value in TCx

    • Flag is set in TMSK1

    • Output pin is changed according to action set in TCTL1 and TCTL2

      • None, set, clear, toggle

    • Interrupt generated if set in TMSK1


Overflow interrupt

Overflow Interrupt

  • The system also has the ability to flag / generate an interrupt on TCNT overflow

    • Interrupt set from TMSK2

    • Flag in TFLG2


Registers

Registers

  • TIOS

    • Input capture / output compare

  • TCNT

    • Counter

  • TSCR

    • Enable, fast clear, wait and background mode

  • TMSK1

    • interrupts


Registers1

Registers

  • TMSK2

    • Prescalers

  • TFLG1

    • Flags for the interrupts

    • Write a 1 to clear

  • TCx

    • This is where you write the values you are using for OC


Servo motor control

Servo Motor control

  • Period of ~21ms

  • Pulse width determines angle (from ~0.9 to ~2.1ms)

  • You will need to calibrate it


Lab 4 servo motor

LCD

  • There is test code on the web that you can use to test the LCD setup before you try to use it in your program

  • You may utilize the code to write your own program, but you need to make sure that you understand what the code is doing and why


Interrupts on the hc12

Interrupts on the HC12

  • You will need to use interrupts if your main program is waiting for user input

  • D-Bug12 re-maps the interrupt vector table

  • Either use the D-Bug12 subroutine to set the vector, or set it yourself using the remapped locations (last slide)

  • More detailed information in the appendix


Hints

Hints

  • The scope can be very helpful to check your output

    • If you don’t know how to use it, please ask

  • Check the LCD setup using the test code before you try to write to it


Interrupt vectors

Interrupt vectors


Academic misconduct

Academic Misconduct

  • Reports and demos are submitted as a group, but it is a SINGLE group effort

  • You may talk with other groups but sharing code or reports is NOT ALLOWED

  • Copying code/reports from previous years is also NOT ALLOWED

  • If we find copying we are REQUIRED to report it


  • Login