Pixel Perfect frame lock AND custom vertical position!

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

Moderators: Dave Moll, Andrew Davie, Steve Anderson

Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Sun Apr 23, 2017 2:43 am

I had a flash of inspiration.

I've spent quite a few hours testing (and failing) on getting the video in the correct position in the frame. Generally I've been doing this by calculating during the infra-red interrupt just how far "out" the video is, based on the video playback pointer. And then I was trying to add an offset to the video playback to adjust that. Unfortunately the playback pointer is ALSO the "system clock" so that added all sorts of complications.

And then I thought... "hey, why not just spin the DISC a little faster/slower"? So I tried that, and it's fantastic. The video here shows the first version in action - the adjustment is only 1 pixel/frame so it takes ages to adjust. But I can increase that by an (almost) arbitrary amount and make the shifting MUCH quicker. But the really neat thing here is that I can be pixel-perfect on the video position not only horizontally but ALSO vertically. And so in the video you see three or four "starts" and after the initial PID synch (still slow, but reliable), then it goes into the "vertical/horizontal picture shift" and stops/stabilises with the frame EXACTLY framed vertically and horizontally. It's a thing of beauty. And all it took was about 3 lines of code... here's the infra-red servicing interrupt with the added code commented.

Code: Select all
ISR(ANALOG_COMP_vect) {

  timeDiff = playbackAbsolute;
  double deltaSample = timeDiff - lastDetectedIR;
  if (deltaSample > 1000) {         // cater for potential "bounce" on IR detect by not accepting closely spaced signals
    lastDetectedIR = timeDiff;

    interrupts();

    // The following 3 lines of code are the complete code for perfect horizontal/vertical framing
    // Achieved simply by changing the rotation speed of the disc ever so slightly
    pbDelta = playbackAbsolute % singleFrame;
    if (pbDelta > 45) {                                            // The 45 gives us vertical positioning - hardwired here for my monitor
        lastDetectedIR-= 1;
    }

    Setpoint = 0;
    Input = singleFrame-deltaSample;
    Compute();          // PID
    OCR0B = (byte)(Output+0.5);        // write motor PWM duty
}


So, for just three lines of code to solve two problems (horizontal AND vertical framing). It's amazing.
Here's the video... the first 'lock' happens at 54 seconds, if you're impatient.


youtu.be/zXrc1Xl-fEc


I'm going to make it faster, of course - but for now I'm really incredibly happy with this solution :) It's elegant.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Klaas Robers » Sun Apr 23, 2017 3:00 am

Can it also do this trick by shifting slowly downwards, when the "horizontal split" is on the right half of the picture? It should be not too difficult to calculate which way is the fastest, isn't it?
User avatar
Klaas Robers
"Gomez!", "Oh Morticia."
 
Posts: 1656
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Sun Apr 23, 2017 3:04 am

Klaas Robers wrote:Can it also do this trick by shifting slowly downwards, when the "horizontal split" is on the right half of the picture? It should be not too difficult to calculate which way is the fastest, isn't it?


Yes, of course :) Easy as. And currently the "step" is just -1, but it can be -10 or -20 or something much bigger to do the shifting quicker. The only proviso is that too big and you affect the PID. I will play with the values over the next few days and hopefully have an optimal direction framer happening relatively rapidly.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Sun Apr 23, 2017 4:02 am

Here's a quick'n'dirty test with a much higher adjustment rate. Clearly I need to sort out the PID overshoot but ignore that for now. Once the PID is roughly locked, then the framer code has more of an influence and it fairly rapidly moves the frame to correct horizontal/vertical. I run through a couple of minutes testing in this video. I think it will be excellent once fine-tuned.


youtu.be/Qc6inqyChfo
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Sun Apr 23, 2017 10:54 am

A cool consequence of this method is that it doesn't matter where the synch hole is on the disc - can be absolutely anywhere! All the synch hole does is guarantee that the interrupt runs once per disc revolution. The 'vertical hold' offset caters for getting the frame locked based on a comparison between internal variables, not the hole position. In other words, it's very robust and not sensitive to the hardware configuration. Speaking of the synch hole, I'm thinking of getting rid of it altogether, and just using one of the scanline holes for synch. That would make construction of a disc simpler yet... no synch holes at all, and the IR LED could be near the edge of the disc. I need to do some experiments to see how good an IR signal I can get through a smaller hole.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Mon Apr 24, 2017 12:23 am

I've done some work on decreasing the time required to lock to perfect frame position from a cold start. It seems clear that I'm going to have to do a bit of special-casing to tailor various parameters to this particular disc and its idiosyncrasies . In any case, this isn't too bad for achieving synch. I can do better, though! The video playing is D.F.McLean's reconstruction of the BBC live recording from the 1930s. It's copyrighted, but I believe this to be fair-use. I did a screen capture of the YouTube video showing this clip playing in an emulator, and then converted the result into my NBTV8 format for playing on my televisor. The various online pictures and animating GIFs of Betty Bolton singing in the 1930s were the reason I became interested and decided to build my own televisor in the first place.


youtu.be/p8-ScIRu1AA
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Pixel Perfect frame lock AND custom vertical position!

Postby Andrew Davie » Mon Apr 24, 2017 10:18 pm

I did some more work on optimising the startup. It's pretty quick now. I thought I'd do a video showing successive startups to evaluate the repeatability and variation and, well, basically show it off. It's taking around 7-9 seconds, pretty consistently. I know it's getting boring seeing the same thing again and again... I'm going to work on the UI tomorrow and allow selection of the file to play from a menu of files on the SD card. But for now, here's the multi-run video of startup synchs...


youtu.be/xvPTrWd396Y
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia


Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 4 guests

cron