5
\$\begingroup\$

I'm working on interfacing to a SPI bus that is exhibiting some... bad behavior.

The bus comes from a control box on a toy drumset. The control box is the SPI master, and it can be turned on and off with a built-in button. A separate circuit that reads from the drumpads is the only slave on the bus.

What I am doing is this: I have basically added a master to the bus, in the form of a microcontroller. I know that this isn't a standard use of SPI, but it is for a hobby project, so I don't care. The two masters never operate simultaneously, so there are no conflicts. I mostly enforce this: If the control box is on, I don't plug in the USB cable to the microcontroller (I'm using a Pro Micro). Also, if the microcontroller detects the control box is on, the uC will end SPI communications.

Here is my circuit. I still need to buffer the MISO line, but other than that it's what I'm using.

enter image description here

There are three states this circuit can be in:

  1. Off - control box is off and the Pro Micro is unplugged
  2. Control box power - The control box is on, but the Pro Micro is off, thanks to the Schottky diode. The control box is the master, and the Pro Micro is isolated from the circuit.
  3. Pro Micro power - The USB cable is plugged in, and the Pro Micro is the master. The control box is off.

My issue occurs during state 1. Although the control box is off, the SPI lines coming out of it are showing 3.3V. For some reason, the control box powers MOSI, CLK, and CS even though its VCC shows 0V! When neither the control box nor Pro Micro is on, the buffer is unpowered, and the outputs are seeing 3.3V. Somehow this is reverse-powering the buffer, which in turn powers the rest of my circuit.

I'm using a SN74AHC125 buffer.

Before I started using the buffer, I connected the SPI lines directly to my microcontroller (ATMega 32U4). I had the same problem: The SPI lines powered my Pro Micro through the reverse protection diodes on the pins.

So how can I drive these lines when they are still powered while the rest of my circuit is off?

\$\endgroup\$
  • \$\begingroup\$ Can you attach a diagram of your connections? \$\endgroup\$ – Bruno Ferreira Jul 6 '12 at 21:03
  • \$\begingroup\$ @Bruno Ferreira: Done \$\endgroup\$ – Chris Laplante Jul 6 '12 at 21:08
  • 1
    \$\begingroup\$ Have you tried to put a 1K resistor between the bus lines and the ground just to to check if the output voltage is active or just a due to pull-ups? \$\endgroup\$ – Bruno Ferreira Jul 6 '12 at 21:25
  • \$\begingroup\$ That's a great idea! Though, it is strange that that would be the case even when the device is off. Once I put the resistors in, how can I check if its active or just due to pull-ups? I don't have an oscilloscope, but I do have a multimeter and logic analyzer \$\endgroup\$ – Chris Laplante Jul 6 '12 at 21:26
  • 1
    \$\begingroup\$ This is easy to fix - all that's needed is all the information :-). The words may contain all the available information but words tend to need careful parsing and beating to death and it's easy to write what seems like a full description but have others find it hard to0 follow. whereas [tm] a truly complete circuit diagram can be analysed in its own right. It may need some words in support but the main information needs to be in the diagram. Your diagram is a good start bur=t is, I think, incomplete. sure, my brain tries to add the missed bits, but what may I miss? | ... \$\endgroup\$ – Russell McMahon Jul 7 '12 at 7:14
2
\$\begingroup\$

Ok, I've solved this. I've added buffers between the control box and the drumpad controller. This is in addition to the buffers between the microcontroller and the drumpad controller.

So, the buffer configuration on (one) of the lines would look like this, with other parts of the circuit omitted for demonstrational purposes.

enter image description here

The unconnected pins on the buffers are the output enable pins, which I didn't connect (again, demonstrational purposes).

This circuit solves the problem because there is never power on the output of a buffer when the buffer isn't powered. Therefore, no reverse flow occurs.

\$\endgroup\$
  • \$\begingroup\$ I'm pretty sure that buffer has input protection diodes. If a voltage is present at the unpowered buffer input, then you will still get current flowing through the protection diodes. It will probably work, but I don't think it's ideal. I'm still puzzled about things like what is being switched off, how many supplies are involved (I think others are too), etc so I may be mistaken. For instance, why can't you just switch the masters (i.e. control box) power off? \$\endgroup\$ – Oli Glaser Jul 8 '12 at 3:09
  • \$\begingroup\$ There are two supplies. The control box has two AA batteries, and the Pro Micro is powered through USB. This is a non-standard use of SPI because I'm trying to interface with an already existing device. I can't switch off the power on the control box. When it's on, it's on. My goal with these buffers is for my circuit (the microcontroller) to "stay out of the way" when the control box is on. When the Arduino is powering the slave, however, that's when I take control of it. \$\endgroup\$ – Chris Laplante Jul 8 '12 at 3:12
  • \$\begingroup\$ Okay - so what does "off" mean when you say "when the drumset is off, the SPI lines are showing 3.3V" - what is off? Also "...even though Vcc shows 0V!" - which Vcc? \$\endgroup\$ – Oli Glaser Jul 8 '12 at 3:18
  • \$\begingroup\$ Sorry, let me clarify that. When the control box is off, the SPI lines coming out of the control box are showing 3.3V. The control box's Vcc, however, shows 0V. \$\endgroup\$ – Chris Laplante Jul 8 '12 at 3:24
  • \$\begingroup\$ But you just said you couldn't switch the control box off?? Again, what do you mean exactly by "off"? Do you mean standby? Where are you reading the control box Vcc from? Have you opened it up to see where the lines are getting power from? I think if you make all the details really clear, you will probably get some good answers ;-) \$\endgroup\$ – Oli Glaser Jul 8 '12 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.