Page 1 of 3

VIC or C64 as Morse code key oscillator?

Posted: Thu Feb 04, 2010 10:50 pm
by rwv01
Hi
I wonder if anyone here do this.
I would like to use either my VIC-20 or C64 as an oscillator for generating Morse code via a code key connected to the control port.

The code would need to work in real time and produce a tone for as long as the key is pressed.

I have tried some type-in programs that do generate tones but am so far unable to get the result I want.

Posted: Fri Feb 05, 2010 5:20 pm
by Mike
This program checks the joystick fire button to produce a tone.

Code: Select all

10 FORT=673TO707:READA:POKET,A:NEXT:SYS673
11 DATA 120,169,5,141,14,144,169,178,141,20,3,169,2,141,21,3,96,216
12 DATA 162,224,173,31,145,41,32,240,2,162,0,142,12,144,76,191,234
It runs every 1/60th of a second in the IRQ to update the on/off status of the tone.

Greetings,

Michael

Posted: Fri Feb 05, 2010 9:36 pm
by rwv01
Cool, Thanks Mike!
I tried this on my VIC and it works very well in real time.
Now I need to know how to change the frequency of the tone and the volume if possible.

I'm testing the oscillator with a ham radio interface that requires the input tone to be within a certain frequency range. 369.994 Hz (F# 4 on piano) works well.

How can I change these variables?

Posted: Sat Feb 06, 2010 4:27 am
by Mike
POKE 675,x changes the volume, x=0..15
POKE 692,x changes the frequency, x=128..255
POKE 703,x changes the voice, x=10..12 (x=13 would be noise)

The frequency output depends on NTSC/PAL. These are the nearest values around 369.994 Hz (location 703 unchanged):

Code: Select all

NTSC: POKE 692,211 => 363.2 Hz
      POKE 692,212 => 371.6 Hz <- nearest

PAL:  POKE 692,208 => 368.5 Hz <- nearest
      POKE 692,209 => 376.5 Hz
The frequency resolution in that range is already very coarse. :(

Posted: Sat Feb 06, 2010 2:18 pm
by pitcalco
Amazing, Mike! :shock:

Is there anything you *can't* do on a VIC 20?

Posted: Sun Feb 07, 2010 12:48 am
by rwv01
Thanks again, Mike.
That did it! The interface responds to the oscillator now.
The frequency variable I used was 234.
The frequency resolution seems to be fine at this setting.

Posted: Sun Feb 07, 2010 3:30 pm
by RobertBe
rwv01 wrote:I'm testing the oscillator with a ham radio interface that requires the input tone to be within a certain frequency range.
That must be the Kantronics transceiver that goes with the Hamtext cart for the VIC-20. :)

Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug
The Other Group of Amigoids
http://www.calweb.com/~rabel1/
Southern California Commodore & Amiga Network
http://www.sccaners.org

Posted: Sun Feb 07, 2010 6:05 pm
by rwv01
RobertBe wrote:That must be the Kantronics transceiver that goes with the Hamtext cart for the VIC-20. :)
Yep! Though actually, the tranciever is the radio it interfaces with.
Since we won't have a radio at the FCUG meeting, I have recorded some signals for the demo of the interface. But now, with the help of Mike's oscillator program, and a code key lent by my dad, (thanks to both!) I think we have a way to do a live demo of it's Morse code translation function. I'll use my VIC-20 to transmit a signal to yours via your radio Interface. We just plug it into my monitor's headphone jack instead of a short wave radio's. In the mean time I'll bone up on Morse! (It's been a long time :) )

Posted: Mon Feb 08, 2010 2:57 am
by RobertBe
rwv01 wrote:I think we have a way to do a live demo of it's Morse code translation function. I'll use my VIC-20 to transmit a signal to yours via your radio Interface. We just plug it into my monitor's headphone jack instead of a short wave radio's.
Yow! That sounds like a kind of network to me. :)

Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug
The Other Group of Amigoids
http://www.calweb.com/~rabel1/
Southern California Commodore & Amiga Network
http://www.sccaners.org

Posted: Thu Feb 11, 2010 1:15 pm
by rwv01
I've tried it with my dad's morse code key (a J-38 streight key),
and it works very well. Their is no problem with latency.

I wonder though, is there a way to adapt this program to use on the C64 as well?

Posted: Thu Feb 11, 2010 1:57 pm
by carlsson
Sorry for getting off-topic (the C64 is considered grossly off-topic at Denial) but this my adaption of Mike's program:

Code: Select all

10 fort=679to731:reada:poket,a:next:sys679
15 data120,169,5,141,24,212,169,0,141,0,212,141,5,212,169,37,141,1
20 data212,169,240,141,6,212,169,203,141,20,3,169,2,141,21,3,88,96
25 data216,162,33,173,0,220,41,16,240,1,202,142,4,212,76,49,234
As you can see it gets significantly longer due to the more complex sound setup. I also added a CLI before RTS, which perhaps is not required. I don't know why CLD in the IRQ routine, but I'm sure Mike has a good reason for using it.

The SID offers much better tuning so I could set up the sound to the exact frequency you need, but since the VIC-20 frequency works fine, this one should too. The sawtooth sound is more shrill than the VIC pulse wave but I couldn't be bothered to spend another ~10 bytes to set up the pulse width.

Oh yes, the parameters:

POKE 681 for volume, currently 5
POKE 694 for crude frequency, currently decimal 37
POKE 699 for sustain level + release, currently 240 = 15 + 0

You need to SYS 679 after changing those three.

POKE 717 for waveform, currently sawtooth (33)

Posted: Thu Feb 11, 2010 4:11 pm
by RobertBe
rwv01 wrote:...is there a way to adapt this program to use on the C64 as well?
That would require a dump of the Hamtext ROM. The FCUG member who can do that is Andrew Wiskow, but he is 4-5 hours away.

Unless we mail the chip to him,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug
The Other Group of Amigoids
http://www.calweb.com/~rabel1/
Southern California Commodore & Amiga Network
http://www.sccaners.org

Posted: Thu Feb 11, 2010 5:14 pm
by rwv01
RobertBe wrote:
rwv01 wrote:...is there a way to adapt this program to use on the C64 as well?
That would require a dump of the Hamtext ROM. The FCUG member who can do that is Andrew Wiskow, but he is 4-5 hours away.
Sorry, Robert, I meant Mike's oscillator program. (though I have seen references to Hamtext for the C64)

Since I only have one VIC-20 and one C64 my self, and your Hamtext cart is for the VIC, A C64 version of the oscillator would allow me to have my VIC receive while my C64 sends for a better test than I'm able to do with just the VIC alone. I tried using VICE for the oscillator but the tone comes out choppy.

Thanks very much Carlsson! I'll try this version out ASAP and let you know how it works.

Posted: Fri Feb 12, 2010 1:13 am
by rwv01
Boy, this thing's demanding near perfect timing! :)
For example, it often reads an L (. - . .) as E T E E (. - . .).
I'll have to play with the perameters ofcourse, practice my Morse!
(which I havn't done since oh, 1985.)

>Robert
Man! If I hadn't tested it this way first, we would have spent half the meeting trying to get the interface to translate my Morse correctly.

Posted: Sat Feb 13, 2010 12:26 am
by RobertBe
rwv01 wrote:If I hadn't tested it this way first, we would have spent half the meeting trying to get the interface to translate my Morse correctly.
Heh, we'll have other things going on at the FCUG meeting while you practice. ;)

Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug
The Other Group of Amigoids
http://www.calweb.com/~rabel1/
Southern California Commodore & Amiga Network
http://www.sccaners.org