loading

PICAXE Ciruit Help needed! I'm trying to figure out why my circiut is not working. Can anyone help?

Note: I have attached a copy of my programming and the schematic of the circuit.

As part of my school systems engineering course, I have decided to build an automated chook shed door. For the electronic side of this project i'm using a PICAXE microprocessor (PICAXE 08M - to be exact) to control the up and down operation of the door - which is done using a 12 volt linear actuator, all powered by a 12 volt battery (eventually to be rechagred by a solar panel). My theory is to basically read in the light level using an LDR and then based on this level to open the door, or close it. The is designed to work through the use of 3 relays (all with built in diode protection). The first relay is connected to the 12 volt power which supllies power to the other set of relays, and in effect the actuator, when ouput 0 is turned to high (I'm using transistors to do this as seen on the in the shematic). When I want to reverse the the motor I again turn ouput 0 to high, but also ouput 1 to high which switches the the other coupled relays (again using a tranistor) and in effect the polarities of the actuator.I'm also using two microswitchs on the bottom of the vertical sliding door as a safety mechanism, so that when the door is closing and an obstuction occurs (i.e a hand or piece of wood), its programmed to lift the door for about a second before trying to close again.  As mentioned before it acts a safety mechanism so that no little fingers can be chopped off, and the actuator it self doesn't overload and blow up (although I'm pretty sure it has inbuilt protection for this anyway).

Ok anyway to the problem, I have wired everything up as to the schematic I have provided, and loaded the program onto the chip (which it does successfully do) - however its not performing as desired. I have placed the same program onto another identical PICAXE system (except it is not obviously connected to all of the stuff mine is) and it works fine. I have also tried reducing the complexity of the program and taking out the LDR readings in the code, and when I do this,  it does successfully turn on the relays as desired. For some reason it appears that the LDR is reading a full light level even when I place my finger over it, and because the IF statment in the program relies on a low LDR to operate, the code which turns on the relays never gets to execute.  At first it seems that there may have been a problem with the LDR, so I changed it  with a new one, but again it continues to read the highest value of 255 (or 1 byte) and therefore the program never executes as desired. I'm not sure why the LDR keeps reading the highest value. CAN ANYONE HELP!







Picture of PICAXE Ciruit Help needed!
I'm trying to figure out why my circiut is not working. Can anyone help?
sort by: active | newest | oldest
AndyGadget6 years ago
 
From what you say it sounds like you've narrowed it right down to the LDR circuit.  It sounds like the ADC input is shorted to 5V - Have you tested for this with a resistance meter?  If it's a short, check and re-check the wiring, especially for solder or wire whiskers between tracks. Also check the value and for dry joints on the resistor to 0V as an open or way too high value would have that effect. 

If all is OK, replace the LDR with a variable resistor and see if it works manually adjusting the 'light level'. 
Mattdog123 (author)  AndyGadget6 years ago
I think I have figured out the problem. I looked at the circuit board under a microscope and found that the track from the resitor to 0v was cut (underneath the green plastic cover). Have put a bit of solder across it and now everything seems to be working as desired.
Mattdog123 (author)  AndyGadget6 years ago
Ok thanks for the advice, I will give that a go. I reckon you might be right about the shorting, because I pulled this circuit board off an hold project of mine which was glued down and in the process a couple of the tracks were scratched leaving the copper showing It's possible like you said that it is shorting across.

Again, thanks for the advice.
AndyGadget6 years ago
 
Thanks for Best Answer. Glad you got it working.
Chook shed doors appear to be fairly popular thing to apply the PicAxe to. A small controller like that is ideal for that sort of task. And the 08m2 has just been released - Check the PicAxe forum.

rickharris6 years ago
See if you can work out how this works - simulates OK

Main:

'assumes pin 3 has micro switch fo door closed
'Pin 4 has micro switch for door open
'output 1 high output 2 low opens the door
'output 1 low, 2 high closes the door.
'ADC writes to B1
' runs in Picaxe 08.


B0=1 ' door closed flag
b1=152

check:

if b1<150 then opendoor
if b1>151 then closedoor

sleep 1000 ' low power mode for 16 mins no need to check light often

goto check

opendoor:

if B0=1 then goto check 'check flag
high 1 ' open door
low 2 ' open door

checkstopopen:

if pin4=1 then stopmotor ' door open
goto checkstopopen

stopmotor:

low 1
B0=1
goto check

closedoor:
if B0=0 then goto check 'check flag
low 1
high 2 ' close door

checkstopclose:

if pin3=1 then stopmotorx ' door closed
goto checkstopclose


stopmotorx:
low 2
B0=0
goto check
Mattdog123 (author)  rickharris6 years ago
Hi there. Yes I understand your program. My code complied fine onto the picaxe, and did work on another identical one, however the LDR is not playing nice input 4 is reading a continuos high voltage- which is the main problem.
Thanks.
As steve said you need to measure the voltage at the LDR/resistor junction i.e. the input to the picaxe ADC. Cover the LDR Uncover see what you get and report back.
Measure your LDR resistance, dark and light, and report back.

Steve
Mattdog123 (author)  steveastrouk6 years ago
Ok i have done the equivalent, using the debug command on the picaxe (which is a representation of the resistance between 0 and 255) and again it remains on the maximum value 255. It means that its receiving pretty much full voltage, which is not what i'm after.
No, that isn't the equivalent. Stick an ohm-meter on your LDR and report the light and dark readings. From that, I can get a better idea what's wrong.

What happens if you open circuit the pin ? What happens if you ground the pin ?

Steve
Mattdog123 (author)  steveastrouk6 years ago
Ok, unfortunately I'm not near a multi-meter at the moment, but will hoepfully report back tomorrow.
Its not generally a good idea to have the computer have sole control of the motor hardware. Its much safer to have limit switches that directly interrupt the relay current, like this circuit I did for another 'ibler.

Steve
Hen door.jpg
rickharris6 years ago
Your going to get a much better response from the Picaxe forum http://www.picaxeforum.co.uk/forumdisplay.php?f=2

However your relay connections look rather funny. In general it is usual to use a "standard" H bridge set up if your going to use 2 relays. like this.

Mattdog123 (author)  rickharris6 years ago
Yeah my relay setup is probably not the greatest, but I'm only just new to eletronics and havent worked with the H bridge before. Thanks for the forum link.
You can perhaps make the programme a bit simpler by setting a "flag" to show the door is open

example:
B0=0 ' door closed flag of not open must be closed


check:
Check daylight if > set level then open the door else close the door.

open:
B0=1 ; set door open flag

rest of code to open the door.

Close:
B0=0 ' set door closed flag