Page 1 of 1

AVR microcontroller based sync circuit

PostPosted: Mon Jul 31, 2017 7:05 pm
by smeezekitty
I've started working on a AVR based NBTV sync circuit which implements PLL in software. I have experience working with AVRs already so that's why I decided to try.
I did some prototyping and so far the results are promising. For now I'm just using an Arduino but if it works out, I can build it into a stand alone circuit.
PLL is implemented by waiting for a pulse from the disk encoder and the signal input. When a pulse is received, the timestamp is recorded and then they are compared.
The motor is driven by PWM (through the mosfet) using PID speed control which tries to minimize the time between the two pulses.
Right now I am only doing frame sync instead of line sync because I don't have good enough sync separation to get individual line pulses. In fact, even finding the missing
pulse for the frame sync is kinda dodgy and it tends to fall out of sync if there is too much white in the picture.

This is the sync separation circuit that I built. Does anyone have suggestions on how to get more reliable sync pulse separation?
Image

You can probably figure out the idea of how it's supposed to work. The positive parts of the signal over 1.2V with bias (diode drop + transistor drop) will turn on the transistor pulling the output down.
The negative half of the signal (Sync pulses) turn the transistor off letting the voltage at the collector go up. It "kind of" works. But it is affected by luminosity way too much. So I have to adjust the bias put for every picture.
So it fails for most moving pictures.

Re: AVR microcontroller based sync circuit

PostPosted: Tue Aug 01, 2017 12:13 am
by Andrew Davie
smeezekitty wrote:I've started working on a AVR based NBTV sync circuit which implements PLL in software. I have experience working with AVRs already so that's why I decided to try.
I did some prototyping and so far the results are promising. For now I'm just using an Arduino but if it works out, I can build it into a stand alone circuit.
PLL is implemented by waiting for a pulse from the disk encoder and the signal input. When a pulse is received, the timestamp is recorded and then they are compared.
The motor is driven by PWM (through the mosfet) using PID speed control which tries to minimize the time between the two pulses.




Have you been following my Arduino Televisor build? I do use a single hole per frame (i.e., frame synch only, no line synch) PID running on an Arduino and am getting excellent frame (and line! lock).

Re: AVR microcontroller based sync circuit

PostPosted: Tue Aug 01, 2017 3:03 am
by smeezekitty
Andrew Davie wrote:
smeezekitty wrote:I've started working on a AVR based NBTV sync circuit which implements PLL in software. I have experience working with AVRs already so that's why I decided to try.
I did some prototyping and so far the results are promising. For now I'm just using an Arduino but if it works out, I can build it into a stand alone circuit.
PLL is implemented by waiting for a pulse from the disk encoder and the signal input. When a pulse is received, the timestamp is recorded and then they are compared.
The motor is driven by PWM (through the mosfet) using PID speed control which tries to minimize the time between the two pulses.




Have you been following my Arduino Televisor build? I do use a single hole per frame (i.e., frame synch only, no line synch) PID running on an Arduino and am getting excellent frame (and line! lock).

I have. It's very interesting but not exactly what I want to do because I want to use the ADC to sync to an incoming signal instead of read it off an SD card

Re: AVR microcontroller based sync circuit

PostPosted: Wed Aug 02, 2017 12:06 pm
by smeezekitty
Andrew Davie wrote:
smeezekitty wrote:I've started working on a AVR based NBTV sync circuit which implements PLL in software. I have experience working with AVRs already so that's why I decided to try.
I did some prototyping and so far the results are promising. For now I'm just using an Arduino but if it works out, I can build it into a stand alone circuit.
PLL is implemented by waiting for a pulse from the disk encoder and the signal input. When a pulse is received, the timestamp is recorded and then they are compared.
The motor is driven by PWM (through the mosfet) using PID speed control which tries to minimize the time between the two pulses.




Have you been following my Arduino Televisor build? I do use a single hole per frame (i.e., frame synch only, no line synch) PID running on an Arduino and am getting excellent frame (and line! lock).

Progress!

I designed a new sync seperator circuit using an op amp configured as a "precision rectifier". There are still some situations where video will come through the sync or it'll miss a couple pulses but overall it is much, much better than the transistor circuit. It also makes a nice 4V square wave that I can use to trigger a digital pin on the AVR (which have schmitt triggers). No more worrying about ADC thresholds or double triggering. Now I've mostly been spending time tuning the PID loop. The hardest part is to avoid oscillations if there is a disturbance.

This shows the PID parameters as it spins up from zero and locks.
Blue is phase error, Green is the derivative term, Yellow is the integral term and Red is the motor PWM duty cycle.
Image

Re: AVR microcontroller based sync circuit

PostPosted: Wed Aug 02, 2017 5:49 pm
by AncientBrit
Hi smeezekitty ,

I've attached two circuits I've developed in the past.

Both work well with rapidly changing average picture levels (APL).

The first is a variant on your PNP sync separator where the base/emitter junction DC restores on the most negative part of the NBTV signal.
IC1A provides a modest amount of gain and gives a more reliable operation.
The 220k to the base of the PNP provides a small amount of bias and also aids recovery after an APL change.
If you don't want the LPF action then remove the caps.

The second circuit dc restores the signal using the perfect diode combination of IN914 and LM358.
One half of the LM358 is used as a sync slicer fed from the now DC restored signal.

Hope these may be of use to you.

Cheers,

Re: AVR microcontroller based sync circuit

PostPosted: Tue Aug 15, 2017 9:44 am
by Robonz
I have been thinking on this. If you had enough bandwidth in the micro, you could do the whole lot in firmware. You could ADC the complete video signal and extract the sync's with software. The micro would have a video in on an ADC pin. An opto in for the line sensor. PWM for the light source and PWM for the motor. Add a few ADC knobs for contrast brightness and gamma etc. Just a handful of components.

I have looked at the Arduino's and think they might be a bit under powered on the ADC speed, I am not really sure though. If you got trickier you could buffer a video frame so the motor speed does not need to be "as" accurate. It could render from the buffer. Again the Arduino runs out of ram except for maybe a mega. I have some Silabs mircos lying around which I am considering for an attempt. They have 200K ADC's. I guess to do it well an Arm Cortex would nail it.

Just some thoughts

Cheers
Keith

Re: AVR microcontroller based sync circuit

PostPosted: Tue Aug 15, 2017 3:28 pm
by smeezekitty
AncientBrit wrote:Hi smeezekitty ,

I've attached two circuits I've developed in the past.

Both work well with rapidly changing average picture levels (APL).

The first is a variant on your PNP sync separator where the base/emitter junction DC restores on the most negative part of the NBTV signal.
IC1A provides a modest amount of gain and gives a more reliable operation.
The 220k to the base of the PNP provides a small amount of bias and also aids recovery after an APL change.
If you don't want the LPF action then remove the caps.

The second circuit dc restores the signal using the perfect diode combination of IN914 and LM358.
One half of the LM358 is used as a sync slicer fed from the now DC restored signal.

Hope these may be of use to you.

Cheers,

Thanks! :)

I've been playing around with it here and there and I seem to have it working reasonably well with an op amp. But I i'll have to mess with it some more.
I have looked at the Arduino's and think they might be a bit under powered on the ADC speed, I am not really sure though. If you got trickier you could buffer a video frame so the motor speed does not need to be "as" accurate. It could render from the buffer. Again the Arduino runs out of ram except for maybe a mega. I have some Silabs mircos lying around which I am considering for an attempt. They have 200K ADC's. I guess to do it well an Arm Cortex would nail it.

You can increase the ADC clock and get 50+KHz sample rates. But yeah an Atmega328 (Arduino) wouldn't really have enough RAM to buffer an entire frame