| |
Professor Tom
Almy had written an alarm clock program for our old Dragon12 board in 2003,
but it still will run on the HCS12/9S12 base Dragon12-Plus board. The source program of his alarm clock
can be
downloaded at http://hcs12text.com/links.html
He has recently written a cool demo program for DC motor and stepper motor working with the
Dragon12-Plus board. The source code is included in our distribution CD and free
for all Dragon12-Plus users. More details can be found in the
Designing with
Microcontrollers textbook
To run his
program, remove the jumper on J24(J24A) and place it on J18. This will provide
VCC to the H-Bridge (U12) and disable the 7-segment display at the same
time. After running his program, don't forget to move the jumper back to
J24(J24A) for enabling the 7-segment display.
Following is the
brief description of his demo program:
; Motor Speed Control Example Program
; Author: Tom Almy
; Date: May 22, 2007
; Copyright 2007, Tom Almy. Permission given to copy for use; in Wytec Dragon12-plus board.
; Function:
; The user enters the desired speed and direction using the keypad.
; 0 through 9 set the speed (stop to full speed). The * button sets
; forward direction and the # button sets reverse direction. The lower
; right button on the keypad turns the driver off.
; In the DC motor version, the motor connects between the MOT1 and MOT2 terminals.
; In the (bipolar) stepper motor version, one winding connects between the MOT1 and MOT2
; terminals while the second winding connects between the MOT3 and MOT4 terminals.
; For the stepper motor, this code will by default give a step rate of 10 to 90 steps/second.
; The board must be configured for the desired motor power voltage and source.
;
Implementation:
; An RTI interrupt at roughly 1mSec rate does the keypad polling and LCD display driving.
; This code is taken from the keypad and frequency meter examples in the Designing with
; Microcontrollers textbook. The subroutine getkey reads the keypad value and blocks if no
; key is available. There is a single byte buffer for the keypad value. The LCD display driver
; is interrupt driven so that the timing delays won't interfere with the control of the motors.
; The subroutines lcd_line1 and lcd_line2 position the cursor at the start of the first and
; second lines, respectively, while msg_out displays the 0-byte terminated character string
; passed to it in X, and putlcd displays the character passed to it in A. These functions will
; block only if the 32 byte buffer is filled, so typically an entire message can be queued for
; display without blocking.
; The main routine ("idle process") reads the key presses, saves the command in variables running,
; reverse, and speed, then updates the LCD display by writing a new status message.
; In the DC motor version, a PWM channel is used to control the speed. Since the PWM generates a
; continuous pulse train without program intervention, the main routine has additional code to
; set the direction (by changing the H-Bridge inputs) and speed (by changing the pulse width).
; In the stepper motor version, a timer channel interrupt is used to advance the H-Bridge through the
; four phases. The LED row display shows the values for the driver enables (bits 7 and 6) and
; the motor drives (bits 3 to 0).
Following is the
brief description of the pre-installed hardware test program:
; Test.asm --- Test program for Dragon12-Plus board, (c)2007, EVBplus.com
; Author: Wayne Chu
;
; Function: This is the factory test program for checking on-board
; hardware only. It checks the DIP switch of port H, the 8 LEDs of
; port B, the pushbuttons SW2(PH3)-SW5(PH0), and the LCD display.
; It scans the keypad and shows key numbers on 7-segment
; LED display while playing a song. It allows to
; adjust the trimmer pot to change LED display's brightness.
;
; New functions for the Dragon12-Plus board:
; The shifting speed of the 7-segment display is controlled by
; the photosensor Q1 (the darker ambient light, the faster shifting),
;
; The music playing tempo is controlled by the temp sensor U14,
; (the hotter temp, the slower tempo).
; Operating instructions:
; Before running the test program, place all individual DIP
; switches at upper (north) positions.
;
; 1. After running the test program, test each individual switch and
; see the corresponding status on the PB0-PB7 LEDs.
; LCD display shows: "PRESS SW2 & SW5 "
;
"WHEN 8DIP-SWs UP"
;
; 2. Test the pushbutton switches PH0-PH3 only when all
; PH0-PH3 switches on the DIP switch are in the upper positions.
; LCD display shows: "PRESS SW2 & SW5 "
;
"WHEN 8DIP-SWs UP"
;
; 3. Set all individual DIP switches at the upper positions.
; Press the pushbutton switches SW2 and SW5 simultaneously, and the
; music should come out. The hex number 0 to F should be
; shifting out on the 7 segment LED display. The RX LED should be off
; and the TX LED should be on.
; LCD display shows: "TESTING IR LIGHT"
;
"NO OBJECT NEARBY"
; 4. Adjust the trimmer pot, the 7 segment LED display's brightness
; should change. If you press any key on the keypad, the 7 segment
; display will display the key number that you pressed.
; LCD display shows: "TESTING IR LIGHT"
;
"NO OBJECT NEARBY"
; 5. Place your hand at 6" in the front of the IR transceiver,
; and to allow the IR light reflect. Both the RX LED and TX LED
; should be on, then observe the message on the LCD display.
; See IR_sen.asm for details.
; LCD display shows: "TESTING IR LIGHT"
;
" OBJECT DETECTED"
; 6. Place your hand over the photo sensor, the 7-segment display will
; shift faster.
; 7. Use a solder iron to touch the temp sensor (U14). Do not overheat it.
; As soon as the tempo of music gets slower remove the iron.
; 8. Place a jumper wire from COL of the opto-coupler to +5V and another
; jumper wire from EMIT of the opto-coupler to the Logic Probe, then
; press key number 1 on the keypad, the Logic Probe LED will be lit.
; 9. Press key number 2 on the keypad the relay will be turned on.
|
|
|