Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 08:17 20 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM interfacing with 5V CMOS

     Page 5 of 7    
Author Message
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 643
Posted: 02:00am 16 Apr 2020
Copy link to clipboard 
Print this post

G'Day All

Thanks for your sympathy  

And now on to the problem

It works....................Almost

Pin 7 (RIGHT) does not work but all others seem OK
I didn't bother with switches I just short the ends of the R using my two CRO earths but I can have four words displayed at once.
AND THAT IS WITHOUT A C ON THE BOARD so more to be done.
I can't see anything in the code that might cause the problem and the pin goes up and down.
I had to do something, there just aint enough room under the bed for anymore.

Peter
Edited 2020-04-16 12:23 by PeterB
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 03:03am 16 Apr 2020
Copy link to clipboard 
Print this post

I'm surprised.

Looking at the code again he is using 8 pulses (0-7) but the data for the first bit is available just after the latch so only 7 pulses are needed to clock in the data (7 more bits). That makes the last clock pulse redundant but I don't think that matters because no data is read after that clock pulse. That's if I'm reading it properly?

Can you see the bit in the data stream?

Regarding capacitors, if you look at the scanned circuit on that link some pages back there a 4 of them across the supply. Having said that they are often a tacked on after-thought when I breadboard a circuit.

Bill
Keep safe. Live long and prosper.
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 643
Posted: 03:15am 16 Apr 2020
Copy link to clipboard 
Print this post

Why are you surprised?
I provided a space for a C on the board but didn't fit it just to see what would happen. The problem is solid as far as I can see so unless I made an error typing it in there must be an error in the code or or or.
It has been a long time since I used this system but it is all coming back slowly and it is fun.
I am now going to sit back, have a read and then do the floors. With luck I will be hit by a "cunning plan".

Peter
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 643
Posted: 11:45am 16 Apr 2020
Copy link to clipboard 
Print this post

I have installed a 0.i uF on the board.
I have looked at the software every which way and the problem is I can't understand it.
The fault is there and rock solid.
I have inserted PAUSE 50 in all sorts of places to no avail.
I am a bit concerned by the last CLOCK pulse being after the out signal goes HI but I think Bill explained that.
What I really need is an  understanding of how the code works.
I will keep at it and the floors are clean.....apart from the carpets.

Peter
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 01:25pm 16 Apr 2020
Copy link to clipboard 
Print this post

The clever bit to me was testing:

IF the bit on the DATA pin is NOT 1 (that is the associated switch is closed)
THEN
ORing in 1 raised to the power of the counter (i) into the variable out

2^0 = 1
2^1 = 2
.
.
2^7 = 128 or &H80

So the variable out has a 1 in each bit (0-7) for each switch that is closed which is the reverse of the data coming in.


Do
Pulse LATCH, DURATION
out = &h0
For i = 0 To 7
  If Not Pin(DATA) Then out = out Or 2^i
  Pulse CLOCK, DURATION
Next i



Does that make sense?

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 06:16pm 16 Apr 2020
Copy link to clipboard 
Print this post

  PeterB said  I am a bit concerned by the last CLOCK pulse being after the out signal goes HI but I think Bill explained that.


I don't think it should matter since we don't read after the 8th CLOCK pulse. I can't personally tell from the datasheet whether subsequent CLOCKS would just put 1's, 0's or repetitions the 8th value on the DATA line.

If you are that bothered use either this:
Do
 out = &h0
 Pulse LATCH, DURATION
 If Not Pin(DATA) Then out = out Or &h01
 For i = 1 To 7
   Pulse CLOCK, DURATION
   If Not Pin(DATA) Then out = out Or 2^i
 Next i
 ' etc.


Or this:
Do
 out = &h0
 For i = 0 To 7
   If i = 0 Then Pulse LATCH, DURATION Else Pulse CLOCK, DURATION
   If Not Pin(DATA) Then out = out Or 2^i
 Next i
 ' etc.


Incidentally I suspect the fastest code is the brute-force approach:
Do
 out = &h0
 Pulse LATCH, DURATION
 If Not Pin(DATA) Then out = out Or &h01
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h02
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h04
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h08
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h10
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h20
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h40
 Pulse CLOCK, DURATION
 If Not Pin(DATA) Then out = out Or &h80
 ' etc.


I wonder if you are not reading the last bit (RIGHT) correctly because you have wired your DATA line to the wrong output pin on the 4021? It looks like you need to read from Q8 aka pin 3 on the package.
Edited 2020-04-17 04:16 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 06:31pm 16 Apr 2020
Copy link to clipboard 
Print this post

  Turbo46 said  You still have the two inverters in series and the only difference is whether you use OUT or OOUT? I cannot imagine that there is any noticeable difference in the clock pulse for those two conditions. Did you try two gates in parallel to drive the clock pulse?


Yes to all, except it's DOUT vs OOUT.

  Quote  I'm beginning to believe that you were sold a pup and the blob is a bit suss. After all the latch signal appears to work as expected.


Except it works with DOUT.

I think it's too easy for me to blame the blob, I suspect I'm doing something stupid and if I had a 2-channel DSO connected to CLOCK and DATA I would be able to suss it out. I think a Rigol DS1054Z lies in my future once CV-19 buggers off.

Anyway my 4021's arrived today (alongside some 4026's that I can't remember why I ordered) so I'm going to build myself a home-made NES controller on perforated board (no bespoke PCB for me) and I suspect it will "just work" (TM).

Incidentally can I have some advice on IC storage. I've started to accumulate a modest quantity that are currently stored in either the (hopefully) anti-static tubing or (equally hopefully) ESD foam that they were shipped in/on. Am I best keeping them in a metal or a plastic box or doesn't it matter - those are my only choices in the short-term, though I intend to buy some more professional storage for them post CV-19.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Warpspeed
Guru

Joined: 09/08/2007
Location: Australia
Posts: 4406
Posted: 09:28pm 16 Apr 2020
Copy link to clipboard 
Print this post

One other tip that might be helpful to anyone interfacing 3v logic to 5v logic.

As you will already know, many CMOS chips have functionality based on the old 74 TTL series chips and have identical pinouts.  

The 74HC high speed CMOS range comes in two varieties, the 74HC series swing rail to rail on the outputs, and the inputs are biased to switch at half the supply or 2.5v

There are often 74HCT versions of the same chip which also swing rail to rail on the outputs, but the inputs are biased to switch at 1.5v
The original idea was that 74HCT is then compatible with 74 and 74Ls TTL logic output swings.
These 74HCT chips will also work reliably when driven from 3v CMOS logic without requiring a pullup resistor.
Cheers,  Tony.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 09:35pm 16 Apr 2020
Copy link to clipboard 
Print this post

  Warpspeed said  ... swing rail to rail on the outputs ...


Could you explain what this means and how iy is relevant? Do you just mean a high is always the IC's Vcc and a low output is always its ground?

Best wishes,

Tom
Edited 2020-04-17 07:37 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Warpspeed
Guru

Joined: 09/08/2007
Location: Australia
Posts: 4406
Posted: 10:06pm 16 Apr 2020
Copy link to clipboard 
Print this post

Yes,
Logic high equals the supply voltage, logic low equals ground.
Commonly called "rail to rail" voltage swing.
Cheers,  Tony.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 10:31pm 16 Apr 2020
Copy link to clipboard 
Print this post

I seems to me that the LATCH signal has probably worked well from the beginning using any method you have tried.

The CLOCK signal has only worked under some conditions:

1. Running the controller at 3.3 volts using a DOUT command on the CMM with no pullup resistor.

2. Running the controller at 5 volts while using a OOUT command on the with a 1K pullup resistor to feed the signal to the controller.

3. Running the controller at 5 volts while using a DOUT command on the with a 10K pullup resistor using two inverter gates in series to feed the signal to the controller.

BUT will not work in condition 3 using the OOUT command! It will not work using no inverters and a pullup resistor 2K2 or greater.

I'm sorry but if all that is true and you are not doing something stupid (which I don't believe) then the blob must be suspect. It just shouldn't be that temperamental. Maybe it is temperature variations or you're just not holding your mouth right but it should just BLOODY work.

Bill

PS. The 4000 CMOS series will pretty much swing rail to rail but don't have much drive capability.
Keep safe. Live long and prosper.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 10:42pm 16 Apr 2020
Copy link to clipboard 
Print this post

  Quote  so I'm going to build myself a home-made NES controller on perforated board (no bespoke PCB for me) and I suspect it will "just work"


That's what I would do. I'd build it to fit into a small plastic box that could be tacked onto the back of the controller box. Very carefully remove the blob and connect the new circuit in its place.

I would then go and find that sledge hammer that you use to crack nuts and dispatch the blob while laughing maniacally.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 10:45pm 16 Apr 2020
Copy link to clipboard 
Print this post

  Turbo46 said  The CLOCK signal has only worked under some conditions ...


You have accurately described everything I've tried and the results.

  Quote  ... but it should just BLOODY work.


I'm glad to hear it, alas the blob isn't listening.

Just idle and ignorant speculation, but the schematic usually drawn for an official NES controller has each button attached to the Vcc rail (5V if running according to spec) by a 1k pull-up resistor. Which is exactly the size that is required for OOUT in my circuit to work. Coincidence?

  Quote  PS. The 4000 CMOS series will pretty much swing rail to rail but don't have much drive capability.


By which you mean they won't source or sink much current?

Also I guess if I'm running then at 3.3V they are "slow" but that is probably a relative term and unimportant to me as a new hobbyist?

Thanks again,

Tom
Edited 2020-04-17 08:46 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 11:09pm 16 Apr 2020
Copy link to clipboard 
Print this post

  Quote  the schematic usually drawn for an official NES controller had each button attached to the Vcc rail (5V if running according to spec) by a 1k pull-up resistor. Which is exactly the size that is required for OOUT in my circuit to work. Coincidence?

Yes, depending on the quality of the switches they may need a bit of wetting (whetting) current through them to cut through corrosion on the contacts. Apart from that the pullup resistors could quite happily be 100k. I fact I think they were 68K on that scanned circuit diagram.

  Quote  By which you mean they won't source or sink much current?

Yes, only about 0.5mA except for the 4049 and 4050 Which were good for driving LEDs and interfacing to TTL.

  Quote  if I'm running them at 3.3V they are "slow" but that is probably a relative term and unimportant to me as a new hobbyist?


You're testing me now. I'm not sure if they are slower or faster (lower voltage from low to high so quicker transition time?). But I don't think it matters.

Bill
Keep safe. Live long and prosper.
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 643
Posted: 11:41pm 16 Apr 2020
Copy link to clipboard 
Print this post

Good morning All

I haven't been under the bed I've been in it.
Thanks for the explanation Bill but I had sort of worked that bit out. I bog down when two or more switches are closed. I think I need to draw the wave forms.
I like Tom's brute force method, that's how I would have done it.
Tom, I think you are learning all the stuff I seem to have forgotten. The different families and what they can and cant do. Perhaps you should look at RTL and DTL.
Just kidding.
I await the result of your experiment with eager anticipation, strewth.

Peter
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 11:47pm 16 Apr 2020
Copy link to clipboard 
Print this post

  PetrB said  Perhaps you should look at RTL and DTL.
Just kidding.


Oh God I hope so.   (shudder)

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 08:37am 17 Apr 2020
Copy link to clipboard 
Print this post

  Turbo46 said  
  PetrB said  Perhaps you should look at RTL and DTL.
Just kidding.


Oh God I hope so.   (shudder)

Bill


LOL. The first thing I did with electronics after flashing the obligatory led with a capacitor and transistor was build a set of RTL logic gates.

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 10:21pm 17 Apr 2020
Copy link to clipboard 
Print this post

Tom,

While I'm thinking of it. Your 'brute force' method may be useful if you want to add the controller into the SNAKE game. I was wondering how you could add reading the controller while matrixing the LEDs.

I think you are using a 1mS timer interrupt to handle the matrixing? Maybe you could read just one or two bits of data from the controller each interrupt using the 'brute force' method?

Bill

PS. After the relays and uniselectors we has a system comprising racks and racks of RTL. It's the stuff of nightmares.
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3865
Posted: 10:39pm 17 Apr 2020
Copy link to clipboard 
Print this post

Hi Bill,

What you describe is exactly the next step in my plan.

Beyond that I want to reduce the pin count so I can switch to a 28-pin Micromite and have some I/O available to add sound fx. I'd like to see if I can do it all with 4000 series CMOS; a decade counter for the rows and a serial2parallel shift register for the columns. I'll also need some sort of driver to source the columns and a Darlington array to sink the rows (currently I have 8 discrete NPNs). After that I may switch to a MAX7219 and a 16x16 matrix. The final step is learning how to layout a PCB for a handheld version, but I won't be etching it myself.

I'll know I've succeeded when I start seeing Chinese knockoffs of my design on eBay ... though actually you can already buy kits for something similar.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 11:05pm 17 Apr 2020
Copy link to clipboard 
Print this post

Hi Tom,

You may want to consider the 74HC series instead. It will work quite happily at 3.3 volts and has more drive capability. No need for 5 volt tolerant pins and pullup resistors.

OK, the controller could use the 4000 series to maintain compatibility.

Bill
Keep safe. Live long and prosper.
 
     Page 5 of 7    
Print this page
© JAQ Software 2024