Bit banging one wire protocol - help needed

Discussion to talk about software related topics only.
Post Reply
ScottM
Posts: 32
Joined: Mon Feb 01, 2010 10:00 am

Bit banging one wire protocol - help needed

Post by ScottM »

I'd planned to use a GPIO pin to bit bang the one wire protocol, but as it turns out, it doesn't work. The one wire protocol expects you to pull the line high with a 4.7k resistor; and then various devices attached to the line drag the pin low (basically by shorting to ground) at certain times. The processor peeks at the line to see if anyone is pulling it low (at times when it isn't busy pulling it low itself.)

It doesn't work because it assumes that the processor will detect a logic 1, when a pin is connected to 3v3 through a 4.7k resistor, and nothing is pulling the line low. As it turns out, my MOD5270 doesn't see a logic 1 in that situation. Anything over about 1k or so, shows up as logic 0. There must be be a righteous pulldown on these pins; I've never seen a processor that needed to be driven so hard to see a logic 1.

Has anyone solved this? I can probably come up with something involving 2n2222 transistors to hack up a workaround, but I can't help thinking there's a neat trick I'm missing that will avoid that. Anyone?
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: Bit banging one wire protocol - help needed

Post by ecasey »

Scott,

That doesn't make sense. What pins are you using? Are they associated with LEDs or other function on the Dev board?
How are you addressing the pins?
I have used 10k pull-ups on many lines without even thinking about it and never had a problem.

Ed
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Bit banging one wire protocol - help needed

Post by Chris Ruff »

I have used the two GPIO approach before successfully:

one line is an output and drives the 1-wire through a diode
the other line is an input from the 1-wire and has the 1.2k resistor pull up

this works fine with 1 or many 1-wire toys.

I haven't even tried to get it all working with one GPIO

Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
ScottM
Posts: 32
Joined: Mon Feb 01, 2010 10:00 am

Re: Bit banging one wire protocol - help needed

Post by ScottM »

ecasey wrote:Scott,

That doesn't make sense. What pins are you using? Are they associated with LEDs or other function on the Dev board?
How are you addressing the pins?
I have used 10k pull-ups on many lines without even thinking about it and never had a problem.

Ed
It absolutely doesn't make sense, which is why I assume I missed something.

I'm using J2-6, and setting it to GPIO mode and hiz() at the start. (Sorry, the code is not in front of me, will post tonight). I use J2[6].hiz() and J2[6] = 0 to make the voltage changes for one wire.

As a test, when set to hiz(), I feed it 3v3 volts from the appropriate pin on J2. If I feed it straight in, or through a 1k resistor, I read a logic 1. Through 2k or 3k (a series of 1k's twisted together), I get logic 0.

I'm using the developer board; maybe it does something unusual with pin 6? I don't have anything else on that pin. My only other guess is that I didn't set the initial mode of the pin correctly.

I think I see a way to work around the issue with a 2n2222 and a diode (or so I think - I'm no wiz at circuit design).
But I'd rather not use it. Or I can do something with two pins and a diode, but don't want to.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Bit banging one wire protocol - help needed

Post by Ridgeglider »

The Dev 100 R12 schematic suggests there might be a resistor connected to j2[6] for use w/ the AD inputs on the 5282s... It looks like it's not usually connected, but don't have a board here to inspect.

The Dev70 boards have a 1K pulldown to ground associated with the Dipswitches.
Attachments
Dev70.jpg
Dev70.jpg (66.09 KiB) Viewed 5802 times
J2-6 with resistor.jpg
J2-6 with resistor.jpg (69.62 KiB) Viewed 5802 times
ScottM
Posts: 32
Joined: Mon Feb 01, 2010 10:00 am

Re: Bit banging one wire protocol - help needed

Post by ScottM »

Ridgeglider wrote: The Dev70 boards have a 1K pulldown to ground associated with the Dipswitches.
Bingo. I'm on a dev70 board, and it never occurred to me to even look at the dip switches. And there's the 1k pulldown. Mystery solved.

Alright. The only reason I'm sticking the 5270 into the dev70 board, is because the board I want doesn't exist, and I don't know how to create boards (or have the knowledge necessary to lay one out). The board I want, would hook a USB to the 5270 (for ease of development, and then to power the thing when I'm done developing), and then it would expose all the other pins with convenient screw terminal or soldering points, ideally nice big soldering points that I wouldn't need a magnifying glass to identify. And it wouldn't do anything else.

But I don't have that, so I'm off to find some pin that isn't going to be affected by the dev board. Suggestions welcome.
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: Bit banging one wire protocol - help needed

Post by ecasey »

The following GPIO pins do not appear to be connected to anything else on the board:

J1[5]
J1[6]
J1[7]

J2[26]
J2[30]
J2[31]
J2[34]
J2[36]
J2[37]
J2[38]
J2[41]
J2[44]

The others go elsewhere on the DEV board, so it's probably best to avoid them.

Ed
ScottM
Posts: 32
Joined: Mon Feb 01, 2010 10:00 am

Re: Bit banging one wire protocol - help needed

Post by ScottM »

J2[41] is working much better for me. Thanks!
Post Reply