Lazy Clock Electronics and Software

Similar documents
ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Lazy Clock Construction Templates

Timer A (0 and 1) and PWM EE3376

Lab 5 Timer Module PWM ReadMeFirst

GF of 9 THE GADGET FREAK FILES CASE #165. Analog Clock Measures Time in Meters

Microcontrollers and Interfacing

CSCI1600 Lab 4: Sound

MICROCONTROLLER TUTORIAL II TIMERS

University of Texas at El Paso Electrical and Computer Engineering Department

Electronic Components

Iowa State University Electrical and Computer Engineering. E E 452. Electric Machines and Power Electronic Drives

A MORON'S GUIDE TO TIMER/COUNTERS v2.2. by

WDTCTL = WDTPW + WDTHOLD; P1DIR = 1; // P1.0 output, all others input. sits here as long as the pin is high while (P1IN & 8); while (!

Using the Z8 Encore! XP Timer

ME 461 Laboratory #2 Timers and Pulse-Width Modulation

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

Xicor Real Time Clock Family Users Guide. New Devices Integrate Crystal Compensation Circuitry AN of 8.

Grundlagen Microcontroller Counter/Timer. Günther Gridling Bettina Weiss

Ocean Controls KT-5221 Modbus IO Module

RC Filters and Basic Timer Functionality

PIC ADC to PWM and Mosfet Low-Side Driver

Jaguar Motor Controller (Stellaris Brushed DC Motor Control Module with CAN)

MSP430 Interfacing Programs

1 Second Time Base From Crystal Oscillator

Brian Hanna Meteor IP 2007 Microcontroller

Ocean Controls KT-5198 Dual Bidirectional DC Motor Speed Controller

Using Z8 Encore! XP MCU for RMS Calculation

NuMicro N76E003 Brushless DC Motor Control User Manual

QUASAR PROJECT KIT # /24 HOUR GIANT CLOCK

Arduino Freq-Mite for Norcal NC40A Mike WA8BXN Jan 2018

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

IZ602 LCD DRIVER Main features: Table 1 Pad description Pad No Pad Name Function

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

LED Field Strength Indicator Kit

Name & SID 1 : Name & SID 2:

Elektor Datalogger Review

Brushed DC Motor Control. Module with CAN (MDL-BDC24)

Figure 1. C805193x/92x Capacitive Touch Sense Development Platform

JTAG pins do not have internal pull-ups enabled at power-on reset. JTAG INTEST instruction does not work

TAPR TICC Timestamping Counter Operation Manual. Introduction

BMS BMU Vehicle Communications Protocol

Training Schedule. Robotic System Design using Arduino Platform

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

PRODUCT OVERVIEW OVERVIEW OTP

Project Final Report: Directional Remote Control

Temperature Monitoring and Fan Control with Platform Manager 2

Houngninou 2. Abstract

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

DIY KIT 141. Multi-Mode Timer

Timer A. Last updated 8/7/18

Measuring Distance Using Sound

Table Of Contents Overview of the operating buttons... 4 The functions of the datalogger... 5 How to start logging from the default settings...

Wednesday 7 June 2017 Afternoon Time allowed: 1 hour 30 minutes

Project: Electromagnetic Ring Launcher

Power Pulse Modulator A High Performance Versatile Square Pulse Generator

ECE 511: MICROPROCESSORS

µtasker Document µtasker Hardware Timers

VORAGO Timer (TIM) subsystem application note

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

Laboratory Final Design Project. PWM DC Motor Speed Control

Application Note: Using the Motor Driver on the 3pi Robot and Orangutan Robot Controllers

Bohunt School (Wokingham) Internet of Things (IoT) and Node-RED

Temperature Monitoring and Fan Control with Platform Manager 2

o What happens if S1 and S2 or S3 and S4 are closed simultaneously? o Perform Motor Control, H-Bridges LAB 2 H-Bridges with SPST Switches

F²MC-8FX FAMILY MB95F200 SERIES. LED Control Reference Solution 8-BIT MICROCONTROLLER APPLICATION NOTE

CHAPTER-5 DESIGN OF DIRECT TORQUE CONTROLLED INDUCTION MOTOR DRIVE

OBSTACLE EVADING ULTRASONIC ROBOT. Aaron Hunter Eric Whitestone Joel Chenette Anne-Marie Cressin

EE152 Final Project Report

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

Triscend E5 Support. Configurable System-on-Chip (CSoC) Triscend Development Tools Update TM

MAKEVMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

Embedded Systems and Software

AN3252 Application note

QRPGuys SMT Digital Dial/Frequency Counter

LM4: The timer unit of the MC9S12DP256B/C

ICS REPEATER CONTROLLERS

AN4507 Application note

ATmega16A Microcontroller

Solar Mailbox project. Pictures of the Solar Mailbox

Cleaning Robot Working at Height Final. Fan-Qi XU*

Application Note, V1.2, Feb AP TriCore. 3-phase complementary PWM with hardware triggered ADC conversion.

STELLARIS ERRATA. Stellaris LM3S8962 RevA2 Errata

B & D Enterprises 1P repeater controller pg 1 INTRODUCTION:

Fixed-function (FF) implementation for PSoC 3 and PSoC 5 devices

AN2581 Application note

Project Name: SpyBot

Circuit Board Assembly Instructions

Product Family: 05, 06, 105, 205, 405, WinPLC, Number: AN-MISC-021 Terminator IO Subject: High speed input/output device

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

Laboratory Exercise 1 Microcontroller Board with Driver Board

PWMLib PWM Library. Jim Schimpf. Document Number: PAN Revision Number: April Pandora Products. 215 Uschak Road Derry, PA 15627

Lecture 6: More on Timers and PWM

Handy dandy little circuit #17 #17

RX23T inverter ref. kit

Designing and Implementing of 72V/150V Closed loop Boost Converter for Electoral Vehicle

The Motor sketch. One Direction ON-OFF DC Motor

Low Voltage, High Current Time Delay Circuit

Transcription:

Lazy Clock Electronics and Software

Introduction The Lazy Clock is a wood gear mechanical clock driven by a low-power solenoid that fires only once per minute. An MSP430 microcontroller, clocked with a watch crystal, is used to trigger the solenoid. This document details the electronic hardware and software for the Lazy Clock. Refer to the References section at the end of this document for more information on the Lazy Clock. 2

Hardware The clock is powered by two AA cells. The coil is about 20 ohms and draws about 150 ma when fully on, but since it fires so infrequently and for a fraction of a second, average current draw is about 0.4 mah. The microcontroller is in low-power mode most of the time and draws negligible current. A 32.768 khz watch crystal provides an accurate time base. D1 protects the microcontroller from reversed batteries and, along with C2, filters power from coil switching transients. C4 filters microcontroller high frequencies. The NPN driver is protected from coil turn-off transients by D2, and C1 filters PWM switching which can be audible. R2 and C3 enable power-on reset. 3

The prototype circuit was built on a Busboard Prototype Systems Limited SB300 breadboard with land patterns on the reverse side as shown. The board was trimmed to size. In the photo the Test Mode jumper is in place. The coil is attached to the other two terminals on the header. Red and black leads connect to a two-cell AA battery holder. Production circuit boards are sourced from ExpressPCB and were designed using that firm's free schematic drawing and PCB layout software. 4

Software The software is written in C and was developed using the Launch Pad Development Board and the free Code Composer Studio v5.1 from Texas Instruments. At $4.30, this is one of, if not the, lowest-cost microcontroller development platforms available. A few connections were made from the Development Board to a pluggable breadboard during hardware and software development. Microcontrollers are subsequently programmed using the Development Board alone, then transferred to production circuit boards. 5

Source code You are free to use the code for personal use. Please obtain permission from the author before distributing the code or selling any clocks or electronics that make use of the code. / Solenoid Driver for Lazy Clock Version 1.0 The "Lazy Clock" is a wood gear mechanical clock driven by a solenoid that fires only once per minute. The MSP430 microcontroller, clocked with a watch crystal, is used to trigger the solenoid. PWM is used to gradually ramp up the voltage to the solenoid coil to provide a smooth operating action rather than a sudden snap. Dick Bipes dick@carveshop.com Copyright 2013 by Dick Bipes. All rights reserved. / / ======== Grace setup ======= This firmware was developed using TI's Code Composer Studio and its Grace graphical interface to set up the MSP430. Grace generates setup code for the MSP430 that otherwise might appear in this source code. Here is a description of the Grace setup: Basic Clock System The Internal High Speed Clock is set to 1.0 MHz. The Main System Clock and Sub System clock are both set to DCOCLK source and divide by 1. The output SMCLK and ACLK are both turned off. The Low Speed External Clock is set to 32.768 khz with 12.5 pf Internal load capacitance. A 32.768 external watch crystal is used. Watchdog Timer The Watchdog Timer is set to Interval Timer Mode and clocked from the Low Speed Clock (the watch crystal at 32.768 khz). 6

The divider is set to 512 yielding an interrupt service call every 15.6 ms or 64 times per second. Interrupts are enabled, and the service routine is WDTISRHandler. Timer A2 The Timer A2 clock source is set to SMCLK at 1000 khz. Counting Mode is Up. Interrupts are not enabled. Timer Capture/Compare Block 0 Mode is set to a Timer Period of 1.0 ms or 999 counts. The Mode is set to Output Compare/Period and the Output Pin are not used. Interrupts are not enabled. Timer Capture/Compare Block 1 is set to an initial desired duty cycle of 30% and the Capture Compare register 300 counts. The duty cycle is gradually increased to 100% under program control. The Mode is set to Output Compare and Output Pin P1.2/Timer_A2.TA1 is enabled. The Output Mode is set to PWM output mode: 7 - PWM reset/set. Interrupts are not enabled. Ports Port P1.2 is a high-active output driving the coil transistor. It is set to output direction. The initial value of P1.2 is set to 0 (low = inactive). The Port Selection Register is initially set by Grace to the Timer A2 PWM output, and the coil is on being driven at 70%. The PWM percentage is gradually increased to achieve full power at 100%. When it is time to turn off the coil, the Port Selection Register bit is reset, disabling the PWM output and setting the port pin to inactive (low). When it is time to turn on the coil, the PWM output is again enabled via the Port Selection Register. Port P1.3 is an input connected to a Test Mode jumper. It is set to input direction. The internal resistor is enabled and the Output Register Bit is set to 1 for pullup. All other port pins are unused. / / ======== Standard MSP430 includes ======== / #include <msp430.h> / ======== Grace related includes ======== / #include <ti/mcu/msp430/csl/csl.h> / ======== Definitions and variables ======== / 7

#define RedLED (BIT0) // Red LED on the LaunchPad (LEDs used during debug) #define GreenLED (BIT6) // Green LED on the LaunchPad #define Coil (BIT2) // Port 1 Bit 2 is high-active to the base of an NPN coil driver transistor #define TestMode (BIT3) // Jumper to ground puts the circuit into Test Mode // Test Mode runs the coil at a faster than normal rate to check out a newly-built clock #define WDticksPerSecond 64 // Number of Watchdog Timer ticks (interrupts) per second // The coil is initially turned on at partial power, then power is increased in increments every 15.2 ms to 100% power. // Total on time is 155 ms and average power is 85%. #define PWM_bump 25 // incremental PWM value (2.5%) #define PWM_init 700 // initial PWM value (70% power) #define PWM_full 1000 // full power PWM value 100% unsigned int WDTticks = 0; // count of Watchdog Timer (interval timer) interrupt service calls unsigned int seconds = 0; // elapsed seconds counted from WDTticks unsigned int PWM; // percent of time to turn on the coil. 1000 = 100%. / ======== Interrupt handlers ======== / / Watchdog Timer Interrupt handler The microcontroller is awakened from low-power mode by the Watchdog Timer. The Watchdog Timer is set to interrupt every 15.2 ms or 64 times per second. Each interrupt or "tick" of the timer is counted, and after 64 ticks the seconds counter is incremented. This is the basic time-keeping function of the clock. The coil is turned on once per minute in normal mode and once per second in test mode. Test mode is set by installing a jumper connected to a port pin. The coil is turned on and off by enabling or disabling the bit in the Port Selection Register which connects the Timer A2 PWM output to the port. When disabled, the port pin is connected to the Port Output which is always set low (inactive) and the transistor is turned 8

off. When enabled, the Timer A2 PWM output is connected to the port pin and the transistor turned on at the PWM duty cycle rate. Also when enabled, at each tick of the Watchdog Timer, or every 15.2 ms, the PWM percentage is increased a small amount. The current into the coil is thus gradually ramped up from partial to full power (100% duty cycle). This ramp up causes the solenoid plunger to activate more slowly and help prevent the clock's pawls from skipping a tooth on the ratchet wheel. The pawl would operate even more smoothly ramping up from 0%, but that would take more current and shorter battery life. The design choice is a trade-off between smoothness and battery life. / void WDTISRHandler(void) { // If the Port Selection Register bit is active, the Timer A2 PWM output is connected to the port pin and the coil is on. if (P1SEL & Coil) // is the coil on or off? { // The coil is on - ramp up the PWM percentage at each Watchdog Timer tick CCR1 += PWM_bump; //increase the PWM percent a modest amount if (CCR1 >= PWM_full) // are we at full power? { P1SEL &= ~Coil; // yes, turn off the coil } } WDTticks++; // count the number of Watchdog Timer ticks to keep basic time if (WDTticks >= WDticksPerSecond) { seconds++; // count seconds } } // once per minute in Normal mode, once per second in Test mode if ((seconds >= 60) (((P1IN & TestMode) == 0) & (seconds)) ) { seconds = 0; // reset the seconds count CCR1 = PWM_init; // set the PWM to initial value P1SEL = Coil; // turn the coil on } WDTticks = 0; // reset the Watchdog Timer ticks counter 9

/ ======== main ======== / int main(int argc, char argv[]) { CSL_init(); // Activate Grace-generated configuration _BIS_SR(LPM0_bits); // Enter Low-power mode and wait for interrupts return (0); } 10

GRACE setup for the Lazy Clock Lazy Clock Electronics and Code 11

12

13

14

15

16

17

References Visit www.carveshop.com for Lazy Clock Electronics and Code More information on the Lazy Clock. The Lazy Clock Carvewright Project instruction manual. Templates and notes to build a clock using conventional tools. Price and availability of a hardware kit for all the non-wood parts necessary to complete the Lazy Clock. Complete schematics for the electronics and source code for the microcontroller if you want to build your own. Price and availability of a wood parts kit for the Lazy Clock. If you're building a Lazy Clock, I'd love to hear from you - dick@carveshop.com. Copyright 2013 by Dick Bipes. All rights reserved. 18