220 likes | 360 Views
Hybrid I/O – Pulses. Digital or Analog?. +5 V. 0 V. It depends on how data is encoded . Analog Signals that Look Awfully Digital…. Pulse Generation Pulse-Width Modulation (PWM) Pulse-Width Measurement (PWM) Event counting Period Measurement Input capture Output compare
E N D
Digital or Analog? +5 V 0 V It depends on how data is encoded.
Analog Signals that Look Awfully Digital… • Pulse Generation • Pulse-Width Modulation (PWM) • Pulse-Width Measurement (PWM) • Event counting • Period Measurement • Input capture • Output compare For a microcontroller – all involve creative use of clocks and counters
Applications of These Signals Applications: • Pulse Generation (sensors, motors, general control) • Pulse-Width Modulation (PWM) (DC Motors) • Pulse-Width Measurement (PWM) (sensors) • Event counting • Period Measurement (frequency measurement/modulation) • Input capture (pattern recognition) • Output compare (timed patterns)
Magnetic Fields Direction of Field: North South
Right Hand Rule Electric Currents Magnetism!
Right Hand Rule Electric Currents Magnetism!
Electromagnet North/South Pole?
Stepper Manipulation • Controlling a stepper involves turning these electromagnets on and off • This must be done in order to create rotation. • i.e. can’t go from top one high to bottom one high • Microcontroller will want to set up its outputs to go through these steps in order by generating pulses on multiple pins • Number of steps (resolution) can actually be doubled with creative pulsing • i.e. top and right on give you a position going “NE”
Right Hand Rule # 2 Electric Currents & Magnetism Force Force Current Magnetic Field
DC Motor Velocity • The velocity of the motor is (roughly) proportional to the force exerted • The power of the force acting on the motor is directly proportional to the magnetic field that is causing the force • The magnetic field intensity is directly proportional to the current that creates it (from running through the wires) • The current is directly proportional to the Voltage across the lines (V = IR) Therefore: The speed of the motor is directly proportional to the Voltage How do I output a voltage?!?
Pulse Width Modulation (PWM) Effective Voltage = Duty Cycle x Supply Voltage
Single Pulse Applications • Sensors: • Ultrasonic range-finders require a pulse to start ranging, and report results based on a pulse length • Servo Motors: • Pulse width describes position
Generating Pulsed I/O on the MPC555 • “Obvious” answer is to use straight GPIO (digital I/O), like the port we used in the QADC, then use the PIT to do timings • While possible, to do a continuous pulse we have to interrupt the processor every ½ period! • Timing is also slightly less accurate (going to an ISR takes time) • The MPC555 has a “MIOS” unit (Modular Input/Output System) • Combines counters and clocks to generate a wide range of pulse widths and periods. • Does so without the need for interrupts
MDASM Modes • Disable mode • Pulse width measurement • Period measurement • Input capture mode • Single pulse generation • Continuous pulse generation