SHARP:USB-cable HW-handshake

Talk in English

Modérateur : Politburo

Répondre
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

SHARP:USB-cable HW-handshake

Message par spellbound »

This post is about how to obtain a reliable, full speed connection between a SHARP pocket computer that is equipped with an RS-232 interface and a PC/MAC. It's about utilizing bidirectional (RTS/CTS) hardware handshake so you do not need the XON/XOFF-protocol, line-delays or lowering baud-rates at all.

SHARP pockets to which this applies are (at least):
  • PC-1600
  • PC-E500 series
  • PC-13xx series
  • PC-1450 / 1475
  • PC-E220
  • PC-G8xx series
  • ...
or in general every SHARP pocket with a 15pin or 11pin RS-232 interface.

There are already many solutions out there but none with a true one-fits-all approach.
Furthermore the wirings I've seen for the E500 and 1350|60 all require the activation of the XON/XOFF-protocol for LOADing.
Especially fixed wirings/cables that offer bidirectional hardware handshake for the PC-1600 in principle cannot do the same for the E500 or 13xx series and vice versa, because there are subtile but relevant differences.

In fact, I found that there are three different types of built-in RS-232 interfaces in the family of SHARP pockets:
  • PC-1600
  • 15pin Standard
  • 11pin Standard
USB-Adaptor
Lets start with the USB-side of an adaptor/cable, which can be the same for all three types:
I recommend an FTDI USB-adaptor/cable with the FT232R-chip, 5V, open ended.
USB adaptor.jpg
USB adaptor.jpg (22.93 Kio) Vu 714 fois
Setup FTDI
Download the tool FT_PROG from the website of the manufacturer: www.ftdichip.com.
With this tool you must logically invert the signals RXD, TXD, RTS and CTS of the FTDI-chip, because the FTDI-chip exposes UART-TTL signal levels, but the RS-232 interface of the SHARP pockets operates on inverted UART-logic. This is a one-off process and the settings are persisted within the integrated EEPROM of the FTDI-chip.
Setup FTDI.jpg
Setup FTDI.jpg (50.72 Kio) Vu 714 fois
So you now have a cable that exposes the following signals with inverted UART logic, 5V HIGH:
GND, VCC, RXD, TXD, CTS, RTS

Now lets care about the specifcs of the three interface types mentioned above and appropriate wirings and settings for bidirectional hardware handshake.

PC-1600 Interface
The port pinout of that machine is as follows:
PC-1600 interface.jpg
PC-1600 interface.jpg (99.59 Kio) Vu 714 fois
As you can see, the TXD and RTS outputs of the PC-1600 are -8.5V LOW and +5.6V HIGH.
The PC-1600 is the only SHARP-pocket, that provides true RS-232 signal levels,
which is the reason for the CE-1601L - CE-1605L beeing just cables and not level shifters like the CE-130T - CE-133T and others.
But the FTDI-chip seems to have internal clipping of negative voltages, so we can use a straight forward null-modem wiring, DTR/DSR/CD can be ignored.
<EDIT>
There are some FTDI-remakes out there, that seem to require additional resistors (10-100 kOhm) in series for the outgoing signals of the PC-1600, which are RTS and TXD. The original FTDI-USB cable does not require those resistors, depicted in red (replace them by a direct wiring in the following diagram).
FTDI remake.jpg
FTDI remake.jpg (23.94 Kio) Vu 714 fois
Within the rest of this article I'm ignoring the additional resistors for those FTDI-remakes.

Setup PC-1600:

Code : Tout sélectionner

SETCOM "COM1:",9600,8,N,1,N,N
SNDSTAT "COM1:",59
RCVSTAT "COM1:",61
OUTSTAT "COM1:"
The SNDSTAT, RCVSTAT and OUTSTAT statements are mandatory! - they activate the RTS/CTS hardware handshake for both directions.

Setup Terminal Program (CoolTerm, hterm, ...)
  • baud = 9600
  • data bits = 8
  • parity = none
  • stop bits = 1
  • XON/XOFF = off
  • RTS/CTS (RS/CS) = on
  • line delay = off
  • character delay = off
  • RTS (initial) output (button/toggle) = ON/HIGH (deactivate to pause transmission from the pocket)
Thats it for the PC-1600 :-)

Unfortunately this wiring does NOT provide bidirectional hardware-handshake for the 15pin SHARP standard interface!

15pin Standard Interface
SHARP pockets with this type of interface are the following:
PC-E500 series, PC-1350, PC-1360, PC-1475 and all others with 15pin RS-232 interface except the PC-1600.
There are two relevant differences between the 15pin PC-1600 interface and the 15pin standard interface
  • Voltage levels are 0V LOW and 5V HIGH
  • The meaning and behavior of the RTS signal
In the mid to late 1980's there was a transition in the industry regarding the interpretation of the RTS signal of the RS-232 standard towards the new RTR meaning (which was not RS-232 standard conformant).

The original, historical meaning was: RTS = "Request To Send", i.e. the computer wants to send data out and requests permission form the connected device to do so via RTS. The device then answers by CTS. The problem is, that this protocol is asymmetrical (RTS and CTS are not independent) and the computer has no means to signal the connected device to pause a data transmition going from the device to the computer, in case the latter is busy.
This soon became a big problem in computer-to-computer communication. What was/is really needed is this: By RTS the computer allows the connected device to send data to the computer. In other words this new interpretation has the meaning of "Ready To Receive" (RTR). RTR and CTS have a symmetrical meaning (i.e. supporting both directions) and are independent from each other. In fact today the meaning of RTS has "quietly" been shifted to RTR, although the label RTS has been kept.
This is also true for the RTS-signal of the PC-1600!

From the pinout below we can read that in the mid 80ies SHARP decided to deal with this problem by providing the original standard conformant RTS(RS) signal as well as an additional RTR(RR) signal for it's standard 15pin interface:
SHARP 15 pinout.jpg
SHARP 15 pinout.jpg (49.75 Kio) Vu 714 fois
So for a wiring that supports bidirectional hardware handshake, we need the RTR(RR) signal and NOT the RTS(RS) signal from this type of interface!

Additionally at least the PC-E500 series requires a DTR/DSR/CD handshake in order to activate the interface.
So we need a respective loopback for that. That means for the SHARP 15pin standard interface we basically have this wiring:
FTDI to 15 pin.jpg
FTDI to 15 pin.jpg (36.87 Kio) Vu 714 fois
Setup PC-1350/60 for bidirectional hardware handshake:

Code : Tout sélectionner

OPEN "1200,N,8,1,A,C,&1A"
CLOSE
Setup PC-E500(S) for bidirectional hardware handshake:

Code : Tout sélectionner

OPEN "9600,N,8,1,A,C,&H1A,N,N"
CLOSE
These settings are persistent (i.e. stored until explicitly changed or the next hard reset is performed).
If you OPEN the port without any parameter string, the stored settings will be used:

Code : Tout sélectionner

OPEN
LOAD / SAVE
CLOSE
The terminal program config is as above (except the max baud rate of 1200 for e.g the 13xx)

11pin Standard Interface
This type of RS-232 interface is the latest in the line of SHARP pocket computers, so it is not astounding that its RTS-signal already has RTR semantics.
Pockets with this type of interface are: PC-E220, PC-G850V(S) and all other with an 11pin RS-232 interface.
Typically the 11pin interface supports different operational modes - here is the pinout for RS-232 mode:
SHARP 11 pinout.jpg
SHARP 11 pinout.jpg (49.84 Kio) Vu 714 fois
The PC-G850V(S) sets DTR to HIGH when the interface is activated, but does not care about DSR and CD. On the other hand, a DTR/DSR/CD loopback is not harmful, so lets include it in the wiring, just to be safe.
Additionally, for the PC-G850V I found it necessary to incorporate a 10KOhm pulldown resistor to the RTS signal. Without that, the host computer has no defined LOW level and does not pause data transmission, when the G850V requests it - leading to I/O errors.
FTDI to 11 pin.jpg
FTDI to 11 pin.jpg (38.07 Kio) Vu 714 fois
PC-E220 and PC-G850 setup:
Menu TEXT->Sio->Format
baud rate = 9600
data bit = 8
stop bit = 1
flow = RS/CS

One-Fits-All 15pin
If you want to build an adapter/cable that supports the PC-1600 hardware handshake as well as the 15pin standard, you obviously have to merge the two wirings from above. And that leads to the necessity of a toggle switch (or similar):
FTDI to 15 pin OFA.jpg
FTDI to 15 pin OFA.jpg (49.54 Kio) Vu 714 fois
11pin to 15pin Adaptor
If you want a solution that supports all three types of interfaces, you could build a modular adaptor with a removable 11pin-to-15pin adapter part that has a 1:1 signal mapping and incorporates the toggle switch. The DTR/DSR/CD loopback and the RTS-pulldown resistor then remains on the part that is attached to the cable.

Here is a picture of how this could look like:
11pin to 15pin.jpg
11pin to 15pin.jpg (105.13 Kio) Vu 714 fois
I hope this was inspiring and informative.
Enjoy
Tom
Modifié en dernier par spellbound le 17 oct. 2021 20:03, modifié 10 fois.
Avatar du membre
pir2
Fonctionne à 9600 bauds
Fonctionne à 9600 bauds
Messages : 4641
Enregistré le : 31 oct. 2006 15:08
Localisation : 67310 Westhoffen
Contact :

Re: SHARP:USB-cable HW-handshake

Message par pir2 »

THanks for this detailled explanation, i will see if this is applicable to the 2 USB-cables i've bought some years ago .... and never really tested :oops:
Image
Image
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

Hopefully yes - good luck :)
Modifié en dernier par spellbound le 31 déc. 2018 19:45, modifié 1 fois.
philoupat
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 12
Enregistré le : 11 mars 2018 21:32

Re: SHARP:USB-cable HW-handshake

Message par philoupat »

Bonjour
j'ai realisé une connection usb avec mon pc1350
j utilise le programme suivant
5 "A"
10 OPEN "1200,N,8,1,A,C,&1A"
20 LPRINT "BONJOUR"
j utilise Hterm
La commande Run fonctionne bien
Les commandes OPEN et LLIST fonctionnent bien(voir ci dessus)
ma question est la suivante comment envoyer un fichier programme dans la machine
la commande LOAD BRK ne donne rien
La commande SAVE BRK ne donne rien
merci pour votre reponse
usb ftdi
usb ftdi
usb.jpg (33.76 Kio) Vu 31033 fois
Le fichier joint Capture.PNG n’est plus disponible.
philoupat
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 12
Enregistré le : 11 mars 2018 21:32

Re: SHARP:USB-cable HW-handshake

Message par philoupat »

capture de hterm
Capture.PNG
Capture.PNG (87.9 Kio) Vu 31032 fois
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

Upload a file from PC:

In hterm:
1. press the „Connect“ button
2. press the „Send file“ button (located at the Input Control section)
3. in the dialog select the file you want to upload from your hard disk (do not press „Send“ by now)

At the 1350:
4. OPEN
5. LOAD (this command will block, do not press BRK - it waits for the file to be send)

In hterm again:
6. press „Send“ in the file dialog and wait until the transmission has completed
Modifié en dernier par spellbound le 27 oct. 2018 18:26, modifié 1 fois.
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

A rather tricky part when performing file uploads of programs found in the internet, is the correct EOL (End Of Line) and EOF (End Of File) handling.
Since many people struggle at this point and asked for help, I give some general advice here.
The essence is that the EOL and EOF setting of your (SHARP pocket) computer must match the actual format of the file to upload.
If the EOL format does not match you will get a transmission error.
If the EOF token does not match or does not exist at the end of your file, the transmission will not terminate (at least when using full hardware handshake, like suggested in this thread).
Note that this compatibility issue does not arise, if you just LOAD a program that you have previously SAVEd with the same settings.
It may arise, when you try to transfer program source-code that has been SAVED with a different computer or has been downloaded from the internet.
It will arise, when you try to transfer program source-code that has been SAVED with different EOL/EOF-settings.

To check or modify the actual file format, I recommend downloading the free source-code editor Notepad++.
The following diagram summarizes all necessary steps:
SHARP Pocket Computer EOL/EOF Handling Sheet

As you can see, with a PC-1350 for example, you can adjust the settings at your pocket, to match the adctual file format. With a PC-1600 you can't, which means you have to convert the file format, if it does not match (check and change respectively with Notepad++).
Modifié en dernier par spellbound le 24 janv. 2024 22:49, modifié 2 fois.
dogrin17
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 3
Enregistré le : 11 août 2020 01:22

Re: SHARP:USB-cable HW-handshake

Message par dogrin17 »

Would anyone know why my G850VS can receive data just fine, but sits on "SENDING" when trying to send? I get no data in the terminal. I've followed all of the steps and I'm a bit lost.

Can anyone help? Thank you.
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

dogrin17 a écrit : 11 août 2020 03:26 Would anyone know why my G850VS can receive data just fine, but sits on "SENDING" when trying to send? I get no data in the terminal.
That means the G850VS is blocked by the RTS-signal from your computer. The most likely reason for that is that you forgot to activate the signal from within your termninal software (see screenshot of hterm above - the RTS toggle button in the input control section has to be switched ‚on‘)
dogrin17
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 3
Enregistré le : 11 août 2020 01:22

Re: SHARP:USB-cable HW-handshake

Message par dogrin17 »

spellbound a écrit : 14 août 2020 23:55 That means the G850VS is blocked by the RTS-signal from your computer. The most likely reason for that is that you forgot to activate the signal from within your termninal software (see screenshot of hterm above - the RTS toggle button in the input control section has to be switched ‚on‘)
Thank you, it's working now. I really appreciate the detailed guide.
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: SHARP:USB-cable HW-handshake

Message par engelen »

After constructing an FTDI adapter for a PC-G850VS, I found that the FTDI driver 1.5.0 for Mac M1 machines fails to respect the FTDI CTS input. Without respecting the handshake, the PC keeps sending to the PC-G850VS and data will get lost. The FTDI drivers for Windows and Mac Intel machines work fine, but the driver for Mac M1 fails. Perhaps a bug.

Also, what is your recommendation with respect to 3.3V versus 5V FTDI adapters? I used a FTDI 5V adapter (Adafruit FTDI Friend) but it didn't work to send from the PC-G850VS to the PC or Mac (with inverted TXD, RXD, CTS, RTS and with CTS/RTS handshake.) Strangely, when I manually disable DTR then it works, which should have nothing to do with CTS/RTS handshake. On the other hand, there is no problem at all with the FTDI 3.3V adapter, but the 5V gives this strange behavior to block sends from the PC-G850 unless DTR is cleared manually.

Here is a longer post on the HP forum: https://www.hpmuseum.org/forum/thread-1 ... #pid169250

- Robert
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

For the G850V/S the RTS-pulldown resistor mentioned above is essential (10-100kOhm). Without it the G850 can‘t reliably pause transmissions from the host, just as you experienced.
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: SHARP:USB-cable HW-handshake

Message par engelen »

For the G850V/S the RTS-pulldown resistor mentioned above is essential (10-100kOhm). Without it the G850 can‘t reliably pause transmissions from the host, just as you experienced.
Yes, I already did that and have the resistor as shown in the pictures in the HP Forum thread. But after several hours tinkering I found that the FTDI driver for MacOS M1 machines has a bug. There is no other explanation. MacOS Intel works fine. Windows machines too. I also tried 3.3V and 5V FTDI cables and different FTDI feathers, but makes no difference (although 3.3V works best, since 5V may have an issue as described earlier). It's the damn driver. The latest FTDI driver for MacOS M1 machines fails. It doesn't respect RTS. Others may not have had this issue if they are using an older FTDI driver or a non-Mac M1.

- Robert
spellbound
Fonctionne à 300 bauds
Fonctionne à 300 bauds
Messages : 100
Enregistré le : 06 mai 2015 12:06

Re: SHARP:USB-cable HW-handshake

Message par spellbound »

engelen a écrit : 03 mars 2023 21:32 I found that the FTDI driver for MacOS M1 machines has a bug. There is no other explanation.
- Robert
ok, I see
Répondre

Retourner vers « Silicium in English »