Jump to content

CMOS 4000-series gates for Arduino

Claryn

Hi.

 

I am looking to create some CMOS-logic circuits on a breadboard, using some digital PWN sensors, LEDS and buttons, all powered by an Arduino UNO (so 5V). I do have an Arduino UNO kit with buttons, breadboards, jumper wires and LEDs. All I am missing are CMOS IC-gates.

 

I am in need of  OR, AND, NOR, NAND and XOR gates. I have been looking at 4000-series IC-gates from Texas Instrument. Only thing is, there are a lot of different types of the same logic gates. An example: You have the CD4011UBE and the CD4011BE NAND gates. What is the difference?
What specific models would you suggest for using like this, and are there any places where I can order them in qt. of 10-20 for cheap? (And Int'l shipping?). Thanks!

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

Excuse me for asking, but why do you want the logic gates + arduino? You normally use either one or the other depending on the application. Arduino is easy, versatile reprogrammable and simple but slow and linear. Logic gates are stupidly fast and parallel but a hell of a lot more complex. You can get either of them really cheap from ebay, as long as you don't mind waiting around for your package to arrive.

 

The main difference between the B and UB is the transit time. UB is faster at 30ns, the B is slower at 60 ns. Some of the minutia is also different, The Vtrans seems to be sharper on the B model among other stuff. Just check the data-sheets:

http://www.jameco.com/Jameco/Products/ProdDS/893283.pdf

http://www.ti.com/lit/ds/symlink/cd4011ub-mil.pdf

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, dany_boy said:

Excuse me for asking, but why do you want the logic gates + arduino? You normally use either one or the other depending on the application. Arduino is easy, versatile reprogrammable and simple but slow and linear. Logic gates are stupidly fast and parallel but a hell of a lot more complex. You can get either of them really cheap from ebay, as long as you don't mind waiting around for your package to arrive.

 

The main difference between the B and UB is the transit time. UB is faster at 30ns, the B is slower at 60 ns. Some of the minutia is also different, The Vtrans seems to be sharper on the B model among other stuff. Just check the data-sheets:

http://www.jameco.com/Jameco/Products/ProdDS/893283.pdf

http://www.ti.com/lit/ds/symlink/cd4011ub-mil.pdf

Would it matter if I get different gates with different transfer-speeds?

 

I only want them to play around with them - creating adders and small 8bit memory etc. Its all just for fun.

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Claryn said:

Would it matter if I get different gates with different transfer-speeds?

 

I only want them to play around with them - creating adders and small 8bit memory etc. Its all just for fun.

Are you gonna process data with frequencies on the MHz range? (your answer is no BTW). You need not worry about minutia, as long as it contains the gates you need/want and you are happy with the operating voltages/current

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, dany_boy said:

Are you gonna process data with frequencies on the MHz range? (your answer is no BTW). You need not worry about minutia, as long as it contains the gates you need/want and you are happy with the operating voltages/current

No I will be dealing with single 8bit addition and fooling around with saving a few bits in "memory" :P.

 

I heard I will need special ICs to have them bee able to power the standard LEDs that come with the Arduino UNO - or a transistor, but Id like to avoid that.

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

You can get whichever one of the logic gates you want, the only difference between them is small details like switching speed, current output, and operating voltage. Unless you are working with current power supplies or high operating frequencies (in excess of 10MHz) then there is no reason to be concerned about the prefix.

Intel Xeon 1650 V0 (4.4GHz @1.4V), ASRock X79 Extreme6, 32GB of HyperX 1866, Sapphire Nitro+ 5700XT, Silverstone Redline (black) RL05BB-W, Crucial MX500 500GB SSD, TeamGroup GX2 512GB SSD, WD AV-25 1TB 2.5" HDD with generic Chinese 120GB SSD as cache, x2 Seagate 2TB SSHD(RAID 0) with generic Chinese 240GB SSD as cache, SeaSonic Focus Plus Gold 850, x2 Acer H236HL, Acer V277U be quiet! Dark Rock Pro 4, Logitech K120, Tecknet "Gaming" mouse, Creative Inspire T2900, HyperX Cloud Flight Wireless headset, Windows 10 Pro 64 bit
Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, Claryn said:

I heard I will need special ICs to have them bee able to power the standard LEDs that come with the Arduino UNO - or a transistor, but Id like to avoid that.

*Sigh* Why does nobody read data-sheets?

Capture.PNG

You'll need a buffer if you want to power LEDs

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, dany_boy said:

*Sigh* Why does nobody read data-sheets?

Capture.PNG

You'll need a buffer if you want to power LEDs

Because not everyone knows what to look for, nor the the necessary voltage or current to power the specific LED. What types of ICs has a buffer, and how do I check for it in the date-sheets?
 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Claryn said:

Because not everyone knows what to look for, nor the the necessary voltage or current to power the specific LED. What types of ICs has a buffer, and how do I check for it in the date-sheets?
 

Output Low (sink) current = the amount of current the output of the IC can receive when you feed current into a low output:

sink.PNG

Output High (source) current = the amount of current the output of the IC can send when you request current from a high output:

source.PNG

You can use a simple transistor in order to drive more power hungry devices

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, dany_boy said:

Output Low (sink) current = the amount of current the output of the IC can receive when you feed current into a low output:

sink.PNG

Output High (source) current = the amount of current the output of the IC can send when you request current from a high output:

source.PNG

You can use a simple transistor in order to drive more power hungry devices

So, if I feed Vdd = 5V into the IC, and I connect an LED with a typical forward voltage of 2.0V that requires 16-18mA, will need another ~16mA to function, correct? Because the output current is 0.4mA at Vdd=5V? Does the input1 and input2 voltage affect this at all?
 

To be sure: Vcc, is Voltage (cathode), so it indicated a component like an LED?

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Claryn said:

So, if I feed Vdd = 5V into the IC, and I connect an LED with a typical forward voltage of 2.0V that requires 16-18mA, will need another ~16mA to function, correct? Because the output current is 0.4mA at Vdd=5V? Does the input1 and input2 voltage affect this at all?
 

To be sure: Vcc, is Voltage (cathode), so it indicated a component like an LED?

I see how you are thinking and it makes sense, but unfortunately it does not work like that. (its about to get technical but stick with me, TLDR at the end)

 

LEDs are current driven with a voltage drop across the component. That means that you need to focus on the current not the voltage in order to drive them properly. For your typical ultra-bright 5mm led, the Vdrop is about 2.5V and the forward current is about 15mA. So if you have a 5v supply you need to current limit the LED with a 166.6 Ohm resistor according to ohm's law. (read more here: https://www.sparkfun.com/tutorials/219) Now lets assume you use the classic 2N2222 to buffer the output of your logic gate. Looking at the data-sheet for the CD4011, we can see that the typical current the device can source is 1mA at 25°C (ambient) and approx 5v. The 2N2222 has a current gain of 75 for 10mA at 10v, since those are the closest parameters we'll go with that. We want a current of 15mA through the LED, so we need a minimum base current of about 200nA. Therefore we need to limit the current from the logic gate to the transistor to a value of at least 200μA and 1mA. Using ohm again, we need a resistor with value between 5KOhm and 25K.

logic and tranny.PNG

TLDR: use the values shown in the circuit schematic and you should be fine (hopefully)

Disclaimer: I have not yet taken proper lessons on circuit design, so I may be wrong on some stuff.

 

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

25 minutes ago, dany_boy said:

I see how you are thinking and it makes sense, but unfortunately it does not work like that. (its about to get technical but stick with me, TLDR at the end)

 

LEDs are current driven with a voltage drop across the component. That means that you need to focus on the current not the voltage in order to drive them properly. For your typical ultra-bright 5mm led, the Vdrop is about 2.5V and the forward current is about 15mA. So if you have a 5v supply you need to current limit the LED with a 166.6 Ohm resistor according to ohm's law. (read more here: https://www.sparkfun.com/tutorials/219) Now lets assume you use the classic 2N2222 to buffer the output of your logic gate. Looking at the data-sheet for the CD4011, we can see that the typical current the device can source is 1mA at 25°C (ambient) and approx 5v. The 2N2222 has a current gain of 75 for 10mA at 10v, since those are the closest parameters we'll go with that. We want a current of 15mA through the LED, so we need a minimum base current of about 200nA. Therefore we need to limit the current from the logic gate to the transistor to a value of at least 200μA and 1mA. Using ohm again, we need a resistor with value between 5KOhm and 25K.

logic and tranny.PNG

TLDR: use the values shown in the circuit schematic and you should be fine (hopefully)

Disclaimer: I have not yet taken proper lessons on circuit design, so I may be wrong on some stuff.

 

I am sorry but this does not match what lectures are saying on how to use a transistor that way. I have a working PCB next to me where we did something similar to have an LED light up. The NAND gates are CD4011UBs, and we have a Vdd = 9V in this case.  Here is the circuit:

WD2jFSy.jpg

 

Now we were using a different transistor, we are using the BC457C, and a 5mm LED that requires 20mA (same as I will be using with the Arduino). Now the data-sheet that I have with the CD4011UB does not show current outputs, but I have actually soldered this circuit onto a PCB and tested the circuit, and it does work. I do have the measurements of the voltage at the D-output which was 8.99V, and Q which was 8.5V (8.6V when the two internal PMOS transistors are in parallel). However, I don't have the measurements of the current that is flowing.

 

Now my point is that I am unsure whether you want to have a collector-source going through the transistor - you would want Vdd, like we do - correct?

However, ideally, I would like to do this -without- the transistor, as I have seen in videos like here:

Edit: I just quickly pulled the CD4011UB I have off the socket in the PCB and tested it on a breadboard with my Arduino, at 5V. If I don't have any resistors to the 5mm LED, it lights up a tinytinytinytiny bit sometimes. Sadly I don't have any transistors that are not soldered into a PCB to test this out. (I will on wednesday at the lab, but I want to order parts before that).

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

sorry forgot to add the LED:

logic and tranny.PNG

 

And for switching purposes they are the same circuit as long as you idealize the bjt.

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, dany_boy said:

snip

Righto, so we agree on that. However, as I said, I don't really want to have to get a transistor for having an LED go off whenever the output is a logic high.

 

I tested this on Arduino UNO running this code:

const int ledPin = 8;
const int cmosPin = 7;

void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(cmosPin, INPUT);
    digitalWrite(ledPin, LOW);
}

void loop() {
    int cmosState = digitalRead(cmosPin);

    if (cmosState == HIGH) {
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(ledPin, LOW);
      delay(1000);
    }
}

What I do is check for the cmosState pin read 5V, if it does (logic high), then you make the LED blink, as long as you have a logic high. I have connected it like this:

ky1SBfM.png

Let's imagine that the IC thers is the CD4011UB on the drawing (it actually is the CD4011UB). As you can see the yellow cmosPin (7) is waiting for a logic high on ouput 3 on the IC. As you can see, I make sure that I have a logic high by giving the inputs (1,0) on port 1 and 2, using the orange wire to give 5V into port 1 on the IC.

And then what I do is connect the digital PWM pin 8 to the LED, so it can light up.

 

However, it doesn't work as intended:

If I remove the orange wire (set the output on the IC to 0), nothing changes, the LED is off. If I connect it, the LED is still off. If I disconnect the yellow pin7 from the breadboard, the led blinks.

I tried reversing it to 'LOW' in the if-statement: then it just blinks all the time, no matter what I do (as long as yellow pin8 is still connected to the LED).

 

Isn't this a workaround for having a LED light up if the output on the IC is a logic high (1)?

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

The green wire on that diagram is shorting the output of the NAND Gaye to ground so you wouldn't get any change. Remove the green wire and it should blink the led. Add a wire from ground, if you correct this to pin 2 the led should turn off and blink again when removed

Link to comment
Share on other sites

Link to post
Share on other sites

If you want the led to turn on/off with the input you need an else statement for the output low.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, r4tch3t said:

If you want the led to turn on/off with the input you need an else statement for the output low.

 

2 hours ago, r4tch3t said:

The green wire on that diagram is shorting the output of the NAND Gaye to ground so you wouldn't get any change. Remove the green wire and it should blink the led. Add a wire from ground, if you correct this to pin 2 the led should turn off and blink again when removed

Removing the wiring that was shorting the NAND gate output did not affect anything.

Adding a wire from ground to pin 2 would still give the same input as right now, 0 and 1, which will yield  1 out from output 3.

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

try this code instead:

const int ledPin = 8;
const int cmosPin = 7;

void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(cmosPin, INPUT);
    digitalWrite(ledPin, LOW);
}

void loop() {
    digitalWrite(ledPin, digitalRead(cmosPin));
}

Also, since you are using a CMOS IC, its a good idea to physically tie all inputs somewhere. If you want an input to be low on the gate, hook it up to ground, don't leave it floating.

Quote or tag if you want me to answer! PM me if you are in a real hurry!

Why do Java developers wear glasses? Because they can't C#!

 

My Machines:

The Gaming Rig:

Spoiler

-Processor: i5 6600k @4.6GHz

-Graphics: GTX1060 6GB G1 Gaming

-RAM: 2x8GB HyperX DDR4 2133MHz

-Motherboard: Asus Z170-A

-Cooler: Corsair H100i

-PSU: EVGA 650W 80+bronze

-AOC 1080p ultrawide

My good old laptop:

Spoiler

Lenovo T430

-Processor: i7 3520M

-4GB DDR3 1600MHz

-Graphics: intel iGPU :(

-Not even 1080p

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, dany_boy said:

try this code instead:


const int ledPin = 8;
const int cmosPin = 7;

void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(cmosPin, INPUT);
    digitalWrite(ledPin, LOW);
}

void loop() {
    digitalWrite(ledPin, digitalRead(cmosPin));
}

Also, since you are using a CMOS IC, its a good idea to physically tie all inputs somewhere. If you want an input to be low on the gate, hook it up to ground, don't leave it floating.

Ill try this thanks.

Also, if Im not mistaken, these gates should give an output of 16mA at logic HIGH, so they can power an LED?

http://www.digikey.no/products/en/integrated-circuits-ics/logic-gates-and-inverters/705?k=&pkeyword=&pv592=283&pv592=48&pv592=5&FV=ffec004c%2C1140050%2Cffe002c1&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=10&ptm=0&fid=0&pageSize=25

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, dany_boy said:

try this code instead:


const int ledPin = 8;
const int cmosPin = 7;

void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(cmosPin, INPUT);
    digitalWrite(ledPin, LOW);
}

void loop() {
    digitalWrite(ledPin, digitalRead(cmosPin));
}

Also, since you are using a CMOS IC, its a good idea to physically tie all inputs somewhere. If you want an input to be low on the gate, hook it up to ground, don't leave it floating.

With a new circuit:

TSHq8QX.png

 

and your code, it now works as intended. Ill order up some ICs and start working on my SR-latches and design to multiply 3 binary numbers together.

 

 

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

If you're in US, have a look at Digikey.com , Mouser.com or Newark.com

 

Digikey.com  : http://www.digikey.com/products/en#cat-32 (scroll down to Logic section)

Newark.com : http://www.newark.com/logic

Mouser.com : http://eu.mouser.com/Semiconductors/Integrated-Circuits-ICs/Logic-ICs/_/N-6j77x/

 

You get discounts at various quantity thresholds (like 10pcs , 25pcs, 100pcs) and shipping is usually cheap (less than 10$ or even free)

 

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, mariushm said:

If you're in US, have a look at Digikey.com , Mouser.com or Newark.com

 

Digikey.com  : http://www.digikey.com/products/en#cat-32 (scroll down to Logic section)

Newark.com : http://www.newark.com/logic

Mouser.com : http://eu.mouser.com/Semiconductors/Integrated-Circuits-ICs/Logic-ICs/_/N-6j77x/

 

You get discounts at various quantity thresholds (like 10pcs , 25pcs, 100pcs) and shipping is usually cheap (less than 10$ or even free)

 

When I required International shipping, I'm probably not in the US.

Running Arch with i3-gaps on a Thinkpad X1 Extreme
Data Science Postgrad

 

Link to comment
Share on other sites

Link to post
Share on other sites

Newark.com is the US/Canada website of Farnell, which is a distributor of electronic components. In other territories, they use http://farnell.com (pick your country from the page) or sell through local distributors. Their shipping costs are usually very reasonable (for example for my country they charge 20 RON or about 4-6 euro for any size package).

 

In Europe there's also TME.eu, which are a good bunch of guys, bought from them and they were great: http://www.tme.eu

 

There's also RS Components (ordered from them as well, reliable, good etc) , which follow Farnell's example of having customized versions of their site for various countries : http://www.rs-components.com/index.html

Their shipping costs are also decent and with all of them you get discounts for buying larger quantities of particular products.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×