Hold on, What the..? LED works Both ways?

alband

Senior Member
Right. I'm sat here with a PICAXE28X1 a switch power and some very individualy minded LED's.
I'm just testing a 2X2 grid of LED's using 4 pins. There are 16 combinations of on and off for a 2X2 grid and I've got it set up to do one each time a press a switch. I've got a circuit set so I'm using output pins 0-3. The LED's are connected as follows:
1. pin3, pin0
2. pin3, pin1
3. pin2, pin0
4. pin2, pin1
(LED no. Negative, Positive)

When I (try to) put LED 2 I do this:
high 1
high 2
low 3
The voltages at each pin are as follows:
0 = 0V
1 = 0.61V
2 = 1.32v
3 = 0.10v
The shock is that LED2 comes on and so does LED4! This means Light Emiting DIODE 4 works backwards!? When I turn it around it shines exactly the same yet when hooked up to a battery one way then the other I get the expected result.
Any Ideas?:confused:
 

BeanieBots

Moderator
STOP STOP
You are going to KILL your PICAXE.

Those voltages suggest that you don't have any current limiting resistors in series with your LEDs. The PICAXE outputs are being over driven and not reaching the voltage you assume to be a logic high. Hence, unpredictable results. Put the resistors in and try again.

If you DO have resistors in place, then those voltages imply that your code is not doing what you expect it to be doing.

Might be a good idea to post both code and circuit just to clarify.
 

alband

Senior Member
Thats the code.
For the schematic, I am yet to find any good schematic software that is just designed to display circuit diagrams at a resonable price any surgestions?

I'm not currently using resistors but have turned of the PIC! Where (earthing pull downs, or in series) and would 1K do?

Still unexpected results are unexpected but this is rediculas.
I've got an LED here that when put between voltages of 0.61V
& 1.32v works both ways?
 

Attachments

BeanieBots

Moderator
Please post code as code:-

Code:
main:
label_477:
label_624:	gosub prc_4	'Do Procedure 
		if pin3 = 1 then label_749	'Decision command
		goto label_624

label_749:
		if pin3 = 0 then label_746	'Decision command
		goto label_749

label_746:	gosub prc_3	'Do Procedure 
		if pin3 = 1 then label_751	'Decision command
		goto label_746

label_751:
		if pin3 = 0 then label_734	'Decision command
		goto label_751

label_734:	gosub prc_34	'Do Procedure 
		if pin3 = 1 then label_753	'Decision command
		goto label_734

label_753:
		if pin3 = 0 then label_740	'Decision command
		goto label_753

label_740:	gosub prc_2	'Do Procedure 
		if pin3 = 1 then label_755	'Decision command
		goto label_740

label_755:
		if pin3 = 0 then label_756	'Decision command
		goto label_755

label_756:	gosub prc_24	'Do Procedure 
		if pin3 = 1 then label_758	'Decision command
		goto label_756

label_758:
		if pin3 = 0 then label_763	'Decision command
		goto label_758

label_763:	gosub prc_23	'Do Procedure 
		if pin3 = 1 then label_760	'Decision command
		goto label_763

label_760:
		if pin3 = 0 then label_765	'Decision command
		goto label_760

label_765:	gosub prc_234	'Do Procedure 
		if pin3 = 1 then label_767	'Decision command
		goto label_765

label_767:
		if pin3 = 0 then label_776	'Decision command
		goto label_767

label_776:	gosub prc_1	'Do Procedure 
		if pin3 = 1 then label_769	'Decision command
		goto label_776

label_769:
		if pin3 = 0 then label_777	'Decision command
		goto label_769

label_777:	gosub prc_14	'Do Procedure 
		if pin3 = 1 then label_771	'Decision command
		goto label_777

label_771:
		if pin3 = 0 then label_778	'Decision command
		goto label_771

label_778:	gosub prc_134	'Do Procedure 
		if pin3 = 1 then label_773	'Decision command
		goto label_778

label_773:
		if pin3 = 0 then label_779	'Decision command
		goto label_773

label_779:	gosub prc_12	'Do Procedure 
		if pin3 = 1 then label_775	'Decision command
		goto label_779

label_775:
		if pin3 = 0 then label_784	'Decision command
		goto label_775

label_784:	gosub prc_124	'Do Procedure 
		if pin3 = 1 then label_781	'Decision command
		goto label_784

label_781:
		if pin3 = 0 then label_786	'Decision command
		goto label_781

label_786:	gosub prc_123	'Do Procedure 
		if pin3 = 1 then label_783	'Decision command
		goto label_786

label_783:
		if pin3 = 0 then label_787	'Decision command
		goto label_783

label_787:	gosub prc_1234	'Do Procedure 
		if pin3 = 1 then label_789	'Decision command
		goto label_787

label_789:
		if pin3 = 0 then label_477	'Decision command
		goto label_789

prc_1234:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_123:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_124:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_12:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_134:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_14:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_1:
		high 0
		low 3
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_234:
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_23:
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_24:
		high 1
		low 4
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_2:
		high 1
		high 2
		low 3
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_34:
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		high 1
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_3:
		high 0
		low 2
		low 0
		low 1
		low 2
		low 4
		return		'End 

prc_4:
		high 1
		low 2
		high 3
		low 0
		low 1
		low 2
		low 4
		return		'End
Well, I don't have the patience to follow that!
You MUST put a resistor in SERIES with each LED to limit the current. 1k will be fine. Do that and see if it fixes the problem.
It might ALSO be that your code is racing. That is, it is running through a loop and turning outputs on/off very quickly making it APPEAR that the lines are at those voltages. Your DVM simply gives an average voltage.
 

BeanieBots

Moderator
Try this:-

1 X 1 grid. (as simple as it can get.)
LED (plus resistor) between pin0 and pin1.

main:
high 0
low 1
pause 5
low 0
high 1
pause 5
goto main

Measure the voltage on each pin, then swap the LED around and measure again.

Should light either way with about 2.5v on EACH leg. So does it work with 0v across it?
 

alband

Senior Member
Yep I understand, It can appear thet it is on both ways but I might have alternating pulses. But I've just wired it up and the problem persists.
The pin voltages with series 1k's is:
0 = 0v
1 = 0.8v
2 = 1.37v
3 = 0.36v
:confused:
 

BeanieBots

Moderator
It's only a problem if your code is meant to leave the pins static.
If your code is meant to be pulsing the pins, then your observation is correct and expected.
Either way, it's down to your code.
 

alband

Senior Member
Cracked it. The code it is running at the time is:
Code:
label_740:	gosub prc_2	'Do Procedure 
		if pin3 = 1 then label_755	'Checks if button is pressed
		goto label_740
prc_2:
		high 1
		high 2
		low 3
		low 0
		low 1
		low 2
		low 4
		return		'End
There is a period wher 1 ins high but 2 is low this is quickly sorted but 2 goes lower that 1 for a tiny portion. Just switched the to "high"s around and it works.
Thanks.
Bit of a shame though - thought I was realy onto something there.
 

BeanieBots

Moderator
thought I was realy onto something there.
Indeed, we all long for an LED which can work with 0v across it:D
Glad you worked it out.
If you want to set pins all at the same time rather than setting each one in turn, then have a look at the "pins=" function in the manual. You can set all 8 outputs at exactly the same time.
 

alband

Senior Member
That sounds useful.
I'm currently using PIClogicator because I'm mentaly lasey and can't be bothered to try and mentaly picture everything, but "PICAXE programing editor" (the one from picaxe.co.uk) is certainly proving its uses - so many more commands.
 

BeanieBots

Moderator
Never tried logicator myself but learning to program in BASIC will open up a LOT more flexibility to you. It will also produce smaller code and, as you've already spotted, open up a lot more features.:)
Give it a go. If you get stuck, there's always this forum to help out:D
 

hippy

Ex-Staff (retired)
[ Read Page 1 and didn't realise there was a Page 2 where you solved your problem - Deleted ]
 

westaust55

Moderator
Thats the code.
For the schematic, I am yet to find any good schematic software that is just designed to display circuit diagrams at a resonable price any surgestions?
Try DIPTRACE which Mycroft has been promoting on this forum recently. A free copy (with 250 hole limitation) can be download from their website.
Have a look at this thread:
http://www.picaxeforum.co.uk/showthread.php?t=10480

In post 41 I drew up the schematic attached thereto in one evening on my first use of DIPTRACE.
Mycroft has even made available his PICAXE related library for DIPTRACE in that thread.
 
Last edited:

davidwf

Senior Member
Thats the code.
For the schematic, I am yet to find any good schematic software that is just designed to display circuit diagrams at a resonable price any surgestions?
I use one called "Livewire" - the standard version is just fine and at £35 is pretty cheap, available from Maplin
http://www.maplin.co.uk/module.aspx?moduleno=33100

It is easy to use and does everything I ask, to post a cct on this forum I just screen dump then copy / paste into Paint and save as a .jpg - see attached example
 

Attachments

Mycroft2152

Senior Member
David,

The 250 pin limit is for the free version. If you need more pins / layers' there is an 1000 pin 4 layer "educational non-profit" version available for $125US. This normally sells for $345. Send an email to support@diptrace.com and they will send you a link to purchase it.

Myc
 

davidwf

Senior Member
David,

The 250 pin limit is for the free version. If you need more pins / layers' there is an 1000 pin 4 layer "educational non-profit" version available for $125US. This normally sells for $345. Send an email to support@diptrace.com and they will send you a link to purchase it.

Myc
I did realise that...but having tried both I felt (and still feel) that livewire is easier to use for us amateurs !
 

Mycroft2152

Senior Member
David,

There are a lot of very good pcb cad programs out there. You need to find one that suits your needs and pocketbook.

I've tried well over a dozen different pcb cad programs over the years. I was looking for an easy to learn schematic cad program that I could also make my own component libraries and provide a direct printout for either photo process or toner transfer homebrew pcbs.

DIPTRACE was, hands down, the easiest one to set up and use at home.

DIPTRACE has both Schematic and PCB layout built in, unlike Livewire which requires the of purchase PCB Wizard to actually make the pcbs.

As Dippy says: "Horses for courses!"

Myc
 
Last edited:

alband

Senior Member
Thanks for the help.
I now have a few pieces of software including one good one for making professional PCB's: "PCB123".
 

Rickharris

Senior Member
The LED can't work in reverse - There has to be something wrong with your circuit - you are getting signals you don't expect.
 
Top