Отговори на тема  [ 12 мнения ] 
За PIC12F629 и съвместимостта му с 12С508А 12С509А 
Автор Съобщение
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение За PIC12F629 и съвместимостта му с 12С508А 12С509А
Пичове, имам следната дилема... :oops:
Имам следната програмка за нещо като димер ключ, но ще го ползвам в радиоуправление за повишаване, намаляване на оборотите на моторче. Оригинално хекса е за 12F629, но го сметнах за съвместим с 12С509А и го нахендрих вътренка...и както се сещате нищо не се случи. Та затова питам, има ли някакви особености и въобще дали е възможно да го метна на някой от двата типа дето имам 508 или 509. Програмката е кратка, но аз съм пълен гьон за програмиране. Поствам го тук освен за въпроса и заради интереса, който може да прояви някой към това чудо.
хекса е:
:100000008316FF23900083122828820700340034CF
:100010002D3440344E345B3465346F34783481345D
:100020008934913498349F34A634AC34B234B83423
:10003000BE34C334C834CD34D234D734DC34E134A4
:10004000E634EB34F034F534FA34FF34FF34FF3463
:10005000A001A1012B282C282D282E282F2830285C
:10006000A00B2A28A10B2A2883160C3085008101B9
:10007000043095008312073099008501A3010130F7
:10008000A400051D4728851D4D285B204128A40A92
:10009000213024020318A4035028A4030319A40A3E
:1000A00024080520A3000C30A1005B20A00B5528DC
:1000B000A10B552841282308A207031C851003180B
:0C00C00085140000000000000000080093
:02400E00943FDD
:00000001FF

а листа:

PM Assembler 4.05, Copyright (c) 1995, 2002 microEngineering Labs, Inc. Page 1

1 ; ******* bitsc ***** ESC for toy car Rx
2
3 ; For mosfet with resistor glued on top of pic.
4 ; Needs its two input connections from the bit
5 ; charger reveiver to be active positive when
6 ; Tx button not pushed, negative when pushed.
7 ; For breadboarding with push buttons instead of
8 ; connections to the Rx, use a 50K pullup
9 ; resistor to the positive rail from Pic's pin 4.
10 ; Uses reverse exponential lookup table for mtr
11 ; speed control.
12
13
14
15 maclib 'P12F629.inc'
16
17
18 device PIC12F629,intrc_osc,wdt_off,mclr_off,bod_off,pwrt_off,cpd_
19
20 data
21 org 32
22
23
24 0020- tmp ds 1 ;general purpose counter
25 0021- cnt ds 1 ;same
26 0022- acc ds 1 ;acumulator for motor channel
27 0023- dty ds 1 ;duty cycle for motor channel
28 0024- speed ds 1 ;motor speed for table lookup
29
30
31 =0085 mtr = gpio.1 ;output for motor PWM
32 =0185 down = gpio.3 ;input for decrease speed
33 =0105 up = gpio.2 ;input for increase speed
34 =000C inputs = 001100b ;inputs on gp3 and 2
35
36 code
37 org 0
38
39 0000- 1683 setb rp0 ;switch to page 1
40 0001- 23FF call 03ffh ;fetch osccal nomber (for 1st time chip prgmi
41 0002- 0090 mov osccal,w ;move it into osccal (for 1st time chip prgmi
42 ; mov osccal,#112 ;move cal# previously found at 03FF into oscc
43 ;use this method after 1st time chip programm
44 0003- 1283 clrb rp0 ;switch back to page 0
45 0004- 2828 jmp start
46
47 0005- 0782 table jmp pc+w
48 0006- 3400 3400 342D 3440 retw 0,0,45,64,78,91,101,111,120,129,137,145,152,159,166,172,17
000A- 344E 345B 3465 346F
000E- 3478 3481 3489 3491
0012- 3498 349F 34A6 34AC
0016- 34B2 34B8
49 0018- 34BE 34C3 34C8 34CD retw 190,195,200,205,210,215,220,225,230,235,240,245,250,255,25
001C- 34D2 34D7 34DC 34E1
0020- 34E6 34EB 34F0 34F5
0024- 34FA 34FF 34FF 34FF
50
51 0028- 01A0 start clr tmp
PM Assembler 4.05, Copyright (c) 1995, 2002 microEngineering Labs, Inc. Page 2

52 0029- 01A1 clr cnt
53 002A- 282B settle jmp $+1 ;wait aprox 1 sec
54 002B- 282C jmp $+1
55 002C- 282D jmp $+1
56 002D- 282E jmp $+1
57 002E- 282F jmp $+1
58 002F- 2830 jmp $+1
59 0030- 0BA0 282A djnz tmp,settle ;for processor to settle
60 0032- 0BA1 282A djnz cnt,settle
61 0034- 1683 setb rp0 ;switch to page 1
62 0035- 300C 0085 mov trisio,#inputs ;set inputs
63 0037- 0181 clr option ;enable global pullups
64 0038- 3004 0095 mov wpu,#000100b ;enable gp2 pullup
65 003A- 1283 clrb rp0 ;back to page 0
66 003B- 3007 0099 mov cmcon,#00000111b ;free gpio.0,1,2 (set comparator to off)
67 003D- 0185 clr gpio
68 003E- 01A3 clr dty
69 003F- 3001 00A4 mov speed,#1 ;speed needs value other than zero
70 0041- 1D05 2847 getsigs jnb up,incrse ;go if up pin lo (bit not set)
71 0043- 1D85 284D jnb down,decrse ;go if down pin lo (bit not set)
72 0045- 205B call pwm ;keep up pwm
73 0046- 2841 jmp getsigs ;keep looping
74
75 0047- 0AA4 incrse inc speed ;inc speed index
76 0048- 3021 0224 1803 csb speed,#33 ;compare & skip next if speed < 33
77 004B- 03A4 dec speed ;if speed = 33 then dec speed
78 004C- 2850 jmp getw ;jump around decrease speed
79 004D- 03A4 decrse dec speed ;dec speed index
80 004E- 1903 snz ;skip next if speed not down to zero
81 004F- 0AA4 inc speed ;if it is zero then inc it
82 0050- 0824 getw mov w,speed ;speed goes to w for table lookup
83 0051- 2005 call table ;get value from table
84 0052- 00A3 mov dty,w ;and transfer to dty
85 0053- 300C 00A1 mov cnt,#12 ;setup cnt for looping
86 0055- 205B next call pwm ;keep up pwm while looping here for
87 0056- 0BA0 2855 djnz tmp,next ;about 3/4 sec to slow down constant
88 0058- 0BA1 2855 djnz cnt,next ;repeating before going back to check
89 005A- 2841 jmp getsigs ;signals from Tx
90
91 005B- 0823 07A2 pwm add acc,dty ;add duty to accumulator
92 005D- 1C03 sc ;if add carried then
93 005E- 1085 clrb mtr ;skip clearing motor bit
94 005F- 1803 snc ;if add didn't carry then
95 0060- 1485 setb mtr ;skip setting motor bit
96 0061- 0000 nop ;add some time here
97 0062- 0000 nop
98 0063- 0000 nop
99 0064- 0000 nop
100 0065- 0008 ret
101
102
103
104

Такааа...значи като го записвах, му дадох интърнал RC, отмаркирах MCLR и CP, а WDT го оставих с чавка.
Де сгреших или въобще не е трябвало да почвам.. 8O :D :roll:
/то ясно, че ще си търся 629-ката да си купувам...ама дотогава ме сърбят пръстите, а след работно време няма как да се докопам до работещ магазин..та явно покупката ще се разтегне във времето/


Прикачени файлове:
Коментар на файл: Схема на джеджавката
BitSC schematic.JPG
BitSC schematic.JPG [ 23.03 KiB | Прегледано 4624 пъти ]
Вто Окт 18, 2005 5:36 pm
Профил
Ранг: Форумен бог
Ранг: Форумен бог
Аватар

Регистриран на: Чет Фев 24, 2005 10:41 pm
Мнения: 1027
Местоположение: Pz
Мнение 
Сега оня нахендрения чип със чиста съвест можеш да го хвърлиш. И друг път да питаш преди да правиш... ненужни разходи :lol: :lol: :lol:
С почти същия успех можеш да запишеш тоя хекс в някой операционен усилвател - и те са с 8 пина (повечето) :D


Вто Окт 18, 2005 6:19 pm
Профил ICQ
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение 
Gogo написа:
Сега оня нахендрения чип :lol: :lol: :lol:
:D

:lol: :lol: :lol: Това го знам...нали са и еднократни на сичкото отгоре... :lol: Ама поне сина си запоява некви паяци и мухи с тех...прави си некво АРТ...балига...
Ама нищо не каза ЗАЩО? А мна мен тванкъ ми е въпроса... :?: И дали също.


Вто Окт 18, 2005 7:30 pm
Профил
Ранг: Форумен бог
Ранг: Форумен бог
Аватар

Регистриран на: Чет Фев 24, 2005 10:41 pm
Мнения: 1027
Местоположение: Pz
Мнение 
С три думи - нямт нищо общо (почти)... За повече инфо иди на сайта на майкрочип и си свали дейташитовете на двата пика.


Вто Окт 18, 2005 7:44 pm
Профил ICQ
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение 
Gogo написа:
С три думи - нямт нищо общо

А ми странно...Направих си много успешно дешифратор на 4 пропорционални канала с програма писана за 12F629, която е на всичкото отгоре доста дълга... и тръгна без проблеми на 508-цата.:roll:
Е...там си пишеше изрично за кои става...ама щом тази дългата става...значи някъде в туй мъничето или или има кво да се пипне, или са съвместими /така си мислех аз.../. Ама нали на начинаещите морето им е до коляно....

Те я и успешната серия:
rxdecode.asm Pulse Position Modulation Decoder for 4 Channel Rx
;***************************************************************************
; Bruce Abbott bhabbott@paradise.net.nz
;
; for Microchip PIC 12C508, 12C509, 12F629 or 12F675.
;
;============================= Description =================================
;
; PPM DECODER:
;
; Each frame consists of 4 to 8 channels (5 to 9 pulses), followed by a sync
; gap. We only decode the first 4 channels.
;
; The width of each channel is 1 to 2mS (1.5mS when sticks centered). The
; sync gap is at least 2.5mS long, and frame length is approximately 20mS.
;
; The input signal should look something like this:-
;
; |<------------------ 1 frame (~20mS) -------------------->|
; |< 1~2mS >|
; _ _ _ _ _ _
; ___________| |_______| |______| |______| |______| |__ // ____________| |____
; sync gap ch1 ch2 ch3 ch4 etc. sync gap ch1
;
; NOTE: This waveform shows positive 'shift'. If your Rx outputs negative
; 'shift', the waveform is inverted.
;
; There is just enough time to generate four decoded outputs after receiving
; channel 4, and before the end of the sync gap.
;
; GLITCH FILTER:
;
; Each channel is averaged with the value from the previous frame, reducing
; servo jitter on weak signals. If any channel in a frame is corrupted, the
; whole frame is discarded and the last good frame is used instead.
;
; FAILSAFE:
;
; On receiving a sufficient number of good frames we save it for failsafe.
; Then, if the signal is corrupted for too long, we output the failsafe frame
; instead of the last good frame.
;
; THROTTLE ARMING:
;
; When entering failsafe the throttle is cut, and it will not be restarted
; until a good signal is detected AND the throttle is manually reset. This
; should prevent the situation where motor-induced RF interference causes
; the decoder to cycle in and out of failsafe repeatedly.
;
; For this feature to work the throttle channel has to be determined. Futaba
; and Hitec tranmitters assign the throttle to channel 3. JR, Airtronics and
; GWS use channel 1.
;
; Some ESC's need to have the throttle set to maximum at startup, perhaps to
; disable the brake or to enter programming mode. Therefore, channel 1 is
; designated as throttle if it measures less than 1.3mS or more than 1.7mS at
; startup, otherwise channel 3 is assumed.
;
; The throttle channel is forced to 1.05mS during failsafe, rather than set
; to its failsafe value, in case that value was full throttle!
;
; =============================================================================
; Summary of Changes
;
; 2003/12/2 V0.5 - Initial release
;
; 2003/12/27 V0.6 - ASM Error if 'addwf PCL' not in page 0.
; - Select processor via MPLab's Device Select menu.
; 2004/1/7 V0.7 - No output until failsafe frame captured. Should now be
; compatible with JR/GWS transmitters (throttle on CH1).
;
; 2004/1/9 V0.8 - Increased range to 0.75~2.28mS, now accepts >125% throws.
; Resolution is slightly reduced (from 5uS to 6uS).
; - Failsafe and Hold frames now use averaged output values.
; - Ignore missing 4th channel (for 3 channel TX) NOT TESTED!
;
; 2004/2/15 V0.9 - Fixed bug:- OSCCAL not initialized in 12F675 code!
; - Detect throttle channel. The throttle is held OFF after
; failsafe, until re-armed manually. This prevents cyling
; into and out of failsafe due to electrical noise coming
; from the motor.
;
; 2004/6/20 V1.0 - Using TMR0 to detect loss of signal. This prevents lockup
; during a clean signal loss (no noise) which may occur if
; used in a receiver which has muting.
; - TMR0 is also used to set frame repeat time in failsafe.
; - Fixed bug:- Initial channel output values were wrong.
;
; 2004/10/24 V1.1 - Positive and Negative shift versions.
; - Ignore short glitches on signal transitions.
; - Ensure throttle is low in failsafe, even if it was maxiumum
; at startup (possible requirement for ESC programming).
;
; 2004/12/12 V1.2 - Fixed bug: JR throttle arming was disabled due to a typo!
;
; 2005/1/20 V1.3 - Now accepts pulse widths from 180uS to 700uS.
;
; -----------------------------------------------------------------------------

#DEFINE version "1.3"

#DEFINE ARM_THROTTLE ; enable if throttle arming control wanted.
#DEFINE DETECT_JR ; enable for JR/Airtronics/GWS throttle detection.

;#DEFINE Negative_Shift ; enable for Futaba/Hitec on 72MHz


; Make sure that PROCESSOR and <include> file are compatible with your CPU!
; 12C508(A) and 12C509(A) can use 12C508 definitions. 12F629 can use 12F675
; definitions (just don't try to use the A/D module...)

;#DEFINE __12C508 ; enable if processor not specified elsewhere
;#DEFINE __12F675 ; (MPLAB:- use menu <Configure/Select_Device>)

;#DEFINE NO_OSCCAL ; enable if OSCCAL value was erased!


ifdef __12C508
PROCESSOR PIC12C508
INCLUDE <P12C508.inc>
__CONFIG _MCLRE_OFF&_CP_OFF&_WDT_ON&_IntRC_OSC
else
PROCESSOR PIC12F675
INCLUDE <P12F675.inc>
__CONFIG _MCLRE_OFF&_CP_OFF&_WDT_ON&_BODEN_ON&_INTRC_OSC_NOCLKOUT
endif

radix dec

errorlevel 0,-305,-302


; Bit definitions for the GPIO register and the TRIS register

#DEFINE CH_1 0 ; pin 7 Channel 1 output
#DEFINE CH_2 1 ; pin 6 Channel 2 output
#DEFINE CH_3 2 ; pin 5 Channel 3 output
#DEFINE PPM_in 3 ; pin 4 input pulse stream
#DEFINE CH_4 4 ; pin 3 Channel 4 Output
#DEFINE LED 5 ; pin 2 Signal Indicator LED

#DEFINE TrisBits H'FF'&~((1<<CH_1)|(1<<CH_2)|(1<<CH_3)|(1<<CH_4)|(1<<LED))


; Bits to be set with the OPTION instruction
; No wake up
; No weak pullups
; Timer 0 source internal
; Prescaler to Timer 0, divide by 256.
;
#DEFINE OptionBits B'11000111'

; =========================================================================
; Macro for generating short time delays
;
NO_OP MACRO count
NO_OP_COUNT SET count
WHILE NO_OP_COUNT>1
goto $+1 ; 2 clocks
NO_OP_COUNT SET NO_OP_COUNT-2
ENDW
IF NO_OP_COUNT
nop ; 1 clock
ENDIF
ENDM

;===========================================================================
; Macro to create offsets for variables in RAM
;
ifdef __12C508
ByteAddr SET 7
else
ByteAddr SET 32 ; user RAM starts here
endif

BYTE MACRO ByteName
ByteName EQU ByteAddr
ByteAddr SET ByteAddr+1
ENDM

; ==========================================================================
; RAM Variable Definitions
;
BYTE Flags ; various boolean flags

BYTE PPMcount ; pulse length. 1~255 = 0.75~2.28mS

BYTE PPM_1 ; channel 1 in
BYTE PPM_2 ; channel 2 in
BYTE PPM_3 ; channel 3 in
BYTE PPM_4 ; channel 4 in

BYTE PWM_1 ; channel 1 out
BYTE PWM_2 ; channel 2 out
BYTE PWM_3 ; channel 3 out
BYTE PWM_4 ; channel 4 out

BYTE PMM_1 ; channel 1 memory
BYTE PMM_2 ; channel 2 memory
BYTE PMM_3 ; channel 3 memory
BYTE PMM_4 ; channel 4 memory

BYTE FLS_1 ; channel 1 failsafe
BYTE FLS_2 ; channel 2 failsafe
BYTE FLS_3 ; channel 3 failsafe
BYTE FLS_4 ; channel 4 failsafe

BYTE GoodFrames ; No. of good frames to go before
; accepting failsafe frame.

BYTE HoldFrames ; No. of bad frames to go before going
; to failsafe

BYTE ArmFrames ; No. of low throttle frames to go
; before arming throttle.
BYTE Temp1
BYTE Temp2



; flag values
;
#DEFINE WATCH 0 ; Watchdog timeout
#DEFINE GOT_FS 1 ; have captured failsafe frame
#DEFINE GOT_4 2 ; 4 channels found in current frame
#DEFINE DET_4 3 ; 4 channel TX detected
#DEFINE JR 4 ; JR throttle detected
#DEFINE ARMED 5 ; throttle armed

; number of consecutive good frames required at startup.

#DEFINE GOODCOUNT 10

; number of consecutive bad frames accepted without going to failsafe.

#DEFINE HOLDCOUNT 25

; number of consecutive low throttle frames required before arming.

#DEFINE ARMCOUNT 10


; macros for working with negative or positive shift

skip_PPM_high MACRO
ifdef Negative_Shift
btfsc GPIO,PPM_in
else
btfss GPIO,PPM_in
endif
ENDM

skip_PPM_low MACRO
ifdef Negative_Shift
btfss GPIO,PPM_in
else
btfsc GPIO,PPM_in
endif
ENDM

;****************************************************************************
; Code
;
ORG 0
goto ColdStart

;-------------------------- version string ----------------------------------

org 8
ifdef __12C508
dt "RXDEC508"
endif
ifdef __12F629
dt "RXDEC629"
endif
ifdef __12F675
dt "RXDEC675"
endif
dt "--V"
dt version
dt "--"
ifdef ARM_THROTTLE
dt "ARMTHROT"
endif
ifdef DETECT_JR
dt "DETECTJR"
endif
ifdef Negative_Shift
dt "NEG_SHFT"
endif

;============================================================================

ColdStart:
bcf Flags,WATCH
btfss STATUS,NOT_TO ; copy Watchdog timeout flag
bsf Flags,WATCH

; get oscillator calibration value and use it to fine-tune clock frequency.
; 12C508/9 has value in W at startup, 12F629/75 gets it from RETLW at 0x3ff.

ifdef __12C508
ifdef NO_OSCCAL
movlw 0x90 ; replace with value for your PIC!
endif
movwf OSCCAL ; set oscillator calibration
else
bsf STATUS,RP0 ; register bank 1 (12F629/75)
call 0x3ff ; get OSCCAL value
movwf OSCCAL ; set oscillator calibration
bcf STATUS, RP0 ; register bank 0
endif

ifdef __12C508
clrwdt
movlw OptionBits
OPTION
else
clrwdt
bsf STATUS,RP0 ; register bank 1 (12F629/75)
movlw OptionBits
movwf OPTION_REG
bcf STATUS,RP0 ; register bank 0
clrwdt
endif


; initialise I/O registers

ifdef __12C508
clrf GPIO ; all outputs low
movlw TrisBits
TRIS GPIO ; set I/O pin directions
else
clrf GPIO ; all outputs low
bsf STATUS,RP0 ; register bank 1 (12F629/75)
movlw TrisBits
movwf TRISIO ; set I/O pin directions
ifdef ANSEL
clrf ANSEL ; disable analog inputs (12F675)
endif
bcf STATUS,RP0 ; register bank 0
movlw b'00000111'
movwf CMCON ; Comparator off
endif

; CPU specific stuff done, now we can start the main program!

goto Main

;----------------------------------------------------------------------------
; GetPPM: Get time to next PPM pulse
;----------------------------------------------------------------------------
;
; input: PPM signal has just gone high.
; output: PPMcount = Pulse Width * 6uS, next pulse has started
; error: PPMcount = XX and error code in W.
;
; Error Codes
; 0 = good channel
; 1 = pulse too short, too long, or next pulse too soon
; 2 = no next pulse (ie. no channel)

PRECHARGE = ((750-15)/6) ; = 0.75mS

GetPPM:
movlw PRECHARGE ; preset count for signal high length
movwf PPMcount

movlw (30/6)
movwf Temp1
high_delay: NO_OP 2
decf PPMcount ; wait 30uS to skip short glitches
decfsz Temp1
goto high_delay
hiloop:
skip_PPM_high ; signal gone low ?
goto pulselo
nop ; 6uS per loop
decfsz PPMcount ; count down
goto hiloop
retlw 1 ; timed out, signal high
pulselo:
movlw PRECHARGE-(180/6)
subwf PPMcount,W
skpnc ; less than minimum pulse width ?
retlw 1
movlw PRECHARGE-(700/6)
subwf PPMcount,W
skpc ; greater than maximum pulse width ?
retlw 1

movlw (30/6)
movwf Temp1
low_delay: NO_OP 2
decf PPMcount ; wait 30uS to skip short glitches
decfsz Temp1
goto low_delay
to750uS:
skip_PPM_low ; signal should stay low until 0.75mS
retlw 1
nop ; 6uS per loop
decfsz PPMcount ; count down to zero @ 0.75mS
goto to750uS
incf PPMcount ; count up, start at 1
to2280uS:
skip_PPM_low ; start of next channel pulse ?
retlw 0 ; return OK
nop ; 6uS per loop
incfsz PPMcount ; count up to 256 @ 2.28mS
goto to2280uS
retlw 2 ; return timeout error @ 2.28mS



;------------------------------------------------------------------------------
; Output PPM widths to channels 1-4
;------------------------------------------------------------------------------
Output:
movf PWM_1,W ; get pulse length
bsf GPIO,CH_1 ; start pulse
call Servo_Delay ; delay 6uS*len
bcf GPIO,CH_1 ; finish pulse
movf PWM_2,W
bsf GPIO,CH_2
call Servo_Delay
bcf GPIO,CH_2
movf PWM_3,W
bsf GPIO,CH_3
call Servo_Delay
bcf GPIO,CH_3
movf PWM_4,W
bsf GPIO,CH_4
call Servo_Delay
bcf GPIO,CH_4
retlw 0


;------------------------------------------------------------------------------
; Delay Timer for Output Pulse
;------------------------------------------------------------------------------
;
; input: W=delay count, 1 to 255 = 0.75 to 2.28mS
;

Servo_Delay:
movwf Temp2
movlw (750-6)/6
movwf Temp1
_ds1: nop
clrwdt
nop
decfsz Temp1 ; wait 750uS
goto _ds1
_ds2: nop
clrwdt
nop
decfsz Temp2 ; wait 0~1.53mS, total = 0.75~2.28mS
goto _ds2
retlw 0

;-------------------------------------------------------------------------------
; Millisecond Delay Timer
;-------------------------------------------------------------------------------
; Input: W = number of milliseconds to wait (max 256mS)
;

dx1k: movwf Temp1
_dx1k1: movlw (1000-5)/5
movwf Temp2
_dx1k2: clrwdt ; avoid watchdog timeout
nop
decfsz Temp2 ; wait 1mS
goto _dx1k2
decfsz Temp1
goto _dx1k1
retlw 0


;*******************************************************************************
; Main
;*******************************************************************************


Main: btfsc Flags,WATCH ; did the watchdog timeout ?
goto Failsafe ; oops! try to keep going ...

clrf Flags ; clear all flags

movlw 250 ; wait 500mS for Rx to stabilise
call dx1k ; (signal LED is on)
movlw 250
call dx1k

Start: bsf GPIO,LED ; signal LED off
movlw (1500-750)/6
movwf PMM_1
movwf PMM_2 ; all channel outputs at midpoint
movwf PMM_3
movwf PMM_4

movwf PPM_4 ; init channel 4 (for 3 channel TX)

movlw GOODCOUNT ; set number of good frames required
movwf GoodFrames ; before saving failsafe values.

movlw HOLDCOUNT ; set number of bad frames allowed
movwf HoldFrames ; before going to failsafe.

movlw ARMCOUNT ; set number of low throttle frames
movwf ArmFrames ; before arming throttle

goto no_signal


Failsafe: movlw 1
movwf HoldFrames ; stay in failsafe until signal returns

btfss Flags,GOT_FS ; do we have good failsafe values?
goto no_signal

movf FLS_1,W
movwf PWM_1
movf FLS_2,W ; get failsafe values
movwf PWM_2
movf FLS_3,W
movwf PWM_3
movf FLS_4,W
movwf PWM_4

call Output ; output failsafe frame

bcf Flags,ARMED ; keep throttle OFF
movlw ARMCOUNT
movwf ArmFrames ; reset throttle arming delay

no_signal: bsf GPIO,LED ; signal LED off

wait_sync: clrwdt ; we're still sane, no reset please!

clrf Temp1
movlw 9 ; set 'gap detect' timeout to 23mS
movwf Temp2

wait_gap: skip_PPM_high ; wait for a gap ]
goto time_gap ; ]
nop ; ]
clrwdt ; ]
nop ; ] 10uS per loop
decf Temp1 ; ]
skpnz ; ]
decfsz Temp2 ; timed out ? ]
goto wait_gap ; ]
goto badframe ; can't find sync gap!

time_gap: clrf PPMcount ; reset gap timer

in_gap: decf Temp1 ; }
skpnz ; }
decf Temp2 ; timed out ? }
skpnz ; }
goto badframe ; can't find sync gap! } 10uS per loop
skip_PPM_low ; still in gap ? }
goto wait_gap ; }
incfsz PPMcount ; gap > 2.56mS ? }
goto in_gap ; no, continue timing }

Get_Frame: movlw 128-(23000/256) ; set frame timeout to 23mS
movwf TMR0
wait_1st: clrwdt
btfsc TMR0,7 ; timer reached 23mS ?
goto badframe
skip_PPM_high ; wait for start of first channel
goto wait_1st
bcf Flags,GOT_4 ; channel 4 not received yet
NO_OP 3
call GetPPM ; get first channel
andlw 255
skpz ; process return code
goto badframe
movf PPMcount,W
movwf PPM_1
call GetPPM ; get 2nd channel
andlw 255
skpz
goto badframe
movf PPMcount,W
movwf PPM_2
call GetPPM ; get 3rd channel
andlw 255
skpz
goto badframe
movf PPMcount,W
movwf PPM_3
call GetPPM ; get 4th channel
andlw 255
skpz
goto error4
movf PPMcount,W
movwf PPM_4
bsf Flags,GOT_4
goto update

error4: xorlw 2
skpz ; channel 4 missing ?
goto badframe
btfss Flags,GOT_FS ; got failsafe frame yet ?
goto update ; no, ignore missing channel 4
btfss Flags,DET_4 ; 4 channels detected ?
goto update ; no, ignore missing channel 4

badframe: clrwdt
movlw 128-((23000-9000)/256); timer reached 9mS ?
subwf TMR0,w
skpc ; wait 9mS to skip other channels
goto badframe
movlw ARMCOUNT ; reset throttle arming delay
movwf ArmFrames
decfsz HoldFrames ; too many bad frames ?
goto hold
goto Failsafe

hold: btfsc Flags,GOT_FS ; good frame available for hold ?
call Output ; yes, output last good frame
goto no_signal ; no, just stay silent

;
; Got a good frame. Output the averaged pulse widths of this frame
; and the last frame.
;
update: movf PPM_1,W
addwf PMM_1 ; PWM out = average(this+last)
rrf PMM_1,w
movwf PWM_1
movf PPM_2,W
addwf PMM_2
rrf PMM_2,w
movwf PWM_2
movf PPM_3,W
addwf PMM_3
rrf PMM_3,w
movwf PWM_3
movf PPM_4,W
addwf PMM_4
rrf PMM_4,w
movwf PWM_4

btfss Flags,GOT_FS ; no output until failsafe captured
goto output_done

ifdef ARM_THROTTLE

btfsc Flags,ARMED ; throttle armed ?
goto do_output ; yes

movlw (1300-750)/6
btfsc Flags,JR
subwf PWM_1,w ; throttle < 1.3mS ?
btfss Flags,JR
subwf PWM_3,w
skpc
goto low_throttle ; yes
movlw ARMCOUNT
movwf ArmFrames ; no, reset arming delay
goto disarm

low_throttle: decfsz ArmFrames ; got enough arming frames ?
goto disarm
bsf Flags,ARMED ; yes, arm throttle now
goto do_output
disarm:
movf FLS_3,w
btfss Flags,JR
movwf PWM_3 ; set throttle to failsafe value
movf FLS_1,w
btfsc Flags,JR
movwf PWM_1

endif ; ARM_THROTTLE

do_output: call Output ; output good frame

output_done: movf PPM_1,W
movwf PMM_1
movf PPM_2,W ; remember this frame
movwf PMM_2
movf PPM_3,W
movwf PMM_3
movf PPM_4,W
movwf PMM_4

movlw HOLDCOUNT ; reset failsafe timeout
movwf HoldFrames

bcf GPIO,LED ; signal LED on

btfsc Flags,GOT_FS ; already got failsafe frame ?
goto frame_done ; yes

clrwdt

decfsz GoodFrames ; got enough good frames ?
goto frame_done ; no

; Got enough good frames, now get failsafe values

btfsc Flags,GOT_4 ; channel 4 detected ?
bsf Flags,DET_4

movf PWM_1,W
movwf FLS_1
movf PWM_2,W
movwf FLS_2
movf PWM_3,W ; copy good output to failsafe
movwf FLS_3
movf PWM_4,W
movwf FLS_4

bsf Flags,GOT_FS ; failsafe frame captured

ifdef ARM_THROTTLE

ifdef DETECT_JR
movlw (1300-750)/6
subwf FLS_1,w ; channel 1 < 1.3mS ?
skpc
goto jr_detected
movlw (1700-750)/6
subwf FLS_1,w ; channel 1 >= 1.7mS ?
skpc
goto futaba
movlw (1100-750)/6 ; failsafe low throttle!
movwf FLS_1
jr_detected: bsf Flags,JR ; JR throttle detected
goto arm
endif ; DETECT_JR

futaba: movlw (1700-750)/6
subwf FLS_3,w ; channel 3 >= 1.7mS ?
skpc
goto arm
movlw (1100-750)/6 ; failsafe low throttle!
movwf FLS_3

arm: bsf Flags,ARMED ; arm throttle now

endif ; ARM_THROTTLE

frame_done: goto wait_sync ; wait for next frame


;---------- Oscillator Calibration Subroutine (12F629/75 only) --------------

ifdef __12F675
org 0x3ff
retlw 0x90 ; replace with oscal value for your PIC!
endif

END


Прикачени файлове:
Коментар на файл: Декодер за 4 пропорционални канала
decode.gif
decode.gif [ 3.25 KiB | Прегледано 4593 пъти ]
Вто Окт 18, 2005 8:02 pm
Профил
Ранг: Форумен бог
Ранг: Форумен бог
Аватар

Регистриран на: Чет Окт 07, 2004 12:22 pm
Мнения: 1947
Местоположение: София
Мнение 
Разликата е, че при PIC12F629 има малко повечко регистри щото е с периферия (ако се не лъжа CCP/PWM модул), a при 12C508/509 имаш гол процесор с 1 таймер, даже няма EEPROM. С малко доработка няма проблем да заместиш единия с другия, бих направил това за тебе, но няма да е точно веднага 8)


Вто Окт 18, 2005 8:06 pm
Профил
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение 
Predator_MF написа:
Разликата е, че при PIC12F629 има малко повечко регистри щото е с периферия (ако се не лъжа CCP/PWM модул), a при 12C508/509 имаш гол процесор с 1 таймер, даже няма EEPROM. С малко доработка няма проблем да заместиш единия с другия, бих направил това за тебе, но няма да е точно веднага 8)

Аха! Сега е много по-ясно. Благодаря. Не се мъчи зарад мен. Ще се опитам в петък да поизбягам от бач и да си купя 629-ка. Ама нещо ни в Пулсатор ни във Футурел ги намирам...явно ще пада обикаляне по центъра... :?


Вто Окт 18, 2005 8:19 pm
Профил
Ранг: Форумен бог
Ранг: Форумен бог
Аватар

Регистриран на: Вто Юни 07, 2005 5:20 pm
Мнения: 3230
Мнение 
Комет бе, Комет - www.comet.bg. PIC първо там се търси :D Не съм от София ама мисля че са на сравнително централно място.
Пък като нямаш време - купи си онлайн :idea: :wink:


Вто Окт 18, 2005 9:44 pm
Профил
Ранг: Почетен член
Ранг: Почетен член
Аватар

Регистриран на: Пет Авг 19, 2005 10:38 am
Мнения: 978
Местоположение: Europe -> BG
Мнение 
ex-man написа:
Комет бе, Комет - www.comet.bg. PIC първо там се търси :D Не съм от София ама мисля че са на сравнително централно място.
Пък като нямаш време - купи си онлайн :idea: :wink:


човека е прав

комет е офиц. дистрибутор на Michrochip - хем евтино , хем от източника хах :)
за централно ми в една пресечка преди пете кьошета или зависи как го гледаш , може да се каже и една пресечка на витошка :)
а за онлайн не знам как стоят нещата :)
успех!

_________________
един факт :-)
Съжалявам , че исках да помогна ...


Вто Окт 18, 2005 10:43 pm
Профил ICQ
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение 
the_real_maniac написа:
ex-man написа:
Комет бе, Комет - www.comet.bg. PIC първо там се търси :D Не съм от София ама мисля че са на сравнително централно място.
Пък като нямаш време - купи си онлайн :idea: :wink:


човека е прав

комет е офиц. дистрибутор на Michrochip - хем евтино , хем от източника хах :)
за централно ми в една пресечка преди пете кьошета или зависи как го гледаш , може да се каже и една пресечка на витошка :)
а за онлайн не знам как стоят нещата :)
успех!


Мерсаж де...мерсаж! :D
И аз ги открих малко по-късно..дори се сетих къде им е магазина. А и питах чичко Гугъл и той ми каза за някъв МК-1 в Младост срещу военните на цариградско. Ама пусти безкрайни командировки... :x


Пон Окт 24, 2005 10:48 pm
Профил
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение Predator!
Predator_MF написа:
Разликата е, че при PIC12F629 има малко повечко регистри щото е с периферия (ако се не лъжа CCP/PWM модул), a при 12C508/509 имаш гол процесор с 1 таймер, даже няма EEPROM. С малко доработка няма проблем да заместиш единия с другия, бих направил това за тебе, но няма да е точно веднага 8)


Определено ще имаме нужда от помоща ти! /имам предвид моделистите/

Пробвания модел се саморазпрограмира от пиковете на моторчето, което управлява /въпреки 3-звездната схема на искрогасящи кондензатори накичени на електродвигателчето/. След програмиране, схемата тръгва отново-еднократно!
Ако ти се занимава и намериш време за този "DAY electronic", моля те спомени и броя бири /1,2-каса, 10 каси.../ за нужната почерпка. 8)
Прикачвам и по-добрия вариант на схемата, който спира двигателя след зададен брой секунди /за да не се изгуби самолета ако излезе от обхват с работещ мотор/. При мен на DIP не тръгна...твърдят, че е само за FP-или повърхностен монтаж както му викате... :oops: Не е нужно да е програмируемо закъснението на спиране...може да е твърдо зададено /примерно 30 секунди/. Ще си пробваш ли уменията?
При мен този вариант въобще не тръгна /но и аз ползвам DIP пикльо при това пак многократно програмируем....

Инструкциите:
" Programmable BitSC version

I discovered while trying to build 3 of the newer versions that the handling
of the pins on the Pic chip was zapping them enough to destroy the code
programmed in. Re-programming will usually correct this, but the required
programming pins were in use. So a new design using a tiny PC board was
made and this will be the "latest" version. The new board will allow "fixing"
the code by re-programming. Below is how the programming works.

This version allows the user to set an automatic
motor cut off feature to the desired time delay in
increments of 15 sec. This is provided for safety
as the airplane can easily out fly the range of the
Tx. Setting the delay is done as follows:

1- When the Rx and wired in BitSC is powered
up, there will be aprox 1 sec delay after which
the motor will blip once for each 15 sec interval
that the BitSC is set for.

2- After the blipping has stopped there is a 2 sec
"window" wherein a new number of increments can be
entered by pushing the "down" button the number of
times equal to the number of 15 sec's desired.
The first press of the "down" button holds the
"window" open to gather the remaining presses.

3- After the desised number of intervals has been
entered, the "up" button is pressed and the unit is
ready for normal use.

4- In the event that the "up" button is pressed
before the 2 sec window is over the unit will hang
waiting for an additional "up" press to be ready.
This has the effect of reducing the number of 15
sec intervals to just one, but ONLY for that single
power up. Thus one can have several intervals of 15
sec stored for normal use, but can switch to just
a single 15 sec interval when desired.

The BitSC uses a reverse exponential lookup table
for motor speed control.

Another benefit of having a separate Mosfet to power the motor with is
that several cells made be used with more powerful motors than is usually
the case with bit charger designs. The design shown measures
.395 (10mm) X .271 (6.88mm) with generous soldering pads !!

I will be trying to find a PC board source and work up something
towards providing a kit for those who cannot program or etch boards."


Прикачени файлове:
Коментар на файл: Programmable BitSC version

I discovered while trying to build 3 of the newer versions that the handling
of the pins on the Pic chip was zapping them enough to destroy the code
programmed in. Re-programming will usually correct this, but the required

BITSC1_H.hex.TXT [1.22 KiB]
219 пъти
Пон Дек 05, 2005 10:45 pm
Профил
Ранг: Минаващ
Ранг: Минаващ

Регистриран на: Вто Окт 18, 2005 5:21 pm
Мнения: 19
Местоположение: Sofia
Мнение Листа
е:


Прикачени файлове:
BITSC1_A.TXT [8.93 KiB]
239 пъти
BITSC1_L.TXT [13.44 KiB]
219 пъти
Пон Дек 05, 2005 10:54 pm
Профил
Покажи мненията от миналия:  Сортирай по  
Отговори на тема   [ 12 мнения ] 

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 1 госта


Вие не можете да пускате нови теми
Вие не можете да отговаряте на теми
Вие не можете да променяте собственото си мнение
Вие не можете да изтривате собствените си мнения
Вие не можете да прикачвате файл

Търсене:
Иди на:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.
Хостинг и Домейни