RC Truck and Construction  

Go Back   RC Truck and Construction > RC Truck's Ag and Industrial Equipment and Buildings > Construction Equipment > Construction Equipment Tech

Construction Equipment Tech Hydraulics, Electronics, General Engineering, ect in constr equip


Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2011, 01:25 PM
iaindunn iaindunn is offline
Newbie
 
Join Date: Apr 2011
Posts: 13
iaindunn is on a distinguished road
Default Re: Hydraulic Pump Motor Control Options

hi all
here is the asm code for a pump switch as used in my excavator for a couple of years. Works on a 12f675 pic. I'll try and post a link to video of it working soon.

;=============================================
; written by Iain Dunn
; 2 August 2010 revision release
; version 1.2 PCB EXPRESSPCB main revised3
; file saved as pumpswitch675.asm
; for 12f675
; int clock 4MHz

;==============================================
; Description,3 or 4 channel inputs for pump control
; via 1 fet 19N10.
; Input 4 not programmed yet
;
; |----||----|
; | 100n |
; 5v--|-------|----0V
; NC----|12f675 |----in2 GP0
;GP4pumpout----| |----in1 GP1
; GP3 in4----|-------|----in3 GP2
;
List P=12f675 ; define processor
#INCLUDE <p12f675.inc> ; processor specific definitions

;================================================= =================
;configuration
;no data protect
;no code protect
;no brown out reset
;no MCLR pin function
;power up timer disabled
;Watchdog timer enabled
;oscillator INTOSC with no CLKOUT

__config _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

errorlevel -302 ;suppress error 302

radix dec ;everything in decimal
;unless indicated



;========== constants========================================= ============

;GPIO,1 chan1 GPIO,3 chan 2 all rest outputs

#define INPUT_1 1
#define INPUT_2 0
#define INPUT_3 2
#define PUMPOUT GPIO,4
#define minpulse 80
#define lowon 140
#define highon 160
#define maxpulse 220
#define OFFDLAY 20 ; delays switching off pump
#define TisBits (1<<INPUT_1)|(1<<INPUT_2)|(1<<INPUT_3)
;========Notes==================================== ========================

;pulses must be larger than 0.8ms to be valid and less than 2.2ms
;The switching limits are
;1.55 ms upper off 1550us
;1.45 ms lower off 1450us


;==========Variables============================== =======================
cblock 0x20

CHAN_1 ; channel 1 width
CHAN_2 ; channel 2 width
CHAN_3 ; channel 3 width
ARM_PULSES ; stores arm pulse count
ARM_1 ; channel 1 arm pulse count
ARM_2 ; channel 2 arm pulse count
ARM_3 ; channel 3 arm pulse count
Dlay
Dlay_outer
Dlay_inner
OffCount ; delays pump switch off for 1/2 second

endc
;=========Declarations============================ =======================

org 0 ;first instruction to be executed

goto START

;========Initilizations=========================== =======================

INIT clrf GPIO ;clear all outputs for now
bsf STATUS, RP0 ; bank 1
call 3FFh ;call osc calibration
movwf OSCCAL
movlw b'1001010' ;WDT scale 1:4 gives around 72ms
movwf OPTION_REG ;before reset
movlw TisBits ;GPIO 2,3,5 input GPIO,0,1,4 output
movwf TRISIO
clrf ANSEL
bcf STATUS, RP0 ;bank 0
movlw b'00000111' ;turn off comparator
movwf CMCON ;digital i/o
clrf T1CON ;turn off timer 1
clrf ADCON0


return

;========== Start of main outer loop of program ===============================

START call INIT
clrf GPIO
clrf CHAN_1 ;
clrf CHAN_2
clrf CHAN_3
movlw OFFDLAY
movwf OffCount
movlw 50
movwf ARM_PULSES
clrwdt
;========== wait for 25 valid pulses to arm =====================

ARMING
clrf ARM_1
clrf ARM_2
clrf ARM_3
btfss GPIO,INPUT_1
goto $-1


ARMLOOP_1 incf ARM_1,f
btfss GPIO,INPUT_1
b ARM2
nop
b $+1
b $+1
b ARMLOOP_1

ARM2 btfss GPIO,INPUT_2
goto $-1

ARMLOOP_2 incf ARM_2,f
btfss GPIO,INPUT_2
b ARM3
nop
b $+1
b $+1
b ARMLOOP_2


ARM3 btfss GPIO,INPUT_3
goto $-1

ARMLOOP_3 incf ARM_3,f
btfss GPIO,INPUT_3
b PULSE_1
nop
b $+1
b $+1
b ARMLOOP_3


PULSE_1 movlw lowon
subwf ARM_1,w ; ARM_1-lowon(148)
bnc ARMING
movlw highon
subwf ARM_1,w ; ARM_1-highon(152)
bc ARMING


PULSE_2 movlw lowon
subwf ARM_2,w ; ARM_2-lowon(148)
bnc ARMING
movlw highon
subwf ARM_2,w ; ARM_2-highon(152)
bc ARMING


PULSE_3 movlw lowon
subwf ARM_3,w ; ARM_3-lowon(148)
bnc ARMING
movlw highon
subwf ARM_3,w ; ARM_3-highon(152)
bc ARMING



VALID_NEUTRAL
clrwdt
decfsz ARM_PULSES,f
goto ARMING

;========= now armed beep from both motors ==========================================
movlw 10
movwf Dlay_outer
clrf Dlay_inner

PWM_LOOP clrwdt
bsf PUMPOUT
movlw 10
movwf Dlay
decfsz Dlay,f
goto $-1
clrf GPIO
movlw 100
movwf Dlay
decfsz Dlay,f
goto $-1
decfsz Dlay_inner,f
goto PWM_LOOP
decfsz Dlay_outer,f
goto PWM_LOOP
clrf GPIO ;turn motors off

;========= Wait for channel pulses to start =========================================




RCIN1 clrf CHAN_1
btfss GPIO,INPUT_1
b $-1
LOOP_1 incf CHAN_1,f
btfss GPIO,INPUT_1
b RCIN2
nop
b $+1
b $+1
b LOOP_1



RCIN2 clrf CHAN_2
btfss GPIO,INPUT_2
b $-1
LOOP_2 incf CHAN_2,f
btfss GPIO,INPUT_2
b RCIN3
nop
b $+1
b $+1
b LOOP_2

RCIN3 clrf CHAN_3
btfss GPIO,INPUT_3
b $-1
LOOP_3 incf CHAN_3,f
btfss GPIO,INPUT_3
b PROCESS_IN_1
nop
b $+1
b $+1
b LOOP_3

;==========process the channel timings ====================================

PROCESS_IN_1
clrwdt
movlw minpulse
subwf CHAN_1,w ; CHAN_1-minpulse(80)
bnc PROCESS_IN_2
movlw maxpulse
subwf CHAN_1,w ; CHAN_1-maxpulse(220)
bc PROCESS_IN_2
movlw lowon
subwf CHAN_1,w ; CHAN_1-lowon(145)
bnc PUMP_ON
movlw highon
subwf CHAN_1,w ; CHAN_1-highon(155)
bc PUMP_ON

PROCESS_IN_2

movlw minpulse
subwf CHAN_2,w ; CHAN_2-minpulse(80)
bnc PROCESS_IN_3
movlw maxpulse
subwf CHAN_2,w ; CHAN_2-maxpulse(220)
bc PROCESS_IN_3
movlw lowon
subwf CHAN_2,w ; CHAN_2-lowon(145)
bnc PUMP_ON
movlw highon
subwf CHAN_2,w ; CHAN_2-highon(155)
bc PUMP_ON
PROCESS_IN_3

movlw minpulse
subwf CHAN_3,w ; CHAN_3-minpulse(80)
bnc RCIN1
movlw maxpulse
subwf CHAN_3,w ; CHAN_3-maxpulse(220)
bc RCIN1
movlw lowon
subwf CHAN_3,w ; CHAN_3-lowon(145)
bnc PUMP_ON
movlw highon
subwf CHAN_3,w ; CHAN_3-highon(155)
bc PUMP_ON


PUMP_OFF
decfsz OffCount,f
b RCIN1
bcf PUMPOUT
movlw OFFDLAY
movwf OffCount
b RCIN1

PUMP_ON bsf PUMPOUT
movlw OFFDLAY
movwf OffCount
b RCIN1

;============End programme ================================================== ========

return
END
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.