Brother Typewriter - ESP32 - Automation

Hi there,

I'm building a EPS32 Interface to communicate with an old Brother WL-20 Typewriter directly reading and writing the 17 Port of the Keyboard. Because it is working with 5V Logic I need converters. I'm able to read the scan and signal pins to read all kind of characters. The next step was to write characters to the machine. Therefore I use the following code part:

void writeSingle(int signalPin, int scanPin)
{

  Serial.print("Writing ");
  Serial.print(signalPin);
  Serial.print(" - ");
  Serial.println(scanPin);
  // Set the signal pin to output and set it high
  pinMode(signalPins[signalPin], OUTPUT);
  digitalWrite(signalPins[signalPin], HIGH);
  
  delay(10);

  // Wait for a new scan cycle
  while (digitalRead(scanPins[0]) != LOW)
  {
  }

  // Wait for the scan pin to go low
  while (digitalRead(scanPins[scanPin]) != LOW)
  {
  }
  
  // Once the scan pin is low, set the signal pin to low
  digitalWrite(signalPins[signalPin], LOW);
  delay(24);
  digitalWrite(signalPins[signalPin], HIGH);
  delay(49);
  // Change the signal pin back to input
  pinMode(signalPins[signalPin], INPUT_PULLUP);
}

in principle the code is working. But every time the line

 pinMode(signalPins[signalPin], OUTPUT);

is triggered there is a strange noise in the signal

noise_outputsetmode - only example, sometimes ist look different and a lot wider.

the problem is, that this signal is recognized sometimes as character ...

Is it know, that the change of a pin from input to output is generating noise ?

Everything else is working perfectly.

Tanks for you replies.

A quick overview from the project

As a lover of typewriters and typist since the age of 10 I must say I already love this effort of yours.
I have a few questions which might help me understand what's going on:

  1. can you post a schematic?
  2. which Logic Level Converters are you using?
  3. are you multiplexing the pins to use them both as input and output?
  4. is the spike at the pin or at the output of the converter?
  5. if the previous point is the case, have you considered that the spike might be caused by the supply you're using? (those modules can be very noisy)

Dear Ubidefeo,

thanks for your response. I also love this kind of digital-mechanic technic.

  1. The noise is also present without anything connected to the ESP32 Pin (tried different pins). When I try to simulate a character by waiting for the SCAN pin and sending a LOW (by default the OUTPUT is HIGH from brother) to a SIGNAL Pin.
  2. As said, the noise is also present without the converter connected by I'm using the standard ones like: RUNCCI-YUN 4-Kanal Pegelwandler Logic Level Converter Shifter 4 Kanal
  3. Yes at first I used the pins as Inputs and Outputs each. I want to use the keyboard as an input option for COMMANDS for the ESP32 (later on it should trigger things like -> now input a questions for ChatGPT)
  4. The spike is directly at the pin and only appears during changing from INPUT to OUTPUT mode in the write Function. Leaving the pin as OUTPUT from beginning the noise spike is not coming up.
  5. Yes I considered this and tried different power supplies external and via USB Port.

Thanks for responses,
JD