Boot up output pin state

So I think I know the answer to this, but I think asking is easier to be sure.

I have a Photon and some NeoPixels connected properly to D0. On D1 I have one of the cheap chinese eBay relay boards, but it’s connected through a level shifter because it wants a 5V signal. I can trigger it fine. BUT, it seems to do random-ish things while booting. My circuit has no pullup or pulldown, but I just noticed in the docs that D1 has a pullup (I think I’m reading that right).

So what’s the rock solid best way to make sure my relay does NOT randomly pull while the thing is booting? Use a different output pin and a pulldown resistor? If so, what value resistor and which output pin(s) are likely fine (looks like some pins try to be JTAG during boot, too)?

–Donnie

Not sure where you read that. Can you provide a link.

But you are right about the JTAG pins (D3..D7) having pull-ups/-downs attached during bootup.

I'd rather think your level shifter (which one?) may have troubles with the floating/Hi-Z nature of D1 during bootup and you should add a pull-down to prevent that :wink:

TXB0108.
And sorry, that was a note about the P1 that D0 and D1 have a pullup. So nevermind on that.

My custom board does have a header on the Photon side of the level shifter, so it’s easy to add a pulldown between them. What would the preferred value be?

Thanks!

10k should be fine.

1 Like

Okay, I marked that as the solution too soon.
I connected a 10k resistor to ground and then to the D1 pin from the Photon, which also goes to the input side of the level shifter. But…it doesn’t change the behavior at all. I feel like I"m missing something.

In setup() I set the pinMode to output and then I write it LOW. But this is clearly going high while the status LEDs are flashing the boot sequence. As soon as it goes heartbeat, the state does go LOW as it should.

Although I was sure there should not be any high signal on D1 during boot-up I went ahead and connected an oscilloscope to double check and as expected there were no unsolicited high signals during boot-up.

So it must have to do with your setup (hardware and/or firmware).

Seeing a schematic, a high res photo and the code would help :wink:

/* Seven Segment Pixel library example code: counting
Counts from 0 up the null character and back down using random colors on
a whole display.
created 2017
by Peter Hartmann
This example code is in the public domain.
<https://blog.hartmanncomputer.com>
*/

#include <neopixel.h>
#include <Seven_Segment_Pixel.h>

// Which pin on the Arduino is connected the NeoPixel display connected to?
#define PIN D0

// How many NeoPixels are in the seven segment display total?
#define NUMPIXELS 56

// How many digits are in the display?
#define DIGITS 2

// How may pixels per segement are there?
#define PIXPERSEG 4

// How many delimeters are in the display?
#define NUMDELIMS 0

// How may pixels per delimeter are there?
#define PIXPERDELIM 0

// When we instatiate a display object we supply the number of digits in the
// custom built display, as well as the number of pixels per segment.
// Additionally we pass the ususal Adafruit_NeoPixel arguments for object
// instatiation.

Seven_Segment_Pixel display1 =
    Seven_Segment_Pixel(DIGITS, PIXPERSEG, NUMDELIMS, PIXPERDELIM, NUMPIXELS,
                        PIN, WS2812B);

int delayval = 500; // delay for half a second

int increment = 1;

int count = 0;

int R1 = D1;
int S1 = A0;
int val = 0;
void setup() {
  pinMode(R1, OUTPUT);
  digitalWrite(R1, LOW);
  pinMode(S1, INPUT_PULLUP);
  display1.begin(); // This function calls Adafruit_NeoPixel begin();
}

void loop() {

  val = digitalRead(S1);
  digitalWrite(R1, val);

  display1.updateDigit(1, count % 10, 255, 0, 0);
  display1.updateDigit(2, (count / 10) % 10, 255, 0, 0);
  display1.show();
  count = count + increment;

  if (count == 0 || count == 100) {
    increment = -increment;
  }

  delay(delayval);
}

So that’s some sample counting code that I grabbed and added support for the relay and a button and the button just drives the relay (badly thanks to the delay(), but I knew that would happen and didn’t care right now).

If I had to guess, I’d say something is wrong with the setup of the TXB00108 and that it’s driving things, which is what you said before. My guess is I’m not understanding how OE is supposed to work on this device?

–Donnie

Oh, and FWIW, the R1 resistor is on this board because it’s specific to a different application. This board was originally designed to plug directly into a custom NeoPixel board and the NeoPixel communication requires a resistor “close to the first NeoPixel.” In that application it worked great because the two boards plug into one another. In this application, however, there’s about 24" of wire (and a small plug) between the board and the first NeoPixel and I had to add ANOTHER resistor near the other end of the wire or things were wonky.

Also, when I designed this board (with some help), I threw a header on those other seven output pins of the TXB0108 just in case I had a future use for them. And in this second application I do, so I thought I could just hook a relay board up to one of them and have it work. And it does, except for this bootup problem.

To shine a tad bit more light on this, the relay is connected to a 24VAC buzzer that’s SUPER loud. I can tone it down a good bit with a set screw, but having that thing sound off every time the power flickers or it’s plugged in is quite unsettling!

–Donnie

You may want to rewire the OE pin to a GPIO to only enable the level shifter once your code is running and for that I’d recommend not to use any of the JTAG pins :wink:

The schmatic also doesn’t show the pull-down on D1 and as we cannot be certain about the behaviour of the levelshifter during boot-up you could consider using another pull-down on the B2 pin.

Well, sadly I can’t really reconfigure OE using this board as I lack the skills to modify the board that way (well, I probably could pull it off, but it would be ugly and I’d have to do it twice as I’m building two of these).
And sorry, I forgot about the pull-down we talked about…the board does have headers that parallel the output side of the Photon, so it is easy to add the pull-down and I did try that. I should post a pic of that in a little while and I think it’s clear I did that properly. I did think about a pull-down on the B2 pin. Stay with a 10k there, too? That’s easy enough to try, certainly.
I’m also thinking of doing some updates to this board design to make it a little more generic and useful as a shield and getting another small run made. I do occasionally need some 5V capable outputs for things. Hmmm.

–Donnie

Here’s the most interesting view of the board:

So the upper left corner is the 24VAC buzzer. There’s a transformer just off the bottom of the camera shot. That’s just painters tape on top of the Photon, and to the right of it I have a tiny riser card plugged into that right header to break out a few ground pins. Then there are resistors plugged in to D1 and D2 and to ground for the pull-down (D2 is there for completeness in case I end up using the second relay for something). The input buttons are connected to the analog pins since all the digital were already connected to the level shifter. They look like this:

(You can see the “volume screw” in that buzzer, but I’ve actually found a thumb screw to replace it so you can more easily change that without needing a screwdriver.)

And here’s what it looks like assembled:

And this is the before:

It’s an old Daktronics shot clock. Used some proprietary serial protocol and four 24VAC light bulbs for each segment. I replaced those with a strip of four NeoPixels for each segment. I have two of these. My intent is to have them be individual scoreboards using the up/down arrows (like for ping pong or whatever) and you can use the third button to cycle through modes. Another mode will be an hour clock, then a mode as a minute clock, and a mode as a second clock. With two of them I can put them side by side and set one as an hour clock and the other as a minute clock and they will present as a giant clock.

—Donnie

2 Likes

Because I can’t get enough of replying to this thread, just want to point out that in reading the data sheet more for the TXB0108, it seems it really doesn’t like pull up/down resistors on the output side. They say if you do it, they need to be at least 50k, but pretty much it’s better not to do that.

I’m starting to think a pull down on the OE and also tie it to an output pin would be way smarter. I didn’t do the EasyEDA work on this, but I think about about to learn EasyEDA.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.