Solenoid Door Opener [Newbie]

Andie

Member
All,

I am working on a project where I have adapted shelving bins by covering the top permanently with acrylic and making an acrylic door which is attached to the top by two open sprung hinges. The door is held closed by a magnetic catch. A push solenoid is then energised to push the door off the magnetic catch and the hinge takes over to fully open the door. I am using a PICAXE 28X2 as there will be 11 of the shelving bins and this number could potentially increase. The solenoid is 12Vdc and 3W. Each bin has its own barcode which will be scanned in order to open that bin. The idea is to have the barcode scanner feed the information to the PC and the PC send this information to the PICAXE through the serial.
I am new to the world of electronics but I have dived in, could anyone tell me if there are any mistakes in my code or schematic (Note: The inductor would not translate to the PCB in DesignSparkPCB so I have used an LED in the schematic instead to represent the solenoid. Also the NFET is supposed to be a MOSFET IRL520 as shown in Manual 3)? Any other suggestions would be appreciated :)

Andie

Code:
main:
	SERTXD("Scan barcode")
	SERRXD b0,b1,b2,b3,b4,b5,b6,b7								;Barcode scanned to the PC and values are read through the 'serial in' port as variables
	SERTXD(b0,b1,b2,b3,b4,b5,b6,b7,13,10)							;Send the values of the variables through the 'serial out' port to the PC
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="1" THEN GOTO compartment1	;If barcode matches screws in compartment 1 jump to 'compartment1' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="2" THEN GOTO compartment2	;If barcode matches screws in compartment 2 jump to 'compartment2' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="3" THEN GOTO compartment3	;If barcode matches screws in compartment 3 jump to 'compartment3' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="4" THEN GOTO compartment4	;If barcode matches screws in compartment 4 jump to 'compartment4' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="5" THEN GOTO compartment5	;If barcode matches screws in compartment 5 jump to 'compartment5' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="6" THEN GOTO compartment6	;If barcode matches screws in compartment 6 jump to 'compartment6' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="7" THEN GOTO compartment7	;If barcode matches screws in compartment 7 jump to 'compartment7' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="8" THEN GOTO compartment8	;If barcode matches screws in compartment 8 jump to 'compartment8' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="0" AND b7="9" THEN GOTO compartment9	;If barcode matches screws in compartment 9 jump to 'compartment9' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="1" AND b7="0" THEN GOTO compartment10	;If barcode matches screws in compartment 10 jump to 'compartment10' label
	IF b2="1" AND b3="9" AND b5="0" AND b6="1" AND b7="1" THEN GOTO compartment11	;If barcode matches screws in compartment 11 jump to 'compartment11' label
	SERTXD("BARCODE NOT RECOGNISED, PLEASE SCAN AGAIN!")					;If barcode does not match any of the screws PC displays "BARCODE NOT RECOGNISED, PLEASE SCAN AGAIN!"
	GOTO main												;Jumps back to the start of the 'main' label
compartment1:
	SERTXD("Compartment 1",13,10)	;Displays "Compartment 1" followed by a Carriage Return (13) and Line Feed (10) on the PC
	HIGH B.1				;Sends voltage to solenoid of compartment 1
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.1				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment2:
	SERTXD("Compartment 2",13,10)	;Displays "Compartment 2" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH B.2				;Sends voltage to solenoid of compartment 2
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.2				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment3:
	SERTXD("Compartment 3",13,10)	;Displays "Compartment 3" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH B.3				;Sends voltage to solenoid of compartment 3
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.3				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment4:
	SERTXD("Compartment 4",13,10)	;Displays "Compartment 4" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH B.4				;Sends voltage to solenoid of compartment 4
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.4				;Stops voltage
	GOTO main				;Jumps back to 'main' label 
	
compartment5:
	SERTXD("Compartment 5",13,10)	;Displays "Compartment 5" followed by a Carriage Return(13) and a Line Feed(10) on the PC
	HIGH B.5				;Sends voltage to solenoid of compartment 5
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.5				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment6:
	SERTXD("Compartment 6",13,10)	;Displays "Compartment 6" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH B.6				;Sends voltage to solenoid of compartment 6
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.6				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment7:
	SERTXD("Compartment 7",13,10)	;Displays "Compartment 7" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH B.7				;Sends voltage to solenoid of compartment 7
	WAIT 5				;Holds voltage for 5 seconds
	LOW B.7				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment8:
	SERTXD("Compartment 8",13,10)	;Displays "Compartment 8" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH C.0				;Sends voltage to solenoid of compartment 8
	WAIT 5				;Holds voltage for 5 seconds
	LOW C.0				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment9:
	SERTXD("Compartment 9",13,10)	;Displays "Compartment 9" followed by a CArriage Return (13) and a Line Feed (10) on the PC
	HIGH C.1				;Sends voltage to solenoid of compartment 9
	WAIT 5				;Holds voltage for 5 seconds
	LOW C.1				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment10:
	SERTXD("Compartment 10",13,10);Displays "Compartment 10" followed by a Carriage Return (13) and a Line FEed (10) on the PC
	HIGH C.2				;Sends voltage to solenoid of compartment 10
	WAIT 5				;Holds voltage for 5 seconds
	LOW C.2				;Stops voltage
	GOTO main				;Jumps back to 'main' label
	
compartment11:
	SERTXD("Compartment 11",13,10);Displays "Compartment 11" followed by a Carriage Return (13) and a Line Feed (10) on the PC
	HIGH C.3				;Sends voltage to solenoid of compartment 11
	WAIT 5				;Holds voltage for 5 seconds
	LOW C.3				;Stops voltage
	GOTO main				;Jumps back to 'main' label
Just realised I forgot to change the values for the resistors so where it says 1K pretend it says 10K :p
 

Attachments

Last edited:

MartinM57

Moderator
Welcome!

I suggest you put the PCB design to one side for quite a long time and concentrate on the schematic and prototyping the circuit and software on breadboard/protoboard/whatever.

A quick look at the schematic shows:
- no +V supply to the PICAXE - and where is that going to come from?
- leg 19 not connected - needs to be connected to 0V
- leg 1 needs to be tied high, possibly with a reset switch to 0V

For all these, see "The minimum operating circuit for the 28 pin devices" in Manual 1 at about page 35

LEDs 5 and 6 (OK, they're the solenoids, I can just about live with that, but surely you can get an inductor symbol in here somehow) aren't connected to anything

..so suggest you fix up the schematic (don't change the PCB design yet) , re-post, and then start prototyping...
 

Jamster

Senior Member
At a quick glance there seems nothing wrong, you best bet is to breadboard the circuit so that you can make any changes without having to reorder and spend time unsoldering PCBs.

Jamster

EDIT: Yet again, I miss the obvious errors...
 

Andie

Member
Thanks for the welcome and the quick reply!
I will take your advice and get on changing the schematic.

Thanks :)
 

Jamster

Senior Member
Much better, but you dont want the reset pin tied to ground. It wants to be tied high and if you want a reset switch it needs to go in between the reset pin and ground, your setup will cause the PICAXE to repeatedly reset. :)

Also, are you sure that the Solenoids will trigger at 5v?

Jamster
 

Andie

Member
The solenoids I have are 12V and are on order so I don't know yet.
In the schematic I have it so that they are part of a 12V net. Is this not the way to go about it?

A
 

MartinM57

Moderator
Solenoids seem fine.

It would be good to detail how the 12v and 5v supplies are obtained as their design and/or quality may be relevant.

No decoupling or reservoir capacitors - 100nF across the PICAXE power pins, plus at least 100uF (or even 220uF/470uF) across the 5v and 12v supplies (sorry, didn't spot that first time round :))
 

MartinM57

Moderator
No - you shouldn't link the 5v and 12v supplies with the capacitor...you should have 2 reservoir capacitors, one from 12v to 0V and one from 5v to 0V

The 100nF is fine.
 

Andie

Member
Ok, thanks for all your help so far. I shall make the amendments.

When my parts arrive I shall start prototyping and let you know how it goes :)

A
 

MartinM57

Moderator
What are you using for the 12v and 5v supplies? "Wall-warts", batteries, voltage regulators (linear/switched mode) ...?
 

MartinM57

Moderator
You could consider a simple 5v linear regulator (7805 type- with suitable capacitors - see its data sheet) to get the PICAXE supply voltage from the 12v power supply - a small increase in complexity that would eliminate the 5v batteries (you really have batteries giving 5v?) and them going flat at the worse possible moment etc
 

Andie

Member
I have a friend who is doing a very similar circuit to me and he tried the 220uF capacitor between 4.5V and ground. The battery pack he was using then melted, was this likely to have been caused by the capacitor or another reason? A
 

MartinM57

Moderator
...he tried the 220uF capacitor between 4.5V and ground. The battery pack he was using then melted..
That is not the normal behaviour associated with putting a working 220uF reservoir capacitor between the battery +ve and 0V.

It was either finger trouble/mis-wired or a failed-short-circuit capacitor...
 

Andie

Member
I actually do! By similar I meant that he has a 12V and 5V supply :p

Do you think it could have been caused by incorrect polarity? He had the negative wire going to ground.

A
 

MartinM57

Moderator
Capacitor negative to ground is fine. So the battery "melted" (whatever that means) and there was no observable effect on the capacitor?

I suggest the capacitor is put in the bin (with the battery), a new capacitor procured, and connected carefully and properly. There is absolutely no fundamental reason for the observed behaviour...
 

JonRen

New Member
Hi, I am said friend that caused this to happen! Basically AA battery pack melted at the pins which was unexpected but thankfully no burnt fingers!

Thanks for the advice I think I'll have to have another go, also a newbie so it could have had something to do with my poor technique...
 

Andie

Member
Hi,

I have programmed the chip using the AXE091U PICAXE Experimenter Board. I have connected the computer to the board using an AXE027 cable. The MOSFET I am using is the ZVN420 6A. The push solenoid I am using is a 12Vdc but it does not work in this circuit. When the pin sends out a 5v pulse for 5 seconds the voltage going in AND going out of the solenoid are both 12V. One lead is connected to the +12V power supply and the other to the drain of the MOSFET which is also giving out 12V (the leads of the solenoid are not polarity sensitive) so nothing is happening. Can anyone see the problem here?

A
 

nick12ab

Senior Member
I have programmed the chip using the AXE091U PICAXE Experimenter Board. I have connected the computer to the board using an AXE027 cable. The MOSFET I am using is the ZVN420 6A. The push solenoid I am using is a 12Vdc but it does not work in this circuit. When the pin sends out a 5v pulse for 5 seconds the voltage going in AND going out of the solenoid are both 12V. One lead is connected to the +12V power supply and the other to the drain of the MOSFET which is also giving out 12V (the leads of the solenoid are not polarity sensitive) so nothing is happening. Can anyone see the problem here?
Have you...
  • Tested the MOSFET by seeing if it can power an LED when the gate is high?
  • Tested the solenoid by connecting it directly to the power supply?
 

Andie

Member
Nick12ab,

I have tried the LED and it is not working, I then checked the three pins of the MOSFET and the drain is 0V, the source is 0V and the gate is 5. I think I need to try replacing the MOSFET.

A
 
Top