Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:41 06 May 2025 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 : It works perfectly, but is it a horrific mess ?

     Page 2 of 2    
Author Message
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1636
Posted: 08:25pm 18 Jun 2021
Copy link to clipboard 
Print this post

Hi Tom,

Did you ever replace the cable on the real controller that was troubling you

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4248
Posted: 10:20pm 18 Jun 2021
Copy link to clipboard 
Print this post

  Turbo46 said  Hi Tom,

Did you ever replace the cable on the real controller that was troubling you

Bill


Hi Bill,

The controller and its replacement cable are even now sitting on my workbench in the cellar taunting me .

I did try that controller on the PicoMite (3.3V) and it did actually work, though a little sluggishly compared with my home-made one.

It is 12 months ago now, and my memory isn't wonderful at the best of times, but I think maybe it always worked at 3.3V it was at 5V where it gave me trouble even though it was spec'd for 5V (and not for 3.3V)

One of these days I will "fix" it and as promised ship you the duff connector to pulverise in your yard .

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4248
Posted: 11:05pm 18 Jun 2021
Copy link to clipboard 
Print this post

  Volhout said  Hi Tom,

I tested the CD4021 on a breadboard (actually a HEF4021, the Philips version), and have to conclude that you should not exceed 2MHz SPI clock.


Wow, that investigation goes rather "above and beyond", thanks.

To be honest I can't see any reason I would need to clock a controller at anything near 2 MHz. Unless I'm missing something 1 KHz should be more than sufficient for reading user input shouldn't it ?

You talk about SPI which is one of the million things I still have to understand, currently what I'm doing is:

Option Base 0
Option Default None
Option Explicit

Const LATCH_PIN% = 9 ' GP6
Const CLOCK_PIN% = 10 ' GP7
Const DATA_PIN%  = 11 ' GP 8
Const PULSE_DURATION! = 0.012 ' 12 micro-seconds

SetPin LATCH_PIN%, Dout
SetPin CLOCK_PIN%, Dout
SetPin DATA_PIN%, Din

Pin(LATCH_PIN%) = 0
Pin(CLOCK_PIN%) = 0

Dim i%, out%

Do
 Pulse LATCH_PIN%, PULSE_DURATION!
 out% = &h0

 For i% = 0 To 7
   If Not Pin(DATA_PIN%) Then out% = out% Or 2^i%
   Pulse CLOCK_PIN%, PULSE_DURATION!
 Next

 If out% <> 0 Then
   If out% And &h01 Then Print "A ";
   If out% And &h02 Then Print "B ";
   If out% And &h04 Then Print "Select ";
   If out% And &h08 Then Print "Start ";
   If out% And &h10 Then Print "Up ";
   If out% And &h20 Then Print "Down ";
   If out% And &h40 Then Print "Left ";
   If out% And &h80 Then Print "Right ";
 Else
   Print ". ";
 EndIf
Loop


Is this just bit-banging SPI ?

Best wishes,

Tom
Edited 2021-06-19 09:35 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4836
Posted: 10:47am 19 Jun 2021
Copy link to clipboard 
Print this post

Hi Tom,

Yeah, you are doing spi in basic. And you invert the data. That is probably because your switches on the controller switch 4021 inputs to ground.

About the real controller: if you run a cd4021 at 5v and connect it to a maximite that runs at 3.3v you do get unreliable communication, the cd4021 requires a logic high level of 70% of Its power rail, 5v. That is 3.5v but the maximite is 3.3v. If it works, be happy, but most likely it will be not working.

Run the controller at3.3v like you do now, and all is dandy....

Good luck with your game development.
If you decide to use hardware SPI you can use my code as an example, but you are tied into using the pins as Peter provides them. Hardware is simpler av faster... software more flexible and educating....;)

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4248
Posted: 12:55pm 19 Jun 2021
Copy link to clipboard 
Print this post

  Volhout said  Hi Tom,

Yeah, you are doing spi in basic. And you invert the data. That is probably because your switches on the controller switch 4021 inputs to ground.


OK, that's because it is a copy of the original NES design.

  Quote  About the real controller: if you run a cd4021 at 5v and connect it to a maximite that runs at 3.3v you do get unreliable communication, the cd4021 requires a logic high level of 70% of Its power rail, 5v. That is 3.5v but the maximite is 3.3v. If it works, be happy, but most likely it will be not working.


That sounds plausible. I'd have to dig though my old TBS threads to remind myself exactly what was going on. I did have help from some of the "old hands" so I wonder if we really let such a fundamental explanation escape us.

  Quote  Good luck with your game development.
If you decide to use hardware SPI you can use my code as an example


Thank you,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4248
Posted: 12:59pm 19 Jun 2021
Copy link to clipboard 
Print this post

  Volhout said  About the real controller: if you run a cd4021 at 5v and connect it to a maximite that runs at 3.3v you do get unreliable communication, the cd4021 requires a logic high level of 70% of Its power rail, 5v. That is 3.5v but the maximite is 3.3v. If it works, be happy, but most likely it will be not working.


Now that I cast my mind back (and look at the half-deconstructed breadboard from that project), we were pulling the latch and clock signals up to 5V through 4k7 resistors and the data signal was coming back to a 5V tolerant pin on the CMM1.

Best wishes,

Tom
Edited 2021-06-20 02:24 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025