Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:03 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : WAVE recording with Picomite possible???

     Page 1 of 2    
Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 949
Posted: 06:48am 12 Sep 2022
Copy link to clipboard 
Print this post

Hi,

is there a possibility to record WAVEs with a Picomite?
I would like to build a player/recorder to load or save programs on old computers like APPLE][, TRS80 or ZX Spectrum.

Frank
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 420
Posted: 08:05am 12 Sep 2022
Copy link to clipboard 
Print this post

Hi Frank

Interesting question.

Currently I'm playing with variations on Manchester encoding to save bits / bytes as generated by Play Tone -- have figured out how to encode / save as audio tones.  Can generate individual characters a bit like morse code.  

Reading / Decoding is another thing all together and still potching at that.

My use case is to save BASIC to cassette tape (as an educational demo)  -- discovered on Friday that out of a class of 25 13 year olds, not one of them had seen / handled a cassette tape and no one had any idea of the linear nature of the medium.   Amazing what we (50 yos) take as assumed knowledge.

N
Entropy is not what it used to be
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 08:35am 12 Sep 2022
Copy link to clipboard 
Print this post

For saving audio to .WAV there are plenty of PC programs but is that what you need?
If you want to capture the data from a cassette sampling with FIN to an array then decoding should work. A very short FOR/NEXT (all on one line, no extra spaces) can get samples at 15uS intervals. You wont need that speed.
 Probably too much data to do all at once. Do it one chunk at a time saving each one to SD and stitching it together later.
Perhaps the samples could be streamed continuously to a file on a SD card, no stitching. Another program would decode it later.
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 420
Posted: 08:50am 12 Sep 2022
Copy link to clipboard 
Print this post

  phil99 said  If you want to capture the data from a cassette sampling with FIN to an array then decoding should work. A very short FOR/NEXT (all on one line, no extra spaces) can get samples at 15uS intervals. You wont need that speed.
 Probably too much data to do all at once. Do it one chunk at a time saving each one to SD and stitching it together later.
Perhaps the samples could be streamed continuously to a file on a SD card, no stitching. Another program would decode it later.


FIN is the way I'm going - literally this is proof of concept. Happy with 300bps.  The limit of what they are saving will be "Hello World" or similar.  It's more the idea that we are digitizing the output, a "1" looks / sounds like this etc etc.  Now once we go differential manchester its a bit more complex and "1" and "0" dont always sound the same.

N
Entropy is not what it used to be
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 09:26am 12 Sep 2022
Copy link to clipboard 
Print this post

The SETPIN pin,FIN,option command can use a "gate time" in the range of 10ms...100000ms.
The fastest gate time (10ms) will limit the cassette speed to 100 bps if you use FSK.
The SETPIN pin,PIN,option will not give sufficient resolution (response is in ms).

The PIO program I made can help you (in the SSTV thread). The PIO measures single cycle period (which you read out of the buffer). This will work fine for 300 baud FSK (and faster). Simply read buffer, if 1200Hz, read 3 more (there are 4 full cycles at 1200Hz, so there will be 4 entries in the buffer), if 2400, read 7 more (there are 8 cycles of 2400baud).
You will probably need some recovery mechanism, since cassette tape was not famous for it's reliability.

The pico is fast enough to do that.

Volhout
Edited 2022-09-12 19:35 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 420
Posted: 10:27am 12 Sep 2022
Copy link to clipboard 
Print this post

  Volhout said  The SETPIN pin,FIN,option command can use a "gate time" in the range of 10ms...100000ms.
The fastest gate time (10ms) will limit the cassette speed to 100 bps if you use FSK.
The SETPIN pin,PIN,option will not give sufficient resolution (response is in ms).

The PIO program I made can help you (in the SSTV thread). The PIO measures single cycle period (which you read out of the buffer). This will work fine for 300 baud FSK (and faster). Simply read buffer, if 1200Hz, read 3 more (there are 4 full cycles at 1200Hz, so there will be 4 entries in the buffer), if 2400, read 7 more (there are 8 cycles of 2400baud).
You will probably need some recovery mechanism, since cassette tape was not famous for it's reliability.

The pico is fast enough to do that.

Volhout


Perfect - 1200 / 2400 is how I'm recording -- granted at this stage at 1 or 2 bps, but it's a start.

Slow is good as being able to see / hear what is going on is what I'm looking for as opposed to this being practically useful.

Will investigate further.

Cheers
N
Entropy is not what it used to be
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 10:37am 12 Sep 2022
Copy link to clipboard 
Print this post

  Frank N. Furter said  ... is there a possibility to record WAVEs with a Picomite?
...
Frank

I would try ADC for short sequences. Whether saving to SD is fast enough is another story.
Regards
Michael
causality ≠ correlation ≠ coincidence
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 01:30pm 12 Sep 2022
Copy link to clipboard 
Print this post

My FIN idea was useless but 2400Hz is slow enough to sample with DIN. At 208uS per half cycle you can get 13 or 14 samples at 15us between samples. CPU speed 378MHz.
Recently used this method to read a data stream of 25uS and 70uS pulses with 50uS spaces, just to see if the Pico could do it. It can.

See the last edit in this post, hopefully there are enough comments for it to make sense.

https://www.thebackshed.com/forum/ViewTopic.php?TID=13832&P=3#174519
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 01:52pm 12 Sep 2022
Copy link to clipboard 
Print this post

Could CIN be used with your own fixed gate period?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 02:35pm 12 Sep 2022
Copy link to clipboard 
Print this post

  phil99 said  My FIN idea was useless but 2400Hz is slow enough to sample with DIN. At 208uS per half cycle you can get 13 or 14 samples at 15us between samples. CPU speed 378MHz.
Recently used this method to read a data stream of 25uS and 70uS pulses with 50uS spaces, just to see if the Pico could do it. It can.

See the last edit in this post, hopefully there are enough comments for it to make sense.

https://www.thebackshed.com/forum/ViewTopic.php?TID=13832&P=3#174519


Yes, the pico is fast! (just played this weekend with the picaxe 08M2 @4MHz (max 1mA power available at 3.3V) trying to make it decode 333baud (special non UART protocol) and it can't do it in basic. The pico can walk circles around the picaxe without getting tired or stressed at all.

But be aware that the execution speed of the pico varies with releases. Most recently a change was made with WS2812 because the first bit was timed wrong. It is not good practise to time your software with delays of instructions, unless you are at bare metal (assembly language).

But...if it works....it works. Just don't plan a firmware update. Put this version of MMBasic in a locked cabinet, and guard it with your life.

Volhout
PicomiteVGA PETSCII ROBOTS
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 02:56pm 12 Sep 2022
Copy link to clipboard 
Print this post

look up "kansas city standard" (without the quote marks) on google. as i recall, it was common to generate the tones (for saving) with the CPU, but use analog electronics for decoding those tones back into a bit stream.

you may find it easiest to use a 300 baud modem chip to generate and decode the tones, such as the MM74hc942, MC145442, or similar. cheap on ebay these days. different encoding to KCS, but this is hardly going to matter for demonstration purposes. presumably you'd like to display the signal on an oscilloscope?

paper tape (punched) would also make for a nice demo if you could find the hardware!


cheers,
rob   :-)
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 03:24pm 12 Sep 2022
Copy link to clipboard 
Print this post

Classic = LM567 set to 1200Hz
PicomiteVGA PETSCII ROBOTS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 03:48pm 12 Sep 2022
Copy link to clipboard 
Print this post

The original CUTS standard used 4 cycles at 1200Hz for a space bit and 8 cycles at 2400Hz for a mark. There were several variations later, but it's somewhere to start. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 04:09pm 12 Sep 2022
Copy link to clipboard 
Print this post

  Volhout said  Classic = LM567 set to 1200Hz


   

circuit here, around halfway down the page:
http://www.mikekohn.net/micro/tape_data_recorder.php


you could feed the output from pin 8 of the LM567 straight into the console's RxD input. and to generate output to record onto the tape an LM555 may well suffice, changing between 1200Hz and 2400Hz (google "555 two tone") with the console TxD pin.

this way LIST would "save" a program, and AUTOSAVE would "load" it.


cheers,
rob   :-)
Edited 2022-09-13 02:11 by robert.rozee
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 06:49pm 12 Sep 2022
Copy link to clipboard 
Print this post

Roman Black has some interesting sound stuff on his web page. There might be some useful ideas there.
Visit Vegipete's *Mite Library for cool programs.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 07:11pm 12 Sep 2022
Copy link to clipboard 
Print this post

- start a program with a set of ''''' as a leader.
- save with 2 stop bits, load with 1 stop bit to compensate for speed variations in the tape.

Very basic, but it should work. There is however a reason why the later systems used blocks of data with crc. Apparently load failures where quite common those days.
Edited 2022-09-13 05:14 by Volhout
PicomiteVGA PETSCII ROBOTS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 11:02pm 12 Sep 2022
Copy link to clipboard 
Print this post

@Volhout
" It is not good practice to time your software with delays of instructions,"

Indeed, to minimize that problem relative timing is what I used, as long as there are at least a few samples in each received element their lengths can be compared. At the point where the bit values are decided there is also compensation for different CPU speeds.
Better still would have been to scan all the data to find the average number of samples for long and short elements then decode based on that. It just seemed too much effort for something that had no practical value.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 01:01am 13 Sep 2022
Copy link to clipboard 
Print this post

An interesting retro idea!  
As I used the Atari 1010 cassette thing in the 80's, I remember the programs on cassette thing well.  I also remember how much of a pain in the arse it was, slow and not exactly reliable a lot of the time, but it was MUCH cheaper then a fancy floppy disk drive at the time, so everyone started out with cassettes.

I know this is more about very simple audio just for educational purposes, but the concept is the same DAC-ADC kinds of conversion so a cassette tape can be your storage medium, so watching this thread with nostalgia-nerd interest.
Smoke makes things work. When the smoke gets out, it stops!
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 06:43am 13 Sep 2022
Copy link to clipboard 
Print this post

At the bottom of this page is some info about the ZX80/ZX81 cassette system and file fomat.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 949
Posted: 06:43am 13 Sep 2022
Copy link to clipboard 
Print this post

Hi guys,
thanks a lot for your input!

The solution with the LM567 looks very interesting - if someone could help me a bit more? I have too little experience...

Frank
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025