6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 28, 2024 11:16 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Serial signal woes
PostPosted: Sun Aug 14, 2022 6:25 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
I'm afraid I've run out of talent again and must throw myself on the mercy of the community. And it's in an area where I generally don't have trouble - serial connections.

The basic situation is that I have a serial board using an SC28L92 which is being run at 5V. This needs to talk to a Raspberry Pi, with its 3V3 pins. My first attempt at this appeared to work, and has been working for months, but I think contained a fatal flaw. With the signals going from SC28L92 TX to RPi RX, I included a resistor divider on the Pi side to bump the level down to 3V3. But going the other way, I figured I didn't need anything, because the 3V3 signals from the Pi would work okay on the SC28L92.

What I hadn't realised is that the SC28L92 holds both RX & TX at 5V when idle. So this was effectively putting 5V on the Pi's TX pin. Like I said, everything worked for a while, but I guess eventually that 5V level took its toll. Long story short, the memorial service for the Pi is next Thursday... (Actually, it still works, all bar the serial port.)

I've since tried going another way. Here's the setup.

Attachment:
serial_connection.png
serial_connection.png [ 420.13 KiB | Viewed 882 times ]


But what I'm seeing is weirding me out.

If the two sides are not connected, the Pi holds its signals at 3V3. On the SC28L92 side I see levels of 0 (RX) and 2.9V (TX). Huh? By the way, the levels on the second serial port, which has no resistors, are the expected 5V.

When the serial cable is in place (and yes, there's a ground connection too), the idle levels are 3.3V and 3.0V.

I've stared at this so long, and have bodged the boards so much that my head's now hurting.

I'm fairly certain the RPi TX -> SC28L92 RX is working okay. On the scope, I see the idle at 3.3V and the signal being pulled down to 0V as expected.

But on the other line, SC28L92 TX -> RPi RX, idle is at 3.0V and the signal doesn't get below 0.45V. And - here's the big problem - I'm getting frequent corruption. I mean, it works mostly. But one time in three at least a bit of the text will be garbled. I suspect that not being pulled all the way to 0V is the problem.

Am I going at this the wrong way? Any advice would be appreciated.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 6:40 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
speculatrix wrote:
And - here's the big problem - I'm getting frequent corruption. I mean, it works mostly. But one time in three at least a bit of the text will be garbled. I suspect that not being pulled all the way to 0V is the problem.

How fast are you going, and how much capacitance is in the cable? Does slowing it down to the next standard speed down stop the garbling? The 22K and 33K together mean the source resistance will effectively be about 13K, and that multiplied by the capacitance in the cable (plus the smaller capacitance of the load at the end of the cable) will make for a time constant that may be too long if you're trying for a really high bit rate.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 6:51 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
I'm running at 9600 baud. The next time I get to the machine, I'll try at 2400. I have another idea, too, which is to drop the resistors on TxDA and go back to using the voltage divider on the RPi side of that line (which is what I was doing originally, without trouble).

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 7:12 pm 
Offline

Joined: Wed Jun 23, 2021 8:02 am
Posts: 166
The thing about the RxD pin being driven to +5V sounds weird to me. The 28L92 datasheet has the RxDA and RxDB pins marked as inputs and no mention of them being driven. Is there a pull up resistor on the board between RxD and +5V ? Even then unless it's a very low value I wouldn't expect it to cause damage to the pi - you should just get a small current through the input protection diode.
By the same token, the RPi Rx line probably has a pullup resistor to +3.3V which would explain the fact that the voltage won't go below 0.45V, since the 28L92 can only drive it low through a 22K resistor.


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 7:25 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
kernelthread wrote:
The thing about the RxD pin being driven to +5V sounds weird to me. The 28L92 datasheet has the RxDA and RxDB pins marked as inputs and no mention of them being driven. Is there a pull up resistor on the board between RxD and +5V ? Even then unless it's a very low value I wouldn't expect it to cause damage to the pi - you should just get a small current through the input protection diode.


Um, yeah, I originally had a 10K pullup to 5V on that line. TBH, I found the wording in the SC28L92 datasheet a little confusing. To quote:

Quote:
The data pins TxD and RxD are considered idle at the logic 1 (HIGH) level when inactive, or active when at the logic 0 (LOW) level. Comments about these levels when RS232 is referenced often refer to Mark and Space levels. Mark usually means inactive and Space means active. The voltage levels represented by the terms Mark and Space are often reversed from those above: Mark is low voltage, and Space is high voltage.


I took this to mean that both lines would be high at idle, and measuring the other port on the same chip, this does indeed seem to be the case.

kernelthread wrote:
By the same token, the RPi Rx line probably has a pullup resistor to +3.3V which would explain the fact that the voltage won't go below 0.45V, since the 28L92 can only drive it low through a 22K resistor.


That makes sense. I think I'll go back to my original plan for the SC28L92 TX -> RPi RX which is to have no pullups and a voltage divider on the Pi side.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 7:38 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
In case it clarifies things, here's the setup I had originally. I thought the pullups would be needed to ensure that the RX pins for both RPi and 28L92 were never floating when the serial port wasn't in use. Looks like I was wrong about that.

Attachment:
serial_connection_original.png
serial_connection_original.png [ 285.74 KiB | Viewed 863 times ]

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 7:54 pm 
Offline

Joined: Wed Jun 23, 2021 8:02 am
Posts: 166
I'd keep a pull up resistor on the 28L92 RxDA line for when it's disconnected from the RPi - it's not good to leave inputs floating.


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Sun Aug 14, 2022 8:05 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
For a simple solution which requires no analysis or brainpower, consider a cheap bidirectional level shifter module like this:
https://www.sparkfun.com/products/12009
(If you like, check out the schematic they provide too)


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 6:56 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
kernelthread wrote:
The thing about the RxD pin being driven to +5V sounds weird to me. The 28L92 datasheet has the RxDA and RxDB pins marked as inputs and no mention of them being driven.


I now think you’re right and that the 5V levels I saw were purely to do with my pullups. In my defence, it was very hot yesterday.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 7:14 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
I've decided to go back to how things originally were for the SC28L92-TxDA <-> RPi-RX, because that *was* workingfine and the Pi sees only 3V3 on that line due to its resistor divider. (The Pi, by the way, is on its own board that plugs into the computer's backplane).

For the other line, I figured I could largely revert to the original design except that, rather than pulling up to 5V I pull up to 3V3 using another divider. This is what the current plan looks like. I'd appreciate any comments about how sensible (or otherwise) this looks before I respin the serial board. I don't intend to go beyond 9600 baud.

Attachment:
serial_connection_proposed.png
serial_connection_proposed.png [ 330.67 KiB | Viewed 812 times ]


And thank you for all the help.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 8:44 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I'm not too keen on this!

I think it will help to consider currents, not just voltages. The voltage divider idea might well work in practice, but you can see that it has a degree of freedom - just how large or small should those resistors be? And why should it matter? It matters because of the current that the driver can produce, and it also might matter because current takes time to charge a capacitor up, and so overlarge resistors will result in an oversmall current and will ultimately limit the signalling rate.

Note the Pi's inputs don't need any external pullups - that's clear, because it ships with a bare connector. Treat this as something which the Pi looks after for itself.

If the serial board does need to have something to stop the input floating - which it might not - then in this particular case where you expect to have both 5V and 3V connections, I'd suggest a very large resistance to ground. Your present circuit is going to affect the signal that the Pi produces and that the serial board sees - possibly minimally, because your resistors are quite large, but it's very unconventional and I'm suspicious of how it might behave!

Rather than a resistive divider to protect the Pi, I think you might be better off with a suitable Zener diode, or maybe a Schottky diode, with the aim of clamping the voltage, and a current-limiting resistor. But it's just slightly beyond my expertise to suggest exactly how. (Edit: simple picture here. Edit edit: perhaps see also here.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 9:48 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
BigEd wrote:
I'm not too keen on this!


Well, I can't say I blame you!

The problematic signal right now is the SC28L92-TxDA -> RPi-RX. This [i[was[/i] working just fine and wasn't putting a 5V signal on the Pi. So I restored both boards to their previous config for this line – the voltage divider on the Pi board and a 10K pullup on the serial board. "We'll be back to normal now," I thought.

Nope.

Still getting occasional corruption. It's not nearly as frequent as before. In fact I quite got my hopes up for a while there. I'll try removing the pullup and see what happens.

[EDIT] It's clearly going to be one of those days. I deactivated the pullup and I swear I did nothing else.

The SC28L92 is still transmitting to the Pi - I can tell from the 6502 machine's boot banner appearing. (No garbling of text there, but it's probably not enough to go on.)

BUT, the Pi board is now not transmitting to the serial board. I haven't the foggiest idea why. I'm going to have to try talking to the serial board with something else, but in the meantime I'm going to curl up in the corner and have a little cry...

[EDIT2]: I changed the RxDA circuitry on the serial board to use the 3V3 pullup and now the boards are talking again. But still getting that occasional corruption, so it might be on to Plan D.

I can see the point Ed made about current. Driving the signal through a 28K resistor is probably not my best laid plan. Reducing the size of the resistors, though, would effectively put a pulldown on the Pi's pin. So I'm looking at level translation options. One I have in mind is the NLSX4373, which is just under €1 a pop from Mouser. Or better yet, this, which doesn't incorporate pullups.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 7:08 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
I'm sure there's no problem with having the receive line pulled to ground when nothing is happening, particularly when the cable isn't even connected and there's no communication going on. The DC circuit analysis for this is very simple, but needs to involve all the resistors, including built-in (and possibly hidden) pull-up and pull-down resistors, and any substantial current sources. If you can post that, I'm sure I can come up with something for you.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Mon Aug 15, 2022 8:18 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
GARTHWILSON wrote:
I'm sure there's no problem with having the receive line pulled to ground when nothing is happening, particularly when the cable isn't even connected and there's no communication going on. The DC circuit analysis for this is very simple, but needs to involve all the resistors, including built-in (and possibly hidden) pull-up and pull-down resistors, and any substantial current sources. If you can post that, I'm sure I can come up with something for you.


Thanks for the offer - I'll see if I'm up to the job of getting all the info. One problem, I suspect, is knowing exactly what's going on inside the RPi and the SC28L92. I've checked the RPi schematics, but they didn't offer much. Same with the SC28L92 datasheet.

FYI, the serial connection is always in use. The RPi is permanently connected to the 6502 machine. It's used as a serial terminal (that I SSH to from elsewhere on the network) and as persistant storage, using my own roll-it-yourself parallel interface.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial signal woes
PostPosted: Tue Aug 16, 2022 8:28 am 
Offline
User avatar

Joined: Thu May 14, 2015 9:20 pm
Posts: 155
Location: UK
If you connect a 1kΩ resistor in series with your multimeter (*1), with your multimeter switched to the 20mA (or equivalent) DC current range, you can measure the ability of a logic circuit to source or sink current. And therefore work out if the voltage on an otherwise unconnected input is due to a pull-up (or pull-down) or is just a bit of small leakage current via the internal circuitry.

*1 by series, I mean meter positive (red) probe to circuit point under test, meter negative (COM, black) lead to the 1kΩ resistor. The other lead of the resistor to the circuit 0V/GND point for testing how much current the point under test can source. Or The other lead of the resistor to the circuit positive supply point for testing how much current the point under test can sink.

The purpose of the 1kΩ resistor is to limit the current flow to a maximum safe value (5mA at 5V, 3.3mA at 3.3V).

If hardly any current flows, then either there is no pull-up or pull-down resistance or it’s a very high value.

In terms of limiting the voltage to a chip or circuit input, as Ed says, normal practice is to use a fast semiconductor diode. Normally a 1N4148 or equivalent and one or two series resistors.

For example like this
Attachment:
File comment: Input protection
BEA67B6E-E67F-47ED-9AB5-1CF0D9746B68.jpeg
BEA67B6E-E67F-47ED-9AB5-1CF0D9746B68.jpeg [ 35.48 KiB | Viewed 703 times ]

Link for web page based circuit simulation (sorry this displays in colour by default, although it can be changed on the options menu by switching off ‘show voltage’ and ‘show current’). Click the switch to change its state.

Don’t panic about the voltage at the input to the chip being at 3.818V, the current is only 159.5µA and thus is perfectly safe for any modern semiconductor chip. Although note that the actual values in a real circuit may vary depending on the actual performance of the chip or internal circuitry. But the voltage and current will always be safe valves.

The 10kΩ resistor is an optional pull-up.

Mark


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: