Wednesday, March 30, 2011

TCM8230MD Breakout

TCM8230MD
The TCM8230MD is a tiny camera from Toshiba theoretically capable of outputting 640x480@30FPS! This post is to document my experience with this devilish cam. 


Breakout
This is my second breakout board for the camera, this one is designed to be connected as a module to another board and doesn't use a crystal oscillator for the clock, I'm using one of the PWM channels instead. However, the older breakout is still in the repo. Both boards were designed with eagle and fabricated at BatchPCB.
Interfacing
The camera has an I2C interface for configuring its registers. A few basic registers must be set for the camera to start outputting frames. Mainly, 0x02 sets the FPS and 0x03 sets the image size/mode and enables the camera.

Next step, is reading frame data, the camera has three interrupt lines, VD, HD and DCLK, when VD is asserted a new frame is ready, each HD edge indicates a new scanline is available, finally, while HD is high each DCLK edge indicates a valid byte on the parallel port.


I enable VD initially and when VD is triggered only then HD is enabled in the IRQ handler. On each HD interrupt the whole scan line is read in a loop inserting some nop's to sync with DCLK. Finally, the whole frame is sent using DMA to the OLED screen.

Eagle files
hg clone https://code.google.com/p/tcm8230md-breakout/

83 comments:

  1. Wow, nice work! I bought one of these from SFE a year (or two?) ago and followed the thread on their forum but last I checked no one had cracked it. Congrats!

    Is the PCB available/shared/for sale at BatchPCB? I might want to order one. Or, are the Eagle files available?

    Also, I'm curious, what is the MCU pictured? I see it's LPC1768-based like the mbed I'm using on my UGV robot.

    ReplyDelete
  2. Hi shimniok,
    It seems that everyone must keep this cam in his junk box for at least a year before they try, I bought mine exactly one year ago :) !!!

    a)I too followed the thread, but I've seen some success with this model and the newer JPEG one TCM8240MD.

    b)BatchPCB doesn't let you sell PCBs outside the US, so I will edit the post and share the Eagle files.

    c)The MCU is indeed LPC1768 running at 100Mhz, the board is blueboard, got it from sparkfun, I used it because it has more I/O pins exposed so I was able to find a continuous 8-bit to use for the data bus instead of read/shift and OR from two different ports.

    ReplyDelete
  3. Thanks much for posting the eagle files! I should be able to make it at home with the exception of one bottom layer trace I need to reroute to accommodate my primitive processes :)

    Re: Blueboard, makes sense. The mbed is a little bit more i/o pin constrained than I'd like. I'd have to do read/shift. Very eager to see what I can do with this camera... once I stop spending all my spare time on the Sparkfun AVC robot :D

    ReplyDelete
  4. you welcome, I've seen your PCBs they look awesome ! I'm sure you could do a 2 layer PCB at home, I tried that once using toner transfer and alignment targets, but it's easier to just reroute the bottom layer like you said, there are two traces by the way, the repo also includes the gerber files you could just send it to batchpcb.

    I haven't tried that with my mbed and I'm not sure there's enough time to do that, there are only a few cycles between each DCLK edge, anyway, let me know how it goes.

    ReplyDelete
  5. Sparkfun just released a video about the AVC on April 23! The barrel obstacles are bright red....................

    I need a color camera! :)

    Do you think there's any chance of me putting one of these together in the next 3-4 days? (I have a bunch of nav code to work on too)

    By any chance, could you share the part numbers for the crystal/osc and two regulators?

    For that matter... I don't suppose you have a spare populated board you might loan me? :) :) :)

    Thanks,
    Michael

    ReplyDelete
  6. Hi,

    Given the time and *processing* constraints and the nature of the task maybe it's better to use a color sensor instead ? something like http://www.sparkfun.com/products/8663

    I wouldn't mind giving you one for free but I'm in Egypt and shipping costs :D.

    Parts:
    ADP121-AUJZ15R7CT
    ADP121-AUJZ28R7CT
    887-1381-1-ND

    ReplyDelete
    Replies
    1. So, the parts listed above are the 1.5V linear regulator, the 2.8V linear regulator, and the oscillator. There appear to be some surface-mount resistors there too. Would you be so kind as to include those parts as well? I don't have Eagle installed at the moment.

      Thank you!

      Delete
    2. Those are 0.1uF and 1uF capacitors

      445-1316-1-ND
      445-1322-1-ND

      Delete
  7. Hi,

    Ive just buyed a TCM8230MD and im gonna use it with a lpcxpresso, it has a lpc1769.
    I was looking at the datasheet and i saw that u need 12mhz for the extclk, and the V for that signal must be 2.8V and that sda and scl must have that voltage too.
    My question is did you do that? i mean is really necesary to give 2.8V or I can just use it with the 3.3 of the core?. And does the camera work with 6Mhz clock?

    Thanks!

    Ezequiel.

    ReplyDelete
  8. Hi,

    I used a 1.5v reg for DVDD and a 2.8v for IOVDD and PVDD. However, the maximum ratings are 3.0v and 3.6v respectively, so yes, theoretically speaking, you can use 3.3v for IOVDD and PVDD but not for DVDD.

    As for EXTCLK, a 6Mhz EXTCLK works very well, I was able to read 7-8 FPS, I know the datasheet says 12Mhz, but that's probably impossible to keep up with anyway.

    I'm doing some more work with this cam, please stay tuned.

    ReplyDelete
  9. I would like to try this with the open source maple a 72mhz arm with 64k ram.
    This can work with arduino like code.
    I will try to make the board in kicad and the maple in kicad so it can be entirely open source.
    So what made you make some of the part selections do you know where I can buy these cameras from a source that has many?
    Is their a updated data sheet?
    The one I am looking at is tenative 1.20v

    ReplyDelete
  10. Well, no particular reason, just make sure that you choose one that has a low voltage drop so that it works with a 3.3v supply, sparkfun sells both the 30MD and the 40MD, last time I checked they had many in stock. As for the datasheet, V1.20 is the only one I could find.

    I will post more info about the cam soon and maybe some code too.

    ReplyDelete
  11. Hello,
    I came across your blog following a link from the mbed forums and I would like to firstly thank you for your ARM guides. I'm new to microcontrollers and development in general but I am learning little by litte. My question pertains to your use of an oscillator in your design, I was under the impression that you could have generated the clock using PWM, was I way off base?

    ReplyDelete
  12. no, it's perfectly fine to generate the clock using PWM, in fact, I've removed the oscillator from the new revision, I only used it when I was just exploring the cam to rule out the possibility of having any problems with the clock, now I guess it's not needed.

    ReplyDelete
  13. Thank you for your response. I understand you may be very busy but I just have some very (I think) general questions about timing and such. Do you mind if I sent you a private message on the mbed website? I think if this does break into conversation it could be lengthy and I'm not sure if you wanted your blog littered with my beginner questions.

    ReplyDelete
  14. That's alright, feel free to contact me here or using the mbed website.

    ReplyDelete
  15. Hello,
    I'm trying to interface the TCM8230MD using an ATMega328P @16MHz and I'm having some problems with the camera configuration (I guess).
    Can you give me some advice, please?
    If you want I can sent you the code I'm using. There is any way to send you a private message?
    Thanks,
    Lara.

    ReplyDelete
  16. Hi there,
    I think you should make sure first that you can talk to the cam over I2C, try reading a register, if not try changing the I2C clock frequency. When you're done with that, move on to reading a frame, I must say though that's probably going to be very difficult with an atmega, I could barely keep up with an ARM running at 100Mhz 64kb sram.

    In a couple of days I will post another post about this cam, it's really overdue, it has more info and some code, maybe it could help.

    You can leave messages here if you like or at:
    i.abdalkader at gmail dot com

    ReplyDelete
  17. can you tell me what the I2C address of the camera is? I do not see it in the datasheet.

    Thanks.

    ReplyDelete
  18. Thanks. Is the data coming out of D0-D7 in this format and order: RGB=5:6:5? Making every pixel 2 bytes?

    Thanks again.

    ReplyDelete
  19. yes, if the second bit of register 0x03 (PICFMT) is set to 1, if it's set to 0 the output is YUV422

    ReplyDelete
  20. Hi, I'm thinking about using this camera module in a QR-code reader. Can you adjust the focus range and how close can you get?
    Thanks,

    ReplyDelete
  21. I'm not quite sure, but the lens seems adjustable somehow, and you can also zoom in if you set the output mode to subQCIF(zoom).

    ReplyDelete
  22. Hi,

    Do you have by any chance any example code on how to work with this camera? I'm using it with LPC1769 in order to develop a 3D Scanner, but I'm having some problems while reading the DCLK interrupt.
    If you have any example code, it would be great to compare what I'm doing wrong. Thanks in advance!

    ReplyDelete
    Replies
    1. Hi, what camera did you go with for your 3D scanner? I was looking for a camera to capture a projected pattern at a distance of 5-20 mm and it seems to be very difficult to find a small camera with such a small working distance..

      Delete
  23. yes, as a matter of fact there's a whole second part to this post with source code and a new breakout, that I've been trying to finish for a while now, I've just been very busy lately, but since you've asked, I promise to wrap it up and post it within a day or so.

    ReplyDelete
  24. Thank you very much! I'll wait for your reply.

    Thanks again!

    ReplyDelete
  25. Hi, do you think that using something like a PIC24FJ128GB206 with 96KB of RAM and a Parallel Port @32MHz can keep up with the TCM8240MD Camera? I really need to interface the camera with low cost devices.

    Thanks,

    Xavier

    ReplyDelete
    Replies
    1. Hi, I think the maximum dbus frequency is 50MHz, see my other post for more info about the timing, but you could either run it on a lower EXTCLK or use a FIFO to buffer the frame and then read it at your own pace.

      Delete
  26. Did you obtain VGA size images?

    ReplyDelete
    Replies
    1. I haven't tried that before, only 128x96

      Delete
  27. Hi,

    Nice work. I just bought this camera (TCM8240MD) and beginning to interface it.

    I managed to use a TQFP64 general purpose PCB for soldering the camera. I have few questions:

    1. I am planning to use a standard frequency crystal at 6Mhz. Do I need the two additional capacitors? If yes, what value?

    2. Do you think I can keep up reading data with LPC2138 at 60MHz?

    3. Have you tried the JPG compression? It is mentioned that it won't work without enabling PLL? Will it multiply the speed at which camera sends data (6Mhz)?

    4. Isn't I2C address 0x3d (binary mentioned in datasheet)? You have mentioned above as 0x3c.

    Thanks and Regards
    Arundale

    ReplyDelete
    Replies
    1. Hi, this post is about the smaller camera, TCM8230MD, so the I2C address will probably be different, but you still need decoupling capacitors, and their values usually range from 100nF to 1uF depending on the frequency they pass. There's a newer breakout, I think much better than this one, I will probably update this post later.

      Delete
  28. Hello,

    We want to interface TCM8230MD with TMS320 C5515 DSP. So, I was wondering if that can be achieved using the breakout board you have designed for this camera. Also, link to the eagle file is broken. Could you please fix this link.
    Thanks a lot for your precious help and time.

    ReplyDelete
    Replies
    1. yes, I don't see why not ? I've tested both boards for months, they are still working if you're wondering :)...but I'd recommend that you use the newer one, it doesn't have a crystal oscillator on board, this way you can experiment with any frequency you like to test the camera, it also connects as a module not to the breadboard. And if you're wondering about the license, I release almost everything using the MIT license.

      PS. I've updated the repo with the new board, and it seems to be working fine.

      Delete
    2. Thanks a lot for quick reply. I created a clone and checked out the 2.0 version files...but when i tried to open the .brd file using eagle layout editor 6.1.0, it gave an error saying this file wasnt an eagle file...do u know why?

      Delete
    3. you're welcome, I've just cloned the project now in the eagle project directory and opened both files normally, I'm not sure but it could be that I'm using an older version of Eagle, version 5.11.0.

      Delete
    4. Thanks... I really appreciate your work and it will be really helpful.. I will try it with different version.

      Delete
    5. Hi I am working on the same project with Rinachi...how do I generate the Gerber Files that BatchPCB requires from your files...and how much does BatchPCB charge?
      Thanks,
      Rahul

      Delete
    6. You don't have to, you can just order the board from BatchPCB here, If you want to know anyway, the Gerber files are generated using Eagle's CAM processor and a CAM file or job, I'm using sparkfun cam file, then you submit the Gerber files to BatchPCB for testing.

      The price generally depends on the size and number of layers of course, I'm sharing my board for free so you only have to pay the cost which is 2.50$.

      Delete
    7. you're welcome, and please let me know how it goes, or if you could send me a link to the project when you're done that would be great.

      Delete
    8. hey how many output pins does your breakout board have?
      thanks,
      rahul

      Delete
    9. 18 total, VCC/GND/DK/HD/VD/SDA/SCL/RST/CLK/D0-D7 plus 1 NC(not connected).

      Delete
    10. oh ok thanks...what components are you using on the board apart from the camera (so that you can send control signals to the camera and read the captured images)? could you please post a circuit diagram?

      Delete
    11. you will need a powerful micro, I'm using a BlueBoard (ARM LPC1768) to control the camera, and send the frames to the other board, MBED, over SPI to be displayed on the OLED screen.

      Delete
  29. Wonderful work you've done! The breakout board looks very neat!
    Currently I'm working on my project which involves TCM8230MD. I followed the Sparkfun forum, but unable to solve my problem: I am not able to write the register values. I successfully read the values and they are remaining to their default state. I'm using 16MHz EXTCLK, 400kHz SCL from PIC18f2455 operating at 2.8V (same as IOVDD of the camera). Please advise me about the initialization of the camera.
    Thanks in advance! :)

    ReplyDelete
    Replies
    1. Thank you :), as far as the initialization sequence goes, it basically involves three delays, one delay after power up for T_VDD, another one after applying EXTCLK for T_EXTCLK, and finally after you release the reset for T_RESET, where T_VDD, T_EXTCLK, T_RESET are 100 ms, 100 cycles of EXTCLK and 2000 cycles of EXTCLK respectively. After that the camera should be ready for I2C commands. There's more about it in page 20 of the datasheet.

      As for the I2C problem, I'm not really sure but if you can read the registers then you should be able to write them as well, so If I were you I would start by lowering the I2C frequency if this doesn't work then use a logic probe to analyse the I2C signals or try another camera.

      Delete
    2. Hi mux! Thanks for the comment!
      I finally interfaced the camera properly!:)
      The problem was a very silly bug in my I2C code! (a missing semicolon! :-| )
      I have interfaced the camera with Xilinx XC2C256 CoolRunner-II CPLD and I'm displaying the footage on a VGA monitor!

      Delete
  30. I'd like to use one of these cameras in manufacturing to take a picture of a 2d bar code and then decode it. I'd be taking the picture at a distance of 1"( or less). Does the camera work at this short distance?

    ReplyDelete
    Replies
    1. Hi Anonymous! The camera (with default lens assembly) does not focus objects closer than 12-15 inches. You may need to mount an external convex lens just outside the camera to have any focal length you want. (Still I believe 1 inch is a very short distance to focus since the camera has noticeable lens abrasion and chromatic abrasion).
      p.s. I tested the focus just now. I've interfaced the same camera with a CPLD and I'm displaying the footage on a VGA monitor. I will further try to play with the focus and reply to you. Provide me more info about your application (like size of 2D barcode to be focused, max distance feasible between barcode and camera).

      Delete
    2. Hi! I have a similar application to Anonymous. I need to capture lines at a distance of 5-20 mm. The lines are 20-100 microns wide and are 1 mm or so apart. Is this not a good choice of a camera for this?

      I guess aberration is unavoidable, so I will have to compensate for this in software.

      Did you manage to focus this or any other camera at such a short distance? Thanks!

      Delete
  31. Hi,
    How did you actually solder the camera to the board (the datasheet says you need a carrier). I'm planning on making my own circuit board so any help is useful!

    Also, the datasheet was a bit confusing; does the camera automatically send frame after frame or is it an I2C command.

    ReplyDelete
    Replies
    1. Hi Joey! In my case I didn't solder the camera directly to the board since I thought it'd damage the CMOS sensor. (I wonder how mux soldered the camera without damaging it! Must be requiring quite a skill at solder/hot air gun!) I instead searched and found a socket (or carrier, as you said) on a dead mainboard of a cellphone (LG KG-195 "Dynamite") that I bought for 100 Rs. from a local mobile-repair shop. The camera "press-fits" into it perfectly.
      There is also a company named "Molex" which manufactures the socket required for this camera. (See for form-6 socket on their website.) But only problem is their Minimum Order Quantity (MOQ) is somewhere in 1000s and they also didn't reply to my "Request a sample" mail. You can have a try though!

      About the I2C command: Only once you have to give the command to camera to enable DOUT. (See Register 0x03, default value 0x80, change it to 0x00). The camera then sends data frame after frame automatically.

      You can refer to an application note here:
      http://go900.angellfear.ru/old-files/nvidia/12/mirror-hwui-read-only/Camera/DATASHEET/CameraModule/Toshiba/TCM8230MD_AplNote_E_040127.pdf

      The AppNote clears many doubts that may arise from the Datasheet.

      All the Best! :)

      Delete
    2. Hi, I just used an iron and some flux, it's not really that difficult, just align the camera carefully and then touch each pad with a bit of solder, that's all. Of course if I had access to a socket I would have used it. Whatever you do don't try hot air, it will liquefy the camera :)...

      Delete
    3. Thanks! I'll start searching for a mount. Perhaps I'll find one on an old cell phone (with a nice replacement camera!)

      Delete
  32. Have you tried displaying video from the camera with the setup shown?

    ReplyDelete
  33. You mentioned in a comment last year that you used a ADP121-AUJZ15R7CT and a ADP121-AUJZ28R7CT as your regulators. Do these components apply to the new board as well, or have they changed? Also, did you buy them through digikey, or somewhere else?
    Thank you for publishing this board. I was really happy to find that I could get the board and that I wouldn't have to design it myself (new to PCB design).

    ReplyDelete
    Replies
    1. Yes I'm still using the same regulators and I bought them from Digikey, however, now that I know better, I think I should have used one regulator with two outputs instead of two regulators because this way it's cheaper and it saves space on the board.

      Delete
  34. Hi, that is really awesome, I would like to ask if I want to implement (Audio/Video) recording, what will you advice me to do ???

    Thanks and I appreciate ur response :)

    ReplyDelete
  35. hi, i want to interface tcm8240md with lpc1114. plz guide me schematics code?
    thank you

    ReplyDelete
  36. Hi...
    I want to buy this complete module for my project purpose.\
    Can you provide any???
    and what cost is the cost of it???
    Please reply early...

    Thank you.

    ReplyDelete
    Replies
    1. I don't usually sell any because shipping is a bit expensive the cost adds up to around $50 including shipping. if you still want one, leave me a comment with your email (I won't publish it) and I will contact you with the details.

      Delete
  37. Hi Mux,
    I'm planning to start working on a project to interface this camera and stream the video over network. I'm going ahead to buy this cam and your breakout board. Can you please provide the list of components to populate on this breakout board at
    http://batchpcb.com/index.php/Products/63046

    Thanks,
    mangesh

    ReplyDelete
    Replies
    1. Hi, I listed the parts here somewhere in the comments.

      Delete
  38. I would like to interface this camera to a PC to take still images. I don't care about frame rate. I just need to grab one frame at a time over a USB connection. What microcontroller could I use that would have a USB interface?

    Thanks
    Kent

    ReplyDelete
    Replies
    1. Hi, you will still need a fast microcontroller, regardless of the frame rate, unless you do some buffering, anyway, maybe an ARM LPC17xx or STM32, both have USB interfaces, good luck.

      Delete
  39. hello
    How are you?
    Can you help me?
    I need a bascom avr code
    for camera with i2c protocol
    camera name is Tcm82330md
    take photo's with camera in jpg format
    and shed in sd card
    I need it soon

    please answer me soon

    ReplyDelete
    Replies
    1. Don't have any, sorry, you can try looking in the sparkfun forums.

      Delete
  40. Hey mux,
    I have been working on this camera for around 2 weeks, and I have even gotten good results and pictures out of it. I just had a question regarding the I2C interface. I am able to write to registers at the beginning when I start up the chip, you kind of have to to get anything to come out, but I can't seem to write once the chip is up and running. I want to play with the registers and see how they effect the picture. Do I need to restart the camera every time I want to change things?

    Setup: I am running an Atmel 328, programming it with Atmel studios 6(AVRISP mkII). clocking the camera at 200kHz. currently using QQVGA, no codes, and RGB565. I got my I2C stuff to work well with a magnetic sensor, but the data sheet doesn't mention I2C being blocked at any time.
    Gary

    ReplyDelete
    Replies
    1. Hi Gary, I think the camera must be disabled to accept commands,the datasheet specifies a window where commands are valid, which is after you reset the camera and before you enable the output, it also describes how to disable the output, if I remember correctly, you might want to try that first see if it works.

      Delete
  41. Hi Mux, just to say thank you for sharing the hints on getting this TCM8230 camera chip to work. I managed to build my own breakout board and interface to PIC32MX7 controller with graphics LCD. The camera works with EXTCLK frequency to as low as 3MHz. ~FK~

    ReplyDelete
    Replies
    1. you're welcome and good luck with your project :)

      Delete
  42. Hi Mux,

    I am curious why you "looped" D0-D4 lines by the header (i.e. D0 has two half-circles, D1 has three half-circles, etc.). Is there an advantage to routing the signals this way?

    Thanks!
    -Tony

    ReplyDelete
    Replies
    1. Those "wiggles" just make the tracks have the same lengths, to make sure the signals arrive at the same time. At this frequency it might not really be necessary.

      Delete
  43. Hi,

    I've just bought the camera TCM8240MD in order to develop a project with PIC32MX795F512L. It is the first time which I program a camera. I know how I2C works, but I don't know how I have to initialize the camera and acquire the data. I don't understand the datasheet a lot. Can you help me?

    Excuse me for my bad english...

    ReplyDelete
    Replies
    1. Hi, that's actually a different sensor, but check out this post anyway maybe it will help.
      http://sigalrm.blogspot.com/2012/01/nrfcam.html

      Delete
  44. hii, plz send me full details to interface TCM8230MD with external peripherals. and microcontroller also. also send me the commands for it.

    ReplyDelete
    Replies
    1. The repositories have everything.

      Delete
  45. Hi Mux,

    Also would like to thank you for posting info on this camera, I'm sure it is going to cut a lot of time off my development time. Great job. My questions is: I have downloaded your PCB file TCM8230MD-3.0 and notice that none of the surface mount capacitors are attached on one side (which I would expect to connected to ground). Is this because I miffed the download/import of the files or is this really the way it is meant to be? I am using Eagle 6.4. I also notice that you outlined the board with dashed traces, top and bottom, is there a reason for that? Thanks in advance for any answers you may have.

    Nate

    ReplyDelete
    Replies
    1. Probably you want to do the ratsnest command in EAGLE, and then it should work fine. This fills in a ground plane on the board.

      Delete