Jump to content

Photo

[AQUARIUS] Micro-Expander: RAM, ROM, AY-8910 and more!


95 replies to this topic

#26 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Sun Nov 15, 2015 9:28 PM

Good News, Bad News.

 

First the bad news:- the CH376 doesn't double buffer internally, so when reading a file it pauses for up to 2ms before reading each sector. This isn't too much of a problem for video, but wreaks havoc on audio playback. I tried playing a wave file with a fixed delay after reading each sample, but the 0.2~2ms gaps caused the sound to be scratchy and off-pitch.

 

To fill in the gaps I had to read the samples into a buffer at a higher rate, then continue to output samples while waiting for the CH376 to read the next sector. Implementing a circular buffer took up so many CPU cycles that stereo playback at 15kHz was impossible. Since the Aquarius doesn't have a hardware timer I had to count CPU cycles and add different delays for each path in the program - not an easy job :(.

 

Now the good news:- I managed to get it working in mono at 15kHz, and it sounds pretty good!

 

The DAC hardware is a little more complex than I had hoped to get away with. An octal buffer is required (I used a 74HC245) because the AY's I/O ports have weak pullups that affected the accuracy of the R/2R resistor ladder. The circuit is still cheap and relatively simple, though having to wire in the 17 1% resistors was a pain. I have an AD558 which would be more accurate and make life easier, but it is an expensive chip. Another possibility is the TLC7524 (which only costs about $2 in one off quantity).  

 

The attached source code plays a raw 8 bit wave file from the CH376 at (approximately) 15Khz. Because the file is read one byte at a time its size is not limited to 64k - the file I used for testing is 6.5MB and plays for over 7 minutes. To convert it from mp3 to raw 8 bit binary I used SoX Sound eXchange. First I converted the mp3 into 15.734 KHz 8 bit mono WAV format (to hear what it sounded like) then I converted from WAV to AFS (raw 8 bit unsigned data). Interestingly the final result was about the same size as the original mp3! SoX 'drag and drop' batch files for doing the conversions are included in the attachment.

 

The attached mp3 is the output from my Aquarius recorded by my PC's sound card. So the original song has gone full circle:- from mp3 to WAV to raw binary, copied to a USB stick and played through a crude DAC on the Aquarius, then re-sampled in WAV format and finally converted back to mp3!

 

It really has to be great to have a huge mass storage device for the computer.  So many possibilities!  Sounds awesome.



#27 Aquaman OFFLINE  

Aquaman

    Moonsweeper

  • 374 posts
  • Location:the Netherlands

Posted Mon Nov 16, 2015 2:58 PM

This really sounds amazing! :)



#28 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Fri Feb 12, 2016 11:28 AM

I changed the file formats to improve compatibility, added support for arrays, and extended the RUN command to allow running executable files directly from disk.

 

Formats are:-

 

1. Tokenized BASIC program: 32 byte CAQ header (same as  Virtual Aquarius).

 

2. BASIC array: 24 byte CAQ header (same as Virtual Aquarius).

 

3. Binary executable: starts with JP $+3 ($C3, $nn, $nn). Destination address is the next instruction, which the loader uses to determine what address to load the code into.

 

4. All other formats: assumed to be raw binary data, and must be loaded to a specified address.

 

Any file can be loaded as raw binary by specifying the load address. If a load address is not specified then the file type is determined from the filename extension (if present) and contents of the file header. Valid headers are:-

 

1. 32 byte CAQ header = BASIC program

2. 24 byte CAQ header = BASIC array

3. $C3  (JP instruction) = binary executable

 

If the first byte in the file is anything other than $FF (CAQ header) or $C3 (JP instruction) then it will be treated as raw binary data.

 

Command syntax:-

 

Load and save numeric BASIC array:-

LOAD "filename",*A

SAVE "filename",*A

 

Load any file to specific address:

LOAD"filename", address

 

Save binary data to file:

SAVE "filename",address, length

 

Load BASIC program or Binary executable:

LOAD "filename"

 

Load and run a BASIC or machine code program:

RUN "filename"

 

If there are no parameters after the filename then the closing " is not required (one less character to type!).

Attached Files


Edited by Bruce Abbott, Fri Feb 12, 2016 11:31 AM.


#29 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Tue Feb 16, 2016 1:27 PM

I found that having to remove the EEPROM from the board and reflash it every time I want to make a change is a pain.  So I have redesigned the circuit to load ROM images from the USB drive into RAM. The upper 16K of the 32K expansion RAM will be remapped over the EEPROM and write-protected. Remapping will done via an I/O port and is 'sticky' so it stays on until the computer is reset or turned off. 

 

For the production PCB I am moving the CH376 interface onto the lower board, leaving just the (optional) AY3-8910 on the upper board. The EEPROM and GAL will be mounted on the underside of the lower board, so they can be removed from their sockets without having to separate the boards. Since the ROM now only needs to be large enough to hold Disk BASIC I can use a smaller capacity (E)EPROM that fits in a 32 pin DIP socket - no more fiddling trying to get it out of the PLCC socket without mashing the pins!  

 

The CH376 module will still be mounted externally, as I am working on a higher performance replacement using an SD Card, that will plug into the same slot.

 

Attached Thumbnails

  • uexp2.PNG


#30 barnieg OFFLINE  

barnieg

    Moonsweeper

  • 387 posts
  • Location:Rugby, England

Posted Tue Feb 16, 2016 6:39 PM

I found that having to remove the EEPROM from the board and reflash it every time I want to make a change is a pain.  So I have redesigned the circuit to load ROM images from the USB drive into RAM. The upper 16K of the 32K expansion RAM will be remapped over the EEPROM and write-protected. Remapping will done via an I/O port and is 'sticky' so it stays on until the computer is reset or turned off. 

 

For the production PCB I am moving the CH376 interface onto the lower board, leaving just the (optional) AY3-8910 on the upper board. The EEPROM and GAL will be mounted on the underside of the lower board, so they can be removed from their sockets without having to separate the boards. Since the ROM now only needs to be large enough to hold Disk BASIC I can use a smaller capacity (E)EPROM that fits in a 32 pin DIP socket - no more fiddling trying to get it out of the PLCC socket without mashing the pins!  

 

The CH376 module will still be mounted externally, as I am working on a higher performance replacement using an SD Card, that will plug into the same slot.

 

 

Do you have an idea of cost for a complete Micro-Expander when design is finished?



#31 First Spear OFFLINE  

First Spear

    Stargunner

  • 1,261 posts
  • Location:Somewhere in Uptown

Posted Wed Feb 17, 2016 9:45 AM

I do not have an Aquarius anymore (I bought and sold one on eBay in the mid 90's for $50 I think), but am really loving all of the, um, love you are putting into this.

 

Could you be persuaded to do anything similar for the Intellivision, in any way? 

 

Apologies for hijacking this thread but your skills are obviously in the stratosphere in this area.

 

 

 

This project is an attempt to squeeze all the functiona[snip]



#32 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Wed Feb 17, 2016 2:25 PM

 

Do you have an idea of cost for a complete Micro-Expander when design is finished?

The main board is 6.35 square inches, so it should cost about $12 from OSH Park ($31.75 for 3 boards). Add to that a 16-64k (E)EPROM, 32k static RAM, GAL16V8, a couple of IC sockets, 16 pin connector for the CH376, and a few smd caps - guessing $15 worth of parts. The CH376 sells for ~$8 on eBay, so that's about $35 for the base unit.

 

The upper board with GAL, all sockets/connectors/etc, and a surplus AY-3-8910 from eBay, will probably cost $25~$30.

 

Those are the basic component costs for people who are able to do their own assembly (cheaper if you already have some of the required parts). To 'burn' The (E)EPROM and GALs you need a programmer such as the TL866CS (~$40 on eBay).

 

Since I have to order 3 of each board I will probably make up 3 complete units, keep one and sell the other two. I could also sell 'short' kits with bare boards and pre-programmed EPROM/GALs. I am not looking to make a profit, but will have to add freight and transactions costs. So perhaps $50 for a built-up base unit with CH376, or $80 for a complete package with both boards.   



#33 Aquaman OFFLINE  

Aquaman

    Moonsweeper

  • 374 posts
  • Location:the Netherlands

Posted Wed Feb 17, 2016 2:33 PM

 

 

Since I have to order 3 of each board I will probably make up 3 complete units, keep one and sell the other two. I could also sell 'short' kits with bare boards and pre-programmed EPROM/GALs. I am not looking to make a profit, but will have to add freight and transactions costs. So perhaps $50 for a built-up base unit with CH376, or $80 for a complete package with both boards.   

Please sign me up for a complete package with both boards  :)



#34 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Sat Feb 20, 2016 9:09 PM

I am going to want a board Bruce if possible.



#35 MattelAquarius OFFLINE  

MattelAquarius

    Moonsweeper

  • 469 posts
  • Location:Washington D.C.

Posted Thu Feb 25, 2016 7:41 PM

I will buy all new Aquarius hardware products you and Jay (or anyone else) can throw our way!

 

:thumbsup:  :thumbsup:



#36 mvdsteenoven OFFLINE  

mvdsteenoven

    Chopper Commander

  • 181 posts
  • Location:Netherlands

Posted Mon Apr 4, 2016 10:35 AM

Wow!

I haven't been very active on the Aquarius front, but Aquaman pointed out your project and it is amazing!!

Cool stuff.

Can you also sign me up for both boards? :)

 

Thanks & keep up the good work.

 

Kind regards,

Martin



#37 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Fri Aug 19, 2016 2:20 PM

Apologies for the delay (I had a few health issues and other distractions). Main PCBs should arrive in about a week. Hope they work!

 

 

 

 

 

 

 

Attached Thumbnails

  • Uexp shipped.jpg


#38 Aquaman OFFLINE  

Aquaman

    Moonsweeper

  • 374 posts
  • Location:the Netherlands

Posted Sat Aug 20, 2016 9:17 AM

Apologies for the delay (I had a few health issues and other distractions). Main PCBs should arrive in about a week. Hope they work!

 

No apologies necessary, I am just glad that you are okay again  :thumbsup:

I keep my fingers crossed that these boards are in 100% working order, so hopefully I can personally see them in action shortly after :).   



#39 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Sat Aug 27, 2016 12:42 PM

The boards have arrived, and they look good. I have started assembling one.

 

I also ordered some CH376 USB modules. Unfortunately the pinouts on the product I got didn't match the photo. The data pins are on the wrong row, and the control and power pins are mixed up. Also it doesn't have a RESET input (only power-on reset). Luckily the data pins line up if the connector is mounted on the top of my PCB (instead of on the bottom) and CS also lines up, so I will only to have rewire 5 pins. My other supplier is no longer listing the original module, so apparently it has been discontinued (some eBay sellers still appear to have it, but I can't trust them).

 

I am considering removing the USB socket from the CH376 module and reattaching it via a ribbon cable. It can then be mounted wherever you like. The CH376 module will be mounted horizontally above the PCB, facing forwards to fit inside the cartridge. This has the advantage of freeing up space at the back of the cartridge for other things such as joystick ports or stereo sound output (which will be on the daughter board). 

 

 

Attached Thumbnails

  • pcb.jpg
  • CH376 variants.jpg


#40 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Tue Sep 6, 2016 5:32 PM

Bruce,

 

What is the datapath from the USB drive to RAM/CPU?   Will it be accessible via machine language or only via disk basic routines?  I seem to remember you doing a data transfer test of some sort.  If all we wanted to do were to blit raw video data to screen and audio data to the AY is there an easy path from disk to memory?  Having the USB space opens up incredibly possibilities if we have a robust data transfer rate.  :)

 

Can't wait to get mine...

 

Chris



#41 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Thu Oct 6, 2016 1:51 AM

It's alive! :)

 

Initially it didn't work and I couldn't figure out why, so I put it aside. Then I metered all the connections again and compared them to my hand-wired prototype, and discovered the error - I had swapped the RD and WR lines to the GAL but the labels didn't move with them, so the circuit diagram didn't show the change and I forgot that I needed to change the GAL program. Reprogrammed the GAL and it now works!  

 

Next step, finalize the AY PCB layout and send it off to OSH Park...

 

 

What is the datapath from the USB drive to RAM/CPU?   Will it be accessible via machine language or only via disk basic routines?

 

Sorry for the late reply (seems I somehow got logged out and didn't notice that the thread was updated).

 

The 'datapath' is through the expansion bus to the CPU, via IO instructions such as INIR and OTIR.

 

All the disk functions (both high level eg. LOAD, and low level eg. READ_BYTES) are accessible via assembly / machine code. If you need to do something differently then just modify the driver source code and include it in your own program (that is how I did double-buffering for playing wave files).

 

I seem to remember you doing a data transfer test of some sort.  If all we wanted to do were to blit raw video data to screen and audio data to the AY is there an easy path from disk to memory?

 

Sadly it's all done through the CPU (I don't know if DMA is even possible on the expansion bus). Theoretically the CPU should still be fast enough to do pretty good video and sound, but unfortunately the CH376 itself is a bottleneck because it doesn't double-buffer data transfers - so if the CPU was faster it would just have to wait longer for the CH376 to finish reading/writing the USB port. That is why I had the idea of creating a replacement for the CH376.     

 

 

Having the USB space opens up incredibly possibilities if we have a robust data transfer rate.

 

 

Even though it's not as good as it could be, the CH376 can still deliver over 100kB/s average throughput with latency of a few milliseconds, which is pretty impressive for a machine of this vintage. Definitely has possibilities!

        

Attached Thumbnails

  • uexp_test.jpg


#42 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Thu Oct 6, 2016 2:07 AM

I just noticed my supplier has some of the original CH376 modules (with pinout matching my PCB) back in stock, so I ordered a few. 

 

But what to do with the other modules? I have taken the pins off one module and it looks like it should fit inside the case. Just have to make an adapter cable to match the wiring of my connector, then I can test it. If it works then you have the option of an internal CH376. 

 

Next question: where should the USB socket be mounted?

 

1. upright like the external module

 

2. horizontal at the rear.

 

3. somewhere else?

 

Tell me what you would prefer!



#43 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Thu Oct 6, 2016 8:22 PM

I just noticed my supplier has some of the original CH376 modules (with pinout matching my PCB) back in stock, so I ordered a few. 

 

But what to do with the other modules? I have taken the pins off one module and it looks like it should fit inside the case. Just have to make an adapter cable to match the wiring of my connector, then I can test it. If it works then you have the option of an internal CH376. 

 

Next question: where should the USB socket be mounted?

 

1. upright like the external module

 

2. horizontal at the rear.

 

3. somewhere else?

 

Tell me what you would prefer!

 

It depends on if we find somebody with a 3D printer to make us cases for them!!!  If that were the case then I'd want it on the top for easy access!



#44 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Thu Oct 6, 2016 8:27 PM

It's alive! :)

 

Initially it didn't work and I couldn't figure out why, so I put it aside. Then I metered all the connections again and compared them to my hand-wired prototype, and discovered the error - I had swapped the RD and WR lines to the GAL but the labels didn't move with them, so the circuit diagram didn't show the change and I forgot that I needed to change the GAL program. Reprogrammed the GAL and it now works!  

 

Next step, finalize the AY PCB layout and send it off to OSH Park...

 

 

 

Sorry for the late reply (seems I somehow got logged out and didn't notice that the thread was updated).

 

The 'datapath' is through the expansion bus to the CPU, via IO instructions such as INIR and OTIR.

 

All the disk functions (both high level eg. LOAD, and low level eg. READ_BYTES) are accessible via assembly / machine code. If you need to do something differently then just modify the driver source code and include it in your own program (that is how I did double-buffering for playing wave files).

 

Sadly it's all done through the CPU (I don't know if DMA is even possible on the expansion bus). Theoretically the CPU should still be fast enough to do pretty good video and sound, but unfortunately the CH376 itself is a bottleneck because it doesn't double-buffer data transfers - so if the CPU was faster it would just have to wait longer for the CH376 to finish reading/writing the USB port. That is why I had the idea of creating a replacement for the CH376.     

 

 

 

Even though it's not as good as it could be, the CH376 can still deliver over 100kB/s average throughput with latency of a few milliseconds, which is pretty impressive for a machine of this vintage. Definitely has possibilities!

        

 

100k per second.... So 1920 bytes per screen in total (one byte per char and one for attribute) so 102,400 / 1,920 = 53 frames per second if just video... seems to me a 30 fps video player is totally possible with sound.  Could store two "fields" per frame to make a flicker mode player/video.  You are right... 100k/second is a lot to play with.  



#45 Aquaman OFFLINE  

Aquaman

    Moonsweeper

  • 374 posts
  • Location:the Netherlands

Posted Sat Oct 8, 2016 9:14 AM

 

Next question: where should the USB socket be mounted?

 

1. upright like the external module

 

2. horizontal at the rear.

 

3. somewhere else?

 

Tell me what you would prefer!

I would vote for 2, but if it placed somewhere else, it's also fine by me!



#46 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 322 posts
  • Location:Massachusetts

Posted Sun Nov 6, 2016 6:18 PM

Any news?



#47 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Mon Nov 7, 2016 6:48 AM

The CH376 boards I ordered seem to have been lost in the post, so I ordered another two (this time with tracking and insurance..).

 

The AY pcb layout is almost finished. I wanted to include a programmable timer but couldn't decide how to do it, so I am just going with the basic AY function for now.

 

I have also been thinking about different locations for the CH376 and USB socket. Right now I have one hanging off the back of the computer via 2 inches of ribbon cable, to make sure it can handle the longer wiring (works perfectly!).



#48 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,954 posts

Posted Mon Nov 7, 2016 6:54 AM

 

It depends on if we find somebody with a 3D printer to make us cases for them!!!  If that were the case then I'd want it on the top for easy access!

 

My 3D printer is pretty touchy given my skill level.  Still, I'd be willing to try an print an .STL file. 

 

My attempt at a sega genesis cart failed but I'm pretty sure that was because it was close to a literal scan and not made for 3D printing.



#49 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 122 posts

Posted Sun Nov 27, 2016 12:12 PM

Unfortunately the GALs I ordered from Element14 turned out to be not available, so I redesigned the circuit to use standard HCT logic ICs instead. Finally finished the PCB yesterday and sent it off to OSHpark. 

 

I added a USB socket to the PCB, which can be placed either horizontally or vertically. This socket is not connected to anything on the AY board, but can be wired to the CH376 if it is mounted internally. 

 

My second order of CH376 modules arrived a few days ago, so soon I should have everything needed to complete the project!

 

Time to polish up the firmware. So far it's only taking up about 4K of the 16K ROM. Does anyone have any ideas for things to add?

 

Attached Thumbnails

  • AY circuit.png
  • AY board.png


#50 Aquaman OFFLINE  

Aquaman

    Moonsweeper

  • 374 posts
  • Location:the Netherlands

Posted Mon Nov 28, 2016 3:27 PM

 

Time to polish up the firmware. So far it's only taking up about 4K of the 16K ROM. Does anyone have any ideas for things to add?

 

I am not quite sure which features are already added, but maybe you could find some inspiration on the following site http://ar.c64.org/wiki/1541_Ultimate?One of these now emulated cartridges were a must have for every C-64 owner back in the day.   

Furthermore I am not sure if it is possible to get some kind of AY music ripper/converter inside? There is a fair share of music available, but to transfer these to work on the Aquarius is still quite difficult for people like myself  :?.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users