using a project from arduino UNO with arduino MKR WIFI 1010

Hi there,
I recently made a code for printing on an old CE-125 (sharp ticket printer) with the arduino. The original code was found on Print to CE-125 with Arduino UNO. There were a few errors so I fixed them and made so that the printer would print text sent to the arduino by serial. You can find this code on https://github.com/tarneaux/printer.
Recently I bought a MKR wifi 1010 module, and tried to make EXACTLY the same program work with it.
Unfortunately it always timed out in the "selectPrinter" function.
I tried finding out the protocol it was using inside the code, but it seems like it just prints it to the pins.
Do I have to use other pins? Change my program?
Thanks

Please post your code here; it seems to be small enough.

The mkr board is a 3.3V device. Perhaps the printer requires 5V signals?

Hmm
thanks for your answer.
I've got a little 3v3 / 5v converter for raspberry pi, so just using it should resolve the problem?

Hmm. I have, of course, no idea. What is this little converter?

For your recvWithEndMarker() function, you might find Serial.readBytesUntil() useful.

Hey there,
It's a little board with 10 pins on each side: Power A/B, ground A/B, and I/O pins. It basically converts the voltage of one to the other.
I'll use the Serial.readBytesUntil() next time, thanks for this one!
currently i'm in holidays, so right now no arduino...
Thanks!

You mean one of these bi-directional level shifters meant for i2c bus?

41j9PU-0GLL.jpg

EDIT: oh, those have 12 pins.

Maybe this:

41j9PU-0GLL.jpg

Yeah, it's kinda the same thing.

Then it might kinda work.

If the 5V device kinda has very low current requirements. Level converters are for data only.

Hi again,
I just tested it. It turns out that my converter is VERY slow, it takes around 10 seconds to send text to the printer (~1.2 secs with uno/nano). Do you know any on-breadboard chip converters that I could use for communicating with a bus?
Thanks

Your conclusion about the cause of the slowness is unlikely to be correct.

Please post a schematic, and post your code here, in code tags.

  Timeout = millis();
  do {
    ACK = digitalRead(IN_ACK);
    if (millis() - Timeout > 50) break;
  } while (!ACK);

This code has a 50ms timeout while waiting for IN_ACK to change. But if a timeout occurs, it is simply ignored. You would not know it was happening, except that the code wold run slowly. Could this be the cause of the slow printing?

oh, totally forgot about that. I didn't get it wortking since last time
Thanks, i'll try that!

Ok,
so actually the protocol is following:

  1. Write bit of data on pin
  2. Turn another pin on
  3. Wait until the printer turns another pin on, ACK in the code.
  4. Turn off the pin of 2
  5. Restart the process for next bit
    Actually the 3 took all the time, and I replaced it with a delay(0.5). Now it works and I have even removed a cable.
    Thanks folks!

delay() does not take a floating point number but an integer. So you have a delay(0).

I mean, i have a delayMicroseconds(500). Sorry 'bout that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.