'---------------------------------------------------------------------------------------- ' Name: Varying_Pulse_Output.TIG ' Type: TIGER-BASIC(tm) Source Code ' Purpose: Demo for pulse output with varying duty and cycle settings without pauses ' using the reload buffer ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' This demo program was compiled with Tiger-BASIC 5.01 for the Plug & Play Lab ' carrying a Tiny-Tiger or BASIC-Tiger. ' Pins needed are: ' L70 Input, level determines pulse settings ' L86 Pin on which pulses are outputted ' ' This program demonstrates how to output pulses with varying duty and cycle settings. ' The duty and cycle for the pulse to be output is determined by the level of pin L70. ' When the state changes, the new settings become active. The pulse count is set from ' endless to 10 and the new pulse settings are written to the reload buffer. This ' ensures a fluent transition from one output to the other. ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' variables must be declared #INCLUDE UFUNC3.INC ' User-Function-Codes LONG count ' count is LONG WORD duty, cycle ' duty and cycle are WORD BYTE Inp, OldInp, EVER ' some help variables TASK MAIN ' begin of task MAIN INSTALL_DEVICE #1, "LCD1.TDD" ' install 4x20 LC display INSTALL_DEVICE #3, "TIMERA.TDD", 1, 125 ' base frequency 20 kHz INSTALL_DEVICE #4, "PLSO2_86.TDD" ' pulse output on L86 DIR_PORT 7, 255 ' port 7 is input OldInp = 255 ' preset old input value Inp = 255 ' preset current input value count = 0 ' no of pulses: endless duty = 20 ' duty = 1 ms (20 * 0.05 ms) = 50% cycle = 40 ' cycle = 2 ms (40 * 0.05 ms) PUT #4, #0, count, duty, cycle ' start pulse output FOR EVER = 0 TO 0 STEP 0 ' endless loop IN 7, Inp ' read port 7 IF Inp <> OldInp THEN ' if change at port 7 OldInp = Inp ' save new level PRINT #1, "<1>Input ="; Inp ' print port 7 level SWITCH Inp ' do depending on input state CASE 255: ' port 7, bit 0 = 1 (high) count = 10 ' output ten more pulses with old values PUT #4, #0, #134, count ' set new value for no. of pulses count = 0 ' unlimited pulses duty = 20 ' duty = 1 ms (20 * 0.05 ms) = 50% cycle = 40 ' cycle = 2 ms (40 * 0.05 ms) PUT #4, #1, count, duty, cycle ' write new output values in reload buffer CASE 254: ' port 7, bit 0 = 0 (low) count = 10 ' output ten more pulses with old values PUT #4, #0, #134, count ' set new value for no. of pulses count = 0 ' unlimited pulses duty = 10 ' duty = 0.5 ms (10 * 0.05 ms) = 50% cycle = 20 ' cycle = 1 ms (20 * 0.05 ms) PUT #4, #1, count, duty, cycle ' write new output values in reload buffer ENDSWITCH ' end of CASE selection ENDIF ' end of IF branch NEXT ' end of endless loop END ' end of task MAIN