Micron/Aptina MT9D131 JPEG Camera

Have a good idea for a new product for SFE or Olimex? Let us know!

Moderator: phalanx

janek@bigpond.net.au
Posts: 7
Joined: Tue Jan 09, 2007 4:26 am

Post by janek@bigpond.net.au » Fri Jan 22, 2010 5:04 pm

vjcro wrote:Hi Aerospace,

we use MT9D131.
As it's said in the MT9D131 Developer guide: 'JPEG data stream sent to the host does not have a header'. You have to create it and attach it to the file you get from the camera in order to get the complete JPEG file. You have the code at the end of Developer guide.

I have some problems with camera configuration. Uncompressed image works fine. But when I set the registers in order to get JPEG image, I get a really small file (about 10kB). Could you please write your register configuration that gives you a compressed image? What's the input clock you provide to the camera?

Thank you in advance.
vjcro,
As I am interested in JPEG camera as well, can you email me the MTD131 Developers Guide? - janek[at]bigpond[dot]net[dot]au
I have filled the form for document request on Aptina website, but had no response from them.
Another question is about optics for that camera sensor. How do you source it?
regards
Jan
jan

vjcro
Posts: 13
Joined: Sat Dec 19, 2009 5:16 pm

Post by vjcro » Mon Jan 25, 2010 1:32 am

janek@bigpond.net.au wrote:
Another question is about optics for that camera sensor. How do you source it?
regards
Jan
The lenses are purchased from Framos Imaging Solutions.

vjcro

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Post by Aerospace » Fri Jan 29, 2010 12:43 pm

So I have been able to consistently capture JPEG images. There still seems to be a problem with my timing, since some of the images are split inside the frame (eg left half of image on the right side), but otherwise the images look good.

Here is the initialization command straight out of my VB code. Hopefully its clear enough:

'Sensor Core (page 0)
Call RegWrite("F0", "0000") 'change page
Call RegWrite("05", "0204") 'H-blanking (context B)
Call RegWrite("06", "0020") 'V-blanking (B)
Call RegWrite("09", "0007") 'Shutter Width
Call RegWrite("20", "0300") 'Read mode for context B
Call RegWrite("65", "2000") 'Clock control (enable PLL)
Call RegWrite("66", "4F07") 'PLL params

'Color Pipeline (page 1)
Call RegWrite("F0", "0001") 'change page
Call RegWrite("08", "01F8") 'Pipeline control
Call RegWrite("0B", "00DF") 'Enable Internal Clocks
Call RegWrite("09", "000A") 'Disable output bypass (output JPEG)
Call RegWrite("48", "0000") 'Test Pattern


'JPEG + FIFO (page 2)
Call RegWrite("F0", "0002") 'change page (no register changes here)


'Sequencer Variables (ID = 1)
Call RegWrite("F0", "0001") 'change page
Call RegWrite("C6", "A120") '8-bit, offset 0x20: Capture Mode
Call RegWrite("C8", "0000") 'write value

Call RegWrite("C6", "A121") '8-bit, offset 0x21: # of Frames
Call RegWrite("C8", "0002") 'write value

'Mode Variables (ID = 7)
Call RegWrite("C6", "2707") '16-bit, offset 0x07: Frame Width
Call RegWrite("C8", "0640") 'write value (1600)

Call RegWrite("C6", "2709") '16-bit, offset 0x09: Frame Height
Call RegWrite("C8", "04B0") 'write value (1200)

Call RegWrite("C6", "270B") '16-bit, offset 0x0B: JPEG enable
Call RegWrite("C8", "0010") 'write value (enable JPEG in context B)

Call RegWrite("C6", "2723") '16-bit, offset 0x23: extra delay
Call RegWrite("C8", "06A1") 'write value

Call RegWrite("C6", "2725") '16-bit, offset 0x25: row speed
Call RegWrite("C8", "0011") 'write value

Call RegWrite("C6", "2772") '16-bit, offset 0x72: 'JPEG data params (adaptive pxl clock, spoof frames)
Call RegWrite("C8", "0267") 'write value (spoof on)

Call RegWrite("C6", "A77E") '8-bit, offset 0x7E: 'Output Format
Call RegWrite("C8", "0000") 'write value

Call RegWrite("C6", "2779") '16-bit, offset 0x79: 'spoof width
Call RegWrite("C8", "0640") 'write value

Call RegWrite("C6", "277B") '16-bit, offset 0x7B: 'spoof height
Call RegWrite("C8", "0258") 'write value

Call RegWrite("C6", "2777") '16-bit, offset 0x77: 'Len_Timing
Call RegWrite("C8", "0606") 'write value

'JPEG Variables (ID = 9)
Call RegWrite("C6", "A906") '8-bit, offset 0x06: JPEG Format
Call RegWrite("C8", "0000") 'write value

Call RegWrite("C6", "A907") '8-bit, offset 0x07: JPEG settings
Call RegWrite("C8", "0014") 'write value

Call RegWrite("C6", "2908") '16-bit, offset 0x08: restart interval
Call RegWrite("C8", "0002") 'write value



I found out the images came out a lot better when I added a restart interval to correct errors in the JPEG. I can post my header generation code if that would be of interest to you as well, but it is very similar to the C code shown in the developer's guide. I will also try and post a picture when I can find a site to host it.

vjcro
Posts: 13
Joined: Sat Dec 19, 2009 5:16 pm

I2C problem

Post by vjcro » Wed Feb 03, 2010 2:33 am

Hi Aerospace!

Thanks for the configuration.
But I'm stuck with something pretty basic. Let me ask you: If you set seq.cmd = 2 and then read seq.state, or mode.context, do you get the right value? I tried to configure the camera and when I write something in a register of page 0 or 1, I can read that value back. But the things I write in 0xC6 and 0xC8 doesn't seem to have any effect. Whatever I set, I get the default values (preview mode, image size 800x600)?!
There is a possibility of HW bug, but could you please tell me is there something I forget in configuration?

Thank you!

vjcro

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Post by Aerospace » Thu Feb 04, 2010 1:33 pm

vcjro,

Yes I've been able to read back the values I set in register 0xC8:1. We use this to know when to capture a valid frame. I'm not sure what could be causing your set up to stay at the default value... Are you being sure to change the value in C6 depending on whether your doing an 8-bit or 16-bit read/write?

Also, just out of curiousity, what are you trying to develop this camera for?

Aerospace

vjcro
Posts: 13
Joined: Sat Dec 19, 2009 5:16 pm

Post by vjcro » Thu Feb 04, 2010 1:49 pm

I managed to read the right values, but after some delay, or for example - I reset the camera, read some registers' values, write my configuration, read the same values again, and I get almost all default values (no effect from my configuration, only the seq.state becomes 'changing to capture'). When I start the same read-write-read process again (without resetting the camera) I get the wanted registers' values on the first read.

I guess it's all about timing...

How's your struggle with timing by the JPEG image doing?

We're designing a wireless image sensor node for a WSN. We want to configure the camera by uC, capture the image, collect it with FPGA, store it in SRAM, and send the image (compressed one) to the coordinator node over ZigBee in sequential packets.
How about you, anything similar?

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Post by Aerospace » Thu Feb 04, 2010 2:29 pm

Another tech working on the problem thinks our timing problem comes from the FIFO buffer we are putting our image through. It needs an extra clock cycle after Frame_Valid and Line_Valid go high before it can start storing bytes. We may need to add some more hardware to our design.

We are trying to develop the camera for a Pico-satellite, a small 10x10x10cm cube. We want high res pictures, but we need them to be compressed since our transfer speed to the ground station is limited.

I'll let you know our progress.

Oh also, here is my proof of success :). This is a thumbnail of one of our good images, so the timing problem doesnt show up.

Image

vjcro
Posts: 13
Joined: Sat Dec 19, 2009 5:16 pm

Post by vjcro » Thu Feb 04, 2010 2:41 pm

Yes, we also find the FIFO buffer to be a potential problem, but haven't got anything in particular to deal with it by now.

I notice 2 or 3 small stripes on the image (one green, one black, one blue), if I'm not mistaken. We also had that in our previous design, and they were longer sometimes. What about that?

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Post by Aerospace » Thu Feb 11, 2010 1:36 pm

Actually the first couple pictures we took had much longer stripes, but I got rid of them by increasing the frequency of the restart interval (jpeg.restartInt). When I had this value set to zero, there were lots of stripes, I set it to 16 and got fewer stripes, but they were still long. The picture I posted had this value set to either 1 or 2. Note, the header had to be changed accordingly as well.

vjcro
Posts: 13
Joined: Sat Dec 19, 2009 5:16 pm

Got the JPEG image!

Post by vjcro » Sat Feb 20, 2010 11:37 am

Hi, Aerospace!

I managed to configure the camera successfully and get the JPEG image (with the register configuration I wrote it worked for us before). I still have troubles with timing, it takes a lot of time for the registers to accept the configuration. I'm not sure yet is it because of the SW (stack on the microcontroller) or the HW (we have the camera connected with a flat cable about 15 cm long).

Anyway, I changed the restartInterval to 0x0002 and got a couple of squares (short stripes), similar as you. Thank you for that suggestion :)
Did you manage to get rid of them or do you think it can't be avoided?

And did you solve your timing problem?

Regards,
vjcro

actaylor
Posts: 3
Joined: Tue Feb 23, 2010 1:18 pm

Post by actaylor » Tue Feb 23, 2010 1:45 pm

vjcro,

I am in the same boat as Jan who posted on Jan 22. I am interested in using this product (for an undergraduate school project), but I haven't heard back from Aptina after I requested the Developer's Guide document quite some time ago. I would greatly appreciate it you could share this document with me.

Thanks!
Alan
alan3@umbc.edu

MaxAlex
Posts: 1
Joined: Tue Mar 02, 2010 6:32 am

Re: Micron/Aptina MT9D131 JPEG Camera

Post by MaxAlex » Tue Mar 02, 2010 7:19 am

Hi vjcro,

Could you please send me "MT9D131 The Development Guide".
I have a contents of sensor's registers and image from working camera if
somebody needs it.

Thanks!

MaxAlex, gvozdevma@gmail.com
Attachments
TestImage.JPG
TestImage.JPG (254.36 KiB) Viewed 3826 times
RegValue.zip
(7.31 KiB) Downloaded 11332 times

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Re: Micron/Aptina MT9D131 JPEG Camera

Post by Aerospace » Fri Mar 05, 2010 12:55 pm

actaylor and MaxAlex,

Are you still in need of the development guide? Let me know and I'd be happy to send it over. The more people working on this the better.

actaylor
Posts: 3
Joined: Tue Feb 23, 2010 1:18 pm

Re: Micron/Aptina MT9D131 JPEG Camera

Post by actaylor » Fri Mar 05, 2010 2:46 pm

Aerospace wrote:actaylor and MaxAlex,

Are you still in need of the development guide? Let me know and I'd be happy to send it over. The more people working on this the better.
vjcro already hooked me up, thanks though!

Aerospace
Posts: 27
Joined: Thu Jun 04, 2009 4:25 pm
Location: Los Angeles

Re: Micron/Aptina MT9D131 JPEG Camera

Post by Aerospace » Fri Mar 05, 2010 3:31 pm

We seem to have everything working, except we occasionally run into this problem with our images being skewed:

Image

Has anyone else seen this error? And if so how did you fix it?

-Aero

Post Reply