I'm rebuilding e pinball machine from the 70s which has four 7segment scores displays, and since it's not possible to buy processors, memories and eproms from that particular era, I decided to rebuild it with recent electronics, namely an Arduino Mega to control the switches and solenoids, and 3 nanos to control the sound, lights and score boards.
I thought the score board would be easy, since I decided to make new PCBs matching the old ones, but with MAX7219 ICs for simplicity. Did some tests in the breadboard without a problem, but after assembling the material in the PCBs they show garbage after some time.
This is the initial circuit. The 6 score boards where connected to each other and the first to the Arduino nano with a 1 (40 inches) meter cable. In this configuration the first score board works but stops working after a while, but the 3rd and 4th don't work a all. So my tests where only with the first score board.
As someone suggested in another topic, I had pull up registers to the CLK, CS and DIN to help minimize the capacitance of the cables. That seemed to help a little, but problem persists.
Well... the MAX7219 has a brother designed to deal with this problems, so I bought the MAX7221 to replace these. Assembled another board with the MAX7221, since those are supposed to be a direct replacement, but it didn't work at all. Not even a single led lit.
Back to the breadboard... It works flawlessly. And back to the PCB, with only one 7 Segment to try to isolate the problem... Nothing. WTF????
Maybe it's a problem in the PCB? Checked everything. It's exactly like the schematic... and it worked with the 7219. I really don't know what to try next.
Also, I tried every single code for the Arduino I found on the net and the problem is always the same.
/*
Basic code for using Maxim MAX7219/MAX7221 with Arduino.
Wire the Arduino and the MAX7219/MAX7221 together as follows:
| Arduino | MAX7219/MAX7221 |
| --------- | --------------- |
| MOSI (11) | DIN (1) |
| SCK (13) | CLK (13) |
| I/O (7)* | LOAD/CS (12) |
* - This should match the LOAD_PIN constant defined below.
For the rest of the wiring follow the wiring diagram found in the datasheet.
Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf
Author: Nicholas Dobie <nick@nickdobie.com>
Date: 30 December 2013
License: WTFPL (http://www.wtfpl.net/)
*/
#include <SPI.h>
// What pin on the Arduino connects to the LOAD/CS pin on the MAX7219/MAX7221
#define LOAD_PIN 7
/**
* Transfers data to a MAX7219/MAX7221 register.
*
* @param address The register to load data into
* @param value Value to store in the register
*/
void maxTransfer(uint8_t address, uint8_t value) {
// Ensure LOAD/CS is LOW
digitalWrite(LOAD_PIN, LOW);
// Send the register address
SPI.transfer(address);
// Send the value
SPI.transfer(value);
// Tell chip to load in data
digitalWrite(LOAD_PIN, HIGH);
}
void setup() {
// Set load pin to output
pinMode(LOAD_PIN, OUTPUT);
// Reverse the SPI transfer to send the MSB first
SPI.setBitOrder(MSBFIRST);
// Start SPI
SPI.begin();
// Run test
// All LED segments should light up
maxTransfer(0x0F, 0x01);
delay(1000);
maxTransfer(0x0F, 0x00);
// Enable mode B
maxTransfer(0x09, 0xFF);
// Use lowest intensity
maxTransfer(0x0A, 0x00);
// Only scan one digit
maxTransfer(0x0B, 0x07);
// Turn on chip
maxTransfer(0x0C, 0x01);
}
void loop() {
// Loop through each code
for (uint8_t i = 0; i < 0x10; ++i)
{
maxTransfer(0x01, i);
maxTransfer(0x02, i);
maxTransfer(0x03, i);
maxTransfer(0x04, i);
maxTransfer(0x05, i);
maxTransfer(0x06, i);
maxTransfer(0x07, i);
maxTransfer(0x08, i);
delay(100);
}
}
EDIT1: Add PCB Drawing
The 10uF is missing there, but I added it in the back of the PCB.
EDIT2:
+5V PIN
DIN
CS
CLK