Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Correct resistor for a circuit?

Status
Not open for further replies.
In this circuit http://www.z80.info/z80test0.htm is 470 ohms really correct for the LEDs?

Assuming a green LED draws 20 mA at 2.1 forward voltage, giving the CPU 5 volts (and assuming 5 volts makes it out on the address pins, should not this be R = (5 - 2.9) / 0.02 = 145 ohm? I attempted to build the circuit just as it is, using green LEDs, but it does nothing. I'm assuming I've made a mistake, but the 470 ohms confuse me.
 
I don't think that you need 20mA flowing through your LED for this circuit.
I am sure that 470 Ohm will give enough current at about 6mA.

JimB
 
I have some ultra-bright Red and Green LEDs that are almost too bright as an indicator at 1mA! The are visible in direct sun...
 
Are you sure that you are getting clock pulses on pin 6 of the Z80 ? Also have you checked that the reset pin (Pin 26) is high ? I think the circuit would be better with a lower clock frequency so you could see the address lines counting. I agree with the previous comments about the LED current. 20 mA is probably the maximum current rating of the LED. Yesterday I traced out the circuit of a Banggood 4 channel remote control receiver. That had a blue LED (3.4 volts drop) It was quite bright and was fed from the output (5 volts) of the microcontroller via a 4.7 K resistor. At first I thought that I had misinterpreted the marking 472 on the SMD resistor so I checked it with a meter and it was 4.7K the LED current would have been (5 - 3.4)/4700 = 0.34 mA

Les.
 
As the port is sourcing the current 470R is OK, ( Z80 great chip ) attached to A0 etc If your clock is wrong the LED may not be ON long . unless you are single stepping ,
 
I did not look at the data sheet but I can't believe the Z80 could lift A0 to 5V at 20mA.
Of course its output will have a voltage drop. The minimum output high of a Z80 with a very low output current (2.4mA for a Cmos Z80 or 0.25mA for an Nmos Z80) is 2.4V that is not enough to light many kinds of LEDs.
 
So that is it. Using a zero ohm resistor, the Z80 will lift the voltage until it hits current limit. Maybe 250uA. No 20mA!

That is why I usually connect the LED to +5V and not ground. That way the Z80 is pulling down. (more drive current)
 
I'm assuming I've made a mistake, but the 470 ohms confuse me.
You are right, he is wrong. As noted above, a Z80 cannot source 20 mA from an I/O pin. But even if it could, my bet is that the original writer was trying to put 10 mA through each LED, and forgot to account for the LED Vf in his calculation.

ak
 
Hi all,
Just out of interest I decided to lash up the circuit I did not bother with the 470 ohm resistors tying the data lines to ground. I just connected them straight to ground. I also used an external pulse generator rather than building the oscillator circuit. Most times it was powered on it needed a reset pulse before it started to count on the address lines. With no load on the address lines the swing was from ground to +5 volts. With a 470 ohm in series with a green led connected to the address lines the swing was from 0 V to about 4.5 V The voltage across the LED was 2.0 volts so the current was (4.5 - 2.0)/470 = 5.5 mA The Z80 that I used from my junk box made by ST and had the part number Z84C00AB6. At least now we know that the circuit does work.

Les.
 
Hi all,
Just out of interest I decided to lash up the circuit I did not bother with the 470 ohm resistors tying the data lines to ground. I just connected them straight to ground. I also used an external pulse generator rather than building the oscillator circuit. Most times it was powered on it needed a reset pulse before it started to count on the address lines. With no load on the address lines the swing was from ground to +5 volts. With a 470 ohm in series with a green led connected to the address lines the swing was from 0 V to about 4.5 V The voltage across the LED was 2.0 volts so the current was (4.5 - 2.0)/470 = 5.5 mA The Z80 that I used from my junk box made by ST and had the part number Z84C00AB6. At least now we know that the circuit does work.

Les.

Very nice. How do you reset the CPU? Do you just give it +5 volt on the reset pin? I could experiment, but I'd rather not destroy the CPU.
 
Not all LEDs operate at 20 mA. There are some 0.5 mA LEDs. Using a reasonable value, I get: 460=(5-2.1-0.6)/0.005

if you use a 5 mA HIGH EFFICIENCY LED. Here's **broken link removed** a low power 2 mA LED that TTL compatible that fits the bill fine which Digikey sells.

I also assumed a 0.6 V drop for the driver which may or may be correct.
 
Cheap ordinary LEDs are made to look brighter straight ahead or appear at a low current by using the case to focus the light into a narrow beam, but then it is almost invisible if it is not pointing directly at you. High quality LEDs have a wide beam angle and the chip is better to appear bright. Cheap Chinese LEDs are available on ebay.

Companies keep changing their names. Years ago my high quality LEDs were made by Hewlett Packard, then their LED division became Agilent, then Avago as shown in the previous post but now it is called Broadcom. They ain't cheap Chinese LEDs.
 
I think I might already have this working, so it is not a problem with the LEDs any longer. I probably just need to reset the CPU. But how do I do that? Can I just give it +5 volt on the reset pin, or will that damage it?
 
Actually for some reason I managed to forget that there is a reset switch built into the circuit. I don't know how I managed to mix that up with the clock line.

Anyway, with the circuit produced exactly as in the diagram all it does it constantly set all address lines to 1, so my LEDs receive 3,8 volts or so, and all three always light up.
 
Hi all,
Just out of interest I decided to lash up the circuit I did not bother with the 470 ohm resistors tying the data lines to ground. I just connected them straight to ground. I also used an external pulse generator rather than building the oscillator circuit. Most times it was powered on it needed a reset pulse before it started to count on the address lines. With no load on the address lines the swing was from ground to +5 volts. With a 470 ohm in series with a green led connected to the address lines the swing was from 0 V to about 4.5 V The voltage across the LED was 2.0 volts so the current was (4.5 - 2.0)/470 = 5.5 mA The Z80 that I used from my junk box made by ST and had the part number Z84C00AB6. At least now we know that the circuit does work.

Les.

I've built it first with the 470 ohm resistors tying the data lines to the ground. The result is that all address lines are set to 1, giving ~3.8 volts or so to my LEDs, making them light up.

I'm giving it around 12 Hz, and I can verify that this is actually 12 Hz going into the clock pin with an oscilloscope.

I've tried to connect the address lines straight to ground like you did, with the same result. I've also tried to let them float, just to see what happens. The result is the same.

I tried to replace the CPU, perhaps it was defective. The result was the same.

I'm giving it more or less exactly 5.0 volts, but I've tried 5.1 and 4.9, slight variations.

I thought perhaps that 12 Hz was fast enough that I couldn't see them blink, this should be very unlikely on the third LED though, but I put it on my scope anyway and there is just a constant +3.8 volts to all address lines, up to A15.

What voltage do you give your CPU, and what frequency on the clock pin? I don't understand why this doesn't work.
 
Hi hallefector,
If you have built the tester exactly as in you link then to reset the Z80 you just press the reset button. I did not fit a reset button so I just touched ground on pin 26 of the Z80. (I wrote this this morning in reply to ypur post #12. (About 13 hours ago.) but forgot to click the "Post Reply" button.)

This is a reply to post #18. It should not matter weather the data lines are tied directly to ground or connect to ground via a 470 ohm resistor. This will cause the CPU to read all the data data lines a zero which is the op code for an NOP instruction. This means that cpu just executes 2^16 (65536) NOP instructions then loops back to address zero. This will repeat for ever. I did not connect the address lines to ground. (Other than via a resistor and LED.) The address lines are outputs from the CPU which would normally specify the memory address (Or I/O address) to read or write data from / to. If you are clocking it at 12 Hz then A0 should flash at 12 Hz, A1 should flash at 6 Hz and so on up to A15 which should flash at 12/65536 Hz. (One flash every 5461 seconds) I powered my test circuit with about 5 volts. (Probably between 4.8 and 5.2 volts.) I think you must of made a wireing error for it not to work.

Les.
 
Hi hallefector,
If you have built the tester exactly as in you link then to reset the Z80 you just press the reset button. I did not fit a reset button so I just touched ground on pin 26 of the Z80. (I wrote this this morning in reply to ypur post #12. (About 13 hours ago.) but forgot to click the "Post Reply" button.)

This is a reply to post #18. It should not matter weather the data lines are tied directly to ground or connect to ground via a 470 ohm resistor. This will cause the CPU to read all the data data lines a zero which is the op code for an NOP instruction. This means that cpu just executes 2^16 (65536) NOP instructions then loops back to address zero. This will repeat for ever. I did not connect the address lines to ground. (Other than via a resistor and LED.) The address lines are outputs from the CPU which would normally specify the memory address (Or I/O address) to read or write data from / to. If you are clocking it at 12 Hz then A0 should flash at 12 Hz, A1 should flash at 6 Hz and so on up to A15 which should flash at 12/65536 Hz. (One flash every 5461 seconds) I powered my test circuit with about 5 volts. (Probably between 4.8 and 5.2 volts.) I think you must of made a wireing error for it not to work.

Les.

Thanks for the input.

It is actually very clear to me what this circuit does (please forgive my ignorance relating to the reset line) regarding that it is being given a continuous NOP opcode on its data bus and that the program counter (address bus) will be incremented until it wraps around.

What is not clear to me is the hardware, can I leave anything floating? Will it confuse the CPU? If I only hook up the CPU as in the linked diagram, will that be sufficient, or did you pull anything else to ground or +5 volts?

Perhaps the CPU doesn't like all frequencies? Is it possible that certain frequency ranges will confuse the CPU? Or can 8-bit CPUs like these always be executed at any frequency from almost nothing up to its rated frequency without it affecting anything?

I've tried to debug the circuit several times now, I don't know what I should look for. I've verified it gets a clock pulse, is there anything else obvious I should check for?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top