ORIC SDCARD

This is the right place to discuss on how to implement hardware vsync, adding a VIA or AY chipset, puting multiple roms, or how to design a new flash expansion card.
Post Reply
User avatar
EdL42
Private
Posts: 5
Joined: Mon Jul 30, 2018 2:51 pm

ORIC SDCARD

Post by EdL42 » Wed Aug 01, 2018 11:07 am

Hello everyone :)

I'm a french guy living in France and I would like to share with you a little device I've done after browsing many very interesting Oric forums topics.

=> NB: a french translation of this text is included in the zip file below.

First, I would like to thank, for their inspiration and code examples:
- Daniel Coulom and his SDLEP READER (http://dcmoto.free.fr/bricolage/index.html)
- Lutz Lisseck and his SimpleSDAudio library (https://www.hackerspace-ffm.de/wiki/ind ... pleSDAudio)
- Fabrice Broche for his excellent book "L'Oric à nu" (I still have mine :) !)

Oric-1 was my second computer when I was a teenager (the first one was a ZX-81 !) :) Being a electronic engineer, I always had the idea to replace the audio cassette with a faster and more reliable support, like a cartridge.
But now, after many technological improvements, it's possible to quite easily read a SD card using a simple Arduino board for a cost of only a few euros !

So I've done this device which links a micro SD card, an Arduino Nano board and the Oric via the printer port (using the expansion port would require more logic circuits for decoding) and load quickly and easily classic ".TAP" files for Oric.


=> REQUIREMENTS:
================
- An Arduino Nano (or equivalent) based on an Atmel 328 (to have enough input/output ports) with its USB cable in order to connect it to a computer and program it.
- A micro SD card board INCLUDING a voltage regulator (to convert 5V into 3.3V).
- A micro SD card (the smallest possible as an Oric file is just a few Ko's !).
- A LCD display 2 lines of 16 characters (to display file names and messages).
- A classic TTL 74LS244 buffer. It should also work with a more recent 74HC244.
- Four push buttons (I used a micro joystick I had since many years which was waiting to be useful one day. Your time has come little joystick ! :)
- Four 4.7 Kohms resistors and one 1 Kohms (for the buttons).
- One 220 ohms resistor for the LCD backlight and one 1.5 Kohms for the contrast.
- A 2x10 pins connector for the Oric printer port.
- A short 20 conductors cable.
- A 11 single row male strip. You can use a larger one and cut it to 11 pins.
- A 830 (min) points breadbord with its cables.

Here are some examples references:
https://www.ebay.fr/itm/1276-ATmega328P ... 1012223048
https://www.ebay.fr/itm/1007-Micro-SD-C ... 0966700407
https://www.ebay.fr/itm/1182-1602-16x2- ... 0983523750
https://www.ebay.fr/itm/1038-40-Pin-2-5 ... 1022505442
https://www.ebay.fr/itm/1324-MB102-Brea ... SwfCZZ2QPX

And other components can be buyed on online or physical electronic components stores.

You will need also:
- The Arduino code below to manage the SD card file list and send the selected file to the Oric.

- The Oric-1 patched ROM below. NB: For the moment only Oric-1 version (as it is the most compatible with games).
So you will need a 16Ko 27128 eprom component too and a way to program it.

Another option is to enter into the Oric the loader code below but it's quite tedious to do...
=> But maybe someone will be able to reduce its size ?

Regarding this point, as I have an eprom programmer (this model is working very well: [url]https://www.ebay.fr/itm/SPECIAL-OFFER-T ... pXV~PB[url]), I don't have yet decided in which way the loader code could be stored without patching the ROM.
=> Don't hesitate if you have some interesting suggestions !

And that's it !

I have assembled all the modules together on a breadboard. Ideally the next step would be to solder them together on top of each other in order to have a compact module that can be clipped at the back of the Oric with the LCD display on top. Or else to make a small printed circuit board if someone is used to do this.

Find the schematic below (thanks to Fitzing).


=> SOME COMMENTS (please read carefully):
=========================================

The Arduino Nano 328 board:
---------------------------

-> 30 Ko of FLASH for programs. Only a third is used currently, so plenty of room for improvements.

-> 2Ko (only!) of RAM, so 50 files could be loaded in the list max for the moment, as there are only 1 Ko remaining for the directory table.
=> Maybe someone has an idea on how to manage more files ? manage file blocs ??

-> 14 digital IO (D0..D13):
- TX(D)1 and RX(D)0 are already used by the board for USB communication. Fortunately they have a 1 Ko resistor pullup. So I reused them for Strobe and Ack signal with the Oric. BUT YOU HAVE TO DISCONNECT TEMPORARELY RX0 FROM THE STROBE PIN TO PROGRAM THE ARDUINO otherwise it fails ! A switch can be added on this pin.
- D2 to D7 are used for the LCD display.
#define pinLCD_E 2 // Enable
#define pinLCD_RS 3 // Register Select
#define pinLCD_D4 4 // Data 4 (4 bits configuration)
#define pinLCD_D5 5 // Data 5 (4 bits configuration)
#define pinLCD_D6 6 // Data 6 (4 bits configuration)
#define pinLCD_D7 7 // Data 7 (4 bits configuration)
- D8 and D9 are used for the printer data (see below why).
- D10 to D13 are used for the SD card communication.
#define pinCS 10 // pin CS (SS) SD card (SPI)
// Pin 11 pin MOSI pour SD card (SPI) by default
// Pin 12 pin MISO pour SD card (SPI) by default
// Pin 13 pin SCK pour SD card (SPI) by default

-> 8 analog IO (A0..A7):
- Fortunately these can be configured as digital IO, BUT NOT FOR A6 and A7 :( So A0 to A5 are used for the printer data d0 to d5 and D8 and D9 are used for printer data d6 and d7.
- A6 and A7 are the only remaining pins for the buttons but they are analog. So there are connected on a 5V voltage divider. 2 resistors splits the voltage. The buttons are grouped by 2. When no button are pressed A6 and A7 read approximatively 1.9V. If "UP" is pressed for example, then one resistor is shorted and the voltage increases to 3.4V (not 5V as there is also a protection resistor). If "DOWN" is pressed then the other resistor is shorted and the voltage decreased to 0V.
#define pinOUT0 A0 // Data 0 (output)
#define pinOUT1 A1 // Data 1 (output)
#define pinOUT2 A2 // Data 2 (output)
#define pinOUT3 A3 // Data 3 (output)
#define pinOUT4 A4 // Data 4 (output)
#define pinOUT5 A5 // Data 5 (output)
#define pinOUT6 8 // Data 6 (output. Using D8 as A6 an analog input only)
#define pinOUT7 9 // Data 7 (output. Using D9 as A7 an analog input only)
#define pinACK 1 // "Ack" Oric = CA1. TX1 (OUT). If = 0 then data ready to be read by Oric
#define pinSTROBE 0 // "Strobe" Oric = PB4. RX0 (IN). Used as a more simple "Busy" signal actually. If = 0 then Oric is ready to receive data

- The Oric SD card board is currently powered by the USB cable. An additional wire should be added to get the +5V from the Oric expansion port.


The Oric printer port:
----------------------

- The printer port (actually the VIA 6522 chip) is setup as an input port (and not an output port).
- The Strobe pin is set by the Oric and used as a Busy signal which is simpler to manage than a Strobe signal. The Strobe pin is actually connected to the PB4 (B port) of the 6522.
- The Ack signal is set by the Arduino board when data are available in the buffer.
- Strobe = 1 => Oric is not ready.
- Strobe = 0 => Oric is ready to receive data.
- Ack = 1 => Not data available in the buffer.
- Ack = 0 => Data (one byte) are available in the buffer. Ack is set to 0 for a short period (100 micro secondes). Be careful it cannot be reduced too much or the Oric will not have enough time to read the data.


- The loader:
----------------

I first wrote the little assembler loader program on the Oric in order to be able to receive data. Then I decided to patch the Oric ROM so the CLOAD function can be used as usual except it will read data on the printer port.
What the loader is doing:
- Disable interrupts.
- Configure the Ack pin (actually the 6522 CA1 pin) to detect a "falling" edge (1 to 0 transition).
- Configure the printer port (actually the 6522 A port) as an input port.
- Display "Searching..."
- Receive the start of the file (0x16, 0x16, 0x16).
- Receive the synchronisation byte (0x24).
- Receive the file header (file name, start address, end address, file type: Basic or ML, auto or not).
- Display "Loading..." + file name.
- Receive the content of the file until the end address is reached.
- Reenable interrupts.
- Launch the loaded program (if auto) or return to Basic prompt.


=> AND NOW HOW TO USE IT :) ?
==============================
Buttons:
UP => previous file in the list
DOWN => next file in the list.
RIGHT => send the selected file !
LEFT => shut down the SD card properly.

- Connect the device to your Oric printer port.
- Format the micro SD card in FAT32 (FAT16 should work too). File fragmentation is not supported. Avoid delete and add files. Reformat the SD card instead (very quick) and copy your files onto it.
- Copy a max of 50 (see above why) Oric "XXXXXXXX.TAP" files on it. Only short names (8 + 3) are supported so rename them if needed (before doing the copy).
- Remove the SD card and insert it into the SD card board.
- Connect the Arduino board to a computer via USB, open the Arduino program into the Arduino IDE and compile it as a check. With the current version of the IDE 1.8.5, it should compile without any issue as all the code is within one file.
- Disconnect RX0 from Strobe (see above why).
- Program the Arduino. It should reboot and the LCD should display "Loading dir...", then the first 2 files found. NB: All this process has to be done only the first time of course.
- Reconnect RX0 to Strobe (see above why).
- Browse the list with the "UP" and "DOWN" buttons.
- Turn your Oric on. Enter CLOAD"" and hit RETURN. You must have the patched ROM so the Oric will read data on the printer port instead of the cassette port.
- Oric should display "Searching...".
- Send the selected file with the "RIGHT" button.
- The message "Sending..." + size of the file should be displayed on the LCD. There is a timeout (2 min.) if the Oric is not responding.
- Oric should display "Loading..." + file name.
- Usually it takes less than 5 (!) secondes to load a file. As a bonus it works also with multi part files as long as they are calling the CLOAD function in the ROM and the timeout is not reached.
- The message "File sent !" should be displayed on the LCD.
- The program should start automatically on the Oric (if it's an AUTO file, for example a game).
- When you have finished or if you want to change the SD card content, don't forget to shut down properly the SD card with the "LEFT" button to avoid data corruption !

Here is a demo:

Now you can play again to l'Aigle d'or and many other hits !

Enjoy ! :)

EdL
Attachments
1_ORIC_SDCARD_V2_Files.zip
(871.42 KiB) Downloaded 45 times
3_ORIC_SDCARD_schematic_V2_small.jpg
6_OricSDcardDemo3_small.jpg

User avatar
Dbug
Site Admin
Posts: 2738
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: ORIC SDCARD

Post by Dbug » Wed Aug 01, 2018 5:42 pm

Interesting project :)

Two questions:
- Would it be possible to use the relay pins of the TAPE port to automatically start the loading, instead of having to press a button?
- Is it possible to also save to the SDCard?

User avatar
EdL42
Private
Posts: 5
Joined: Mon Jul 30, 2018 2:51 pm

Re: ORIC SDCARD

Post by EdL42 » Wed Aug 01, 2018 9:54 pm

Thanks ! Interesting remarks too :)

- Why not. It would require to add 2 more wires from the tape socket and connect them to the "right" button. In fact it should work straight as the rom CLOAD function already activates the remote relay. Good idea :wink:
Edit1: I try it and it works very well :) But there is a drawback :( When you reset the Oric (yes I've added a reset button to avoid switching off and on the Oric for each game), the relay is closed during the first 3 sec. triggering the sending of the selected file. And also the keyboard is stuck.
Edit2: Finally solved by changing 1 ligne in the Arduino code. When the RIGHT button is tested also test if Strobe = 0 :)

- Not for the moment, but yes the Arduino program can be extended to have a save function to the SDcard. There is still plenty of room available. It could be used to save states, for example inside an adventure game. But the buffer circuit would have to be changed for an bidirectional one and the rom patched to trigger the save or maybe an additional button ?
Last edited by EdL42 on Sat Aug 04, 2018 10:18 am, edited 5 times in total.

User avatar
Dbug
Site Admin
Posts: 2738
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: ORIC SDCARD

Post by Dbug » Thu Aug 02, 2018 7:02 am

It's mostly a question I ask because changing the ROM is not trivial, it means your device is not just "plug it when you need it: If a rom patch is required, it means your Oric is now not usable anymore to load and save from normal tapes without your device connected.

Just thinking practical :)

In theory, if you extended your system to also have a connector that plugs on the expansion bus, then you could enable the overlay to make a copy of the rom and patch it in ram.

User avatar
Symoon
Archivist
Posts: 1394
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Re: ORIC SDCARD

Post by Symoon » Thu Aug 02, 2018 11:05 pm

Very nice, well done!
Dbug wrote:
Thu Aug 02, 2018 7:02 am
In theory, if you extended your system to also have a connector that plugs on the expansion bus, then you could enable the overlay to make a copy of the rom and patch it in ram.
That certainly would be the perfection.
Specific ROM is always a problem IMHO: casual users that just want to play again their old games on the original computer might not be able to burn a ROM; while some (many?) of the "Wizard users" (call them the way you'd like) might not change a ROM to play games.

Another option could be to store the loader on the SD card as a WAV file, and load it on the tape port 1st (so requiring an sound output in your design to connect to the tape port).
If this loader is small enough to fit in page 1 (less than 220 bytes?), it would work with 95% of the programs and avoid any ROM patch.
EDIT: ah, bad idea. That wouldn't work with multipart programs that use CLOAD command.

User avatar
EdL42
Private
Posts: 5
Joined: Mon Jul 30, 2018 2:51 pm

Re: ORIC SDCARD

Post by EdL42 » Fri Aug 10, 2018 9:26 pm

Hi all,
Some picture of the Oric SDcard assembled and soldered.
Attachments
IMG_0845.JPG
IMG_0849.JPG

User avatar
Dbug
Site Admin
Posts: 2738
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: ORIC SDCARD

Post by Dbug » Sat Aug 11, 2018 7:57 am

The two small pins... are they the connection on the tape connector?

User avatar
EdL42
Private
Posts: 5
Joined: Mon Jul 30, 2018 2:51 pm

Re: ORIC SDCARD

Post by EdL42 » Sat Aug 11, 2018 9:44 am

Yes, correct :) To the cassette remote relay.
The red wire is also to get the +5V from the expansion port. A bit hazardeous but it's quite simple and it works. A full expansion connector would be too big I think.
It was quite a mess to solder all those wires. Obviously a printer circuit would be better :)
Attachments
IMG_0851.JPG
IMG_0852.JPG

User avatar
EdL42
Private
Posts: 5
Joined: Mon Jul 30, 2018 2:51 pm

Re: ORIC SDCARD

Post by EdL42 » Sat Aug 11, 2018 5:48 pm

In attachement is the Fritzing file with the rough schematic and printed circuit.
Attachments
Oric-SDcard - Fritzing file.zip
(26.49 KiB) Downloaded 39 times

User avatar
kenneth
Flying Officer
Posts: 185
Joined: Fri Nov 26, 2010 9:11 pm
Location: France PdD
Contact:

Re: ORIC SDCARD

Post by kenneth » Sun Sep 02, 2018 1:21 pm

nice project :D
The +5v is also available on the main power socket of the Oric computer.
The relative voltage from the Oric ground is -4v and +5v (negative regulator).

User avatar
tingo
Officer Cadet
Posts: 49
Joined: Sat Jul 11, 2009 11:30 am
Location: Oslo, Norway

Re: ORIC SDCARD

Post by tingo » Sat Oct 27, 2018 2:54 pm

I agree - nice project - well done!
Maybe I should unpack my Oric-1 and see if it still works.
Torfinn

User avatar
ibisum
Wing Commander
Posts: 1029
Joined: Fri Apr 03, 2009 8:56 am

Re: ORIC SDCARD

Post by ibisum » Sun Oct 28, 2018 6:18 pm

I don't know much about Fritzing but I opened this up to have a look - do I have to Autoroute the PCB first, to get something I could send off to be made? Because when I do that it seems to make a PCB with a lot of empty space ..

The other thing is, should we maybe coordinate a group buy of PCB's once we get this worked out? Wouldn't mind giving this a try..

romualdl
Officer Cadet
Posts: 41
Joined: Tue Jan 17, 2006 9:42 pm
Location: France

Re: ORIC SDCARD

Post by romualdl » Fri Nov 02, 2018 11:15 pm

Thanks to Dbug to bring me alive ;)

@Edl42 : Nice project and even greater to share it.

@Ibisum
ibisum wrote:
Sun Oct 28, 2018 6:18 pm
I don't know much about Fritzing but I opened this up to have a look - do I have to Autoroute the PCB first, to get something I could send off to be made? Because when I do that it seems to make a PCB with a lot of empty space ..
You could but first before routing you should check connections because if you have a look at the board and the schematics you will notice discrepancies. R3 should be connected to R7 and S1 it is on the test board but not the circuit schematics. The same for R1, the connection to the Led+ pin of the lcd is on the schematics but not on the PCB board. Of course it's not a real problem a wire would do the trick but it's better to check before.
For the size you can resize the pcb by clicking on the grey area and resize the pcb just like a window. The price would then be lower btw.

Post Reply