I2C for the Oric

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.
User avatar
HigashiJun
Officer Cadet
Posts: 35
Joined: Tue Dec 10, 2019 9:29 am
Location: Tokyo (Japan)

Re: I2C for the Oric

Post by HigashiJun » Thu Jan 30, 2020 5:20 am

Badger wrote:
Wed Jan 29, 2020 7:25 pm
HigashiJun wrote:
Tue Jan 28, 2020 1:41 pm

Wouldn't pass-through RTCs like Dallas DS1216E run in our machines ?
They could work in an oric, but you'd still need some code to read the time.
A couple of disadvantages I can think of are :-

No longer manufactured (I dont know if there is a replacement) so would rely on Ebay etc for supplies and is more expensive than the I2C module equivalent.

Would need to open the Oric to fit and I dont know if there would be enough clearance inside the case for the extra height. I dont think we need to worry about voiding the warranty though :D

Would need bespoke code to read the time whereas the I2C modules uses a defined standard protocol for data across any module you care to fit.

They also have a battery which at some point would need replacing. Harder to do with an internal module rather than external.

Having said all that, there is no reason I can see that it wouldnt work , and its an interesting scheme they came up with to be able to read and write to the device by reading rom addresses in a certain order.

A quick update on my module testing is that I now have the RTC fully functioning and testing an LCD display connected to the same I2C bus. If that works then it will proove that both data read/writes are working as they should.

Next step is see if it is possible to use an Arduino of some description to to act as a go between I2C on the Oric and USB on a PC. That could pave the way for an initial way of getting file tranfers from PC->Oric and even Net connectivity. Thats still a way off though.

I'll keep plodding along :)

Ian
Thank you for your exhaustive feedback.

The reason why I'm thinking about the DS1216E is because I have its equivalent (DS1216F) in my Atari 1040STE and it works flawlessly...

Even if the battery inside the chip is quite everlasting, you can however disable it and add an external one as described in the link below:

http://www.minuszerodegrees.net/5160/ds ... arning.htm

As you mentioned it, an issue would be the clearance, but I think it's possible to desolder the Atmos ROM and solder the RTC directly on the mainboard, avoiding thus a socket and then insert the ROM on top of the RTC module.

These RTC modules can be easily found on Ebay and are not so expansive, so I might give it a try...

The other issue would be to get a code for time reading, and I am not a specialist in this field on Orics.

Cheers.
HigashiJun

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Sat Feb 01, 2020 11:59 am

Another Update :-

Due to not getting the LCD module to work yet, I decided to rest that one and move on to the next stage.

Here we have an Oric communicating over I2C to an Arduino and displaying the results on the arduino serial monitor on a PC. Very simple, but works.

I used an arduino mega as it was the first one I picked up and the sda/clk lines have dedicated pin-outs, but any arduino could be used. Ultimately I plan on a nano that would plug directly into the Oric printer port.
You will need - an oric, an arduino, 3 wires, usb cable from arduino to PC.

For the oric connect to arduino.
Pin 3 (bottom row , 2nd pin from left) is the SDA line
Pin 5 (bottom row, 3rd pin from left) is the CLK line
Any of top row is GND and connects to GND on the arduino.

The code is attached below for both oric and arduino and also available on github with the source https://github.com/BadgeOric/OricI2C

Pictures below of it running. Bonus points for naming the computer in the first picture top right :D - no prize though.
oric_2_arduino1.jpg
oric_2_arduino1.jpg (89.99 KiB) Viewed 504 times
oric_2_arduino2.jpg
oric_2_arduino2.jpg (47.57 KiB) Viewed 504 times
oric_2_arduino3.jpg
oric_2_arduino3.jpg (54.74 KiB) Viewed 504 times
Seems the board wont let me add the code in this post so will be in the next post.
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Sat Feb 01, 2020 12:01 pm

Files for the above post.

The arduino sketch is not an accepted file format so will post the code directly. Tap file is the oric assembly and basic for the comms.

Code: Select all

// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include <Wire.h>

void setup()
{
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop()
{
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  while(1 < Wire.available()) // loop through all but the last
  {
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.write(x);         // print the integer
  if (x==13) { Serial.write("\r\n"); }
}
Attachments
or2ard.tap
(2.26 KiB) Downloaded 6 times
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
HigashiJun
Officer Cadet
Posts: 35
Joined: Tue Dec 10, 2019 9:29 am
Location: Tokyo (Japan)

Re: I2C for the Oric

Post by HigashiJun » Sat Feb 01, 2020 1:57 pm

Well done !

The LED on the computer on the right looks very familiar to me...

:D
HigashiJun

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Tue Feb 04, 2020 9:52 pm

I now have 2 way comms between PC and Oric with the arduino in the middle.

USB I2C
PC<------->Arduino<------->Oric

Nothing special, type on either PC keyboard or Oric and it appears on both (terminal emulator on PC). Its useless at the moment, just another step down the line. Other than the I2C code the send/receive code and printing is in BASIC so it isnt the fastest and does miss some letters occaisionally when typing fast.

I have on order a couple of wifi shields for the arduino, so hopefully will have wireless comms over LAN/WAN soon with the arduino taking care of the connection and TCP/IP stack.

If this works , I will see if works using an Arduino nano rather than the mega I'm using at the moment.
All being well, I can then prototype a plug in module for the oric which will consist of a 20 pin connector for the printer port, an arduino nano, a wifi module, 5v power regulator and power connector similar to the one on the Scart cable to supply the module.

Rough guess cost about £10-£15 .

All we would need after that is some useful software like an ftp client, web browser(???).Without the I2C and utilities being in rom though, I'm not sure how you could load things over wifi without overwriting the wifi software.

Any help or suggestions would be welcome.

Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Chema
Game master
Posts: 2553
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: I2C for the Oric

Post by Chema » Tue Feb 04, 2020 11:32 pm

This is great! Just a terminal emulation program supporting this and you'll be able to connect to BBSs!

I'd go for disk software, so you have access to the overlay ram, load/save to disk, etc.

User avatar
ibisum
Wing Commander
Posts: 1187
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: I2C for the Oric

Post by ibisum » Thu Feb 06, 2020 9:01 pm

Would love to contribute to this if it were possible - open source repo somewhere?

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Thu Feb 06, 2020 9:47 pm

There is some code at https://github.com/BadgeOric/OricI2C.

Its pretty fluid as I come across bugs and things that need adding, but it does work fdor the real time clock module.

I have recieved these https://smile.amazon.co.uk/gp/product/B ... UTF8&psc=1 today which basically is an arduino like device with wifi all on one module.

Once I've worked out how I did it, I will create some instructions on how to set these things up with the correct firmware as its not intuitive, Its fairly easy once you do the correct steps in the right order.

I now have one working on wifi on my pc with an I2C temperature monitor on it displaying in a webpage on the pc. So will look at that tommorow with the Oric being the I2C device and see if I canget something working over the next few days.

All help, ideas code testing, or anything really would be much appreciated. It will be fully open source and would like as many people to try it out as possible.

It would also be fun to see if we could get some internet playable games at some stage in the future, anyone for Orico-Kart? Even 2 player chess or Pong to start would be great :)

Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
ibisum
Wing Commander
Posts: 1187
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: I2C for the Oric

Post by ibisum » Fri Feb 07, 2020 11:01 am

8-bit Unity has a multiplayer module and I believe 8-bit Dude is planning on a hardware release alongside that allows 4 people to play against each other - when you get multiplayer up and running over WiFi, it'll be an almost sure thing that support for this will be added to 8-bit Unity itself, imho.

Just to give you some context - I wrote the OS for the MagicShifter, which is an ESP8266-based light synthesiser (repo here: https://github.com/magicshifter/MS3000/ .. I think that with your work we are a step closer to adding capabilities akin to, e.g. the Amstrad CPC6128's M4 Board, which has storage and WiFi (and a working web server) onboard to bring the machine into the 21st Century. M4 board for the Oric, or maybe Cumulus Reloaded gets a WiFi upgrade somewhere along the line as well .. wouldn't that be awesome?! :)

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Sat Feb 22, 2020 9:14 pm

Another quick update.
I have finally managed to get reliable transfers from PC to Oric (although more on this below). Its all a matter of timings and how many bytes can reliably be transferred in one block (turns out 5 is a good number but will probably use 4 for multiplication reasons).

Text transfers both ways seem to be pretty much done, however other byte transfers are problematic. I suspect its something to do with the way the Arduino core in the wifi module deals with certain incoming bytes. My reasoning :- Text transfers work at any size. All the text is is a byte with a value between 32 and 127. Therefore the errors I get when transfering other files are due to bytes that fall outside this range. Since all the code does on the oric side is put the byte value into memory then I think the issue lies with the wifi module side.

Here are 2 pictures of a hires picture transfer. Pictoric was used to generate the original and shows perfectly on the emulator on the PC.
emulator.jpg
emulator.jpg (120.42 KiB) Viewed 196 times
I stripped off the header (OSDK header.exe) and sent the file over wifi to a real Oric.
oric.jpg
oric.jpg (92.04 KiB) Viewed 196 times
As you can see the basics are there but obviously useless for any file transfers.
Another clue to what is going on is the fact that the received pattern is always the same even comparing 2 memory dumps, which is another reason I suspect the wifi module is doing someting silly.

On the plus side , can transfer ASCII Art pictures :)

Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Sun Feb 23, 2020 11:53 am

AND ITS SOLVED!!!!!! :D

Its always something silly. The terminal client (RealTerm) I was using to send over wifi was set to telnet mode which split bytes less than #10 into 2 bytes so a #0a would be sent as #0 and then #A. Setting this ro RAW mode solved this.

So now the wifi transfer of a hires picture looks like this :-
Oricpic.jpg
Oricpic.jpg (199.33 KiB) Viewed 163 times
I have uploaded all the code to github at https://github.com/BadgeOric/Oric-I2C
and some basic instructions are in the readme file.

Here is a picture of the wifi module on its breadboard :-
orici2cbb.jpg
orici2cbb.jpg (165.9 KiB) Viewed 163 times
If anyone has any ideas, code, improvements on the code then please don't hesitate. Whilst I may not be able to make a commercial plug in module, I would like as many people as possible to make it useful

Regards Ian
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
ibisum
Wing Commander
Posts: 1187
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: I2C for the Oric

Post by ibisum » Sun Feb 23, 2020 12:51 pm

Wow, nice work! Yeah, its a long shot, but I need to ask - is there any opportunity for us to add this hardware feature to the Cumana Reborn, by any chance? Maybe there's a spare pin onboard that could be used? I can only imagine how cool it'd be to have a Cumana with WiFi capabilities ..

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

Re: I2C for the Oric

Post by Dbug » Sun Feb 23, 2020 1:23 pm

Whilst I may not be able to make a commercial plug in module, I would like as many people as possible to make it useful
and
can only imagine how cool it'd be to have a Cumana with WiFi capabilities ..
The main issue at the moment, is that we have multiple devices that are mutually exclusive, or suffer from minor issues (compatibility, how easy it is to patch, support of standard formats, etc...).

Ideally, I would be ok to pay for something that can do all that in one single device:
- that like the Cumana Reborn that supports both real floppy drives, and SD cards.
- that like the Erebus makes it easy and fast to load tape games
- that like your wifi i2c module that provide the ability to exchange data between the oric and other machines

Except I also want something that does more than there devices do at the moment:
- only supporting HFE instead of DSK is a problem, because not the entire ecosystem supports it
- Erebus can't save and does not support multi-file programs so we lose all the intro sequences

Since Erebus is basically built on the concept of having a patched ROM that can load stuff in a different way, that logic could easily be translated in having the patched ROM be in overlay ram instead - which also would make it easy to use custom ripping ROMs designed to LOAD from the actual real TAPE input, and then SAVE to the SDCard (or send by wifi).

I'm not a hardware guy, so I'm not sure how all that is doable, but between all of you, plus the 8bit Hub guy, possibly you could all come up with something awesome that does not forces people to choose between device A or device B :D

User avatar
Badger
Officer Cadet
Posts: 59
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: I2C for the Oric

Post by Badger » Sun Feb 23, 2020 5:14 pm

ibisum wrote:
Sun Feb 23, 2020 12:51 pm
Wow, nice work! Yeah, its a long shot, but I need to ask - is there any opportunity for us to add this hardware feature to the Cumana Reborn, by any chance? Maybe there's a spare pin onboard that could be used? I can only imagine how cool it'd be to have a Cumana with WiFi capabilities ..
I dont see why it couldnt be added. There's lots of spare gpio pins on the board. In essence its an arduino nano with a lot more ram and built in wifi.

It may be easier to tag the board on to the cumana reborn and instead of using the I2C connection to the oric, treat it like a 2nd drive. I know people have used them as webservers and fileservers from sd cards.

The main issue at the moment, is that we have multiple devices that are mutually exclusive, or suffer from minor issues (compatibility, how easy it is to patch, support of standard formats, etc...).
Ideally, I would be ok to pay for something that can do all that in one single device:
- that like the Cumana Reborn that supports both real floppy drives, and SD cards.
- that like the Erebus makes it easy and fast to load tape games
- that like your wifi i2c module that provide the ability to exchange data between the oric and other machines
I agree with Dbug , it would be good if things could be brought together in one box which supported multiple formats, with maybe even a eeprom that could be flashed over USB to update both the device rom and Oric rom that would be put into overlay ram.

Also like Dbug, I am at the limits of my hardware knowledge and whilst I kind of know the theory and what I would want to acheive I have no idea how to actually do it.

I will continue to work on the code for the I2C and wifi as it can be used for a lot of things other than file transfers and also the code I have put together is a mish-mash that isnt very efficient.

I think these are exciting times. If back in the 80's someone had told me that one day I could load anything from anywhere with my Oric I would have laughed.

To be honest, if someone had said that one day I would understand assembly I would have laughed :D
flag_uk Amateurs built the Ark, Professionals built the Titanic.

User avatar
Chema
Game master
Posts: 2553
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: I2C for the Oric

Post by Chema » Sun Feb 23, 2020 5:46 pm

I probably misunderstood something, but I thought this device plugged in the printer board, thus not interfering with a disc unit.

I am for a simple device which could act as a modem. I am aware there are few BBSs still around, but it would be nice to have an terminal emulation and some ftp-like software which could be used taking the benefits of a disc unit. Making it part of the cumana reborn, makes getting one mandatory, and, despite how great it is, I have a controller and a cumulus (and an Erebus).

As a side note, I think I could ask some people I know and who could probably create a small batch if a working solution is available :)

Post Reply