diff --git a/.gitignore b/.gitignore index 278494b..e333c41 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.hex *.obj + +*.cof diff --git a/MakeHexFiles.bat b/MakeHexFiles.bat new file mode 100644 index 0000000..d0987fd --- /dev/null +++ b/MakeHexFiles.bat @@ -0,0 +1,45 @@ +REM build script v2.0 by Chris Osgood 2013-09-07 http://lunarflow.com/ + +@echo off +SETLOCAL enabledelayedexpansion + +IF "%1"=="" ( + FOR /F "tokens=1,2,*" %%i in (Makefile) DO ( + IF "%%i"=="ALL_TARGETS" ( + FOR %%F IN (%%k) DO ( + call :DoCompile %%~nF + IF !errorlevel! NEQ 0 goto error + ) + goto exit + ) + ) +) else ( + FOR %%F IN (%*) DO ( + call :DoCompile %%~nF + IF !errorlevel! NEQ 0 goto error + ) +) + +:exit +pause +goto :eof + +:error +echo ********** ERROR ********** +pause +goto :eof + +:DoCompile +echo. +echo ========== BUILD "%1" ========== +echo. +IF NOT EXIST %1.asm ( + COPY tgy.asm %1.asm + avra -fI -o %1.inc.hex -D %1_esc -e %1.eeprom -d %1.obj %1.asm + SET err=!errorlevel! + DEL %1.asm +) else ( + avra -fI -o %1.inc.hex -D %1_esc -e %1.eeprom -d %1.obj %1.asm + SET err=!errorlevel! +) +exit /B !err! diff --git a/avra.exe b/avra.exe new file mode 100644 index 0000000..453c098 Binary files /dev/null and b/avra.exe differ diff --git a/rct30nfs.inc b/rct30nfs.inc new file mode 100644 index 0000000..9361aea --- /dev/null +++ b/rct30nfs.inc @@ -0,0 +1,77 @@ +;*************************************************************** +;* For RCTimer NFS 30A all n-Channel FETs * +;* Original fuses are -U lfuse:w:0x2f:m -U hfuse:w:0xCA:m * +;* By Nils Högberg * +;* * +;* https://github.com/sim-/tgy * +;*************************************************************** + +.equ F_CPU = 16000000 +.equ USE_INT0 = 0 ; used by channel C +.equ USE_I2C = 0 ; We could, no FETs are on the I2C ports +.equ USE_UART = 1 +.equ USE_ICP = 1 + + +;********************* +; PORT D definitions * +;********************* + +.equ ApFET = 4 +.equ AnFET = 5 +.equ BpFET = 3 +.equ BnFET = 7 +.equ CpFET = 2 + +.equ txd = 1 +.equ rxd = 0 + +.equ INIT_PD = (1< ?V at ADC2) +.equ mux_temperature = 1 ; ADC1 temperature input (100 from +5V, ?k NTC to gnd at ADC1) + + +.equ O_POWER = 220 +.equ O_GROUND = 39 + +.equ INIT_PC = 0 ;(1< ?V at ADC2) + + + +.equ O_POWER = 10 +.equ O_GROUND = 1 + +.equ INIT_PC = 0 +.equ DIR_PC = 0 + +;********************* +; PORT B definitions * +;********************* +;.equ = 5 ; SCK +;.equ = 4 ; MISO +;.equ = 3 ; MOSI +.equ AnFET = 2 +.equ BnFET = 1 +.equ CnFET = 0 + +.equ INIT_PB = 0 +.equ DIR_PB = (1<0: hard-coded number of cells (for reliable LVC > ~4S) .equ BLIP_CELL_COUNT = 0 ; Blip out cell count before arming .equ DEBUG_ADC_DUMP = 0 ; Output an endless loop of all ADC values (no normal operation) @@ -208,10 +212,10 @@ ; These are now defaults which can be adjusted via throttle calibration ; (stick high, stick low, (stick neutral) at start). ; These might be a bit wide for most radios, but lines up with POWER_RANGE. -.equ STOP_RC_PULS = 1060 ; Stop motor at or below this pulse length -.equ FULL_RC_PULS = 1860 ; Full speed at or above this pulse length -.equ MAX_RC_PULS = 2400 ; Throw away any pulses longer than this -.equ MIN_RC_PULS = 768 ; Throw away any pulses shorter than this +.equ STOP_RC_PULS = 1000 ; Stop motor at or below this pulse length +.equ FULL_RC_PULS = 2000 ; Full speed at or above this pulse length +.equ MAX_RC_PULS = 2060 ; Throw away any pulses longer than this +.equ MIN_RC_PULS = 940 ; Throw away any pulses shorter than this .equ MID_RC_PULS = (STOP_RC_PULS + FULL_RC_PULS) / 2 ; Neutral when RC_PULS_REVERSE = 1 .equ RCP_ALIAS_SHIFT = 3 ; Enable 1/8th PWM input alias ("oneshot125") .equ BEEP_RCP_ERROR = 0 ; Beep at stop if invalid PWM pulses were received @@ -237,18 +241,18 @@ ; Number of PWM steps (too high and PWM frequency drops into audible range) .if !defined(POWER_RANGE) -.equ POWER_RANGE = 800 * CPU_MHZ / 16 + MIN_DUTY +.equ POWER_RANGE = 1000 * CPU_MHZ / 16 + MIN_DUTY .endif .equ MAX_POWER = (POWER_RANGE-1) .equ PWR_COOL_START = (POWER_RANGE/24) ; Power limit while starting to reduce heating -.equ PWR_MIN_START = (POWER_RANGE/6) ; Power limit while starting (to start) -.equ PWR_MAX_START = (POWER_RANGE/4) ; Power limit while starting (if still not running) +.equ PWR_MIN_START = (POWER_RANGE/3) ; Power limit while starting (to start) +.equ PWR_MAX_START = (POWER_RANGE/2) ; Power limit while starting (if still not running) .equ PWR_MAX_RPM1 = (POWER_RANGE/4) ; Power limit when running slower than TIMING_RANGE1 .equ PWR_MAX_RPM2 = (POWER_RANGE/2) ; Power limit when running slower than TIMING_RANGE2 .equ BRAKE_POWER = MAX_POWER*2/3 ; Brake force is exponential, so start fairly high -.equ BRAKE_SPEED = 3 ; Speed to reach MAX_POWER, 0 (slowest) - 8 (fastest) +.equ BRAKE_SPEED = 6 ; Speed to reach MAX_POWER, 0 (slowest) - 8 (fastest) .equ LOW_BRAKE_POWER = MAX_POWER*2/3 .equ LOW_BRAKE_SPEED = 5 @@ -262,8 +266,8 @@ .if !defined(START_DELAY_US) .equ START_DELAY_US = 0 ; Initial post-commutation wait during starting .endif -.equ START_DSTEP_US = 8 ; Microseconds per start delay step -.equ START_DELAY_INC = 15 ; Wait step count increase (wraps in a byte) +.equ START_DSTEP_US = 6 ; Microseconds per start delay step +.equ START_DELAY_INC = 12 ; Wait step count increase (wraps in a byte) .equ START_MOD_INC = 4 ; Start power modulation step count increase (wraps in a byte) .equ START_MOD_LIMIT = 48 ; Value at which power is reduced to avoid overheating .equ START_FAIL_INC = 16 ; start_tries step count increase (wraps in a byte, upon which we disarm)