bulletford
Posts: 4
Joined: Sun Aug 05, 2012 1:32 pm

"Low" speed synchronous serial communication: How?

Tue May 18, 2021 8:21 am

My current project is to get a Raspberry Pi to act as a virtual keyboard for an old ACT Apricot F1 computer for which I don't have the infrared wireless keyboard.

The communication uses a synchronous serial protocol with a clock rate of 2.24KHz, which is too slow for the SPI interface on the Pi which would otherwise be ideal for driving the communication.

So, does anyone have any idea how I might do this?

From what I understand both the I2C and 1-wire are unsuitable.

User avatar
joan
Posts: 15622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 9:14 am

Do you have a link to the specs of the synchronous serial protocol with a clock rate of 2.24KHz?

bulletford
Posts: 4
Joined: Sun Aug 05, 2012 1:32 pm

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 10:49 am

It's not a bidirectional protocol as it's one-way.

The connection is via infrared and are packets of four bytes:
  • 0x5a synchronisation code
  • status (shift or control pressed, it's a repeat of the previous packet and whether it's from the keyboard or mouse)
  • y-keyboard matrix position or y movement of mouse
  • x-keyboard matrix position or x movement of mouse
The status, y-keyboard and x-keyboard values are nibbles which have been encoded using a Hamming code, making them 8 bits.

Each packet is separated from the next by at least 15ms.

User avatar
joan
Posts: 15622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 11:17 am

pigpio will be able to handle that.

Have you connected the signal to a GPIO?

If so just use piscope to confirm the signal(s).

http://abyz.me.uk/rpi/pigpio/piscope.html

You could also check the data with something like http://abyz.me.uk/rpi/pigpio/examples.h ... SPI_mon_py

bulletford
Posts: 4
Joined: Sun Aug 05, 2012 1:32 pm

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 11:46 am

Ah, I'm trying to generate the signal from the Pi rather than read it.

I'm guessing that you misunderstood the problem.

Essentially I'm trying to get the Pi to act as if it's the original keyboard for the ACT Apricot F1 computer.

User avatar
B.Goode
Posts: 12085
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 11:55 am

bulletford wrote:
Tue May 18, 2021 11:46 am
Ah, I'm trying to generate the signal from the Pi rather than read it.

I'm guessing that you misunderstood the problem.

Essentially I'm trying to get the Pi to act as if it's the original keyboard for the ACT Apricot F1 computer.


I think my fellow volunteer, who is usually pretty smart, is suggesting that you could code your transmitter using their own pigpio library, and that thereafter you could use the related piscope utility to monitor the resulting packets being transmitted.


My far more dumb question would be whether you know enough about the electrical/physical connection of the pseudo keyboard to be able to send the clock signal needed for a synchronous connection. {Post-Edit: just realised I am unclear whether you are giving the RPi an IR transmitter, or connecting it to the Apricot by wire.}


[Apricot: a forerunner in the fruity-computer stakes. It would be great to see you get it running again.]
Last edited by B.Goode on Tue May 18, 2021 12:10 pm, edited 1 time in total.

User avatar
joan
Posts: 15622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 11:57 am

Okay. No problem. Does the output have to have a carrier wave? Domestic IR (TVs and such) have a 38 kHz carrier.

bulletford
Posts: 4
Joined: Sun Aug 05, 2012 1:32 pm

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 12:52 pm

No, it's purely synchronous bit banging, precisely the same as SPI uses but at a lower bit frequency.

i.e. each bit has a specific time period determined by the clock frequency.

So, for example, if each bit had a 1ms time period then the byte 1101000 would be encoded as 2ms "high", 1ms "low", 1ms "high" and 3ms "low". The bit position is implicit from the time. Both the sender and receiver have to have synchronised clocks and know when the data stream begins.

In the case of this keyboard interface the computer looks for the 0x5a sequence in the IR (and has a circuit to synchronise the beginning of the clock rise with the clock input on the Z80-SIO chip) at which point it knows when the beginning of the data will be and then reads the following 24 synchronous bits. Each bit being 5 uS in length.

User avatar
joan
Posts: 15622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 3:15 pm

No problem.

Use pigpio waves.

See http://abyz.me.uk/rpi/pigpio/examples.h ... se_code_py for some ideas.

pidd
Posts: 2081
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: "Low" speed synchronous serial communication: How?

Tue May 18, 2021 5:20 pm

joan wrote:
Tue May 18, 2021 11:57 am
Does the output have to have a carrier wave? Domestic IR (TVs and such) have a 38 kHz carrier.
That is why they had to use so much hamming error detection/correction code, the error rate was horrendous because it wasn't using a carrier. The reference below is technically incorrect but has the correct gist.
Due to the large amount of interference that other infrared sources could cause, the communications protocol used by the keyboard had to feature 4 parity bits per byte. Engineers found that any less than this would not work correctly.

SOURCE

Return to “Interfacing (DSI, CSI, I2C, etc.)”