News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Universal Serial Interface for Amstrad CPC (a.k.a USIfAC)

Started by ikonsgr, 19:20, 05 January 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ikonsgr

Check the evolution of this board here

Hello everyone,

What i'm going to present you here,is a "Universal" serial interface for Amstrad CPC (or USIfAC (Universal Serial Interface for Amstrad CPC)  naming courtesy of Gunhed  :) )
Although i know that other serial interfaces for amstrad cpc already exist, this one offer many innovations that makes it a rather modern, cheap and useful solution:

[attach=4,msg169084]

- Completely "from the scratch" project,based on a modern 8bit PIC 16F1579@32Mhz MicroController!
(all other serial interface projects, use the rather old, expensive and bulky 40pin 16C550 UART chip)

- Very easy to use by only two BASIC commands, INP() and OUT!

- Completely free DIY project, rather easy and cheap to make (total cost for the DIY kit +all extra parts, would be less than 6euros!).

- SUPER FAST loading of many games/programs, DIRECTLY from the PC!(see "Direct Load" function in User's Guide, and here is a list of games already tested and working)

- Easy and fast transfer of dsk images directly to Amstrad CPC disks!

- Easy and fast individual file transfer (check link for 1000's of games extracted from dsk images)directly from/to Amstrad's Disks!

- Equipped with a reset button and a pause switch for Amstrad CPC!


And here is a small demonstration: Playing PONG in network with a Commodore 64!   :D

You can find everything you will need here, it contains:

-The circuit diagram,
-The gerber files for the pcb,
-The bill of materials,
-The Pic 16F1579 microcontroller Hex file (you will need a pickit2/3 in order to flash it into PIC 16F1579),
-Amstrad's utility dsk image disk (you can transfer it to a real disk with CPCDISKXP using an ide or a usb 3.5" floppy Drive),
-The PC utility program,along with CPCLOADER (for easy extracting dsk images) and a folder including the utility disk files,for direct loading from PC using "Direct Load" function,
-The User's Guide.

I have also developed a windowsprogram which you can use it to comunicate with Amstrad:

[attach=5,msg169084]

It can be used for terminal file transfer, dsk image transfer, and RUN many games/programs directly from PC!


Serial  Interface is equipped with a big receive buffer of 920 bytes (more than 3.5X the buffer of the classic 16C550 UART chip, or booster/booster+ adapters), and can achieve speeds up to 576000bps, using a direct usb2serial cable adapter, or 460800bps using a Bluetooth or Wifi Module.
Serial interface can be used with a  USB2serial cable adapter
(PL2303HX), an HC-05 Bluetooth module, a WiFi module (an ESP-07 or an ESP-01 along with a 5V adapter) or even
this Usb host board which, depending on loaded software, can host many different USB devices, like USB modems, flash drives, keyboard,mouses, joysticks, Midi interfaces etc. So, if you connect this usb host module to the serial inerface ,ALL of these devices can potentially communicate with amstrad cpc!
In practice, any device with a UART interface can be connected!


So, first let's take a look at the circuit. And this is the pcb board.

You can connect it to an external port raiser adapter like MX4 board, or directly to Amstrad's Expansion port using this adapter.
Interface usage, is pretty simple and straight forward. Communication with the device is accomplished using only two ports:
&FBD1: The control port
&FBD0: the data port

And the two BASIC commands INP() for receive and OUT for send.
To send a byte, just give the BASIC command:
OUT &FBD0,x (x:0-255)
Or on assembler, the instructions:
LD A,x (x:0-255)
LD BC,&FBD0
OUT (C),A

To receive a byte, you must first check if there is any byte available at the buffer, by reading the control port.
Use the BASIC command: INP(&FBD1). If it returns '255', there is a byte available, if not, it returns '1'.
So, in order to receive a byte from serial port, you just give the BASIC command:

IF INP(&FBD1)=255 THEN A=INP(&FBD0) (variable A contains the received byte)

And if you want to wait until a byte is available, you can use a small loop like:

WHILE INP(&FBD1)=1:WEND:A=INP(&FBD0)
And here is the assembly code for doing the same thing:

check_BYTE:   
        LD A,&FB
        iN A,(&D1) 
        DEC A
        JR Z,check_BYTE
ld   a ,&FB
in   a,(&D0)

Accumulator A now has the  received byte.

You can also give various commands to the interface (OUT &FBD1,x), using the control port, like reset interface, change serial port speed, clear receive buffer and some other.


And If anyone wants a ready made Serial interface, i can offer:

- A ready made board for 8euros+shipping (2.5euros for standard, 5euros registered/tracked).

- A Basic DIY kit for 4euros,including postage. You will get the PCB board and PIC 16F1579 (flashed with the program).All other parts can be easily found in any electronic parts shop,check Bill of Materials here)

- A Complete DIY kit for 6euros,including postage. This DIY kit will have everything:PCB board+PIC 16F1579 (flashed with the program)+4002Logic Chip+DIP sockets+Pause switch+reset button+resistors+caps+bjt+diode

- Extra Edge connector adapter costs +2euros.

- Extra Centronics connector adapter costs +5euros.



Having a cheap, easy to make and easy to use Serial port, and considering the strong and vivid program community for Amstrad CPC, it could open many prospects for future developments, like LAN or WAN games, Apps for communicating with smart phones and tablets, even a basic Web client...  ;)


GUNHED

Very nice project indeed. However that's the same we already have with MiniBooster and CPC-Booster+. But cheaper and probably more easy though.  :)

What I would love to see are:
- A way bigger buffer, because with that high transfer rates 1 KB buffer is filled up literally in no time. So a buffer of at least 16 KB would be helpful.
- Either a 2nd port or a RS4xx, to enable a network of a ring of CPC computers. Great fun on meetings.

That's just my 3 Pfennige, since I'm more a software person I don't know if this is doable.  :)

Good luck with it anyway, look great!  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

#2
Well, i don't think that  MiniBooster and CPC-Booster+ are "competitive" to this project. For one thing, they offer much more than a serial port (A/D converters, PWM channels etc pretty much like MULTI purpose I/O device), and for that, are surely much more complicated and expensive to make. Moreover,they are pretty old projects, so i really don't know if they are available any more...  ::)
My intention was to design a small, cheap and easy to make (and use) serial port, that everyone with a soldering iron and a few euros, could make it by himself!  ;)


As for your requests,at one thing, it's difficult to find 8bit Microcontroller with 16+KB of ram, and they would be rather expensive too.But i think that a nearly 1Kb receive buffer, is already pretty much (16C550 UART and booster boards have much smaller buffers of ~250bytes), and believe me, if you use assembly code, it's easy to empty the buffer really fast too! :-) In anycase, you will always need to have some transfer control for fast speeds ,regardless of the buffer size you have. One good solution for example,is, for the sender to transmit a packet of bytes at the size of buffer at once, and then wait for acknowledge, to send the next. As for the networks, it's easy to make one ,using the WiFi modules! These WiFi ESP8266 modules can either connect or create TCP servers! So, you can have one Amstrad with a serial interface and a WiFi module running a TCP server, all other amstrads can connect to this server as TCP clients,and here is your Amstrad CPC network! ;-)

ComSoft6128

Individual/batch file transfer from/to the 3" drive interests me, transfer from the 3.5" B drive is what I'm really looking for but that might came at a later date.
I'd like to buy one for a 6128 Plus.

Cheers,

Peter

ikonsgr

#4

Ok, peter, send me your address with a pm or to my email ikonsgr745@hotmail.com to arrange it then.
Now,i think you're gonna love this, INDIVIDUAL file transfers from/to 3" disks was the reason i design this interface at the first place!  :)
I have dozens of 3" disks ,from the good old era, with many programs and listings me and friends had made, but the procedure to transfer them to a pc for safe keeping was somewhat combersome and timeconsuming, as all existed transfer methods are for copying hole disks or dsk images at once! So, i had to copy 3"disks to 3.5" disks using discology, and then (using an old pc that has an ide floppy drive), transfer the 3.5" disk to a dsk image using cpcdiskxp...
Now,i can just select individual files from a 3" disk and with a press of a button, transfer them directly to my pc! And, after a lot of study and work,i've managed to do it rather fast too, it takes less than 15seconds to transfer a hole 42kb game from 3"disk to pc, and about 20seconds for writing it back to a disk from pc!
In 2 words, having this interface, allows you to use your amstrad without needing ANYTHING extra, either a 3.5" drive, or a gotek emulator drive, just a good old 6128 with a bunch of 3" disks ;)

ComSoft6128

This sounds ideal ;D
Will PM to organise.

Thanks,

Peter

GUNHED

Ah, so if I do understand that right, we can have a few CPCs with your card and the WiFi-modules and they all can talk to each other, right?

Since I'm not familiar with WiFi at all: Do we need a WiFi router unit for this, or do we just need some CPCs with your card + Wifi module?

Also: How would this look like from the software side?

This would be really a great thing, to have a network based on CPCs (without PCs).  :) :) :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

#7
Exactly! Esp8266 it's really a marvel-chip, apart from creating a tcp server or connecting to another, it can be also used as an access point!
So, if you have a bunch of amstrad cpc's with serial interfaces and wifi modules installed, you can set the tcp server and the access point at one of them, and then, all the others can  connect to this access point, get ip's, and then connect to the tcp server, and thus create an Amstrad CPC-only wireless LAN,without even needing a router!It might sound complicated, but it's really a matter of a few AT commands to do all this!
I already have a small section in my user guide, that has a small list of the most useful AT commands, although the complete AT user manual for the wifi module supports 100's of commands!

GUNHED

That really sounds awesome! Now we need somebody who can use AT commands and tell us how to make such a CPC LAN.  :) :) :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

Quote from: GUNHED on 18:13, 06 January 19
That really sounds awesome! Now we need somebody who can use AT commands and tell us how to make such a CPC LAN.  :) :) :)


Well,it's so easy to do it, that i'm pretty sure ,if you take a look at the user's guide and the BASIC terminal program, that "somebody" may well be... you!  ;)

ComSoft6128

And this is one D20 disk - have a look at the number of files for transfer :o

LambdaMikel

Quote from: ikonsgr on 17:22, 06 January 19
Exactly! Esp8266 it's really a marvel-chip, apart from creating a tcp server or connecting to another, it can be also used as an access point!
Isn't that chip also on the M4 board?
(well or related, it has the ESP12F)

ikonsgr

Quote from: LambdaMikel on 16:32, 07 January 19
Isn't that chip also on the M4 board?
(well or related, it has the ESP12F)
I suppose so, the chip is actually called ESP8266, and comes either as plain chip on a board or on board various pcbs for easier communication with existing hardware like ESP-01, ESP-07 which only need  Tx, Rx and power supply connections.

GUNHED

One more question: Is the port of this nice device compatible to the Mini-Booster Pins? Sorry, for that question.  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

#14
The serial port consists of only 4 pins, Tx, Rx, 5V and ground, so in practice any device with a UART interface can be connected!
Apart from the bluetooth and WiFi modules mentioned, there is also this Usb host board which can be connected directly to the serial interface,and depending on loaded software, can host many different USB devices, like USB modems, flash drives, keyboard,mouses, joysticks, Midi interfaces... 
So if you connect this usb host module to the serial inerface ALL of these devices can potentially communicate with amstrad cpc!
Hmmm, read/write files to usb flash drives? That sounds nice... 

or maybe, sending SMS messages with your CPC? That sounds fun too...
And what someone could possibly do with a Synthesizer connected to an Amstrad CPC through midi?....    Infinite prospectives! :D

It  would be only a matter of developing the software on amstrad cpc  to do this! And considering the simplicity and ease of use of the serial interface, it would be rather easy to develop such programs even using locomotive BASIC!    ;)



rpalmer

to connect any modern device such as USB the CPC would need a driver of significant code in order to get it to work at all.

rpalmer

LambdaMikel

I could certainly use an RS232... don't have one yet.

LambdaMikel

Quote from: rpalmer on 04:31, 09 January 19
to connect any modern device such as USB the CPC would need a driver of significant code in order to get it to work at all.

rpalmer
depends. there are certainly also rs232 / serial devices which have the controller and driver "on board" and don't need complicated drivers.

ikonsgr

#18
Quote from: rpalmer on 04:31, 09 January 19
to connect any modern device such as USB the CPC would need a driver of significant code in order to get it to work at all.
rpalmer

Fortunately for us, the "driver" needed for a usb device, is already implemented in the usb host module firmware mentioned! Take a look here and select "related products" tab.
All the "dirty" work needed for identify,nagotiate and establish connection with a usb device, is done from host module!
After that, you can perfectly communicate directly with the device through serial port simply by sending/receiving bytes/characters using simple inp() and out commands, even using BASIC! ;)



rpalmer

Quote from: ikonsgr on 09:54, 09 January 19

Fortunately for us, the "driver" needed for a usb device, is already implemented in the usb host module firmware mentioned! Take a look here and select "related products" tab.
All the "dirty" work needed for identify,nagotiate and establish connection with a usb device, is done from host module!
After that, you can perfectly communicate directly with the device through serial port simply by sending/receiving bytes/characters using simple inp() and out commands, even using BASIC! ;)
Well yes you are correct that this device appears to have done all of the work to convert the "serial" to "USB".

There is still the matter of a driver to handle such things as protocols like USB packets from Wifi, keyboard, mass media and so on. This i feel is where the majority of the work will be for a CPC to use such a device. Also dont forget a USB device is not one in which it provides an interrupt to the host meaning the CPC would constantly be polling it for status if done entirely in S/W and would need to handle what ever packet sizes the USB could issue (not impossible, but can be very difficult to handle and by all means give it a go).

I could easily imagine though a H/W device much along the line of a CPC I/O port to a simple PIC chip which then interacts with the above attached USB device. The pic chip would then interrupt the CPC following the Z80 protocols.
rpalmer

ikonsgr

#20
First update: "Cold Start" having ONLY an Amstrad CPC!  :)

Ok, you have the serial interface, but in order to use it, you need to have some utlitites on your amstrad.
Of course i give you a utility disk image, but the "problem" is that you need first to transfer it to a disk (or to a usb stick if you have a gotek/hxc drive), in order to use it...
How nice would it be, if you didn't need to do that, and be able to use the serial interface t
o transfer programs, games,utilities,DIRECTLY, having ONLY a  plain Amstrad CPC...

Well, now you can do that! ;)

The "trick" to accomplish this, is by using a small BASIC program loader, that initally copies the assembly routine for file transfers from PC to CPC, DIRECTLY to Amstrad's memory, and then it's executed, in order to transfer files to a floppy disk!
Procedure is very simple and fast:
First, type and save this small BASIC listing to your Amstrad CPC:

10 MODE 2:MEMORY &7FFF   
20 OUT &FBD1,0:OUT &FBD1,1   
30 FOR I=0 TO 127
40 WHILE INP(&FBD1)=1:WEND
50 POKE &8000+I,INP(&FBD0)     
60 NEXT I
70 OUT &FBD1,0:OUT &FBD1,1   
80 PRINT"waiting for file..."
90 WHILE INP(&FBD1)=1:WEND
100 OUT &FBD0,9:OUT &FBD1,2:CALL &8000       
120 PRINT"file copied":OUT &FBD1,3:GOTO 70


Run the program, and open the Communication Utility on your PC, press 'Connect button' to establish a serial connection,and then press "Cold Start" Button. (function selection must be set to 'Terminal' and serial Speed to '115200')
After a few seconds,you should get a "waiting for file..." message on your Amstrad screen. Now select "File copy to CPC" from Function selection list, press 'select files' button,and select the files "PC2CPC.BAS" and "PC2CPC.BIN" inside "Amstrad Utility disk files" subfolder in program's folder. After a few seconds the 2 files should be transferred to your 3" disk.
Now, you can reset your Amstrad and run the "PC2CPC" utility, in order to transfer any other program, utility or game you want from PC!

I have updated the PC utility program and add the procedure to the User's guide, along with some extra Wifi AT commands (useful for making a wireless "Amstrad cpc only" network!)

GUNHED

#21
Hi Ikonsgr,
Well, I would like to order 5 of these boards (or DIY kits). Please PM me the details. It's a great device for a great price and it has the potential to become a new network / communication standard.  :)
EDIT: MX4 version please.  ;) :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

asertus

Hi,


I am interested in 2 of them, with adapters.


THanks.

ikonsgr

Quote from: GUNHED on 15:44, 10 January 19
It's a great device for a great price and it has the potential to become a new network / communication standard.  :)


Well, that exactly was my intention! It surely has all the "requirements" for that: DIY,Cheap,easy to make and use.
If it get's enough acceptance from the community, it can surely become a standard. ;)





ikonsgr

NEW UPDATE!


I've uploaded a new utility disk image, i add a small FORMAT utility (i compiled this assembly code from CPCWIKI with maxam, hope there is no problem wtih that), and revised the User's Guide with some extra info.Also i upload a big collection of many games extracted from disk images ,(you can find them in the 1st post), in order to easy transfer them to disks using the PC to CPC function.

Powered by SMFPacks Menu Editor Mod