28.01.2018 14:22
Který řádek definuje nulový plyn 1 '=============================================================================== 2 ' 3 ' V E R S A T I L E E N G I N E S O U N D U N I T 4 ' 5 ' PROGRAM 1 OF 4 - SPEED DEMAND PROCESSING 6 ' 7 '=============================================================================== 8 ' VERSION 2.0 14th October 2008 © A.F.Bond 2008 9 ' 10 ' (ONLY FOR USE IN CONJUNCTION WITH v2.0 SOUND GENERATION MODULES) 11 '=============================================================================== 12 ' 13 ' This module manipulates and scales the input signal from a radio control 14 ' receiver prior to generating a 4Khz PWM signal whose duty cycle varies 15 ' in a quasi logarithmic manner with the throttle position. A 25 element lookup 16 ' table defines the control law to take account of the logarithmic nature of 17 ' sound plus the sound generation PIC's fixed processing time overheads which 18 ' occupy an increasingly disproportionate amount of the silent period as the 19 ' engine speed increases. Overall this yields a linear sounding throttle 20 ' response. A bi-directional throttle channel is assumed with neutral/stop based 21 ' on receiving a 1.5mSec pulsewidth. Full ahead therefore relates to a 1mSec 22 ' pulse and full astern to a 2mSec pulse. 23 ' 24 ' The code assumes a negative going pulse as the receiver signal has been 25 ' inverted by an input buffer stage - included for compatibility with 2.4GHz 26 ' sets which have insufficient output voltage swing to drive the PICAXE direct. 27 ' 28 ' The PWM signal from this module is low pass filtered and the dc level that 29 ' results is used as the control voltage for the sound generation module. 30 ' 31 ' NOTE: In the description below be aware that PIN1, PIN2 etc are virtual 32 ' pins and not to be confused with the device's phyical pins, which in PICAXE 33 ' parlance are refered to as 'legs' 34 ' 35 '=============================================================================== 36 37 'VARIABLE DEFINITIONS 38 symbol speed=w0 'assign variable to speed demand 39 40 'INITIALISATION 41 setfreq m8 'set 8 Mhz operation to yield 5uSec resolution 42 43 44 45 'MAIN LOOP 46 main: 47 'get throttle demand from receiver at "PIN3" and assign it to the variable 'speed' 48 pulsin 3,0,speed 49 'note: 1 to 2 mSec will equate to values for 'speed' in the range 200 to 400 50 51 'now scale speed 0 to 100 in fwd and reverse 52 if speed>300 then 53 speed=speed-300 54 else 55 speed=300-speed 56 end if 57 58 'guard against over-range 1 C:\VERSATILE MARINE ENGINE\V2.0 SOFTWARE\SPEED DEMAND.BAS 59 if speed>100 then 60 speed=100 61 end if 62 63 'quantise speed into 25 values for lookup table 64 speed=speed/4 65 66 'scale logaritmically for use by PWM command (duty cycle 0 to 100% = 0 to 800) 67 lookup speed,(0,0,126,217,296,365,425,478,524,564,599,629,655,678,698,715,730,743,755,765,774,782,789,795,800) ,w1 68 69 70 'assert PWM train on "PIN2" 71 pwmout 2,199,w1 72 73 goto main 74 75 76 77 78 '=============================================================================== 79 ' VERSION HISTORY 80 '=============================================================================== 81 82 'v1.0 1st October 2008 83 'first release 84 85 86 'v2.0 14th October 2008 87 'Logarithmic lookup table function moved from sound generation modules into 88 'this module.This yielded spare program space in the sound generation modules 89 'and allowed a longer lookup table to be used without code execution time 90 'problems as this code only has to run at the transmitter frame rate rather 91 'than the engine revolution rate. The resulting throttle response of the 92 'overall system is thereby much smoother. 93 '===============================================================================
ReelyElektroRockCrawler/JeepWrangler AxialSCX10/JeepWranglerRubicon HimotoHI4170/Shortcourse TrialCar/AxialSCX10/Chassis homemade/ChevroletEarly50sPickup TrucTrialCar/HomemadeSCX11.2/Chassis homemade/V3s (Vejtřaska)Závodní model