5

I've followed this Arduino guide to build a circuit using a CD4021BE PISO shift register, and 10k pulldown resistors. It works perfectly fine with the Arduino's 5v supply.

I then attempted to use this circuit with my Raspberry Pi's GPIO, which only supplies 3.3v, and I was getting very unreliable readings from the data pin. Increasing the clock delay to 1ms improved it a bit, but it's still very unreliable. (Some bits read high every few seconds, when everything should be low.)

I assume that running a CD4021BE shift register at 3.3v requires a different value for the pulldown resistors, so which value would you recommend? I have seen this answer to a similar question about pullup/pulldown resistors, but would like to know if there is any 'rule of thumb' for pulldown resistors in a 3.3v circuit. I would guess that a 5k resistor should solve the problem, but I wanted to get some advice before buying resistors and desoldering the existing ones.

ndbroadbent
  • 193
  • 9
  • 1
    http://www.ti.com/product/cd74hct165 but the pinout is different. – Ignacio Vazquez-Abrams Jun 18 '13 at 01:48
  • 4
    Christ, as usual, the Arduino docs are sloppy and full of errors. You need a 0.1 uF bypass capacitor as close as you can get it to the power connections of each CD4021. – Connor Wolf Jun 18 '13 at 03:29
  • The fact that the tutorial doesn't include bypass capacitors tells you: A - it was not written by a person who is very familiar with electronics, and B - the arduino people apparently don't have any actual engineers or even people familiar with electronics proofreading their documents. – Connor Wolf Jun 18 '13 at 03:33
  • I already had a rather low opinion of their electrical engineering prowess from looking at their terribly drawn schematics, but their "tutorials" are apparently equally haphazard. – Connor Wolf Jun 18 '13 at 03:35
  • Thanks for your help! Switching the pulldown resistors didn't do anything, so I'll solder a 1$\mu$F bypass capacitor between the VCC and GND pins of the CD4021. – ndbroadbent Jun 18 '13 at 07:01
  • @ConnorWolf The tutorials (including the one referred to) are written by random people on the Internet, not by company staff. The same level of sloppiness would be seen in pretty much any random tutorial on any arbitrary subject found on the Internet on any non-peer-reviewed public site. This has nothing to do with Arduino per se: your bias is shining through. Incidentally this isn't in defense of the company: I'm pretty vocal myself about their shoddy work (pin headers misaligned "by mistake" in a mass produced design!) and their shoddier attitude (Banzi going beserk on KickStarters). – Anindo Ghosh Jun 18 '13 at 09:30
  • 1
    @AnindoGhosh - Bullshit - The url is www.arduino.cc, I certainly don't see any disclaimers that the content is crowd-sourced (hell, the URL doesn't even have "wiki" or similar in it. it's www.arduino.cc/en/Tutorial/ShiftIn). If they want to run a wiki, and have it include random, poorly written tutorials, they need to be pretty damn sure that it is CLEAR that said wiki and it's content is not directly affiliated with their brand. They have entirely failed to do this. – Connor Wolf Jun 19 '13 at 02:16
  • Hell, I would say that if you are running a website with the express purpose is to be a good educational resource, that you pretty much are obligated to have some sort of editorial oversight and proof-reading, at least for obvious stuff. If you want to run a wiki, do it on another domain, with branding and site-styling that CLEARLY delineates the two sites. – Connor Wolf Jun 19 '13 at 02:20
  • @ConnorWolf I can see some pretty strong bitterness against the brand creeping through. Nice and balanced comments. – Anindo Ghosh Jun 19 '13 at 03:04
  • @ConnorWolf An illustration of how contributory open source projects usually work - Arduino is OSH/OSS: ShiftIn tutorial "Started By Carlyn Maw and Tom Igoe Jan, '07". One is Co-Founder & CEO at Crash Space, Greater Los Angeles Area. The other is Associate Arts Professor at ITP/New York University. Neither lists any association with the Arduino company in their CVs. Other open source efforts like linux work the same way. You too can contribute to one. – Anindo Ghosh Jun 19 '13 at 03:44
  • @AnindoGhosh - Honestly, I'm glad that the arduino people are bringing in more people interested in electronics, I wish they would just be more responsible about it. With great power (or marketshare) comes great responsibility. – Connor Wolf Jun 19 '13 at 06:09
  • 3
    Also, their schematics are f**king horrible. – Connor Wolf Jun 19 '13 at 06:09
  • With regard to the way linux works, they have a very strong community commitment to quality. If you write a kernel-patch, and don't properly document it and keep to the kernel code style-guides, they will not apply your patch until you fix it. The same approach needs to be done here. – Connor Wolf Jun 19 '13 at 06:13
  • Basically, if the arduino people want to call themselves proponents of education, they have to quality check their stuff (whether it's stuff they wrote, or simply host under their banner). This isn't something that is arduino specific, I feel the same about any other organization that bills itself as being targeted as "educational". On the other hand, if they're just basically saying "look what I did, here is how I did it, no guarantees it would work for you" (e.g. most blogs), I would have no problem. It's the absence of a disclaimer of any sort that really bothers me. – Connor Wolf Jun 19 '13 at 06:16
  • @ConnorWolf the arduino.cc site seems to be pretty much all a wiki. The footer has EDIT PAGE and HISTORY links (see http://arduino.cc/en/Tutorial/ShiftIn?action=diff ). Who gets to update info, I have no idea. And I agree it is chaotic, full of errors, contains much obsolete info and has zero authoritative value. A Google search often turns up more accurate info than the "official" site which is basically unusable. Except for their product pictures which help identify counterfeit arduinos being peddled on eBay (in vast numbers, its a popular toy). – Ron J. Jun 20 '13 at 20:31
  • Hi @ConnorWolf, I've added a 0.1 uF capacitor across the VCC and GND pins of the shift register, but I'm still getting lots of bad readings. I don't have an oscilloscope to see what's going on, but would you recommend also adding a 50uF capacitor in parallel? – ndbroadbent Jun 21 '13 at 00:48
  • @nathan.f77 - I think at this point, you can probably say your problem is somewhere else. Basically, by testing it with some supply decoupling, you have more-or-less eliminated the possibility of your issue coming from high-frequency bypassing problems. A 50 uF capacitor couldn't hurt (and it could help), but it's significantly less likely. At this point, I'm not sure where to go without tools like an oscilloscope. Do you at least have a voltmeter? – Connor Wolf Jun 21 '13 at 01:56
  • OK, thanks for the advice. I do have a multimeter. I think I've solved the problem in my code, by just reading the bits again after 2ms and waiting for the two reads to be consistent. It's been running for 10 minutes so far without any problems, so I think that's a decent workaround. Thanks again! – ndbroadbent Jun 21 '13 at 02:27
  • Try adding pull-down resistors to the interface between the shift register and the RPi. You can also do this in software on the RPi. – Solitz May 30 '14 at 05:01

2 Answers2

1

The pullup/pulldown resistors for the buttons can take almost any value, limited only by power supply current capacity (1-10 ohm) and noise resistances (hundreds of kilohms).

So in the referenced schematics, you can put any resistor between 1K and 500K, and it will work, no matter what the power supply voltage is - 3.3 or 5V. I like using 4.7K resistors because I have a big box of them.

For more complex cases (I2C, etc..) the rules may be more complicated, but buttons/switches really do not care.

theamk
  • 3,222
  • 11
  • 16
0

The Texas Instruments data sheet for CD4021BE does allow for supply voltage from 3v to 18v.
However, notice in all of the timing diagrams that the device is only characterized down to 5 volts.

Operating the CD4021 at 3.3 volts means that things like propagation delay and transition time will be increased to an un-specified amount. The data sheet does show that maximum clock frequency also decreases as the supply voltage is decreased.

As suggested above by Ignacio Vazquez, changing over to the CD74HC165 (not CD74HCT165), will yield much better guaranteed performance. (The HCT device is only characterized down to 4.5 volts)

Marla
  • 5,240
  • 1
  • 22
  • 31