5V serial signal through a long wire. What did I do right?

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I've been using maxim's DS1822 thermometers successfully for quite a while now. They're very easy to integrate into a 5v circuit, and all they require is a few simple lines of code (assuming you know how to handle timing instructions) to be interfaced to an 8051 MCU.

But today I ran into an interesting mystery. As I've already mentioned, these things work with a 5V supply, and at an average frequency of 16 KHz. They have an open collector i/o that must be pulled up with a resistor to work. See attached datasheet if you're interested in more details.

The way I normally use them is I solder their pins to a #22ga shielded cable, and then I glue them to the part whose temp I want to measure. Then I connect the cable to the MCU's PCB, which is normally no more than 2 or 3 meters away.

Today, I had to use a 6 meter cable and everything went haywire after that. I was getting off the chart readings from them in the lab. And obtained absolutely no readings when I took them out on the field (an industrial environment). At first I thought that I had damaged the wire, but after checking each node with a multi-meter, I couldn't find anything wrong. I didn't check it with a scope, though.

To make the story short, this is what happened. The datasheet recommends that the device be connected this way.

Capture.PNG

But the data received by the MCU was unintelligible when I used the previous configuration.


After doing some thinking, tweaking and guessing. I decided to experiment and was finally able to make it work by connecting it this way:

Untitled01.png

If I remove either of the pull up resistors, the arrangement stops working. My guess is that this has nothing to do with the current that the device is able to sink, and may have lots to do with the cable's length and how its inductance and/or capacitance is affecting the signal. I have a theory about the way both resistors at each end of the cable prevent a capacitive charge from building up. But I'm not sure if I'm saying something stupid here...

Can anyone here explain to me what's going on? I'd like to have a deeper understanding of this sort of phenomena.
 

Attachments

Last edited:

crutschow

Joined Mar 14, 2008
38,336
Assuming a nominal 25pF/ft shielded cable capacitance, the total cable capacitance for 6 meters of cable is about 500pF.
A 4.7kΩ pull up gives a rise/fall time-constant of 2.3μs.
You said it works at a "average" frequency of 16kHz but what's the minimum pulse width of the signal?

Certainly adding another 4.7kΩ resistor in parallel will halve the time-constant, which will help if the 2.3μs time is too long for proper signal detection.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
Assuming a nominal 25pF/ft shielded cable capacitance, the total cable capacitance for 6 meters of cable is about 500pF.
A 4.7kΩ pull up gives a rise/fall time-constant 2.3μs.
You said it works at a "average" frequency of 16kHz but what's the minimum pulse width of the signal?

Certainly adding another 4.7kΩ resistor in parallel will halve the time-constant, which will help if the 2.3μs time is to0 long for proper signal detection.
Many thanks, crtuschow. The datasheet says that the signal's typical pulse width for some instructions (which is the actual width I'm using in the MCU) is 15 µs. Also, if it helps, the device's comm line capacitance is 25pF
 

#12

Joined Nov 30, 2010
18,224
I did this with guitar cables at 50 feet, 900 pf, and 20KHz, with 1500 ohms.
It's about cable capacitance and discharge time per RC.
Even that is within my feeble grasp of electronics.
 

Attachments

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
I did this with guitar cables at 50 feet, 900 pf, and 20KHz, with 1500 ohms.
It's about cable capacitance and discharge time per RC.
Even that is within my feeble grasp of electronics.
Thanks, that throws some light into my problem. My cable is almost 20ft long, so maybe a 4k7 resistor at the sensor's end is overkill.... I wish I could understand the math better, though.
 

#12

Joined Nov 30, 2010
18,224
(My) Book one, page 73:
Let Fmax = 20,000
Let loss <3db
Eo=.708 Ein
Let R=1K
1/R + 1/Xc = 1/0.708
Xc = 2424.66 ohms
Therefore, R = 0.4124 x Xc

Let C = 20' x 41.7 pf per foot of cable
C=834pf
Xc = 9.542K
R = 3.935K
 
Last edited:

crutschow

Joined Mar 14, 2008
38,336
Below is the simulation of a 15μs pulse into a 500pF cable load with a 4.7kΩ resistor and two in parallel (2.35kΩ).
The output waveform looks reasonably good for both cases.

upload_2017-7-18_0-36-23.png
 

Papabravo

Joined Feb 24, 2006
22,058
What is the potential difference between uC Ground and device Ground. According to your schematic it could be anything. Try measuring it. You might be surprised.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
What is the potential difference between uC Ground and device Ground. According to your schematic it could be anything. Try measuring it. You might be surprised.
Haven't measured it yet, but both grounds are connected through the same 6m shielded cable
 

Papabravo

Joined Feb 24, 2006
22,058
Haven't measured it yet, but both grounds are connected through the same 6m shielded cable
If both power and ground go through the 6 m cable you could have substantial IR losses. Enough to degrade transmit levels so they approach receiver thresholds. A thick guage power pair may be required.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
If both power and ground go through the 6 m cable you could have substantial IR losses. Enough to degrade transmit levels so they approach receiver thresholds. A thick guage power pair may be required.
#22 isn't thick enough for 5V/1 mA at 6 meters ?
 

Papabravo

Joined Feb 24, 2006
22,058
#22 isn't thick enough for 5V/1 mA at 6 meters ?
#22 ga. should be more than sufficient if that is the actual power draw. Now the capacitance comes back into play because whatever is driving the cable lacks the shtutz to charge and discharge the capacitance of the cable quickly.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
#22 ga. should be more than sufficient if that is the actual power draw. Now the capacitance comes back into play because whatever is driving the cable lacks the shtutz to charge and discharge the capacitance of the cable quickly.
That is exactly my suspicion. I'm going to pay closer attention to the datasheet, and see if I can sim it in LTspice.
 

BR-549

Joined Sep 22, 2013
4,928
How many conductors are in the cable....how many are you using? Your diagram shows two conductors....and neither are ground. May we see what you are calling shielded cable?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,727
Here's a picture of the cable. There are 4 #22 ga conductors in it, plus the shield. Two sensors are connected to the cable, so there's a ground cable (black), 5V (red), and one communication cable for each sensor (blue and yellow). As you can see, the sensors look like small transistors, they are in fact, in a TO-92 package. The two pieces of black electrical tape are hiding a couple of 4.7k resistors. They're soldered between the power cable and the comm cable of each sensor.

35e4446c-9b8d-4b4a-abbb-bb18906ab4bc.jpg
 
Top