It Lives!

A "new fashioned" televisor, using an Arduino to drive the motor and display.

Moderators: Dave Moll, Andrew Davie, Steve Anderson

It Lives!

Postby Andrew Davie » Thu Mar 23, 2017 10:20 pm

I got it working. Finally!

Of course there's LOTS still to do, but I now have a recognisable - even good - picture! As I noted after this set of experiments, I had tracked down the fault in my display to "something in the WAV file handling". Indeed, that's what it turned out to be. I had originally grabbed some sample WAV playback code from online, and it seemed to work OK. Only there was a hidden flaw deep inside it. The playback mechanism consisted of an interrupt running at 44.1kHz which processed and played samples from a small (64 bytes) buffer. When that buffer was used-up, it switched to a secondary buffer and marked the first one as "empty". A second interrupt looked for empty buffers, and when it found one, proceeded to read 64 bytes from the WAV file on the SD card, and hopefully those two interrupts marched in tandem with each other and everything was happy. Only what I didn't know was that the buffer-filling interrupt did nasty things. Firstly, it switched ALL interrupts off, and then disabled its own interrupt, and then enabled all interrupts. Since my whole system has interrupts happening everywhere, this pretty much screwed with the timing of everything!

The solution was to junk that 2nd interrupt (buffer filling) routine, and move it to the main loop. I had to increase the buffer size a bit to make things happier - for, reading from a SD file at 44.1kHz rate is really pushing things. It's possible, as shown in the video, but I'm inclined to resample the files to something like 22kHz which will really ease the timing pressures on the whole system.


youtu.be/26OWSCWFSZg

The video you see is an episode of Doctor Who - and despite my finger-speed-setting being a bit wobbly, the picture is really pretty good. There's a strange thing where some videos come out "negative" and some "positive" - undoubtedly a sign-error in my code somewhere. That's why the "scanline blank" in this code is white. I still have to do clamping and gamma correction, but you have to admit even without gamma correction this picture doesn't look too shabby!

So this is now a complete standalone system - an Arduino reading NBTV files in real-time from a SD card and playing to a Nipkow disk with the LEDs driven by PWM. It all... actually... hangs together! Pretty stoked, as I worked quite hard to get to this point. Now I need to clean up, refine, and make it solid.

But, yeah... celebrations!
Attachments
VID_20170323_214151.mp4
(11.35 MiB) Downloaded 401 times
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: It Lives!

Postby Andrew Davie » Fri Mar 24, 2017 1:19 am

A quick test with a track resampled to 22050Hz with Audacity - file plays nearly perfectly without any changes to the code at all. The only odd thing is bright white dots in some of the black areas. So there's a bug, but at least all the timers, and basic picture stuff are fairly robust.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: It Lives!

Postby gary » Fri Mar 24, 2017 9:18 am

Gratz Andrew! Looking good. Well done.

I still say, if you are going to resample at all, why not resample to an integer multiple of the video rate?, 32 * 12.5 = 400 So 400*48 = 19200 (abs min), 400*49 = 19600, 400 * 50 = 20000, and so on for any integer n.

This will remove the tearing at the top and bottom of the picture without having to do any nasty filtering :-).
gary
 

Re: It Lives!

Postby Andrew Davie » Fri Mar 24, 2017 10:36 am

gary wrote:Gratz Andrew! Looking good. Well done.

I still say, if you are going to resample at all, why not resample to an integer multiple of the video rate?, 32 * 12.5 = 400 So 400*48 = 19200 (abs min), 400*49 = 19600, 400 * 50 = 20000, and so on for any integer n.

This will remove the tearing at the top and bottom of the picture without having to do any nasty filtering :-).


Good point; I will do this if Audacity allows it. I do see the benefit of optimising the file but also want to make sure the televisor can play anything you throw at it. However, I may have to abandon 44.1kHz - it's right on the limit of capability.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: It Lives!

Postby gary » Fri Mar 24, 2017 11:33 am

It seems that Audacity allows you to specify an arbitrary sample rate for a track, but then won't let you export it as anything other than a limited number of "project" rates.
I am investigating a way around that, in the mean time here is a snippet resampled to 20kHz via cool edit.

Yes I am with you on your system being able to handle anything thrown at it, but that doesn't preclude us from starting from a known point - sort of a "benchmark" for later development.

BTW, is there anyway to get a forum like this capable of supporting custom video formats?, I had a happy thought that it would be cool if posted NBTV wave files appeared as embedded videos on this forum - it could only happen if the forum software supported plugins (or similar) of course, and the video would probably need to be streamed to the browser in some other format it supports, possible but only if the forum software supports it.
Attachments
resample test.wav
(526.95 KiB) Downloaded 406 times
gary
 

Re: It Lives!

Postby Andrew Davie » Fri Mar 24, 2017 11:42 am

gary wrote:BTW, is there anyway to get a forum like this capable of supporting custom video formats?, I had a happy thought that it would be cool if posted NBTV wave files appeared as embedded videos on this forum - it could only happen if the forum software supported plugins (or similar) of course, and the video would probably need to be streamed to the browser in some other format it supports, possible but only if the forum software supports it.


All the forum really does is feed HTML to the browser. The tags that I have added recently just translate directly into HTML code and it's the browser that does the embedding/linking to videos. So if you can get it working in a browser, then yes, I can add a tag into our forum to make that easy to configure and have NBTV file playback. Someone has to write a browser-compatible plugin and that's the hard part :)
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: It Lives!

Postby gary » Fri Mar 24, 2017 12:00 pm

Ok, that makes sense, although limits it to one kind of browser - but everyone uses firefox don't they? ;-)
gary
 

Re: It Lives!

Postby gary » Fri Mar 24, 2017 3:02 pm

Ok, I have solved the problem with changing the Audacity "project rate".

All it is, is the default keyboard bindings have been set to some of the keys you may type into the "project rate" edit box - for instance "1" - has been set to move by 1 second, etc.

Some of the ways around this are:

Remap the offending bindings.
turn num lock on and use the keypad
cut and paste the required value from elsewhere, eg notepad.

It was just bad luck for me that the first rate I tried to enter was 19600 - if I had typed 2000, for instance, it would have accepted it.
gary
 


Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 6 guests

cron