ADC - Sampling the NBTV signal

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

Moderators: Dave Moll, Andrew Davie, Steve Anderson

ADC - Sampling the NBTV signal

Postby Andrew Davie » Thu Mar 02, 2017 11:04 pm

The analogue-digital-converter on the Arduinos has the following properties....

input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.
Given our NBTV input of, what, 1.5 volts? Have to check this, that's from memory... this would give a range of 1024*1.5/5 = 307 values/brightnesses. Well, that's not perfect but it's going to be better than the eye can see for such a tiny picture. Maybe! If needed, we could always pre-amplify the signal so that the maximum is 5V. That's for later.

Here's a gotcha...

"It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."

Well, I guess that 10kHz is going to be our maximum rate - but actually that sits quite well with the advertised NBTV club standard.


So, at this stage I've determined...
* timer interrupts can run plenty fast - in fact 10kHz timers are barely making the processor lift a finger.
* the ADC converter has a maximum reading rate of about 10kHz.
* we should be able to use a timer to read the audio/NBTV waveform at sufficient rate to give a good picture
* the NBTV signal stanard is 1V pp but the ADC handles 5V
* we might be able or should have to (one of those) amplify the signal before hitting the Arduino to 5V pp to give better brightness resolution
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC

Postby Klaas Robers » Fri Mar 03, 2017 12:16 am

Andrew, video is very different from audio. We can hear a quantization worse than 16 bits (32000 steps up and 32000 steps down). If it is less we can hear the back ground noise.

But we see nothing strange from video signals that have just 64 steps (6 bits) between black and white.
If you also encode the sync pulse (40% of black to white) you can do with 7 bits, 128 steps.
In both cases you see no artefacts, best seen in a grey back ground, not evenly lit. Then you see a kind of circles where the grey value goes one step up or down. With 64 steps black to white, we don't SEE this any more.

The above is for gamma corrected signals. But video signals are always gamma corrected. CRT picture tubes have the gamma correction built in the electron gun and LCD screens simulate this.
User avatar
Klaas Robers
"Gomez!", "Oh Morticia."
 
Posts: 1656
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: ADC

Postby Andrew Davie » Fri Mar 03, 2017 12:22 am

Klaas Robers wrote:But we see nothing strange from video signals that have just 64 steps (6 bits) between black and white.


I just wanted the best :) But thanks - yes OK, no need to pre-amplify then - the 1V (I checked this time) pp range is 1/5 of 1024 roughly 200 values so that's going to be just fine!
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC

Postby Andrew Davie » Fri Mar 03, 2017 11:27 am

Here's a great page on audio ADC.
Of special interest is using an internal 1.1V reference voltage and its use.
The above link gives some really interesting analysis of the accuracy too. Great read.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC

Postby Steve Anderson » Fri Mar 03, 2017 6:11 pm

Andrew Davie wrote:Here's a gotcha...

"It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."


Really? That slow? Most recent PICs can convert at 50ks/s (50kHz), quite a few somewhat faster. Same number of bits (10). Are you sure of that 100us figure?

NBTV is usually quoted as having a bandwidth of around 10kHz which requires a sampling rate of 20kHz minimum. The Shannon-Nyquist equation.

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5401
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: ADC

Postby Andrew Davie » Fri Mar 03, 2017 7:05 pm

Steve Anderson wrote:
Andrew Davie wrote:Here's a gotcha...

"It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."


Really? That slow? Most recent PICs can convert at 50ks/s (50kHz), quite a few somewhat faster. Same number of bits (10). Are you sure of that 100us figure?

NBTV is usually quoted as having a bandwidth of around 10kHz which requires a sampling rate of 20kHz minimum. The Shannon-Nyquist equation.

Steve A.



Klaas pointed me to some code which samples at 38kHz.
My current understanding is there is one ADC which is shared on multiple pins. You can get faster speed but at the expense of less inputs.
Still sketchy on this, and as I build up my understanding will post here.
This is essentially true.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC

Postby Steve Anderson » Fri Mar 03, 2017 7:19 pm

Yep, that true of most micros, one A-D module which can have a variety of input pins. But if you only need to A-D the video that's one pin and you can go flat out. No channel/source switching required which requires a bit more time and code.

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5401
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: ADC

Postby Andrew Davie » Fri Mar 03, 2017 8:55 pm

Steve Anderson wrote:Yep, that true of most micros, one A-D module which can have a variety of input pins. But if you only need to A-D the video that's one pin and you can go flat out. No channel/source switching required which requires a bit more time and code.

Steve A.


I'm going to need an A/D on the IR sensor too, but I thought a simple external circuit could convert that to a binary 0/1 and then use a digital pin for that.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC

Postby Klaas Robers » Fri Mar 03, 2017 10:06 pm

Indeed, a Schmidt trigger, two inverters and you have a binary signal.
User avatar
Klaas Robers
"Gomez!", "Oh Morticia."
 
Posts: 1656
Joined: Wed Jan 24, 2007 8:42 pm
Location: Valkenswaard, the Netherlands

Re: ADC

Postby Steve Anderson » Sat Mar 04, 2017 3:39 pm

Andrew Davie wrote:[...but I thought a simple external circuit could convert that to a binary 0/1 and then use a digital pin for that.

Does this device not have an internal comparator? I'm not familiar with these chips...

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5401
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: ADC

Postby Andrew Davie » Sat Mar 04, 2017 4:06 pm

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

Re: ADC - Sampling the NBTV signal

Postby Steve Anderson » Sat Mar 04, 2017 8:08 pm

Depending on how the comparator can be configured you could either use an internal or external reference to determine the switching voltage and if the output of the comparator is available also on another pin provide some positive feedback to get a nice clean rapid switch between 0 and !...and the reverse.

What is the actual chip's designation (part number, e.g. an example PIC would be PIC18F2620) so I can have a peer at the datasheet for it...I'm not saying that I'll be able to help!!

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5401
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: ADC - Sampling the NBTV signal

Postby Andrew Davie » Sat Mar 04, 2017 8:22 pm

Steve Anderson wrote:Depending on how the comparator can be configured you could either use an internal or external reference to determine the switching voltage and if the output of the comparator is available also on another pin provide some positive feedback to get a nice clean rapid switch between 0 and !...and the reverse.

What is the actual chip's designation (part number, e.g. an example PIC would be PIC18F2620) so I can have a peer at the datasheet for it...I'm not saying that I'll be able to help!!

Steve A.


Arduino Micro is the board I'm using at the moment. It has an ATmega32U4 processor.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: ADC - Sampling the NBTV signal

Postby Steve Anderson » Sat Mar 04, 2017 9:16 pm

A quick scan through the datasheet reveals that the comparator output isn't available on an external pin. Never mind, it should be OK without any feedback. The (single) comparator can cause an interrupt if that's the way you wish to go...the ISR should be able to clean up ragged edges...polling the output could lead to erratic performance. At least it saves you some external hardware.

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5401
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: ADC - Sampling the NBTV signal

Postby Andrew Davie » Sat Mar 04, 2017 9:59 pm

Steve Anderson wrote:A quick scan through the datasheet reveals that the comparator output isn't available on an external pin. Never mind, it should be OK without any feedback. The (single) comparator can cause an interrupt if that's the way you wish to go...the ISR should be able to clean up ragged edges...polling the output could lead to erratic performance. At least it saves you some external hardware.

Steve A.


Klaas will be disappointed - I've already bought the components :P but yes, never occurred to me there would be on-board capability. Thanks for spotting that.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Next

Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 1 guest

cron