6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 8:55 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Apr 03, 2020 8:12 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
In the Weird data bus write problem thread there was some discussion of why a Ben Eater-type "poor man's logic analyzer" made by planting an Arduino on a 6502 address and data bus was detecting a write as a $00 rather than the value the code was writing; this turned out to be because an accidentally-enabled EPROM (and perhaps other things) were also driving the data bus. I started discussing ways of detecting "bad" bus signals that were being pulled away from the proper 0 and 1 voltage levels by posting about my "Octal TTL Logic Probe."

Since that seems to be turning into a bit of a discussion, and I'd like to avoid too far derailing speculartrix's thread, I'm reposting my first post about that here as the start of a new thread. You may also wish to read the two replies there from GARTHWILSON and Chromatix after reading this first post but before continuing on with the remainder of this thread.
___________________________________________________________

Regarding using a logic analyzer on circuits, I had some strong worries about this when I was having difficulties with the output of my 6821 PIA. The outputs on that are very weak compared to modern chips, and I wasn't sure if something I hadn't noticed was driving the line even a little. I wanted to look at all eight outputs at once (too many for my 'scope), but a regular old logic analyzer wasn't going to tell me if I had firm or dodgy voltages.

To solve this, I was inspired by an idea I saw in the second of Garth's schematics in the Interfacing to SPI and Microwire section of his circuit potpourri page. There he uses op-amps rigged as comparators against a 2.5 V reference to light LEDs when the input voltage is above that level. I realized that if sent this input to a pair of op-amps and LED, one rigged to light when input is between 0 and 0.5 V and the other rigged to light when the input is between 2.7 V and 5.0 V (all the figures assume that Vcc is 5.0 V and scale with Vcc), you'd have a logic probe, and you'd know if the "low" or "high" light was on that it was truly a low or high signal. If neither light is on, you're somewhere in between and in trouble. Plus, since you're using op-amps as the front end, with very high-impedence inputs, you know that they'll be having a minimal effect on the circuit under test.

So I consed up a little design with four quad LM324 op-amps (chosen specifically because they were the only op-amps I had in my parts bin :-P), sixteen LEDs, and some resistors and trimmer pots to let me set and trim the reference voltages. It's described it in more detail in my Octal TTL Logic Probe notes, and I've attached pictures below.

(The blue trim pots are on the lower side of the voltage dividers producing the reference voltage, allowing me to tweak it a bit. Below that are the high-side resistors and a socket for custom resistors; each resistor can be switched in and out using the switches below them, the left four for the low reference and the right four for the high reference. The permanently mounted resistors give me a choice of 0.5 V or 0.8 V (TTL max out and max in for "0") as a low reference, and 2.7 or 2.0 V (TTL min out and min in for "1") as a high reference. I stuck in the socket so I could do CMOS levels or whatever as well, should I ever have the need.)

This board would be fine for examining the situation in a single-stepped system, and might even be adequate for examining the OP's situation, where he was running the system at 1 Hz, but of course you won't be able to keep up with it at faster speeds. But if you swapped out the LEDs for a couple of parallel-input shift registers read by an Arduino, you've turned your "poor man's logic analyzer" into a multi-input logic probe that will much more reliably tell you if your voltages are solid or if you have rubbish on your bus.

And, oh yeah, if you're going to build one of these, consider using a bigger board than I used. This one is really tight and was a nightmare for me to solder. :-)


Attachments:
8ttl-lprobe-top.jpg
8ttl-lprobe-top.jpg [ 725.8 KiB | Viewed 1004 times ]
8ttl-lprobe-bottom.jpg
8ttl-lprobe-bottom.jpg [ 1.73 MiB | Viewed 1004 times ]
8ttl-lprobe-operating.jpg
8ttl-lprobe-operating.jpg [ 1.05 MiB | Viewed 1004 times ]

_________________
Curt J. Sampson - github.com/0cjs
Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 03, 2020 8:37 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
cjs wrote:
To solve this, I was inspired by an idea I saw in the second of Garth's schematics in the Interfacing to SPI and Microwire section of his circuit potpourri page. There he uses op-amps rigged as comparators against a 2.5 V reference to light LEDs when the input voltage is above that level.

Small correction there: The LM339 is a quad, open-collector comparator, not an op amp. It's not very fast as comparators go, but it's quite a lot faster than the LM324 op amp. Op amps don't do very well as comparators because they're designed to stay in the linear region and it takes them longer to come out of saturation after the output has gone as positive or negative as it can.

_________________
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  
PostPosted: Fri Apr 03, 2020 9:02 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
GARTHWILSON wrote:
Small correction there: The LM339 is a quad, open-collector comparator, not an op amp. It's not very fast as comparators go, but it's quite a lot faster than the LM324 op amp. Op amps don't do very well as comparators because they're designed to stay in the linear region and it takes them longer to come out of saturation after the output has gone as positive or negative as it can.

Oh, that just made things a boatload more clear! I'd not really understood that comparators are not exactly op-amps. (They sure look the same on schematics, until you read the text. :-))

I'd also not considered the speed, though I'm guessing that's probably not an issue for an LED display that humans will be observing. But I also guess that could certainly could be an issue for a logic analyzer running at typical microprocessor speeds.

Within a few weeks the the major problem I have with the LM339 should be solved (i.e., that I don't have any. :-)). It seems cheap enough: under a buck for ten in DIP-14 packages. (Sadly, it has a different pinout so I can't just pull the 324s from my board and plug in 339s.) I also poked around a bit and found some interesting application notes giving all sorts of uses for this quad comparator. But would it be fast enough to run a bus analyzer at 1-2 MHz?

And also, after a bit more reading I see that these have open-collector outputs, which I'd never heard of on an op-amp and I'm still kinda trying to wrap my head around. This means that bus pullups will be necessary, and the speed will be limited by those as well, right? Obviously that's not an issue in my LED design, where the comparators' job is just to bring the LED cathode low, but would be if connected to, say, a shift register. It's kinda feeling like a different part might be wanted when building a logic analyzer.

Chromatix wrote:
One could even go a step further here, and test against three voltage thresholds: TTL/CMOS low, TTL high, and CMOS high.

These could be processed into a 2-bit code, synchronised with a clock and trigger, and recorded into a sample buffer, which is the essence of a logic analyser, but with some basic analogue-domain information included.

My design already has the ability to change the two voltage thresholds being used; plop in the appropriate resistors into the sockets, calibrate using the test points on the right and then you should just be able to flip a couple of (well, four) switches and now you're using CMOS instead of TTL thresholds.

So are you suggesting doing both TTL and CMOS high just because there's an extra value available in what one's recording anyway (i.e., because we have to use two bits to record three values, so might as well record four)? That's no problem on the recording side, but seems it would require adding a whole 'nother set of comparators, increasing cost and complexity. If I'm going to add more comparators, I'd personally rather use them to add more inputs.

Quote:
If the thresholds can be adjusted by hand, this can also be made useful in an LVCMOS context.

My thresholds are developed via voltage dividers using VCC, so one can just change Vcc and and work with whatever levels you like, within reason. I think the current op-amps are spec'd to work between 3.0 V and 12 V. And if you replace the LEDs with a typical AVR MCU, that should run fine at 3 .3 V as well (so long as you're not clocking it above 8 Mhz), so no issues there.
__________________________________________________________

So, I guess my main question here is, does it make sense to build a logic analyzer this way? Will the comparators provide significantly higher impedence inputs than going directly into an AVR MCU, and is that really helpful? Is this sort of threshold detection really going to be useful in practice, or am I just a nervous Nellie?

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 03, 2020 9:42 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
cjs wrote:
Oh, that just made things a boatload more clear! I'd not really understood that comparators are not exactly op-amps. (They sure look the same on schematics, until you read the text. :-))

Another contrast is that they don't even try to control the phase margin or gain margin, because they're not intended to be used with linear feedback. Some op amps won't be happy if the differential input voltage exceeds some small amount like 0.6V, whereas comparators are always made to handle a large differential input voltage with no problem.

Quote:
Within a few weeks the the major problem I have with the LM339 should be solved (i.e., that I don't have any. :-)). It seems cheap enough: under a buck for ten in DIP-14 packages. (Sadly, it has a different pinout so I can't just pull the 324s from my board and plug in 339s.)

Yeah, it'd be nice if they pinned it out the same. Actually, it is the same when you're comparing the LM358 (which is a dual op amp, half a 324) and the LM393 (which is a dual comparator, half a 339).

Quote:
I also poked around a bit and found some interesting application notes giving all sorts of uses for this quad comparator. But would it be fast enough to run a bus analyzer at 1-2 MHz?

See my post at viewtopic.php?p=7612#p7612 for tips and speed limits.

Quote:
And also, after a bit more reading I see that these have open-collector outputs, which I'd never heard of on an op-amp and I'm still kinda trying to wrap my head around. This means that bus pullups will be necessary, and the speed will be limited by those as well, right?

In your case, the LEDs and their resistors will be the pull-ups; but normally, yes, you would need pull-ups. Typically resistors are used, in the neighborhood of 4.7K but the best value depends on several things. If you're thinking of the RxC time constant between the pull-up resistor and the bus capacitance, an alternative is using a matched pair of transistors like the BCM62B as a current source so the charge current does not diminish with rising voltage like it would with just a resistor. Theoretically you could get a much faster charge-up; but I have not tried it with the 339 or 393.

_________________
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  
PostPosted: Fri Apr 03, 2020 10:59 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
GARTHWILSON wrote:
If you're thinking of the RxC time constant between the pull-up resistor and the bus capacitance, an alternative is using a matched pair of transistors like the BCM62B as a current source so the charge current does not diminish with rising voltage like it would with just a resistor. Theoretically you could get a much faster charge-up; but I have not tried it with the 339 or 393.[/color]

Yup, the pull-up vs. the bus capacitance is exactly what I was thinking of. I guess I was asking, if you need to be adding pullups that you otherwise wouldn't be, just because the 339 is open-collector, perhaps this isn't the right part for the job?

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 03, 2020 11:24 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
The disadvantage of the LM339 is, that it has PNP input stages,
means a +5V powered LM339 might be acting "somewhat unpredictable" for input voltages of more than +3V.

There are faster (but more expensive) comparators, like the ADCMP602.

When selecting fast comparators, better take a look at the maximum "Differential Input Voltage" in the datasheets.
Because some of the comparators tend to have protection diodes or such between the positive and negative signal input,
and this might give you small currents flowing between your reference voltage and between the bus lines you are out to monitor.

Hmm... the next step probably would be adding some fast SRAM with a fast counter at the SRAM address lines...


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 03, 2020 7:12 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
ttlworks wrote:
The disadvantage of the LM339 is, that it has PNP input stages,
means a +5V powered LM339 might be acting "somewhat unpredictable" for input voltages of more than +3V.

The open-collector output allows you to power the '339 with 9V, 12V, or whatever is nearby (like before the 5V regulator), and pull the output up to a different voltage, whether 3.3V, 5V, or something else. I always have higher voltages on the board anyway for other things. As long as one of a 339's sections' inputs remains in the workable range though, there won't be any problem if the other one goes above that range. In any case, if the 339 is powered with the higher power-supply voltage, the entire 0-5V range of 5V logic is valid. Also, it can pull the output basically all the way to the negative rail, unlike many op amps and even Schottky TTL (like 74LS).

_________________
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  
PostPosted: Sat Apr 04, 2020 6:30 am 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 491
Location: Switzerland
I'm using 74HC4049 or 74HC4050 for this purpose. The threshold is approx 50% of the supply voltage and the inputs are allowed to go up to 15V regardless of the supply voltage and even when not powered.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 51 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: