Exact match. Not showing close matches.
PICList
Thread
'[PIC]: ASM Weirdness'
2005\03\21@195134
by
Anthony Van Herrewege
|
Hi,
I'm having some weird problem with PIC12F509 ASM code. It's supposed to check 3 inputs and if either one of them is high for at least 2 seconds it has to make an output pin high. As long as any of the 3 inputs is high, the output has to stay high too. If the 3 inputs go low, the output has to stay high for another minute.
The inputs are all 2 wires (one connected to +5V, one to the PIC's input) which will be lying in a basement to check if there's any water in it (if used diodes and resistors and stuff to keep it safe, so there won't be any massive currents in the water if anyone is wondering). The ouput drives a relay which will in turn power a waterpump.
To check if a minute has passed I use a variable which increments each half second if neither input is high. Then, when the variable is 120, the output goes low.
I've checked the code over and over, and I'm sure I'm overlooking something, but when the inputs stay high, the output goes low for 1 second after 60 seconds, then goes high again. This shouldn't be possible, since as long as either input is high, the counter remains at 0.
I tried creating the code in Hi-Tech PICC, but for some reason, when I try to program it, it's gives an error at address 0x0000. The reason is probably that I've never used Hi-Tech before.
Anyway, could someone please be so kind as to see if I've missed any stupid mistake in my ASM code? I've uploaded it here: users.skynet.be/devil_hack/etc/waterpump.asm
Thanks a lot!
Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
2005\03\21@205519
by
Jinx
> Anyway, could someone please be so kind as to see if I've missed
> any stupid mistake in my ASM code?
Sorry, I don't have time to go through your code thoroughly but can
I offer a couple of suggestions
This is the sort of code which you need to test patiently with a set
of logic conditions. It can be tedious but it's also character-building
and necessary
There are a limited number of conditons and combinations that can
occur. Put these into a logic table or a list and work through them
For example, Sensor1 can be 0 or 1 ditto Sensor2 and Sensor 3
and relay
So, begin mental execution at "Start" with the various logic settings
of the inputs and outputs and see where the program flow takes you.
If you genuinely (which requires that you DO NOT assume anything
about what you "think" you wanted the code to do) see no problem
there, try it with the counters ready for rollover or at their limit. This
process does need some patience and self-discipline and you should
justify everything that happens as you follow the flow. You have to
distance yourself from what you've written - often coming back to
it the next day helps
Also, is the PIC protected from
(a) Relay turn-on / turn-off. They can create MCLR spikes which
will seriously ruin your day
(b) read-modify-write
Hope that helps. Debugging your own code is not the fun part and
I fully appreciate your bewilderment
2005\03\22@035401
by
Alan B. Pearce
> Anyway, could someone please be so kind as to see if I've missed
> any stupid mistake in my ASM code?
This is the sort of code that should be easily tested in the MPLAB
simulator. Use the timing function to verify just how long something lasts
for. I suspect you have miscalculated a timing constant, as well as having a
logic fault.
2005\03\22@035931
by
Anthony Van Herrewege
|
Hi,
> This is the sort of code which you need to test patiently with a set of logic conditions. It can
> be tedious but it's also character-building and necessary
That's the weird thing, I must have simulated it with MPLAB SIM for at least 3-4 hours and everything seemed to work.
> Also, is the PIC protected from
> (a) Relay turn-on / turn-off. They can create MCLR spikes which will seriously ruin your day
> (b) read-modify-write
a) Well, there's a diode across the relay if that's what you mean.
b) Even if the read-modify-write problem would occur, I don't think it's the reason of the bug. The PIC just executes code that it shouldn't be able to execute (you know, like an if condition that test as false, but is executed anyway). I'm sure I'm missing something very obvious, but I can't seem to see it.
Anthony
Jinx <spam_OUTjoecolquittTakeThisOuT
clear.net.nz> wrote:
> Anyway, could someone please be so kind as to see if I've missed
> any stupid mistake in my ASM code?
Sorry, I don't have time to go through your code thoroughly but can
I offer a couple of suggestions
There are a limited number of conditons and combinations that can
occur. Put these into a logic table or a list and work through them
For example, Sensor1 can be 0 or 1 ditto Sensor2 and Sensor 3
and relay
So, begin mental execution at "Start" with the various logic settings
of the inputs and outputs and see where the program flow takes you.
If you genuinely (which requires that you DO NOT assume anything
about what you "think" you wanted the code to do) see no problem
there, try it with the counters ready for rollover or at their limit. This
process does need some patience and self-discipline and you should
justify everything that happens as you follow the flow. You have to
distance yourself from what you've written - often coming back to
it the next day helps
Also, is the PIC protected from
(a) Relay turn-on / turn-off. They can create MCLR spikes which
will seriously ruin your day
(b) read-modify-write
Hope that helps. Debugging your own code is not the fun part and
I fully appreciate your bewilderment
2005\03\22@050958
by
Jinx
> a) Well, there's a diode across the relay if that's what you mean
That will protect individual components, such as the driver transistor,
from the back-EMF when the relay turns off, but doesn't prevent a
spike getting on to Vdd and MCLR or other pins/components. A
relay is a "dirty" component which should have either a well-buffered
(at least the PIC's supply should be) or its own supply. It would pay
to look at it just to see if there is any undesirable noise in the circuit
even if you find the ultimate cause to be somewhere else
> b) Even if the read-modify-write problem would occur, I don't
> think it's the reason of the bug. The PIC just executes code that it
> shouldn't be able to execute (you know, like an if condition that
> test as false, but is executed anyway). I'm sure I'm missing something
> very obvious, but I can't seem to see it
Consider this - hour many hours do you think I wasted here because
"it just simply couldn't be the code" ?
http://www.piclist.com/techref/scenix/sxrmw.htm
and
http://www.piclist.com/techref/readmodwrite.htm
Obviously you've spent more time on your code than I have and I
don't intend this as a suck-eggs or condescending reply but .... look
at it this way. The PIC is doing what you're telling it to do or the
circuit is behaving the way you've set it up to. I just know that if you
break it down logically and methodically, the veil will lift as if by magic.
My apologies for not providing you with a specific answer, really
2005\03\22@054205
by
William Chops Westfield
On Mar 22, 2005, at 12:59 AM, Anthony Van Herrewege wrote:
>
> That's the weird thing, I must have simulated it with MPLAB SIM
> for at least 3-4 hours and everything seemed to work.
I note that if the circuit restarts for some reason, it will
turn off your relay. One second after turning the relay on is
an odd time for it to restart, but... I would stick code at
the restart address that sends some sort of signal to the LED
to indicate the reason for restart.
I didn't like where your code checked a register bit to see if
a count had reached 4; if it were to reach 8, your bit would go
off again. However, other code seemed to prevent this from
happening, so i don't think that's the bug...
BillW
2005\03\22@063735
by
Anthony Van Herrewege
|
Hi,
> This is the sort of code that should be easily tested in the MPLAB simulator. Use the timing
> function to verify just how long something lasts for. I suspect you have miscalculated a
> timing constant, as well as having a logic fault.
I tested it a lot in the simulator and everything worked OK in there. Except for one very weird thing: a LED is connected to GPIO4 and I XOR the 5th GPIO bit to toggle it on and off. However, in the simulator, GPIO4 stays 0, no matter what I try. When I program the chip, it works just fine. Very weird. (Btw, if I try to toggle GPIO5 in my code, it simulates just fine.)
> That will protect individual components, such as the driver transistor, from the back-EMF
> when the relay turns off, but doesn't prevent a spike getting on to Vdd and MCLR or other
> pins/components. A relay is a "dirty" component which should have either a well-buffered
> (at least the PIC's supply should be) or its own supply. It would pay to look at it just to see if
> there is any undesirable noise in the circuit even if you find the ultimate cause to be
> somewhere else.
I see. There's a 330µF cap after the voltage regulator and a 100nF one right next to the PICs pins (which are 1cm away from the 330µF cap). I've got a tons of tantalum caps lying around though, so I could add some more capacitance. Would a 100µF cap acros the PIC be enough to fix any possible problems? The supply is +5.7V because it's a 6V relay, the power to the PIC goes through a diode first, thus making it +5V. I could also put a zener acros the diode going to the PIC. Would that help?
> Consider this - hour many hours do you think I wasted here because "it just simply couldn't
> be the code" ?
Thanks for those links!
> Obviously you've spent more time on your code than I have and I don't intend this as a suck-
> eggs or condescending reply but .... look at it this way. The PIC is doing what you're telling it
> to do or the circuit is behaving the way you've set it up to. I just know that if you break it
> down logically and methodically, the veil will lift as if by magic.
I know PC's only do them what you tell them to do, that's why I was so frustrated, because I couldn't find the mistake ;).
> My apologies for not providing you with a specific answer, really
No problem at all!
Anyway, I messed around with the code a bit, but it kept simulating the same as before (except for the weird GPIO4 thing), so I decided to program my lastest HEX file in the PIC12F509 again. IC-Prog kept giving errors (it doesn't support the 12F509, you have to use the 12C509), so I ereased it (telling IC-Prog it was a 16F84A) and tried programming it again and now everything works just fine. I don't really get it, but well, as long as it's working as it should, I'm happy :).
One last question, it hasn't got to do with ASM though. Yesterday night I also made the code in Hi-Tech C, which wasn't to much work (getting it to compile was though) since it's only like 5 if-clauses (and it could be even shorter, but I wanted it to be very easy to understand). Anyway, the code compiles, but only as long as I comment out my very first line: asm("MOVWF OSCCAL"); It says it doesn't know OSCCAL, although it's defined in the PIC125xx.h file. So, I tried doing it with C, but I can't seem to find the name of the W register. Is there any way in Hi-Tech C to read the W register directly? The OSCCAL value is in W on reset, so I need to know the value stored in it.
Thanks, Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Make Yahoo! your home page
2005\03\22@082819
by
Alan B. Pearce
>Anyway, I messed around with the code a bit, but it kept simulating
>the same as before (except for the weird GPIO4 thing), so I decided
>to program my lastest HEX file in the PIC12F509 again. IC-Prog kept
>giving errors (it doesn't support the 12F509, you have to use the 12C509),
Ahh, another case of not giving all the information.
Now are you sure the CONFIG bits are the same? Are you sure that the
watchdog is being turned off? This was another thing that I thought about
earlier, but dismissed because you said it worked in the simulator. What
happens if you set the simulator to 12C509, and run the 12F509 code without
re-assembling it????
2005\03\22@120152
by
Anthony Van Herrewege
|
Hi,
It's working now as it should, but:
> Ahh, another case of not giving all the information.
>
> Now are you sure the CONFIG bits are the same? Are you sure that the watchdog is being
> turned off? This was another thing that I thought about earlier, but dismissed because you
> said it worked in the simulator. What happens if you set the simulator to 12C509, and run
> the 12F509 code without re-assembling it????
Ah, sorry for not being clear. What I meant was that you can't select the PIC12F509 in IC-Prog as the PIC you're programming. You can program it though, but you have to select the PIC12C509 if you want to do so.
By the way, I just noticed that I've also programmed a PIC12C509A by accident and it works just fine.
"Alan B. Pearce" <.....A.B.PearceKILLspam
@spam@rl.ac.uk> wrote:
>Anyway, I messed around with the code a bit, but it kept simulating
>the same as before (except for the weird GPIO4 thing), so I decided
>to program my lastest HEX file in the PIC12F509 again. IC-Prog kept
>giving errors (it doesn't support the 12F509, you have to use the 12C509),
2005\03\22@125325
by
Jan-Erik Soderholm
Anthony Van Herrewege wrote :
> Ah, sorry for not being clear. What I meant was that you
> can't select the PIC12F509 in IC-Prog as the PIC you're
> programming. You can program it though, but you have to
> select the PIC12C509 if you want to do so.
It was, IMHO, perfectly clear that that was what you ment.
The problem was that you didn't say so in your *original* post...
Jan-Erik.
2005\03\22@164825
by
Wouter van Ooijen
> (Btw, if I try to toggle GPIO5 in my code, it simulates just fine.)
You do know about the read-modify-write issue? If not start googling!
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\03\22@223458
by
Anthony Van Herrewege
Hi,
> You do know about the read-modify-write issue? If not start googling!
I do, but what I mean is that when I simulate the pin toggling code it doesn't work. When I compile it, program it and let it execute on an actual PIC it does work.
I've been trying to add some fancy things to the Hi-Tech C code that I've also written, but I keep getting weird errors. The fact that I get the same errors with both the ASM and the C code (which should do exactly the same, in fact, they simulate both exactly the same), makes me thing it's a hardware issue.
At first I thought it was the voltage regulator that was overheating and shutting itself down, but I just measured it's temperature and it's settles around 28 °C, so that can't be it. I'll try to figure it out tomorrow.
Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site
2005\03\23@011716
by
Jinx
> Would a 100µF cap acros the PIC be enough to fix any
> possible problems?
Probably not, not on its own anyway
> The supply is +5.7V because it's a 6V relay, the power to the PIC
> goes through a diode first, thus making it +5V
If you find relay noise on the PIC -
send the 5.7V through a diode to the relay too (k to the relay side).
That will further keep the two supplies apart and stop any relay
section glitches drawing power from the PIC side. A 6V relay should
be OK from 4V-10V, although at the very lowest V the pull-in won't
be so strong as at nominal V
=================
In fact it may not pull-in at all at 4V, but will hold (albeit a little
weakly). On this page
http://www.piclist.com/techref/io/relays.htm
is a temporary voltage-doubling technique that I've used with
battery-powered PIC circuits to save power
(note comments about cap and diode)
2005\03\23@080107
by
John J. McDonough
----- Original Message -----
From: "Anthony Van Herrewege" <anthony_v_h
KILLspamyahoo.com>
Subject: RE: [PIC]: ASM Weirdness
> I do, but what I mean is that when I simulate the pin toggling
> code it doesn't work. When I compile it, program it and let it
> execute on an actual PIC it does work.
Pay very close attention to what you are doing in MPSIM. When you click on
the button to toggle an input, the response is not very good. It seems as
if most times you need two clicks - one for the button to get the focus and
one to activate the button. Of course, the way windows is, the focus
frequently isn't where you expect it, so clicking twice every time doesn't
do it, either. You just need to pay very close attention.
This is, by a long way, the most amateurish part of MPLAB. Somebody from
Microchip apparently wanted their 10 year old to say that had a part of the
product or something. This particular feature is really bad.
--McD
2005\03\23@090813
by
alan smith
IF you think its the relay causing noise, isolate it.
Use a LED to emulate the relay, or drive with an opto
or use a solid state relay such that you don't get the
spikes on the power supply (if thats what is causing
the issues)
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
2005\03\23@090958
by
Anthony Van Herrewege
|
Hi,
Ok, I've tracked down the problem, well, kind of. When the relay is enaged for some odd reason the voltage at the PIC's supply pins drops from 5.1V to 3.7V. This isn't a problem for the PIC, since the datasheet says it should work with Vdd as low as 2V. However, the problem lies with the "sensors". When the 2 wires are shorted together and the relay is not engaged there's a voltage high enough on the PIC's input pins to be always recognized as a high input. (I haven't measured how much it is, but I guess at least 3V, probably more.) Now, when the voltage drops, the "high" input drops to 1.5V which seems to be too low for the PIC to recognize as high, so it immeadiately enters the "1-minute-countdown" mode.
What I find weird is that the voltage drops so much. The relay needs 80mA supply current (according to it's datasheet) and the transformer I'm using should be able to supply 166mA, which should be overkill, really.
Has anyone got any idea why it is that the voltage drops that much? I was thinking it might be a short, but I just checked and can't seem to find any. I wouldn't want to find out I've got the same problem after I've designed a new PCB.
> send the 5.7V through a diode to the relay too (k to the relay side). That will further keep the
> two supplies apart and stop any relay section glitches drawing power from the PIC side. A
> 6V relay should be OK from 4V-10V, although at the very lowest V the pull-in won't be so
> strong as at nominal V
Thanks for the tip (and the link!), I'll definately do that!
Thanks, Anthony
Website: http://members.lycos.nl/anthonyvh
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
2005\03\23@093219
by
Howard Winter
Anthony,
On Wed, 23 Mar 2005 06:09:57 -0800 (PST), Anthony Van
Herrewege wrote:
> Has anyone got any idea why it is that the voltage
drops that much?
It would *really* help to see the circuit diagram,
otherwise we're guessing in a vacuum.
Cheers,
Howard Winter
St.Albans, England
2005\03\23@100115
by
Anthony Van Herrewege
|
Hi,
I just n
> I would stick code at the restart address that sends some sort of signal to the LED to
> indicate the reason for restart.
Meanwhile, I added some lines to the C code I also wrote to make the LED blink double as fast when the chip enters the "1-minute-'till-relay-off" state. That helped me find the problem (I think).
> I didn't like where your code checked a register bit to see if a count had reached 4; if it were
> to reach 8, your bit would go off again. However, other code seemed to prevent this from
> happening, so i don't think that's the bug...
I don't think it's the software. In the C code I do the same, except I test for Counter <= 4 and I get the same bugs. It's some hardware thing.
Anyway, I noticed something very stupid. I haven't placed a resistor between the darlington's base and the PIC's output pin. Could this be a reason that the voltage is dropping so much? Does the PIC limit the current though it's pins or not?
Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Make Yahoo! your home page
2005\03\23@101701
by
Wouter van Ooijen
> What I find weird is that the voltage drops so much. The
> relay needs 80mA supply current (according to it's datasheet)
> and the transformer I'm using should be able to supply 166mA,
> which should be overkill, really.
I did not catch most of this discussion, but is your reservoir cap large
enough?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\03\23@112855
by
Jan-Erik Soderholm
Anthony Van Herrewege wrote :
> Anyway, I noticed something very stupid. I haven't placed a
> resistor between the darlington's base and the PIC's output
> pin...
Yes, that was "stupid" :-) :-)
As seen from the PIC pin, the darlington is just two
serial diods to the emitter. Depending on where your
emitter is connected (to gnd ?) you could easily get
a current rush into the base. One of three things
would probably happen. The PIC pin breaks down.
The base of the darlington breaks down. Or your
power supply can't supply the current and the voltage
drops down until the current is "limited".
A FET will handle this better, but should also normaly
have a current limiting resistor to limit the current
pulse when the gate capacitor charges and discharges.
> Could this be a reason that the voltage is dropping so
> much?
Why not just try *with* a resistor ?
> Does the PIC limit the current though it's pins or not?
No, there is no current limiting function builtin. At some
undefined level it will act as a non-resetable fuse, and
that is guarantieed to not happen below the "max current
per pin" value in the data sheet. That's all you have to know...
Jan-Erik.
2005\03\23@113409
by
Alan B. Pearce
> What I find weird is that the voltage drops so much. The
> relay needs 80mA supply current (according to it's datasheet)
> and the transformer I'm using should be able to supply 166mA,
> which should be overkill, really.
OK, when you talk about a transformer, what sort is it? If it is a Walwart,
which judging by the current you quote it could well be, then what is the
nominal output voltage, and how much ripple does it have on the DC when the
relay pulls in. Does it all improve if you put a large electrolytic cap on
the supply?
>I don't think it's the software. In the C code I do the same,
>except I test for Counter <= 4 and I get the same bugs. It's
>some hardware thing.
Well that is an assumption. it could well be that you are making the same
code logic mistakes in the C code as the assembly code. Also I have not seen
an answer to my query about checking the CONFIG differences between a 12F508
and a 12C508. Are there any, specifically that affect the watchdog timer?
>Anyway, I noticed something very stupid. I haven't placed a
>resistor between the darlington's base and the PIC's output
>pin. Could this be a reason that the voltage is dropping so much?
Not very likely.
>Does the PIC limit the current though it's pins or not?
It does, but to a much higher current than the darlington will require to
put it into saturation.
Another thing I have not seen an answer to - someone else asked what happens
if you use an LED instead of a relay while you are testing. have you done
this? Does it show the same symptom?
2005\03\23@114811
by
Jan-Erik Soderholm
Alan B. Pearce wrote :
> > Does the PIC limit the current though it's pins or not?
>
> It does, but to a much higher current than the darlington
> will require to put it into saturation.
But, even after the darlington is saturated, it (the darlington)
will not limit the current flow into it's base, right ? It's just
two diods to gnd (if the darlington is connected between
the gnd and the relay). And feeding 5V from the PIC pin
through two diods to gnd is no good, is it ?
Jan-Erik.
2005\03\23@130926
by
Anthony Van Herrewege
|
Hi,
* Howard Winter wrote:
> It would *really* help to see the circuit diagram, otherwise we're guessing in a vacuum.
Here you go: http://members.lycos.nl/anthonyvh/index.php?page=pump. I didn't update the circuit with tips people on the list gave me, the circuit you see is the one I'm having trouble with.
I created a new circuit + PCB the last 2 hours.
* Jan-Erik Soderholm wrote:
> Yes, that was "stupid" :-) :-) As seen from the PIC pin, the darlington is just two serial
> diodes to the emitter. Depending on where your emitter is connected (to gnd ?) you could
> easily get a current rush into the base. One of three things would probably happen. The PIC
> pin breaks down. The base of the darlington breaks down. Or your power supply can't supply
> the current and the voltage drops down until the current is "limited".
Indeed, the emitter is connected to ground. I really, really, really hope it's the 3rd thing that's happening in my circuit (I think I'm going to go crazy if I can't find the reason it's acting weird).
> A FET will handle this better, but should also normaly have a current limiting resistor to limit
> the current pulse when the gate capacitor charges and discharges.
I just routed a PCB with SMD parts instead of TH and I've got both SOT-23 NPN darlingtons and FETs lying around, so I could try both. The routing's really crappy though, I did it in a rush the past hour, I hope I didn't forget anything :). (I find SMD PCBs easier to "fix", since all pads are accessible from the top, no wire that need to go under the PCB. Also it looks a lot nicer.)
> Why not just try *with* a resistor ?
That's kind of my problem: I'm in Leuven now, where I go to university and the only thing I got here is a PIC programmer, the circuit and a DMM. No soldering equipment of any kind (I wouldn't be able to put all my electronics stuff in my room anyway). So, I'll have to wait untill Friday evening to fix it.
> No, there is no current limiting function builtin. At some undefined level it will act as a non-
> resetable fuse, and that is guarantieed to not happen below the "max current per pin" value
> in the data sheet. That's all you have to know...
Great, more reason to believe that that's in fact what's causing the problem :).
* Wouter van Ooijen wrote:
> I did not catch most of this discussion, but is your reservoir cap large enough?
330µF both before and after the regulator + 100n right across the PIC's supply pins.
* Alan B. Pearce wrote:
> OK, when you talk about a transformer, what sort is it? If it is a Walwart, which judging by
> the current you quote it could well be, then what is the nominal output voltage, and how
> much ripple does it have on the DC when the relay pulls in. Does it all improve if you put a
> large electrolytic cap on the supply?
It's on the PCB itself, it's one of those "blue block" PCB mount transformers. My DMM isn't great, but it doesn't show any ripple, when the relay's engaged it stays 3.75V (no change in at least 50 seconds).
> Well that is an assumption. it could well be that you are making the same code logic
> mistakes in the C code as the assembly code. Also I have not seen an answer to my query
> about checking the CONFIG differences between a 12F508 and a 12C508. Are there any,
> specifically that affect the watchdog timer?
I know, but after all the C code's only 4 if-clauses, it's not like it difficult. I might have overseen something, but I don't see any mistakes in those 4 if-clauses.
Hm, I don't know about CONFIG differences between the 12F509 & 12C509, but lots of people on the IC-Prog forum say that choosing the 12C509 as device when programming the 12F509 in IC-Prog works perfectly.
I don't think it's the watchdog timer, because sometimes the relay opens again after 1min05, sometimes after 1min20, sometimes after more than 2 minutes.
> Another thing I have not seen an answer to - someone else asked what happens if you use
> an LED instead of a relay while you are testing. have you done this? Does it show the same
> symptom?
I will do that, but I can't right now, since I can't (de)solder anything untill Friday evening.
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone
2005\03\23@134613
by
olin_piclist
Alan B. Pearce wrote:
>> Anyway, I noticed something very stupid. I haven't placed a
>> resistor between the darlington's base and the PIC's output
>> pin. Could this be a reason that the voltage is dropping so much?
>
> Not very likely.
I disagree. The darlington base will look like two silicon diodes in series
to the PIC output. It won't be able to drive this higher than about 1.5V,
which will cause out of spec current going out of the PIC output pin when it
tries but fails to raise it to 5V. If it doesn't fry the PIC, it could
easily be reponsible for higher than expected supply current.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
2005\03\23@135021
by
Wouter van Ooijen
> http://members.lycos.nl/anthonyvh/index.php?page=pump.
What is the (nominal) secondary voltage of your transformer? I would not
feel comfortable with less than 9V, 12V would be better.
What is that diode doing in the ground wire of the 7805?
If you used a dual-secondary transformer as indicated in the circuit,
did you connect the two secondaries in the right way?
The circuit shows both +5 and +5/1. IMHO these should be connected.
I don't understand what those 1N4148's are for, but they won't hurt.
Same for the 10k between the sensors and the +5.
And of course, as mentioned, you did put a resistor (1..10k) between the
PIC and the BC517, did you?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\03\23@140520
by
William Chops Westfield
>>> I haven't placed a resistor between the darlington's base and the
>>> PIC's output pin. Could this be a reason that the voltage is
>>> dropping so much?
>
> If it doesn't fry the PIC, it could easily be reponsible for
> higher than expected supply current.
>
Yeah. If the power supply is about 166mA, and the relay consumes
80mA, it doesn't seem inconceivable that the PIC could source the
approximately 80mA that you have left in the power budget.
The 300uF filter cap you have after your bridge rectifier seems
smaller than usual. Did you do any calculations to ensure that
that's sufficient?
BillW
2005\03\23@154920
by
Dan
FWIW, These are on ebay and had caught my interest, they could have
applicability in your water-pump application.
ULN2429A Fluid Detector and Level Sensor IC 100 pcs NOS
cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=7501352198&ssPageName=ADM
E:B:WN:US:1
Dan
{Original Message removed}
2005\03\23@161119
by
Jinx
> http://members.lycos.nl/anthonyvh/index.php?page=pump
I'd move the relay to the pre-regulator voltage. That both takes
it off the 7805 (you can then sub it with a cheaper 78L05) and
isolates it somewhat from the post-reg voltage. Put a resistor in
series with the coil to get the V across it within a comfortable
range if you want
Hesitate to ask - what type of water pump and have you tried
switching it yet ? Maybe there's Round Two to come.....
2005\03\23@162353
by
Randy Jones
|
Anthony,
The first thing you need to do is connect an appropriate value resistor
between the PIC I/O pin and the base of the transistor. As others have
said, the heavy current flow through the I/O pin and the transistor may be a
significant part of your problem.
Before discussing the proper value of resistor, it would be good to think
about which transistor is best for this application. The high sensitivity
of the Darlington is not needed here, and Darlingtons have a built-in
voltage drop in saturation of at least .7 to .8 volts -- which steals much
of the voltage you want to apply to the relay and also heats the transistor.
So the extra 0.7 volts you gained by placing the diode in the ground
connection of the voltage regulator is being thrown away by the voltage drop
of the Darlington transistor.
Since your relay only needs about 80 mA, a small NPN switching transistor
(non-Darlington) will be fine with the current available from a PIC I/O pin.
I don't know the BC numbers well enough to make a suggestion, but US numbers
for a suitable part would include 2N3904, 2N4401, and PN2222. The latter
two part numbers have better gain at the relay's load current than the
2N3904, and therefore would be a nicer match than the 2N3904.
If you look at a 2N3904 data sheet, for example, you will see that the DC
current gain is best around 10 mA of collector current, and has dropped
drastically by the time collector current reaches 100 mA. It will still
work at 100 mA, but you'll have to drive the base current harder than a
device like the 2N4401 where it's best gain is at a collector current more
closely matched to your relay current.
http://www.fairchildsemi.com/ds/2N%2F2N3904.pdf
http://www.fairchildsemi.com/ds/2N%2F2N4401.pdf
Looking at the 2N4401 data sheet, it has the same gain at 150 mA collector
current that the 2N3904 does at 10 mA collector current. So the 2N4401
works better at higher currents than the 2N3904 and would be a nicer match
for your relay current of 80 mA.
Using a BC transistor number similar to the 2N4401, a base resistor of
approximately 1k ohms would be a good starting point. I would expect it to
provide good saturation with your 80 mA relay current. Actually, I have a
12F509 right here on a breadboard and it will just take a moment to test...
A 1.0k base resistor is being used with a 2N4401 being driven from a PIC I/O
pin. The "load" is a 47 ohm resistor connected between the 2N4401 collector
and a good 5.0 volt supply. This will give a load current of 100 mA.
Here are the measurements using a Fluke 45 bench meter (all referenced to
Vss/common):
Power rail = 4.97 V, PIC I/O pin (high) = 4.73 V, 2N4401 base = .81 V,
2N4401 collector = .106 V, and the 1/4 watt 47 ohm resistor is getting
warm -- heh, heh!
So this is working very well, with the voltage drop across the transistor
(Vce) at only 0.1 volts -- which is much better than you could get with the
Darlington. If you find a similar "BC" transistor number it should work
just as well.
Personally, I would move the positive connection of the relay coil to the
input side of the voltage regulator, and put an appropriate series dropping
resistor if needed to get the voltage at the relay down to 6V or so. Then
you could eliminate the diode between the voltage regulator pin and ground
to get the regulator output back to 5.0 volts and connect it directly to the
PIC. This would provide more isolation between the relay and the PIC.
If the voltage to the relay still drops excessively when it is turned on,
check the rectifier bridge to make sure it is working correctly, and then
the transformer to make sure it can supply adequate voltage under load.
With a 7805 5V regulator, you'll need at least 7.5 volts to make sure it
stays in regulation.
Hope that helps,
-Randy
http://www.glitchbuster.com
2005\03\23@163219
by
Anthony Van Herrewege
|
Hi,
* Wouter van Ooijen wrote:
> What is the (nominal) secondary voltage of your transformer? I would not feel comfortable
> with less than 9V, 12V would be better.
My god, you can't believe how stupid I feel righ now. I must have made at least 5 power supplies in the last year and then I do something as stupid as using a 6V secondary to get 5.7V out of an 7805.... Djeez....
Ok, so there's definately the problem. (Well, probably together with the resistor thing.)
> What is that diode doing in the ground wire of the 7805?
The relay is 6V DC, I figured driving it with 5.7V would be a sure way to get it in the on state, instead of using just 5V.
> If you used a dual-secondary transformer as indicated in the circuit, did you connect the two
> secondaries in the right way?
I do, and yes, they're connected correctly.
> The circuit shows both +5 and +5/1. IMHO these should be connected.
No, actually +5V is +5.7V (because of the diode in the ground wire of the 7805), the +5/1V is the +5.7V + a diode in series, thus actually +5V.
> I don't understand what those 1N4148's are for, but they won't hurt. Same for the 10k
> between the sensors and the +5.
Indeed, the 1N4148's don't really have much use, in the circuit I routed this afternoon I put 1 diode in series with the red wires you see on the photograph, since they are connected directly to +5V. I wouldn't want 230V AC entering the circuit through there in case there's some short when the basement's flooded.
The resistors are there to limit current, the ones connected directly to the input of the PIC indeed have no use either, but I did put one in series with the red wire too, since I don't want massive currents flowing when the wires get shorted by the water.
> And of course, as mentioned, you did put a resistor (1..10k) between the PIC and the
> BC517, did you?
No, so I guess we found the problem: too low sencondary voltage + no base resistor. As I said, I can't solder where I am during the week, but I'll fix it in the weekend.
You've all been of great help, I would probably have taken me a lot of time before I would have spotted those stupid, stupid mistakes!
Thanks a lot everyone!
I'll inform you all how it works during/after the weekend, when it's fixed.
Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
2005\03\23@172408
by
Jan-Erik Soderholm
Anthony Van Herrewege wrote :
> ...since I
> don't want massive currents flowing when the wires get
> shorted by the water.
Now, I'm not sure, but I would not think that water alone
would "short" the wires. Actualy, distilled water is close
to an isolator, I think. Heavily salted water will be a less
of an isolator, but "shorted" and "massive currents", well,
I don't know...
The other interesting question is, *why* would the
basement get flooded in the first place ??
:-)
Regrads,
Jan-Erik.
2005\03\23@182601
by
Jinx
> using a 6V secondary to get 5.7V out of an 7805.... Djeez....
If it's 6VAC then you might be OK if you dispense with the 5.7V
idea. Assuming the worst and it's just 6VAC that would give around
8VDC after the bridge. It should actually be higher if the transformer
is rated to deliver 6VAC at a current greater than what you're drawing.
If voltage differential across the 7805 really is marginal you could try
an LDO or Xena and a good reservoir cap to supply the turn-on
current for the relay.
Maybe a bit of a power waste but put the secondaries in series ? The
creation of a centre-tap would give you two voltages to use or choose
from. One for the relay (unregulated) and one for the digital. Add a
series resistor to the regulator to reduce its i/p V to a more reasonable
V if you select the higher transformer V for it, then the resistor will heat
up rather than the regulator
2005\03\23@204116
by
Anthony Van Herrewege
|
Hi,
Thanks both Randy and Jinx for the tips, I changed the schematic to accomodate for the things you said. I did do one thing different: I put the relay after the transistor, that way it will be like there's a diode in series with the unregulated supply, first of all it will drop 0.7V, so the resistor won't heat up as much, second I hope it will keep voltage spikes on turn off out of the regulator's input. (Of course the transistor will heat up, but I'm hoping it will be able to cope with it.)
Dan, thanks for the eBay link. I don't really need the chip though, although it used a much more sophisticated way to detect fluids than what I'm doing, my method should be sufficient for the simple thing I'm trying to acomplish.
* Jan-Erik Soderholm wrote:
> Now, I'm not sure, but I would not think that water alone would "short" the wires. Actualy,
> distilled water is close to an isolator, I think. Heavily salted water will be a less of an isolator,
> but "shorted" and "massive currents", well, I don't know...
The basement won't be flooded with distilled water, I think that would be a bit expensive ;). Anyway, I'm pretty sure a basement full of water will be able to conduct more than the meager 170mA my supply can deliver. So for the supply it will be way more than it can handle.
> The other interesting question is, *why* would the basement get flooded in the first place ??
Good question and I have no idea. I've never even seen it hapen and I hope for our sake that it doesn't, but my mother's boyfriend really wants to have a pump in the basement.
* Jinx wrote:
> If it's 6VAC then you might be OK if you dispense with the 5.7V idea. Assuming the worst
> and it's just 6VAC that would give around 8VDC after the bridge. It should actually be higher
> if the transformer is rated to deliver 6VAC at a current greater than what you're drawing.
It doesn't really matter, I'll re-use the 6VAC transformer for some 3.3V project and just buy a 9VAC one, that way I'm 100% sure that it's at least not the transformer that's causing trouble.
Anthony
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
2005\03\24@015748
by
Wouter van Ooijen
> If it's 6VAC then you might be OK if you dispense with the 5.7V
> idea. Assuming the worst and it's just 6VAC that would give around
> 8VDC after the bridge.
( sqrt(2) * 6 ) - ( 2 * 0.7 ) = 7.08
So where do you buy your diodes?
And note that this is the top value across the buffer elco, so you must
take the ripple into account. And the trafo rating will have a
tolerance, maybe 6V 10%. And the AC mains input certainly has a
'tolerance', often 10% or even 20%.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\03\24@015755
by
Wouter van Ooijen
> No, so I guess we found the problem: too low sencondary
> voltage + no base resistor. As I said, I can't solder where I
> am during the week, but I'll fix it in the weekend.
In my experience: when it is difficult to find *the* problem it is very
likely that your are looking at at least 2 problems, which requires a
different mindset.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\03\24@024535
by
Jinx
> ( sqrt(2) * 6 ) - ( 2 * 0.7 ) = 7.08
>
> So where do you buy your diodes?
"Magical Diodes 'R' Us" of course
My mistake, I took only 1 diode drop. I think in a low
power circuit with a marginal supply you could get away
with a Schottky bridge, but that's straying from Andrew's
problem. I'm sure that the 6VAC would be at the rated
o/p current and would be worth testing before swapping
it for a higher V transformer
2005\03\24@030931
by
Jinx
> with a Schottky bridge, but that's straying from Andrew's
Andrew ? Who's Andrew ? Sorry Anthony
2005\03\24@031401
by
ThePicMan
At 19.45 2005.03.24 +1200, you wrote:
>> ( sqrt(2) * 6 ) - ( 2 * 0.7 ) = 7.08
>>
>> So where do you buy your diodes?
>
>"Magical Diodes 'R' Us" of course
By the way, sometime, somewhere, I'm sure I've read that it's
possible to make a "zero voltage drop rectifier" using MOSFETs.
Can anyone can elaborate on that, please?
Cheers,
TPM
2005\03\24@070502
by
Anthony Van Herrewege
* Jinx wrote:
> I'm sure that the 6VAC would be at the rated o/p current and would be worth testing before
> swapping it for a higher V transformer
I'll try using it. I believe I needed to make 2 circuits anyway, because there will be 2 pumps. I'll make one with a 9VAC transfo and one with the 6VAC one (they're both the same size).
> Andrew ? Who's Andrew ? Sorry Anthony
No problem. That mistake's a lot less stupid than all the ones I made in my circuit ;).
Website: http://members.lycos.nl/anthonyvh
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
2005\03\24@083112
by
olin_piclist
ThePicMan wrote:
> By the way, sometime, somewhere, I'm sure I've read that it's
> possible to make a "zero voltage drop rectifier" using MOSFETs.
>
> Can anyone can elaborate on that, please?
Look up "synchronous rectification".
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
2005\03\24@102057
by
ThePicMan
At 08.31 2005.03.24 -0500, you wrote:
>ThePicMan wrote:
>>By the way, sometime, somewhere, I'm sure I've read that it's
>>possible to make a "zero voltage drop rectifier" using MOSFETs.
>>
>>Can anyone can elaborate on that, please?
>
>Look up "synchronous rectification".
Thanks, Olin.
More... (looser matching)
- Last day of these posts
- In 2005
, 2006 only
- Today
- New search...