AVR microcontroller based sync circuit

Forum for discussion of narrow-bandwidth mechanical television

Moderators: Dave Moll, Andrew Davie, Steve Anderson

AVR microcontroller based sync circuit

Postby smeezekitty » Mon Jul 31, 2017 7:05 pm

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.
smeezekitty
Just nod and pretend you understand me
 
Posts: 229
Joined: Fri Jan 29, 2010 11:42 am
Location: USA

Re: AVR microcontroller based sync circuit

Postby Andrew Davie » Tue Aug 01, 2017 12:13 am

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).
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: AVR microcontroller based sync circuit

Postby smeezekitty » Tue Aug 01, 2017 3:03 am

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
smeezekitty
Just nod and pretend you understand me
 
Posts: 229
Joined: Fri Jan 29, 2010 11:42 am
Location: USA

Re: AVR microcontroller based sync circuit

Postby smeezekitty » Wed Aug 02, 2017 12:06 pm

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
smeezekitty
Just nod and pretend you understand me
 
Posts: 229
Joined: Fri Jan 29, 2010 11:42 am
Location: USA

Re: AVR microcontroller based sync circuit

Postby AncientBrit » Wed Aug 02, 2017 5:49 pm

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,
Attachments
NBTV Sync Separator 1.jpg
Sync sep 1
(55.98 KiB) Not downloaded yet
NBTV Sync Separator 2.jpg
Sync sep 2
(77.52 KiB) Not downloaded yet
AncientBrit
Green padded cells are quite homely.
 
Posts: 858
Joined: Mon Mar 26, 2007 10:15 pm
Location: Billericay, UK

Re: AVR microcontroller based sync circuit

Postby Robonz » Tue Aug 15, 2017 9:44 am

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
User avatar
Robonz
Evil Genius
 
Posts: 149
Joined: Sat Aug 12, 2017 7:15 pm
Location: New Zealand

Re: AVR microcontroller based sync circuit

Postby smeezekitty » Tue Aug 15, 2017 3:28 pm

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
smeezekitty
Just nod and pretend you understand me
 
Posts: 229
Joined: Fri Jan 29, 2010 11:42 am
Location: USA


Return to Mechanical NBTV

Who is online

Users browsing this forum: No registered users and 26 guests