Control multiple solenoids using PIC12f675?

Thread Starter

prabhubng

Joined Sep 29, 2009
6
I am new to Electronics and PIC programming, my problem is I need to control 100 small sized solenoids (made by me), using a PIC Micro controller, there are many suggestions on internet to use a MOSFET or a Diode or a PWM Driver to control a single solenoid, can any expert please suggest me how to approach this problem using a better and simple design.

Thanks in Advance
 

JDT

Joined Feb 12, 2009
657
The problem is, of course, that you want to drive 100 solenoids and there are not 100 I/OP pins on your micro-controller. The solution is to use a shift register. Then you will be able to drive all your solenoids with just 3 pins!

I reccomend using a number of ICs like the Allegro A6821SA (or similar) that has an 8-bit serial in shift register and 8 high current, high voltage, darlington outputs. It also has a latch so that the outputs can be maintained while shifting in your new output array.

For 100 outputs you would link 13 of these chips together (actually 104 outputs). Serial out of the first one is connected to the serial in of the next. One output of the PIC goes to all the clock inputs connected together. Another output on the PIC goes to all the strobes linked together. The third PIC output goes to the serial in on the first chip.

So you have 3 outputs on your PIC:-
Clock, Serial Data, Strobe.

Here is a link to the data sheet http://www.farnell.com/datasheets/57610.pdf Take care to put a reversed diode across each of your solenoid coils. Also check to total current consumption if all your solenoids are on at the same time!

Now just write the code!
 

JDT

Joined Feb 12, 2009
657
Here is some PIC code. Assuming data is clocked in on the rising edge and transferred to latch when strobe is high. You may have to check this.

#define Clock PORTA,0
#define S_Data PORTA,1
#define Latch PORTA,2


;******************************************************************************
ORG 0x000 ; processor reset vector


;Switch ON or OFF bits in the registers as required.
BSF Reg1,0
BSF Reg5,6
; ......

;Shift data out to solenoid drivers
CALL ShiftOut

;Subroutine to load shift registers
ShiftOut
MOVLW H'64' ;100
MOVWF Count ;Set up loop counter
loop1 BCF Clock ;Clock pin low
RLF Reg1,F
RLF Reg2,F
RLF Reg3,F
RLF Reg4,F
RLF Reg5,F
RLF Reg6,F
RLF Reg7,F
RLF Reg8,F
RLF Reg9,F
RLF Reg10,F
RLF Reg11,F
RLF Reg12,F
RLF Reg13,F
BTFSS STATUS,C ;Transfer carry flag
BCF S_Data ; to data pin
BTFSC STATUS,C
BSF S_Data
BSF Clock ;Clock pin high (load on rising edge)
DECFSZ Count,F
GOTO loop1
;100 shifts done
BCF Clock ;Clock pin low
BSF Latch ;Update latch
;Do 5 more shifts to restore original state ((8 x 13) + 1)
MOVLW H'05' ;5
MOVWF Count ;Set up loop counter
loop2 RLF Reg1,F
RLF Reg2,F
RLF Reg3,F
RLF Reg4,F
RLF Reg5,F
RLF Reg6,F
RLF Reg7,F
RLF Reg8,F
RLF Reg9,F
RLF Reg10,F
RLF Reg11,F
RLF Reg12,F
RLF Reg13,F
DECFSZ Count,F
GOTO loop2
;All done. Clear latch
BCF Latch ;Latch pin low
RETURN

END


Also, another solenoid driver Texas TPIC6595:-
http://focus.ti.com/lit/ds/slis010b/slis010b.pdf

No, I haven't got much going on here today!! (and no, code not guaranteed!)
Actually, this code is for a PIC 16F series. May have to be modified for your 12F.
 
Last edited:
Top