SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By spcutler
#12443
Sorry for the crummy subject line, but it's a bit difficult to summarize my problem.

I have a device that I want to hook up to a uC (16f88 in this case). The device has 4 pins: Vcc, clock, data, and ground. It runs at 1.5v. The device sends data to the uC via the clock/data lines. The uC runs at 5v.

What I have done so far is tie the grounds together, and hook the clock and data lines directly to the uC (right now, Vcc is provided by a small battery). This actually works just fine, even though logic high is only 1.5v. It's not a mission-critical app, and I'm triple sampling in any case, so even if I'm dropping a bit here and there, it's not a big deal.

The trouble is this: the device has two "buttons" on it (only one of them is physical), which I need to "press" in a sequence upon startup. This is done by pulling either the clock or data lines to Vcc (preferably with a 1k or so resistor inline). Of course, I want the uC to do this automatically.

Obviously I can't just set TRISIO==0, since that will send 5v to the pin, which is too much. I don't want to short the thing out. One thought is to use a resistor network and a diode, but wouldn't that cause some kind of current loop, especially if the voltages were a bit off? I'd like to use a transistor, but I've only ever used them (NPN kind) to "pull a wire to ground", not to a specific voltage. And what if the base voltage is higher than what I'm trying to pull the pin to?

What about MOSFETs? I've got some handy, but I've never really understood how to use them. Can I just connect the gate to the uC, the source to +1.5v, and the drain to a 1k resistor and then to the device?

I know that a relay would work fine, but that's just such an ugly solution that I want to avoid it.

Incidentally, I will eventually need to connect 3 of these devices, and would like to use as few pins as possible. Obviously, unless I mux them, I need at least 6 for the 3 sets of clock/data, and presumably 2 more for pulling clock/data high (I don't need independent control for the buttons). I can't really spare any more than this (and would like to mux the clock/data pins eventually anyway).

Thanks for any help!

-Scott
By Roko
#12449
Could you just use a resistor divider network? A 5.6K resistor going from ground to the 'button', then a 10K resistor going from the "button" to the MCU will drop the 5 volt MCU signal down to about 1.8 volts at the 'button' line.

Code: Select all
Poor Attempt at an ASCII Circuit:

           *----- MCU (5 Volts)
           |
           /
           \  10 K Ohm
           /
           \
           |
Button-----*
           |
           /
           \  5.6 K Ohm
           /
           \
           |
          GND
By spcutler
#12452
I thought about that, but a couple of problems came to mind:
- The 5.6k resistor in your diagram would be constantly draining the signal sent by the device on that same line. Now, with enough resistance I can make that not a problem, but if I do that the button press might not register. I'm not sure a happy medium is possible.
- I'm wary about mismatched voltages between Vcc (as provided by a regulator or a battery) and the divided 5v. Maybe it's not an issue, especially if I am conservative about the voltage I send. But again, if it's too low then the buttonpress might not register.

Thanks for the suggestion, though (BTW, your ASCII art is just fine!).
It's definitely worth a try.

-Scott
By spcutler
#12455
Cool, that sounds exactly like what I need. SMT is a bit of a problem, but I'll bet I can find a DIP part with enough looking around. I wouldn't mind fixing it with the parts I have on hand (standard issue stuff--resistors, diodes, NPN/PNP transistors, MOSFETS, etc.). But if I can't do that I'll definitely go for one of these things...

-Scott
By NleahciM
#12456
I recently had to interface a 2.8V part to a 3.3V part. The 2.8v outputs I could connect directly to the 3.3v part, but the 3.3v outputs had to be brought down to 2.8V. I ended up using a Fiarchild NC7N734 : http://www.fairchildsemi.com/pf/NC/NC7NZ34.html

Though that one is a bit small for you if you aren't a fan of surface mount soldering, hopefully it'll give you a good idea of what you need.
By wiml
#12458
You can turn your "pull a line to GND with a NPN transistor" circuit into a "pull a line to VCC with a PNP transistor" circuit. Then you'll need an NPN to drive the base of the PNP (so that it'll either be pulled to GND, turning it on, or left floating, turning it off). This works fine but it is several components. Since you have several outputs you need to do this for, a level-translator IC is probably the easy way.

FWIW, it's possible your 1.5v chip has 5v-tolerant inputs --- unlikely, but it's worth a glance through the data sheet, since it'd simplify things considerably if true. :)
By Kuroi Kenjin
#12460
What about an opotcoupler? It might be a bit larget than a few transisotors, but it'll definately work.

oh... 1.5V probably won't light an LED, nevermind
By spcutler
#12480
Hmm, I can handle a multiple transistor approach. I did try a MOSFET, and it seemed to work, but I didn't have the multiple voltages going yet (I just saw that it would successfully pull the line to Vcc). An NPN+PNP sounds like the "correct" way of doing it.

I only wish I had a datasheet for these devices. In case anyone is wondering, these are the Chinese-made linear scales popular with mini-mill and lathe owners. I'm trying to make my own digital read-out (DRO) device. There's a short tutorial on their operation here:
http://www.shumatech.com/support/chinese_scales.htm

Shumatech has a schematic for interfacing the scales with a uC, but it's overly complicated in my opinion and I want something simpler.

I did consider an optocoupler, but you're right--1.5v isn't enough to drive one. Though it might work combined with another component.

-Scott