ADJUSTED RESISTOR VALUES FOR MOSFET SWITCHES
The voltage divider network hidden inside the IBM 1130 logic, specifically the switch debouncing circuits, required a much smaller resistor on my MOSFET switches to produce logic low and logic high levels on the gates fed by the signal. I changed over to 470 ohm resistors for the three switches that work with 12V.
The switch that drives the -TWR CB RESPONSE signal has to deliver 48V when active and that voltage sinks to ground through the MOSFET when it is turned on. While I don't have the exact resistor values inside the debouncing circuit for the 48V signals, I believe that a 1K resistor will allow the gates to see logic low and logic high as it switches. That will consume a bit under 2.5 W when on steadily.
CHASING DOWN ANOMALY WITH PHANTOM RED SHIFT COMMAND
I can see from the output to the terminal that immediately after the emulator box turns on, it believes it has received a Shift to Red command from the 1130. However, the logic in the 1130 is designed to fire off a Shift to Black when it starts up, so this looks like the wires are crossed somewhere in my box.
In point of fact, I had misinterpreted the string of characters - it was actually a shift to black exactly as it should be. No issue.
SWITCHED TO DIRECT PORT ACCESS FOR DIGITALREAD AND DIGITALWRITE
I removed the digitalRead and digitalWrite statements, instead using direct access to ports such as PORTL and PINL. Much faster. Running my code in WokWiki, an online Arduino simulator, it appears to not produce output characters at the maximum rate of 15.5 cps. The simulator web page claims that it runs as fast as the Mega 2560 hardware.
I will need to run some printing software to hit the maximum rate and check to see if any characters get dropped. If there is a speed problem, I will have to get even more clever to meet the timing requirements.
If port commands hurt your eyes and make code unreadable - use digitalwritefast.
ReplyDeletehttps://github.com/ArminJo/digitalWriteFast
I like it because the PIN numbers stay readable and you can simply replace all the calls.
That is a helpful system and it does seem to support a reasonable number of Arduino board types.
DeleteI do use #defines to make my code a lot more readable. For example:
#define SelectT2 22
#define readT2 !(PINA & (1<<0))
. . .
doT2 = readT2;
For writes, I could have used parameters but chose to define two separate statements:
#define onTENA PORTC |= (1<<6)
#define offTENA PORTC &= ~(1<<6)
. . .
onTENA;
I could extract the defines into a header file to further clean up the main code file.
The biggest differences using my method instead of digitalWriteFast are the need for me to carefully look up the pin mapping, the need to change my code if the board type is changed, and the fact that it is less 'standard'.
Thank you for the tip.
That is exactly where it comes in helpful! You do not have to care about new pin assignments when changing (supported) platforms and the complexity is hidden. Absolutely crazy how much time is left by checking everything every single call in the standard arduino library.
ReplyDelete