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

Re: ADC - Sampling the NBTV signal

Postby Andrew Davie » Sat Mar 04, 2017 10:00 pm

Andrew Davie wrote:
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 for an external schmitt trigger :P but yes, never occurred to me there would be on-board capability. Thanks for spotting that. Doesn't make much sense doing it externally, now.
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 » Mon Mar 06, 2017 12:01 pm

When selecting a micro to perform a specific task I try and find one with as many of the required peripherals built-in. It saves board space, usually cost and build time and complexity. Recently Microchip have released a range of 16F devices with both a 10-bit A-D and a 10-bit D-A. Always worth keeping an eye on new releases.

You can't have everything though, power devices and specialised-function devices will continue to be external.

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

Re: ADC - Sampling the NBTV signal

Postby Andrew Davie » Sat Mar 11, 2017 7:48 pm

OK, it's time to start handling the NBTV signal. My thoughts - it's coming from line-out or possibly even headphone jack. It's definitely going to be under 5V, but not sure yet about the current. I would assume that's going to be very small, but to be confirmed. The NBTV signal format is pretty well defined -- in fact just 1V maximum.

videosignal.gif
videosignal.gif (2.65 KiB) Viewed 4958 times

Image courtesy http://www.nbtv.wyenet.co.uk/standards.htm

The signal will be coming in on an analog pin. A0 is in use already for the IR sensor, so let's use A1.

We need to sample that at a high frequency - signal is 10kHz so at least 20kHz is required. Earlier we saw that it's possible to do 38KHz sampling so let's just hog out and go for that. The goal then will be to sample/read the A1 pin as fast as we can and then process. By process I mean detect and strip out the sync pulses - but for the very first test I don't really see any reason we can't just send the input directly to a LED array.

Which means that it's going to be reasonably important to have the LED array working first. So I'm going to switch over to that problem and get that working first.
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 Andrew Davie » Tue Mar 14, 2017 11:32 am

OK, the LED array is now hooked up and apparently working.

Back to the signal sampling. I've spotted some demo code that does the 38KHz sampling on an analog pin. What I think it does is actually switch into an internal "fast read" mode which simply samples and places the sample on a hardware register. That's all. No interrupt associated with it - just running in the background.

See Arduino Audio Input for an interesting example of 38KHz sampling and an explanation of the process. So that code basically sets up an automatic 26 us sample of an analog pin. It then in the main processing loop (which runs at indeterminate frequency) reads the ADCH value from hardware. That's the most significant 8 bits of the ADC value.

So I don't want my reading/processing in the main loop. I want a regular and "high" frequency interrupt running to do the reading of the ADCH and subsequent processing, which will include...

  • detecting synch pulses
  • detecting missing synch pulse for a frame pulse
  • clamping (finding the bottom level of the sync, and location of the "black")
  • separating the video signal from the sync pulses
  • amplification =brightness, right?
  • contrast <--- no idea how to do this/how it works yet
  • gamma correction (which might be done externally...?)

For my first trick, though, I think I'll try and setup a 30kHz or so interrupt to read ADCH and simply turn the value into a duty cycle for the LED PWM output pin. I obviously need to be running the LED PWM at a high frequency to allow changes for pixels. Will calculate that later. If I can get that working, then I should be able to run the disc at a selected RPM (well, hopefully 750RPM) and see a steady picture. And then I can take it from there to work on the sync pulses, find the missing sync for frame, and then, finally, I'll be able to work on frame lock.

I can concentrate on the quality of the picture later on - I just need anything recognisable at this stage.
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 Andrew Davie » Tue Mar 14, 2017 11:39 am

According to this post's top answer it's not going to be possible. However, this post mentions the possibility of using and external ADC, which I should probably consider. In short, "Connecting an external ADC (via SPI or whatever) makes it possible to sample data at the desired speed."
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 Andrew Davie » Tue Mar 14, 2017 11:46 am

Here's a 16-bit 4 channel ADC breakout board. I like the idea of having dedicated hardware doing the hard work on this, but jury's out on if this is just a dead end idea or not.

Here are a few from AliExpress...

16-bit ADC 4-channel Module with Programmable Gain Amplifier

16 Bit I2C ADS1115 Module ADC 4 channel with Pro Gain Amplifier


...aannnd they're going to be no good with too few samples per second. I will need an ADC that's going to be able to give me up to 40kHz, AND be able to put that on an arduino pin or (via protocol) at around the same speed. MMh... is that even possible?
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 Andrew Davie » Tue Mar 14, 2017 11:53 am

Just some light reading... Arduino Projects: Digital Audio Recorder
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 Andrew Davie » Tue Mar 14, 2017 1:14 pm

A very comprehensive analysis of Fast ADC on Arduino.
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 Andrew Davie » Wed Mar 15, 2017 10:05 am

I am no longer working on the ADC part - I found a much better solution.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Previous

Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 4 guests