diegosantos
New Member
is posible use the logicator for programing a normal pic ?
(means not picaxe)
(means not picaxe)
'Free Flight Timer Requirements
'1. When switched on, Timer is set to open throttle position (default)
'2. Engine is started, short button press starts timer, LED lights timer is armed.
'3. Time elaps, engine is cut, throttle stays low until switched off.
'Response
'Switch1 on GPIO3,pin4 Start Timed engine run and also on Switch1
'Switch1 hold down while switching ON to record new Time
'Steady LED = Timer is running
'1 second flash when new time is being recorded
#Picaxe 08M2 ' delete the 2 in this declaration if using 08M
eeprom 0,(15) ' pre-loading Time elapse into non-volatile memory
servo 1,200 ' servo to high, initiating servo command
start:
if pin3=1 then main ' Switch for new Time at Switch/ON only
start2:
servopos 1,200 ' Hi throttle, (default)
pause 22 ' wait for GO and time for servo RC frame
if pin3=0 then start2 ' Initiate Time at Hi throttle
high 2 ' Timer running, Steady LED during Hi
read 0,b0 ' Get Time, in seconds from eeprom
for b2=1 to b0 ' Count off the seconds
wait 1 ' 1 second
next b2 ' Inc counter
low 2 ' Time finished LED extinguished
Fin:
servopos 1,100 ' Low throttle held till switch is OFF
pause 100 ' Servopos works in background,needs time
goto Fin ' Stay Low till switched off
Main:
servopos 1,100 ' Indicates Changing Time
high 2
pause 500 ' Half second ndicator
low 2
pause 500 ' Second half second
b2=b2+1 ' Added to b2
if pin3=1 then main' Switch to end new Time
write 0,b2 ' Replace old Time in eeprom
low 1 '
goto start ' End of new timing. Switch OFF
;Generated by: BAS2ASS Compiler (Programming Editor)
;File Version: 3.20
;From source : c:\docume~1\temp\code.bas
;Copyright: (c) Revolution Education Ltd 1997-2003
;Web: [url]www.rev-ed.co.uk[/url]
;Limitations: Please see end of file below.
; *******************************
; ***** Setup MPASM defines *****
; *******************************
list p=12F629 ; list directive to define processor
#include <p12F629.inc> ; processor specific variable definitions
errorlevel -302 ; suppress page warning 302
; **********************************
; ***** Setup PICmicro config. *****
; **********************************
; All routines for 4MHz oscillator (using internal oscillator)
__CONFIG _CP_OFF & _WDT_ON & _INTRC_OSC_NOCLKOUT & _PWRTE_ON & _BODEN_ON & _MCLRE_OFF
;Warning - the watchdog timer is set and may timeout on loops
;that take longer than 2.3s & do not include a 'clrwdt' instruction!
; ******************************
; ***** RAM File Registers *****
; ******************************
CBLOCK h'20'
Temp ; Temporary Scratchpad
HighByte ; High Byte Value
LowByte ; Low Byte Value
HighByte2 ; High Byte2 Value
LowByte2 ; Low Byte2 Value
HighTemp ; High Temp Byte Value
LowTemp ; Low Temp Byte Value
HighRand ; High Random Byte Value
LowRand ; Low Random Byte Value
B0 ; Basic Byte Variable
B1 ; Basic Byte Variable
B2 ; Basic Byte Variable
B3 ; Basic Byte Variable
B4 ; Basic Byte Variable
B5 ; Basic Byte Variable
B6 ; Basic Byte Variable
B7 ; Basic Byte Variable
B8 ; Basic Byte Variable
B9 ; Basic Byte Variable
B10 ; Basic Byte Variable
B11 ; Basic Byte Variable
B12 ; Basic Byte Variable
B13 ; Basic Byte Variable
ENDC
#define PORTIN GPIO ;define inputs on gpio
#define PORTB GPIO ;define portb as gpio for output commands
#define TRISB TRISIO ;define trisb as trisio for output commands
; ***********************************
; ***** Start of assembler code *****
; ***********************************
; ***** Reset vector *****
org d'00' ; Reset vector
btfss STATUS,NOT_TO ; Return if Watchdog Timeout
return
goto B_init ; jump to B_init
; ***** Interrupt vector *****
org d'04' ; Interrupt vector
return ; Return by default
; ******************************************
; ***** Start of common sub-procedures *****
; ***** All added even if not required *****
; ******************************************
; ***** Get a pin mask value *****
getmask:
clrf PCLATH ; make sure page 0
andlw b'00000111' ; mask just in case
addwf PCL,F ; W = Bit Mask
retlw b'00000001' ; return pin0
retlw b'00000010' ; return pin1
retlw b'00000100' ; return pin2
retlw b'00001000' ; return pin3
retlw b'00010000' ; return pin4
retlw b'00100000' ; return pin5
retlw b'01000000' ; return pin6
retlw b'10000000' ; return pin7
; ***** Pause sub-procedure (ms units) *****
pause: ;Pause (word length delay)
comf HighByte,F ;Take 2's complement
comf LowByte,F ;of word value
incf LowByte,F ;
btfsc STATUS,Z ;
incf HighByte,F ;
call B_Del_lp ;do 1ms delay
incf LowByte,F ;check LowByte
btfsc STATUS,Z ;if not done skip
incfsz HighByte,F ;HighByte all done?
goto $-4 ;do another loop
return
; Delay for 1ms (=1000 us) routine
B_Del_lp
movlw d'100' ; 100 x 10us = 1ms loop
movwf LowTemp
B_lp1: clrwdt ; 1us pat the dog
goto $+1 ; 2us delay
goto $+1 ; 2us delay
goto $+1 ; 2us delay
decfsz LowTemp,F ; 1us skip if zero
goto B_lp1 ; 2us loop 1
return ; return
; ***** Compare two values to see if =, > or < *****
compare: ; compare sub-procedure
movfw LowByte2 ; get LowByte2 variable
subwf LowByte,W ; LowByte2 - LowByte
btfss STATUS,C ; test carry
retlw B'00000010' ; LowByte < LowByte2 so set bit 1
incf LowByte2,W ; get HighByte + 1 into W
subwf LowByte,W ; LowByte - (LowByte2+1)
btfss STATUS,C ; test carry
retlw b'00000001' ; LowByte = LowByte2 so set bit 0
retlw b'00000100' ; LowByte > LowByte2 so set bit 2
; *********************************
; ***** End of sub-procedures *****
; *********************************
; *********************************
; ***** Start of main program *****
; *********************************
; ***** Initialise the Ports *****
B_init:
clrf GPIO ; clear GPIO
call H'3FF' ; retrieve calibration byte
bsf STATUS,RP0 ; move to page 1
movwf OSCCAL ; into register
bcf STATUS,RP0 ; move to page 0
movlw b'00000111' ; set port
movwf CMCON ; to digital input
bsf STATUS,RP0 ; move to page 1
movlw b'11111111' ; set all high
movwf OPTION_REG ; set option register
movwf TRISIO ; set gpio as inputs
bcf STATUS,RP0 ; move to page 0
; ***** Clear all the variables *****
movlw B13 ; get highest variable
movwf HighTemp ; store in HighTemp
movlw B0 ; get start variable
movwf FSR ; set FSR
B_clear:
clrf INDF ; clear indirect register
incf FSR,F ; increment FSR
decfsz HighTemp,F ; all done?
goto B_clear ; no so loop
; *****************************************
; ***** Now include the Basic program *****
; ***** The original is prefixed <B> *****
; ***** and added as a comment below. *****
; *****************************************
;<B> '1. When switched on, Timer is set to open throttle position (default)
;<B> '2. Engine is started, short button press starts timer, LED lights timer is armed.
;<B> '3. Time elaps, engine is cut, throttle stays low until switched off.
;<B> 'Response
;<B> 'Switch1 on GPIO3,pin4 Start Timed engine run and also on Switch1
;<B> 'Switch1 hold down while switching ON to record new Time
;<B> 'Steady LED = Timer is running
;<B> '1 second flash when new time is being recorded
;<B> '#Picaxe 08M2 ' delete the 2 in this declaration if using 08M
;<B> eeprom 0,(15) ' pre-loading Time elapse into non-volatile memory
;EEPROM data is embedded at end of file
;<B>
;<B> pulsout 1,200 ' servo to high, initiating servo command
bsf STATUS,RP0 ;page 1
bcf TRISB,1 ;pin low for output
bcf STATUS,RP0 ;page 0
clrf HighByte ;clear higher byte
movlw d'1' ;get value
call getmask ;get