[EN] TasmARI

Moderator: bbiernat

Post Reply
User avatar
pancio
Administrator
Posts: 77
Joined: 18 September 2013, 23:02 - Wed
Location: SILESIA

[EN] TasmARI

Post by pancio »

TasmARI: Tasmota + Atari = The Universe Control Center

Introduction
I'd like to introduce you to my new, very simple device for the Atari XL/XE.
TasmARI is a simple connection between an ESP32 microcomputer running under Tasmota operating system and an Atari. This allows for a greater expanse of the Atari's capabilities in the broadest sense of the word, while also enabling our Atari to be part of a set of IoT devices. Thanks to the Tasmota OS, our Atari can communicate with other IoT components and manage our digital home using e.g. Home Assistant software. Now your Atari can become a control center... you can turn the lights on and off, make your morning coffee in the espresso machine, or play your favorite Internet Radio track on your Atari. The possibilities are limited only by your imagination and... the type of devices connected to the network...

It is also worth mentioning that initially TasmARI was supposed to be based on the ESP8266 chip, but I thought that since it was to be shown at the annual ABBUC HW competition, it would be necessary to use more powerful hardware :)

General description of the system.
The heart of the system is a module containing an ESP32 microcomputer – I chose the LoLIN D32 PRO version because it has an SD card port, a TFT display connector, an I2C connector, and a connector for connecting a battery. The module communicates with the Atari via a serial port, which is the easiest to use and allows for compatibility with the Atari OS and interoperability with other devices connected to the SIO connector. Proper operation also requires a voltage level shifter between Atari and ESP32. The remaining components are user-defined. These can include any sensors using the I2C, SPI, or OneWire bus – the only limitation is the type and version of the installed Tasmota OS software. For example, adding a PCF8574 chip provides an additional register that can be connected to, for example, PIA PORTB, allowing for control and management of the Atari's memory management. Another example is the use of EEPROM chips such as the AT24C256, the BMP280 – a digital barometer, thermometer, and hygrometer, and many other interesting sensors. Furthermore, the Tasmota OS allows remote access to all other sensors and controllers in network using the MQTT protocol.

TasmARI - version 1
In the first version, the project was implemented based on a pre-built LoLIN D32 PRO module and equipped with 74HC07 buffers. Basic software communicating with the Atari is written in the Berry scripting language, which is embedded part of the Tasmota OS software. Berry allows for simple peripheral management and also includes file management functions. This version of hardware was prepared for two very common modules ESP32: LoLIN and Dev-Kit:
tasmari-modules.jpeg
tasmari-modules.jpeg (1.38 MiB) Viewed 1114 times
First version as few variants of TasmARI first tests, schematic and visualization:
tasmari-pcbfront..png
tasmari-pcbfront..png (169.8 KiB) Viewed 1114 times
tasmari-pcb-visualization1.png
tasmari-pcb-visualization1.png (459.18 KiB) Viewed 1114 times
tasmari1r4.png
tasmari1r4.png (347.84 KiB) Viewed 1114 times
tasmariv1r4-pcbfront.png
tasmariv1r4-pcbfront.png (501.12 KiB) Viewed 1114 times
tasmari1r0-pcb1.jpeg
tasmari1r0-pcb1.jpeg (874.79 KiB) Viewed 1114 times
tasmari1r0-pcb-run.jpeg
tasmari1r0-pcb-run.jpeg (988.71 KiB) Viewed 1114 times
This hardware version supports an OLED display over the I2C bus, which can also contain four buttons (also operated by a PCF8574 connected to I2C). Music can also be played by using two DACs and feeding them into the Atari's AUDIO input. I also equipped TasmARI with a LED bar graph indicator - also supported by PCf8574.

In subsequent hardware revisions, there was always something that needed fixing. For example, I'd get the GPIO number wrong or forget that some signals could only function as inputs or outputs. They could also be used as strapping pins—used during ESP32 bootup. There were several fixes, a lot of testing, and disappointments...

And icing on the cake... I decided to add a regular pin header because SIO sockets are terribly expensive and terribly annoying to install :-)

However, the modules used have their limitations - especially when it comes to the number of GPIO signals and their versatility... so I decided to replace the ESP32-WROOM with the ESP32-S3-WROOM-1 and that's how the second version of TasmARI was created.

TasmARI - version 2

The second version of TasmARI has been slightly 'trimmed'... the LED bar graph has been removed and replaced with a pin header for SPI displays. I figured I could always present results on a larger, color display instead of just a few LEDs. There's also a pin header for the PCF8574 multiplexer and control for a WS2812b-based LED strip. However, I've retained compatibility with OLED displays (along with the four buttons). Using the ESP32-S3 has a huge advantage over the ESP32, including more GPIOs, support for 16MB of flash and 8MB of PSRAM. You can also easily connect a microSD card reader. And all this without interfering with any SIO signal handling. Unfortunately, I also had to give up audio support, as the ESP32-S2 lacks 8-bit DACs. But don't worry, you can always connect an external DAC :-)

For the reasons described above, both versions were no longer compatible with each other and I focused on developing only the second version.

Several hardware revisions were also made for TasmARI v2 because I kept encountering issues. Ultimately, testing is currently being conducted on version 2.0R0, with version 2.1R2 in production – and this is the version covered in the rest of this description.

Schematic
TasmARIv2.1R2-schematic.png
TasmARIv2.1R2-schematic.png (333.5 KiB) Viewed 695 times
Brief description:
  • The dark blue GPIO pins are responsible for connecting to all SIO signals in the Atari. The most important are GPIO17 (TX -> DATA_IN) and GPIO18 (RX <- DATA_OUT).
  • The green GPIOs are assigned to the SPI bus and are primarily used to control the color display.
  • The two turquoise GPIO pins: GPIO8 and GPIO9, are the SDA and SCL signals of the I2C bus, respectively. They are used for communication with the OLED display and the PCF8574 multiplexer. They are also connected to a separate pin header, allowing connection to other I2C-enabled systems.
  • The red pins are GPIOs used by FLASH and PSRAM memory. Using them requires careful consideration, and if you decide to use them, you must disable support for additional memory.
  • Also marked in red are the stripping pins. They can be used, but remember that they are used to configure the ESP32-S3 during startup. Their state must be precisely defined at power-up. I decided against using these signals, and the DevKitC module is responsible for their proper configuration.
  • The brown GPIO pins are used for communication with USB, serial port and microSD card.
ESP32-S3-DevKitC.png
ESP32-S3-DevKitC.png (147.06 KiB) Viewed 679 times

Board - prototyp
For now, the PCB is the same size as in the first version, but I plan to reduce it to such a size that it will perfectly fit the case of our friend @Beetle (he made a great case for FujiNet modeled after the Atari 800XL).
TasmARIv2.1RC2-front-visualization.png
TasmARIv2.1RC2-front-visualization.png (354.45 KiB) Viewed 684 times
TasmARIv2.1RC2-right.png
TasmARIv2.1RC2-right.png (581.3 KiB) Viewed 684 times
The prototype I'm testing on:
TasmARIv2.0RC0-proto.jpeg
TasmARIv2.0RC0-proto.jpeg (1.34 MiB) Viewed 669 times
And prepared for next stage PCB:
TasmARI-boardv2.1RC1.jpeg
TasmARI-boardv2.1RC1.jpeg (874.16 KiB) Viewed 313 times

Tasmota OS configuration
For our interface to work with the Atari, it needs to be configured. The same applies to the display. Let's start with configure GPIOs for LCD and WS2812b:
TasmotaOS-display-ws.png
TasmotaOS-display-ws.png (205.99 KiB) Viewed 659 times
The display can be configured in various ways, but I chose to use the Universal Display and Universal Touch drivers (uDisplay/uTouch) included in newer versions of TasmotaOS. Configuration involves "guessing" the display driver and entering the appropriate configuration string into the display.ini file and saving it in the TasmotaOS filesystem:
tasmota-cfg1.png
tasmota-cfg1.png (77.03 KiB) Viewed 661 times
TasmotaOS-display.ini.png
TasmotaOS-display.ini.png (80.74 KiB) Viewed 659 times
TasmotaOS-filesystem.png
TasmotaOS-filesystem.png (85.53 KiB) Viewed 657 times
If you have other display (different display driver) you need to find proper configuration on Tasmota GitHub page or write your own. Refer to uDriver Page

Example for ST7735 driver with 128x16 (display.ini):

Code: Select all

:H,ST7735,128,160,16,SPI,1,*,*,*,*,*,*,*,40
:S,2,1,1,0,40,20
:I
EF,3,03,80,02
CF,3,00,C1,30
ED,4,64,03,12,81
E8,3,85,00,78
CB,5,39,2C,00,34,02
F7,1,20
EA,2,00,00
C0,1,23
C1,1,10
C5,2,3e,28
C7,1,86
36,1,48
37,1,00
3A,1,55
B1,2,00,18
B4,1,04
B6,3,08,82,27
F2,1,00
26,1,01
E0,0F,0F,31,2B,0C,0E,08,4E,F1,37,07,10,03,0E,09,00
E1,0F,00,0E,14,03,11,07,31,C1,48,08,0F,0C,31,36,0F
11,80
29,80
:o,28
:O,29
:A,2A,2B,2C,16
:R,36
:0,C0,00,00,00
:1,A0,00,00,01
:2,00,00,00,02
:3,60,00,00,03
:i,20,21
#

You've probably noticed there are a few other files in the folder... some of them are my tests, but one is quite important: autoexec.be. This file is executed immediately after TasmotaOS boots. In it, you can define all your TasmotaOS functions and behavior, configure Atari transmission, and so on. In this file, I simply clear the display and display a banner for 5 seconds :-)
TasmARI-banner-autoexec.be.png
TasmARI-banner-autoexec.be.png (94.53 KiB) Viewed 450 times

Now that we have a working display, it's time to focus on communication...

Communication
To communicate with the Atari, we need to do two things: write a program in the Berry and any Atari program that will receive or transmit information via SIO.

Let's start by sending data from the Atari:

Code: Select all

;  main.asm    
;  
;  Copyright 2025 pancio <pancio@pancio.net>
;  
;  This program is free software; you can redistribute it and/or modify
;  it under the terms of the GNU General Public License as published by
;  the Free Software Foundation; either version 2 of the License, or
;  (at your option) any later version.
;  
;  This program is distributed in the hope that it will be useful,
;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;  GNU General Public License for more details.
;  
;  You should have received a copy of the GNU General Public License
;  along with this program; if not, write to the Free Software
;  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
;  MA 02110-1301, USA.

irqens  equ $0010

keycode equ $02fc
random  equ $d20a
kbcode  equ $d209

audf3   equ $d204
audf4   equ $d206
serout  equ $d20d
serin   equ $d20d
irqen   equ $d20e
irqst   equ $d20e
skctl   equ $d20f
skstat  equ $d20f    

    org   $600
;main program               

init:
        lda #$28        ;define speed to 19200bout
        sta audf3
        lda #$00
        sta audf4
        lda #%00100111  ;enable POKEY to send data
        sta skctl
        
start:
        lda #'A'
        sta serout
        jsr wsent
        lda #'t'
        sta serout
        jsr wsent        
        lda #'a'
        sta serout
        jsr wsent
        lda #'r'
        sta serout
        jsr wsent 
        lda #'i'
        sta serout
        jsr wsent
        lda #'!'
        sta serout
        jsr wsent 
                
;wait for shift(exit)
exit:   
        lda skstat
        and #%00001000
        bne start
        
        rts   
        
;wait for byte sent 
wsent:   
        lda irqst
        and #%00001000
        bne wsent
        rts
First, we configure the POKEY chip, set the transmission speed and allow data sending (:init). Then, we periodically send data in the form of the string 'Atari!' (:start) in a loop - POKEY SEROUT register contains byte to send.. The loop also includes an exit condition for the sending program, which checks for a POKEY interrupt for the SHIFT key (:exit). POKEY also triggers an interrupt after each byte is sent – ​​we use this to load the output register with the next byte at the appropriate moment (:wsent). If we did everything correctly, we can see that the SIO_OUT LED is lit (actually blinking quickly).

Now it's TasmotaOS's turn. We need to define a function that will retrieve data from the Atari:

Code: Select all

ser = serial(18, 17, 19200, serial.SERIAL_8N1)   #RX18, TX=17
def read_sio()
    import string
    var msg = ser.read()
    tasmota.cmd(msg.asstring())
    print(msg.asstring())
end
Just copy/paste above to Berry console on TasmotaOS.

The program contains a definition of the 'ser' object of the 'serial' class and defines the transmission parameters and a simple read_sio() function that receives data from the serial interface (RX - GPIO18) and outputs it directly to the console screen.

Now we are ready to receive data on TasmARI. From console tool type 'be read_sio()' then observe results:
TasmARI-read_sio.png
TasmARI-read_sio.png (181.9 KiB) Viewed 399 times
Voilà!

In the same time you may sens data to LCD. Let's modify out read_sio() function:

Code: Select all

ser = serial(18, 17, 19200, serial.SERIAL_8N1)   #RX18, TX=17
def read_sio()
    import string
    var msg = ser.read()
    tasmota.cmd(msg.asstring())
    tasmota.cmd(string.format("DisplayText %s ",msg.asstring()))
    print(msg.asstring())
end
And results:
TasmARI-SIO2LCD.jpeg
TasmARI-SIO2LCD.jpeg (851.23 KiB) Viewed 390 times
Have you noticed that some characters are being 'lost' during transmission? Don't worry about that now... I'll just say that it's a result of the length of the wires between SIO -> TasmARI -> ESP32-S3. Eventually, these wires won't be needed, and things should be much better!

Ok. Time to receive data from TasmARI on your Atari using very simple function in Berry:

Code: Select all

def write_sio(text)
    ser.write(bytes().fromstring("text"))
end
run as: be write_sio("Sending some text to Atari") in TasmotaOS console or just write_sio("Sending some text to Atari") in Berry console. During sending data, the SIO_IN LED shall blinking. Each quoted char will be send via TX-GPIO17 pin and received by Atari in POKEY SERIN register.

All things toherter...
...




t.b.c.
Attachments
TasmARI_v2.1R2-KiCAD.zip
(523.65 KiB) Downloaded 14 times

Post Reply