Enterprise Forever

:UK => Hardware => Interface => Topic started by: dangerman on 2018.December.06. 17:58:53

Title: USB to Enterprise serial
Post by: dangerman on 2018.December.06. 17:58:53
Hello. I'm thinking about connecting my Enterprise to a Linux PC to transfer files and other stuff across - only at 9600 baud!

But sadly modern PCs don't have the old serial ports any more - they just have USB. There are plenty of USB-serial adapters on the internet but most of them (certainly the cheap ones) seem to work with 5V logic (or even 3.3V). The Enterprise serial port is 12V of course... or -5V to +7V if you use the reference ground :|  

Has anyone successfully connected the Enterprise to a PC USB port?
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.06. 23:29:38
One friend of mine has such circuit. It needs some minor fixings on the 3,3v conversion, but he has little time now as he is teacher on the University.

On the tests we made it worked perfectly on input or output access on Basic programs, but not on half-duplex due to an error on Basic.

I can't say you a date of release, but probably before next Summer....
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.07. 00:19:54
Oh dear - so it needs a special circuit. It can't be done with a standard USB-to-serial adapter?? :(

It appears it was possible to connect an Enterprise to an old PC serial port with just a couple of resistors - Application Note 29 (http://enterprise.iko.hu/technical/Enterprise-AppNote-29.pdf) - but I presume this wouldn't work for a USB-serial adapter...
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.07. 11:13:31
This is the first prototype.

[attach=1]

[attach=2]

But it has a number of errors:

-The EDGE connector is mirrored. A cable was used instead.
-The footprint for the CH340G has to be narrower, it hardly coincides with the chip's legs.
-The CH340G should be feed with +3,3v and the levels of RX and CTS be with pull-up to +3,3v instead of +5v.

What the circuit does is to standardise the Enterprise serial signals to TTL compatible or to USB serial.

The CH340G (https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjUsoeUvI3fAhWLDMAKHR_PBwwQFjAAegQIChAC&url=https%3A%2F%2Fcdn.sparkfun.com%2Fdatasheets%2FDev%2FArduino%2FOther%2FCH340DS1.PDF&usg=AOvVaw3tSh23kX2SiulRzwSTpbJb) chip is used on some USB serial adapters, and fits the Enterprise because it manages the two data signals and also the two handshake signals.

The 74LS06 (https://unicornelectronics.com/ftp/Data%20Sheets/74ls06.pdf) and some diodes and resistors are used to invert and adapt the Enterprise levels.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.07. 11:37:04
Ah, now I remember, the circuit also allows the direct connexion of an ESP8266 ESP-12F, that also has a handshake serial mode.

(https://rlx.sk/10412-large_default/esp-12f-wifi-module-esp8266-er-ccw08266f.jpg)
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.09. 14:16:20
Good stuff. Wifi on the Enterprise? That would be cool!! I see that the 74LS06 is used inside the Enterprise to drive the serial line, so seems like a good choice.


I haven't yet done anything about investigating USB, but I have managed to hook up the Enterprise serial port to an Amiga, which has a good old RS232 port. Data transfer works but I can't seem to get handshaking working (maybe because I'm not using the offset ground?)

If I enable handshaking on the Amiga, then it doesn't send anything to the EP.
If I disable handshaking, I can send up to 24 bytes at a time to the EP but then have to wait (that's the limit of EP buffering).

Writing data from EP to Amiga seems to work though.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.09. 15:47:34
The handshaking doesn't work  properly on Basic, but it can work on machine code. Yes, we have used the 74LS06 due to being used inside the Enterprise.

The Wifi chip doesn't need handshaking, only when the user sends Enter the chip returns his text. The Enterprise buffer is  not big, but I don't remember only 24 bytes. To avoid the end of buffer better read immediately from the channel every incomming character.

We have opted to not use the offset, due to the isolation needed,. For a real Serial port you also don't need to use it, as the levels are 0 and +12v.
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.09. 21:25:05
When you say machine code - do you mean writing directly to the port 0B7h?

I'm using the standard EXOS SERIAL: device, which I think works the same whether used from BASIC or machine code.

As far as I can tell, the STATUS OUT line is +12v when the Enterprise is ready to read data, but for some reason nothing gets sent (or at least nothing gets received!). Sadly I can't really see what's going on because I only have a voltmeter, not an oscilloscope.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.09. 23:42:45
No, I mean using the serial device on machine code, avoiding Basic. I don't know why but think it interferes with the reading of the serial bits 4 and 5 on port B6.

In Basic, Zozo advised me to use READ £X + an error handler, instead of GET £X, but I haven't been able to make it work.

Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.10. 18:03:44
I was using this...
Code: [Select]
OPEN £1:"SERIAL:"
COPY FROM £1 TO £0

That seemed to work ok, but because there was no handshaking I could only transfer 24 bytes at a time.

Maybe I'll give it a go from machine code.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.10. 18:30:50
Actually you copy the data to the Editor: channel directly. Better use an intermediate variable in a loop, for example:

GET £1:a$

This will take only a character every time. Then you can add the character in a$ to other variable, for example b$, and print the sentence to the default channel £0 if you find a ^M, Enter, chr$(13) or other convenient character.

You can also use READ instead of GET, but you will need an error handler routine. You can read examples on the Basic manual.

To add variable strings you must use b$=b$&a$, & instead of +,  used to add numbers.
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.10. 23:21:48
Unfortunately my problem is not the Enterprise reading, but it's the other computer sending.

Without handshaking, the other computer can only send 24 bytes at a time - otherwise the Enterprise's buffer will become full and bytes will be lost - whether I'm using BASIC or machine code.

So I either insert a delay after sending every few bytes (at the Amiga/PC end) to give the EP enough time to process it's buffer; or else I really need to find out how to get handshaking working.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.11. 09:06:33
Can you put here an example of the routine?
Title: Re: USB to Enterprise serial
Post by: tofro on 2018.December.11. 12:08:00
Some USB/Serial dongles don't support hardware handshake lines at all, some do RTS/CTS, some very sophisticated ones even support DSR/DTR. For those that support the hardware lines, you need to have a proper driver that supports hardware handshake as well (The USB stick needs to convert the pin change to a USB handshake packet and send that to the host and vice versa)

So, the first questions is: Does the chipset on the dongle support hardware handshake? The most common chips known to do that are FTDI USB/Serial chips. In case your dongle has one (and not a cheap Chinese rip-off), chances are high it works.

Another common chip range is the Prolific 2303 - Of these, only the SA, HXD and RA variant seems to support hardware handshake. The others don't (Those are mostly intended for printer interfaces only).

That is the first step to success - The next one is if the Dongle maker managed to expose the hardware handshake lines from the chip - Some do, some don't.

And the next step is whether you got a proper USB driver on the host computer that supports Hardware Handshake. Again, some do, some don't.

Best check very carefully the above points in the product description before you buy such a dongle to get HWHS to work

Tobias
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.11. 19:12:49
@Tobias - Thanks for the tips. I already have an FTDI based interface on order so we'll see if that works.

And thanks for the tips about the driver - I wonder if my Amiga serial port needs DSR/DTR instead of (or as well as) RTS/CTS handshaking. I'll look into that.
Title: Re: USB to Enterprise serial
Post by: dangerman on 2018.December.23. 12:18:17
SUCCESS!

So I haven't looked any more into getting my Amiga handshaking with the Enterprise's serial port, but... I did manage to get the Enterprise talking with a Linux PC using this adapter (https://uk.farnell.com/ftdi/chipi-x10/cable-usb-db9-male-rs232-10cm/dp/2352019). After I worked out how to enable handshaking on Linux, it's working flawlessly.

I can send messages back and forth easily.  I've even managed to send and receive whole text files - although for now I have to deal with the end of file manually, because there's no notion of files on a serial stream.
Title: Re: USB to Enterprise serial
Post by: Zozosoft on 2018.December.23. 14:00:03
Wow! Well done!
Title: Re: USB to Enterprise serial
Post by: IstvanV on 2018.December.23. 19:58:12
Could this hardware be combined with the MIDI port, assuming that gets built? With hardware serial/parallel conversion, it would probably have some advantages compared to the built-in serial port on B7h, such as higher baud rate.
Title: Re: USB to Enterprise serial
Post by: gflorez on 2018.December.23. 20:41:18
Yes, some advantages, astounding transfer speed, independence from the processor frequency, memory emulation?, PC as a HD?, MIDI Host?, even Internet access with all their added benefits...?

And surely many more...

Ah, and B7h left definitively only for the Boxsoft-EnterMice interface.
Title: Re: USB to Enterprise serial
Post by: IstvanV on 2018.December.25. 13:48:38
I can send messages back and forth easily.  I've even managed to send and receive whole text files - although for now I have to deal with the end of file manually, because there's no notion of files on a serial stream.

It may be possible to modify the tapeserver (https://enterpriseforever.com/egyeb-temak/tapeserver/msg32470/#msg32470) program I wrote some time ago to use serial I/O. It allows for accessing a directory of PC files via an EXOS device, similarly to FILE: on ep128emu. Although the baud rate of the EP serial port (9600 maximum?) is not actually better than that of tapeserver, it could still be more convenient to use than audio based communication.
Title: Re: USB to Enterprise serial
Post by: ron on 2019.July.01. 20:30:21
I do not know if it is the right place to continue talking about the USB to serial adapter for enterprise. Any way I would like to compile more information  and if it is possible to do something, it is very much appreciated.

[attachimg=1]


Glorez brought this serial port to USB interface.
Last Friday and Sunday, we were in my workshop doing communications tests, with discrete results.

So we have not been able to find any communications program for Enteprise, except what has been done by the Danes. We have done tests from Basic, with results that we believe that with some adjustments we could do something.

Something like:

Code: [Select]
  100 PROGRAM "term.BAS"
  110 SET 191,4
  120 LET A$="":LET LOCAL=-1
  130 TEXT 80
  140 OPEN #1:"SERIAL:"
  150 IF LOCAL=-1 THEN PRINT #102:CHR$(27);"O";
  160 IF LOCAL=0 THEN
  170   GET #1:A$
  180 ELSE
  190   LET A$=INKEY$
  200 END IF
  210 IF A$<>"" THEN
  220   LET A=ORD(A$)
  230   IF A<>13 THEN
  240     PRINT CHR$(A);:PRINT #1:CHR$(A);
  250   ELSE
  260     LET LOCAL=NOT(LOCAL)
  270     IF LOCAL=0 THEN PRINT #102:CHR$(27);CHR$(111+(LOCAL*32));
  280     PRINT #1:CHR$(13);CHR$(10);:PRINT :LET A$=""
  290     IF LOCAL=-1 THEN PRINT #102:CHR$(27);CHR$(111+(LOCAL*32));
  300   END IF
  310 END IF
  320 GOTO 160


We have also been doing tests under IS-DOS and with the most common communications software for CP / M, but we are in the same point. It does not work.

Then, with IS-DOS there's the command MODE
MODE {[80] | [40]} | [Logical-device:=EXDOS-device]

Devices: [LST: , AUX:, RDR:, PUN:, NULL]

Well, all help and advice are welcome, the interface is working and with tcpser and minicom from Linux we can exchange characters between the PC and the Enterprise, there's a lot of test to do.

Regards


Title: Re: USB to Enterprise serial
Post by: dangerman on 2019.July.02. 21:40:42
I was considering writing a simple zmodem client for the Enterprise. But then my EP stopped working and so I'll have to fix that first unfortunately :(

Also, since I had to open it up to try and fix it, I had the bright idea to "upgrade" it to 6MHz. But of course this will destroy all the timings for the serial driver. Seemed like a good idea at the time, though.

As an alternative, is there any serial support in ep128emu?

Title: Re: USB to Enterprise serial
Post by: gflorez on 2019.July.02. 22:09:06
There is a serial card, the schematics is here (http://www.ep128.hu/Ep_Hardware/Ep_Sorosk.htm). It was a Hungarian "classic-time" project intended for use with serial mice(or serial external keyboard), but has been superseded by the EnterMice.

The Mouse driver (https://enterpriseforever.com/programming/universal-mouse-driver/msg75937/#msg75937) deals(more or less) with that card. You can peek on the code if you want to know how it can be accessed. It is based on a PC UART, so it can be used for other tasks.

Also on classic times, a Danish firm developed an external serial card, even they run for a time an Enterprise oriented BBS. The software has been preserved, but not the hardware.
Title: Re: USB to Enterprise serial
Post by: Zozosoft on 2019.July.02. 22:12:52
Something like:
I don't see in the program setting of serial parameters (baud, parity, stop bits). It is not needed for that device?
Title: Re: USB to Enterprise serial
Post by: gflorez on 2019.July.02. 22:15:53
It uses the default... 9600 8, 2, 0, Handsake. The chip CH340G (https://www.mpja.com/download/35227cpdata.pdf) adapts itself and converts to a virtual serial port on the USB at the PC.

The program has been written by me, but it has some faults.

Zozo, you described a way to use READ instead of GET, but I have not been able to find the way. Can you explain it?
Title: Re: USB to Enterprise serial
Post by: gflorez on 2019.July.02. 23:41:56
The problem with GET is that it is trapped by the PC RTS/CTS protocol, STATUS_IN is set(negative on the signal) even if there is nothing to receive from the PC, so the Enterprise waits forever. Is for that I have used a "conversation" scheme instead of the Half duplex one. The control is alternated between the PC and the Enterprise when an Enter is received(13, Ctrl+M).