Hello everyone,
Sorry about the title, that it’s not clearer. I’m not really sure how to phrase my issues so clearly in such a short title. Hopefully I can explain it better here.
I’m trying to use the Arduino to emulate a shift register chip. It seems to work, but then it doesn’t. What I’m trying to do is mimic a S88. The shift register is controlled down the line by a controller, a Marklin CS2.
First, a couple of links.
S88 - Principle and Problems ← This is some basic information on the principles of the s88 and the shift register.
http://usuaris.tinet.cat/fmco/images/s88_sch.gif ← This is a schematic of an s88. There are two shift registers, and 4 other chips which capture input. I only really need to utilize 3 of the 6 lines. Data Out, Clock, and Load. The reset is used to reset the latches on the chips that capture the input.
The basics here is that I’m trying to emulate the 4014N chip in that schematic, which is a shift register chip.
Now, there are two people I’ve found that tried to do this.
First: http://forum.arduino.cc/index.php?topic=226538.msg1639859#msg1639859
Second: S88NAVR/S88ArduinoProMini.ino at master · dirkjankrijnders/S88NAVR · GitHub
We will refer to them as GuyA, and GuyB.
I’m using the code from GuyA. I think the issue I’m having is similar to what he had? But it’s not been solved, from what I can tell. I stripped the code down to the basics and adjusted it so it only sends out two bits. 01
The problem is that at some point it starts sending out 101. An extra bit gets added to the front, which is the same value as the last bit. I’m not exactly sure how it’s getting shifted around. This makes more sense with a longer string.
So, on an 8bit string, normally it’d send something like 00100101, but when it sends the incorrect bits, it sends it as 100100101, so an extra bit is added. If the string was 00100100, then the incorrect string would be 000100100. If the correct string was 10100100, the incorrect string would be 010100100. And so forth.
I don’t know if this is an issue with the software, or a hardware issue. The code seems to function fine. Maybe it can’t keep up with the controller? It’s not a purely random thing though, It will go, say, 20 seconds sending the correct bits, but then it’ll go 20 seconds sending the incorrect bits. I’ve not timed it to know if it’s that consistent. The point is, it’s not a one off send, it sends it several times in a row with the bits shifted incorrectly, but at some point starts sending the correct bits again.
I can manipulate the bits it sends. Turning one of them on and off with a switch. That works fine, it doesn’t seem to have issues other than the bits getting shifted over.
I’ve looked at the code from GuyB. I think GuyA’s code is based off of his, but simplified greatly. I didn’t understand GuyB’s code until I saw GuyA’s code. I’ve not been able to try GuyB’s code yet, so I’m not sure if it’d have the same issue.
Maybe the Arduino isn’t fast enough to keep up with the controller? With how GuyA programmed it. GuyB uses a different method to communicate with the pins, but I don’t really understand how that is all setup yet. I’ve not got a chance to read into it beyond a few lines.
I’ve tried to put in some code to output some figures to the serial monitor, but everything seems okay. Maybe I’m looking at the wrong part of the program to know? I just output one of the values of the S88data array, and it shows the correct value, even when the controller (The CS2), shows the data shifted. So it makes me think that there is an issue with the communication from the Arduino to the CS2, like the timing gets off? Or something. I don’t know.