Pages: [1] 2 3   Go Down
Author Topic: Composite Video Generating  (Read 7436 times)
0 Members and 1 Guest are viewing this topic.
The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am working on generating composite video with the due. It uses the dac, and it works great already. I will post some photo's tomorrow.
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are some pictures. (Yes, I use a camera as tv screen, since I have no tv in my room) The generated signal is 150x287, and uses 'fake' progressive: It only outputs one field.
Edit: ATM I am trying to get color working.


* DSC00919.png (809.75 KB, 1024x680 - viewed 226 times.)

* DSC00920.png (717.99 KB, 1024x680 - viewed 148 times.)

* DSC00923.png (1262.86 KB, 1024x680 - viewed 176 times.)
« Last Edit: March 09, 2013, 02:11:00 pm by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, implementing color seems to be very hard. I don't understand what I need to generate from the RGB values. Since there is a color burst + the signal itself.
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Be careful about connecting the output of the DAC directly to a video input, as video inputs usually have a low impedance (75 ohms) and some of us have broken our DACs by connecting them directly to low impedance loads. Use a buffer amplifier or emitter follower.

Generating colour is very complicated. The colour subcarrier needs to be at a very specific frequency (3.579545 MHz for NTSC or 4.433619MHz for PAL) and I doubt the DAC can go that fast.
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Be careful about connecting the output of the DAC directly to a video input, as video inputs usually have a low impedance (75 ohms) and some of us have broken our DACs by connecting them directly to low impedance loads. Use a buffer amplifier or emitter follower.

Generating colour is very complicated. The colour subcarrier needs to be at a very specific frequency (3.579545 MHz for NTSC or 4.433619MHz for PAL) and I doubt the DAC can go that fast.
I have it connected to my scope too (which has 1M impedance). But anyway, I could try making a R2R ladder or something. That would be much faster. But I am not sure if I have the right resistors.
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have it connected to my scope too (which has 1M impedance).
I'm right yo you must have all parallel connected, so the smalest resistor will beat all other if you connect it and messure the impedance value you will get ~75 Ohm even with the 1M impedance. God will be an operational amplifire as voltage follower between the DAC and the rest of the connections or something else how has an high input impedance and an low output impedance.
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The more I think about this the more I wonder if it might actually be possible - an R-2R ladder on the external memory pins (34-41) together with DMA should work reliably at 10.5MSPS and may even go as high as 21 or 28MSPS (I learned that doing the VGA library). The dealbreaker would be how close to the exact colour subcarrier frequency you have to get. In my experience, with old CRT TVs you have to be very accurate, but more recent LCD panels have more tolerance for the frequency and amplitude of the colour subcarrier being wrong.
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The more I think about this the more I wonder if it might actually be possible - an R-2R ladder on the external memory pins (34-41) together with DMA should work reliably at 10.5MSPS and may even go as high as 21 or 28MSPS (I learned that doing the VGA library). The dealbreaker would be how close to the exact colour subcarrier frequency you have to get. In my experience, with old CRT TVs you have to be very accurate, but more recent LCD panels have more tolerance for the frequency and amplitude of the colour subcarrier being wrong.
That would be awesome, but first I need to add an op-amp to my ladder, otherwise the signal drops when connecting to my camera. Can you give me some lm#### ic numbers?

Edit: I ordered some samples of the AD811 (http://www.analog.com/en/all-operational-amplifiers-op-amps/operational-amplifiers-op-amps/ad811/products/product.html). It seems to be a good one. I hope I will get them in a week or 2.
« Last Edit: March 18, 2013, 11:26:49 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working on my r2r ladder without an op-amp now (I mean the signal b/w not color yet). I only needed to change the pin numbers.

Can someone tell me how to add dma?
« Last Edit: March 19, 2013, 11:36:12 am by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just found some resistors for an R-2R ladder but they are only 1% tolerance. I was going to measure them more accurately and select some for the ladder, otherwise things start going wrong after 5 bits. Even then I think there will be too much noise on the digital outputs for full 8 bit accuracy. I'll see how well I can do.

DMA for the external memory port is quite hard to set up as it is AHB DMA - I use it in the VGA library but the code is impossible to follow  smiley-mr-green I'll try and do a simpler example once I've got the ladder done.
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just found some resistors for an R-2R ladder but they are only 1% tolerance. I was going to measure them more accurately and select some for the ladder, otherwise things start going wrong after 5 bits. Even then I think there will be too much noise on the digital outputs for full 8 bit accuracy. I'll see how well I can do.

DMA for the external memory port is quite hard to set up as it is AHB DMA - I use it in the VGA library but the code is impossible to follow  smiley-mr-green I'll try and do a simpler example once I've got the ladder done.
I have 8 bit now. With 5% tolerance. (R is 10K each. I use 2 of them for the 2R. I know that this resistor is a bit too high)

Hmm, too bad. Isn't dma just setting a source and a destination pointer? On the ds for example there are functions like these:
Code:
void MI_DmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size);
Which you use like this:
Code:
MI_DmaCopy32(3, &px[0], VramPixels,512 * 192);
Aren't there such functions on the due?
« Last Edit: March 19, 2013, 12:08:52 pm by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is an example of a picture generated with the due. (It is captured in jpeg using the camera I use for viewing it, so not the best quality)


* DSC00137.JPG (74.03 KB, 640x480 - viewed 137 times.)
Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With 5% resistors the R-2R ladder may lose too much accuracy. 5% of 255 is almost 13 which is a 4-bit number, so you could lose 4 bits of accuracy out of the 8, which is too much. Try connecting the analog output of the ladder to an analog input on the Due, then write a sketch which outputs 0-255 onto the ladder and reads the value on the analog input. You might find that the ladder isn't monotonic (sometimes when the input goes up by 1 the output voltage goes down instead of up).

THe DMA needs to be continuous (a bit like an audio buffer would be, just a lot faster)  which is why it's more complicated than just DMAing blocks of memory.
Logged


The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 144
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With 5% resistors the R-2R ladder may lose too much accuracy. 5% of 255 is almost 13 which is a 4-bit number, so you could lose 4 bits of accuracy out of the 8, which is too much. Try connecting the analog output of the ladder to an analog input on the Due, then write a sketch which outputs 0-255 onto the ladder and reads the value on the analog input. You might find that the ladder isn't monotonic (sometimes when the input goes up by 1 the output voltage goes down instead of up).

THe DMA needs to be continuous (a bit like an audio buffer would be, just a lot faster)  which is why it's more complicated than just DMAing blocks of memory.
Yea, but it works good enough for now. I will use other resistors (1%) later on.

Oh, okay. I realize how it need to work now. I will try to understand your code, since I only need to change the frequency and the source pointer.
« Last Edit: March 19, 2013, 02:05:17 pm by Gericom » Logged

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the sketch I used to check my ladder:
Code:
char pins[]={34,35,36,37,38,39,40,41};

void writeval(int v){
  for(int i=0;i<sizeof(pins);i++){
    digitalWrite(pins[i],v&1);
    v>>=1;
  }
}

void setup() {
  Serial.begin(115200);
  analogReadResolution(12);
  for(int i=0;i<sizeof(pins);i++)
    pinMode(pins[i],OUTPUT);
}

void loop() {
  int l=0;
  for(int i=0;i<(1<<(sizeof(pins)));i++){
    writeval(i);
    delay(10);
    int m=analogRead(0);
    printf("%d : %d  d=%d\n",i,m,m-l);
    if(m<l)printf("!!!!!!ERROR!!!!!!!!!! non-monotonic\n");
    l=m;
  }
  delay(2000);
}

If you get errors then just swap the resistors around until they go away.
Logged


Pages: [1] 2 3   Go Up
Jump to: