Close
0%
0%

VIC-20 RTC

This is a real time clock for a Commodore VIC-20 (and likely C64) that communicates over the serial (IEC) port.

Similar projects worth following
Since the VIC-20 doesn't have an internal Real Time Clock, this project provides one that can be read through the serial (IEC) port like an external peripheral. The inspiration was a real time clock peripheral that came out in the 80s by Hayes to provide a clock for computers that used a serial port. The project uses an Arduino Uno and a Dallas DS3231 RTC breakout board. The software uses an IEC driver sketch developed by Lars Pontoppidan for his MM2IEC project. Thank you Lars! It also uses an Adafruit DS3231 driver for talking to the real time clock IC. Since this is a "one-off" type of project, off-the-shelf boards are used along with a project box, a couple of 6 pin DIN connectors and a 1k resistor network. I set the RTC to be at address 12 on the serial bus with 3 sub addresses. Sub address 1 is for the time, Sub address 2 is for the date and Sub address 7 is for setting the clock. All communications can be done using Commodore BASIC.

The intent is to be able to use the RTC in Commodore BASIC programs that need a real time clock.   Programs like a display clock, reminders, or anything else that needs the date and time.  All times are in 24 hour format.

The RTC can be hooked into the daisy chain with disk drives and printers, so it is just another peripheral to the computer.   

I don't have a Commodore 64 to test with, but since the IEC protocol is the same, it should work just fine with a C64.

Here is BASIC code to read the time and date:

10 OPEN 1,12,1 { open connection to read time }
20 INPUT#1, A$ { read the time = hhmmss}
30 PRINT"{CLEAR}"
40 PRINT LEFT$(A$,2); { display hh:mm:ss }
45 PRINT ":"
50 PRINT MID$(A$,3,2);
55 PRINT ":"
60 PRINT RIGHT$(A$,2)
90 CLOSE 1 { close connection }
100 OPEN 1,12,2 { open connection to read date }
110 INPUT#1, B$ { read the date = yymmdd }
120 PRINT MID$(B$,3,2); { display mm/dd/yy }
130 PRINT "/"
140 PRINT RIGHT$(B$,2);
150 PRINT "/"
160 PRINT LEFT$(B$,2)
200 CLOSE 1

And here is BASIC code to set the time and date:

10 OPEN 1,12,7 { open connection to set time/date }
20 PRINT#1,"YYMMDDhhmmss" { substitute current time and date digits }
{ YY = year, MM = month, DD = day }
{ hh = hour (24), mm = minute, ss = seconds }
30 CLOSE 1 { close connection }

For example, PRINT#1, "250801202235" would set the time and date to Aug 1, 2025, 8:22:35 PM.  

RTC_test.txt

Commodore BASIC test program with comments added

plain - 533.00 bytes - 08/02/2025 at 01:04

Download

RTC_SET.txt

Commodore BASIC program to set the RTC

plain - 280.00 bytes - 08/02/2025 at 01:04

Download

RTC schematic.pdf

Schematic of the hardware design

Adobe Portable Document Format - 28.77 kB - 08/02/2025 at 01:04

Preview

VIC20_RTC.ino

Arduino sketch for the main program

ino - 4.18 kB - 08/02/2025 at 01:03

Download

IEC_driver.ino

Driver for IEC adapted from Lars' MM2IEC project

ino - 12.22 kB - 08/02/2025 at 01:03

Download

View all 6 files

  • 1 × Arduino Uno
  • 1 × Arduino Uno prototyping shield
  • 1 × DS3231 RTC breakout board
  • 1 × 1K x 5 Resistor Network
  • 2 × 6 pin DIN connector

View all 9 components

  • Overview

    David Hunter08/02/2025 at 01:29 0 comments

    The project was developed from May to July 2022.   It went together fairly well.    The biggest issue was understanding the IEC protocol and adapting the work by Lars on the MM2IEC to this project.   I didn't need all of the capabilities that a disk drive needs, so I took out the parts that weren't needed.   Having the IEC driver was a HUGE help in getting this working. 

    The hardware is straight forward, and by using an Arduino Uno and a proto shield to hold the RTC module.   As I recall, I got the boards from Amazon.   It uses point to point wiring.     I used an old Radio Shack project box that I had laying around.   A project box or 3D printed case would work fine.

View project log

  • 1
    Building tips

    All of the parts should be available from multiple sources.   Chances are you have most of the parts on hand.   The software could be adapted to other Arduino boards.  Wiring is not critical for this project.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates