로그인회원등록 내글장바구니주문조회현재접속자
 상품 검색








 게시판 검색





 
 
회원등록 비번분실


온라인 입금계좌
ㆍ기업은행
ㆍ219-043192-01-028
ㆍ이건영

      거래은행 바로가기
 
 SX, MPU Applications
SX, MPU 자료실
작성자 leeky        
작성일 2006/03/16
첨부#2 sx18_videosync_det.jpg (0KB) (Down:8)
Link#1 hsync-ng.htm (Down:46)
ㆍ추천: 2  ㆍ조회: 2208   
  SX18 영상(NTSC) 동기검출

Untested SX code for detecting video sync with the onboard comparator
Nikolai Golovchenko says:

Sync detection is sure possible with a SX. I made a quick test on the evaluation board (50 MHz SX28),
 just for horizontal sync, using the comparator to catch the sync pulses.
 It works in most cases, but sometimes, when video is bad quality (noisy, but screen is stable) lines
 are missed with that setup. There are a few problems:

1) Comparator lowest input voltage level is 0.4V. With a 0 to 1V video,
sync threshold is at about 0.15V. So it is out of specs, though seems to be working.

2) Noise. I wonder how screen remains stable even when signal is noisy.
There must be some filtering in a TV. I'll try to dig the sync separator circuit from an old TV.

3) SX counts the pulse width in a loop like:
measure_ov2
mov w, #5
mov dx, w
measure3
mov w, #128-100
mov RTCC, w
mov w, #compMode
measure3a
mov !RB, w
mov temp, w
snb temp.0
jmp measure_ok
sb RTCC.7 ;or any other reg my be used for
;counting
jmp measure3a
decsz dx
jmp measure3
;too long - repeat pulse catch
jmp wait_1

.
The inner loop takes 8 cycles (without comparator that would be 6 cycles).
So the comparator is sampled every 8 cycles, and maximum jitter in sync detection is 8 cycles.
That can be visible if SX frequency is too low.
Probably, it will be better to build an external circuit on a transistor and not use the comparator altogether.

Nikolai Golovchenko says:
Okay, synchronizing to horizontal pulses video in software works now.
The trickiest part was to lock to sync pulses with the free running internal oscillator.
Even the smallest errors (under 0.01 us per line) build up very quickly and synchronization fails...
The program implements only horizontal sync locking,
but vertical sync pulses detection should be a bit easier since they coincide
with horizontal ones. Here is the details:

I used the built-in comparator and a DC level shifter to separate sync pulses.
 Here is the circuit in ascii 'art'.

The resistors R2,R3 and diode VD1 set about a 60 mV threshold
above the sync pulses lower level (sync pulses are negative going).
Surprisingly, the comparator negative input reference should have been taken *above*
the transistor base (as it is in the circuit).
One would assume that BE voltage drop is about 0.6V and the negative input
of comparator is already 0.6V above the sync 'floor'.
 
But it is not so. The capacitor C2 has almost no way to discharge and consequently it is charged
with very low current and the BE drop is about 0 V.
Therefore, the sync floor potential is equal to the voltage set by divider at the transistor base.
 When the charging current rises, which happens when a new sync pulse arrives,
so does the difference between comparator inputs, so the pulse at this moment is not missed.

The circuit takes 3 pins: 2 comparator inputs and 1 output.
Comparator output could be checked by polling its configuration register,
 but it takes 3 instructions to check it this way:

waitHigh mov !RB, w ;exchange comparator conwfiguration
;with w (mode = $08)
mov temp, w
sb temp.0
jmp waitHigh ;6 cycles in loop
while it takes just 1 instruction to check the port pin

waitHigh sb RB.0
jmp waitHigh ;4 cycles in loop
So I chose to sacrifice the pin as it is better to sample the comparator output a little faster
(and smaller code size too).

Locking to the HSync frequency is the most difficult part here.
As Simon Nield suggested I use two PLL modes:

1.) Crash PLL. It is used after chip reset and when too many sync pulses are missed.
On each external pulse (longer than 2 us) SX resets RTCC and calculates error on the next pulse.
Errors are summed up for 256 samples and the timer load value is corrected
with the average error value.
The timer load value is 16 bit, higher byte adds directly to RTCC and lower one to phase accumulator.
This mode works until average error goes low enough. After that the SX enters the fine PLL mode.

2.) Fine PLL. This is the hardest part. In this mode, the RTCC load value is not corrected
(that is the line is assumed to have a fixed length), only RTCC is corrected.
The correction value is produced by a low pass filter, which averages the errors.
This works like an integral term in a PI regulator.
I found out that proportional term (subtracting current error from RTCC) doesn't help really,
because the error signal is so noisy that subtracting it from RTCC results in passing the noise further.
It works pretty well for a wide range of video sources, maybe just a bit worse than the TV circuit.
Another possible issue may be that a line can have slightly different length for a different video source. That may result in a different position of overlaid image on the screen,
because the clock is not adjusted, only its period is adjusted by PLL.

By the way, this was tested on SECAM,
but I think NTSC and PAL are very close to SECAM in the horizontal sync parameters.
 In SECAM horisontal period is 64 us, sync pulse is 4.7 us, and equalizing pulses are 2.35 us.
Next step is vertical sync...

; PLL Syncronized signal over video (horizontal sync)
; SX28-52 demo board
; Crystal: 50 MHz
; Connections:
; Connections:
; RB3 - button (active low)
; RA0 - output --//---|>|--- to video
; R1 220 VD1
; RB0 - comparator output (sync active low)
; The program locks to horizontal sync pulses and outputs
; two vertical lines when the button is pressed.
;
; RTCC is used without prescaler as a time base. A full line
; takes 64us*50=3200 cycles or 12.5 periods (overflows) of timer.
; At the start of each line a phase variable (default is 128) is
; added to RTCC, so RTCC overflows 13 times per line.
;
DEVICE SX28AC, BANKS8, PAGES4
DEVICE OSCHS3, TURBO, OPTIONX
RESET start
첨부된 압축파일을 내려받기 하십시요.

■ Reference : RS-170 Wave form
 
 

RS-170 Sync wave form
 

The color subcarrier frequency is chosen such that the black and white dots produced
by the color subcarrier appear as white and black dots in the next frame.
[ed: every second field (odds and evens) has opposite chroma polarity]
Your eye then averages these out removing the effects of the color subcarrier on b/w television receivers.

NTSC vertical sync was designed to be easily implemented on very cheap and primitive hardware,
 thus, it's just a little bit funky! What happens is this.
Each frame takes up 525 lines' worth of time,
and believe it or not, each field is exactly 262.5 lines long.
 
The magic of vertical sync happens during nine lines' worth of time
at the top of each field, called the vertical interval.
Three lines' worth of time is spent sending six pre-equalization pulses.
Then three lines' worth of time is spent sending six actual vertical sync pulses.
Finally three lines' worth of time is spent sending *either* six or seven post-equalization pulses.
You probably already guessed that it is the second field that gets the extra post-eq pulse
and its purpose is to account for a half line offset.

Inside even the most ancient TV set is a PLL that locks to the horizontal sync pulses
 in order to accomplish horizontal sync.
In order to make sure that the PLL wouldn't lose sync,
the NTSC standard guarantees that a continuous stream
 of pulses shall arrive at the horizontal sync rate.
But there's half lines in there! Riiight. In order to get that to work,
 the pulse rate is doubled up temporarily during the vertical interval.

In terms of horizontal sync, here's what the TV set sees. First, frame 0 begins.
There are 6 pre-eq pulses, 6 vertical synch pulses, and 6 post-eq pulses,
all at double the horizontal scan rate, taking up the first nine lines' worth of time.
Only the first and every other subsequent pulse is regarded by the PLL.
In other words, the PLL locks on to every other pulse,
at the horizontal frame rate. After those first nine lines, normal scan lines are sent,
with just one horizontal sync pulse each.
The PLL stays locked to those. At the bottom of the field, line 262 starts as usual,
but halfway through the scan line, boom!, here comes the first pre-eq pulse for field 1.

This first pre-eq pulse of field 1 is of course completely out of phase
from the other horizontal sync pulses and therefore it will be missed by the PLL.
But that's okay because the eq pulses come at double the horizontal scan rate.
So, the second and every other subsequent pulse is regarded by the PLL.
The seventh post-eq pulse brings the whole system back into sync so
that the tenth line of field 1 is consistent phase-wise with the lines in field 0.
It's really a pretty clever design for the 1930s!
[The president of the company where I work might take umbrage: he was in on the design
and certainly the engineers who participated in the birth of television were no slouches!]

For vertical sync detection, also inside the ancient TV is a simpleminded low pass filter.
The pre-eq and post-eq pulses are mostly "black" level with fleeting sync level,
so the average voltage for those three-line intervals is relatively high (close to .3v for black level).
 In between there are the three lines' worth of vertical sync pulses
which are very high duty cycle into the sync voltage range, and average closer to 0 volts.
 
The vertical sync pulses are the only part of the entire waveform
with an average voltage anywhere near 0 volts, so they are hard to miss,
even with primitive tube circuits ;^)
While some of today's TVs ignore some of the pulses,
it is easy to generate the standard NTSC signal, and of course that is recommended.

So, to recap: Field 0 contains 262.5 lines, as follows.
3 lines: 6 pre-eq pulses
3 lines: 6 vertical sync pulses
3 lines: 6 post-eq pulses
253 lines: normal scan lines (many of these are invisible and some are reserved for closed-caption data,
 cable tv scrambler data, etc... but so far as sync is concerned, these lines are all "normal" scan lines)
.5 lines: the last line of the field quits right in the middle!
Field 1 contains 252.5 lines, as follows.

3 lines: 6 pre-eq pulses
3 lines: 6 vertical sync pulses
3.5 lines: 7 post-eq pulses
253 lines: normal scan lines

More Information
http://www.sxlist.com/techref/io/video/ntsc.htm
   
윗글 SX28 Serial to TV
아래글 SX28 디지털 스코프
    N         제목    글쓴이 작성일 조회 추천
48 SXB 무료 Basic 컴파일러 SX18/20/28 avrtools™ 2008/12/03 (수) 1568 0
47 SX28 IR-Remote Signal Analyzer avrtools™ 2016/01/22 (금) 445 0
46 삼성 안드로이드폰 GT-i5700 무선 오실로스코프 avrtools™ 2011/09/10 (토) 2866 10
45 SX28 Clock Timer 소스 avrtools™ 2008/12/03 (수) 1844 0
44 SX28 Scanning a 4x4 Keypad 소스 avrtools™ 2008/12/03 (수) 1974 0
43 SX28 Thermometer 소스 avrtools™ 2008/12/03 (수) 1664 0
42 SX28 Serial LCD 소스 avrtools™ 2008/12/03 (수) 1644 0
41 SX28 Digital Dice 소스 avrtools™ 2008/12/03 (수) 1500 0
40 IDE51-C 8051 C컴파일러 (사용제한 없음) avrtools™ 2008/12/03 (수) 2365 0
39 uc51 검파일러 8K 무료버전 avrtools™ 2008/12/03 (수) 1714 0
38 SXC Demo avrtools™ 2008/12/02 (화) 1388 0
37 SxSim (UBICOM의 SASM 어셈블러를 지원) avrtools™ 2008/12/02 (화) 1618 0
36 SXkey52.exe SX48, SX52 전용 소프트 avrtools™ 2008/12/02 (화) 1463 0
35 SX 칩 프로그래머/인서킷 에뮬레이터 SXKey v3.0 avrtools™ 2008/12/02 (화) 1417 0
34 Serial port keyboard stuffer avrtools™ 2008/11/09 (일) 2162 0
33 IBM AT Keyboard의 Hexa 값 leeky 2007/11/12 (월) 2147 0
32 PC 소프트웨어 오실로스코프 avrtools™ 2008/10/07 (화) 2526 0
31 저항 읽는 방법과 저항 소프트웨어 avrtools™ 2008/09/26 (금) 2388 0
30 BMP to LCD avrtools™ 2008/09/22 (월) 2123 0
29 SX18/20/28용 무료 베이직 SXB V3.1 leeky 2006/03/03 (금) 3425 22
28 절연 RS232C 회로 avrtools™ 2008/08/29 (금) 2634 0
27 문자표시 LCD 모듈의 사용방법 leeky 2006/04/06 (목) 4710 0
26 Bin2Hex.exe leeky 2007/11/12 (월) 2633 0
25 LPT Port Tester leeky 2007/11/12 (월) 2556 0
24 PC 프린터 포트의 사용법 leeky 2007/11/12 (월) 2812 0
23 병렬포트(LPT1) 시험 소프트웨어 leeky 2007/11/12 (월) 2464 0
22 SX 칩 4비트 LCD 소스 leeky 2006/02/20 (월) 2848 30
21 SxSim (UBICOM의 SASM 어셈블러를 지원) leeky 2006/02/13 (월) 2278 27
20 SXkey52.exe leeky 2006/02/13 (월) 2065 28
19 SX 프로그래머/에뮬레이터 SXKey v3.0 leeky 2006/02/13 (월) 2259 24
18 SXC Demo Version leeky 2006/03/16 (목) 2142 27
17 SX52 웹서버 + 겜보이 카메라 leeky 2006/03/16 (목) 2379 5
16 CMUcam2 (Cam + 5 Servo) leeky 2006/03/16 (목) 2801 3
15 CMUcam Vision Sensor KIT with SX28 leeky 2006/03/16 (목) 3134 4
14 SX52 이더넷 평가기판의 소스 (iSX 소프트) leeky 2006/03/16 (목) 3020 1
13 SX52-이더넷 평가기판 (하드웨어) leeky 2006/03/16 (목) 2418 1
12 SX52 MMC(메모리카드) WAV화일 녹음과 재생 leeky 2006/03/16 (목) 2996 5
11 SX28 USB 분석장치 (SX-Atpapch) leeky 2006/03/16 (목) 2749 5
10 SX color TV 게임기 leeky 2006/03/16 (목) 2964 4
9 SX28 Serial to TV leeky 2006/03/16 (목) 2488 3
8 SX18 영상(NTSC) 동기검출 leeky 2006/03/16 (목) 2208 2
7 SX28 디지털 스코프 leeky 2006/03/16 (목) 2582 3
6 SX28 500KHz DDS 신호발생기 leeky 2006/03/16 (목) 2693 0
5 SX Morse Code Keyer avrtools 2006/03/16 (목) 1945 2
4 SX28 Video OSD Module leeky 2006/03/16 (목) 2883 0
3 1.2MHz/2.4GHz Exciter leeky 2006/02/25 (토) 2276 0
2 16F84 G3RUH 9600BPS Modem leeky 2006/02/25 (토) 2359 2
1 16F84 Morse Decoder leeky 2006/02/25 (토) 3205 1
1

바구니 : 0
 보관함 : 0
오늘뷰 : 0
HOME   |   회사소개   |   제휴안내   |   회사위치   |   서비스이용 약관   |   개인정보 보호정책   |   사이트맵
17015 경기도 용인시 기흥구 동백중앙로16번길 16-25, 508호. 전화 : 031-282-3310
사업자 등록번호 : 697-47-00075 / 대표 : 이건영 / 업태 : 제조업 / 종목 : LED조명, LED전원, 제어장치.
개인정보 관리책임자 : 홈페이지 관리자 . Copyright ⓒ2016 아크레즈 (ACLEDS INC.)
HOME TOP PREVNEXT 0 0 0