Microcontroller interface - Feature Requests - CHDK Forum supplierdeeply

Microcontroller interface

  • 8 Replies
  • 5119 Views
Microcontroller interface
« on: 28 / April / 2008, 12:01:18 »
Advertisements
Hi all, its really late here in oz, so I appoligise if I'm rambling. I just found your site today. you've done an amazing job.

I've been reading through it searching for a way to interface a canon camera to an arm7 microcontroller such as the lpc2129 or similar. I'm thinking of either faking a usb protocol with the camera (maybe using GPIO) or possibly faking a sd card to the camera to pull the images from it.

If I faked a USB:
-do you guys think i could compile chdk to spit the image out the usb port without being requested so i could sample with the microcontroller.
-perhaps using a script which recieves the usb click as described here building usb-remote-cable and in the scripts section, to kick off the trasfer post image capture.

if I faked a sd card:
-can I specify the sdcard output to be in spi mode?
-could i change the data rate on the sd card bus?
-can i put chdk onto the cameras memory so i can take the sd card out and wire the memory card port directly to my microcontroller

alternaively could i transfer an image using the flashing led technique? i found one post that quoted about a 10K transfer rate.

does anyone have any other ideas??? or has anyone seen a microcontroller friendly method for this around.

Sorry for all the questions, I think this would be usefull to the community. If I'm successful it'll be released under an open source liscence most likely the GPL.

cheers for taking the time to read all of that,
NoobSchoolBus


*

Offline jetzt

  • ****
  • 316
  • [A710IS,(SD200)]
Re: Microcontroller interface
« Reply #1 on: 28 / April / 2008, 14:19:57 »
So I have to leave you with the search, because I don't know much more than that what is already on the forum here,
but I have at least one answer. :D
Quote
-can I specify the sdcard output to be in spi mode?
No I assume not, cause in that case the camera is the controller, and this means that you will almost certainly have to change the firmware.
Nothing is impossible, but easier would be boring.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Microcontroller interface
« Reply #2 on: 28 / April / 2008, 15:25:30 »
First, any fast I/O to CHDK would be greatly appreciated. Having the camera perform as USB mass storage and enabling USB webcam type operation with all camera models (not just ones which work with Canon's newly obsoleted remote control features) score pretty high in the "Which missing features would you like to see?" poll on this forum and any work that touches this even at a distance may help us to get there sooner.

You may want to check this: http://chdk.setepontos.com/index.php/topic,903.0.html thread for some information about how little we currently know. I'd be happy just to have a speed equivalent of a 300 baud modem for USB input and output to communicate with CHDK or scripts, and currently we are quite far from that.

If you are to spend time trying to make a uC interface to work, I'd suggest you try to get it done with USB, because finding out how to do it would be immensely useful to all of us (as it could also enable PC control and simpler remote control compared to what you are thinking of). A hardware hack of the SD/MMC interface would of course be cool, but it would be less accessible to most users.

That said, emulating an SD/MMC card or spying on one in parallel would need less knowledge of the camera. I doubt you'll be able to use the SPI interface unless the camera already uses the cards in that mode but that's just a guess (it's been a while since I've played with those, am I right if I remember that SD/MMC cards perform significantly slower in SPI compared to the MMC interface?). If you end up communicating by writing to an actual Flash card, you should remember that they have limited write/erase cycle lifetime.

-can i put chdk onto the cameras memory so i can take the sd card out and wire the memory card port directly to my microcontroller
That I don't know (and I can't test it since my camera doesn't have any internal memory for jpeg storage). The developers familiar with porting would know better; my guess is that the firmware update feature in the camera probably only works from a card. Again, just a guess.

alternaively could i transfer an image using the flashing led technique? i found one post that quoted about a 10K transfer rate.

I believe you can. You should probably use a photodiode instead of a phototransistor for receiving as the latter may be too slow. AFAIK, there are watchdogs to worry during transmit but I'd think that just means that you need to pass control to the firmware every now and then. Of course, this way you only have output. Data input is limited to something like one bit per 10 ms or slower using the USB supply voltage method.

*

Offline BB

  • ***
  • 164
Re: Microcontroller interface
« Reply #3 on: 28 / April / 2008, 16:47:05 »
I don't know if anyone has tried an "Eye-Fi" card (2 GB SD card with WiFi interface):

Eye-Fi » Home

But if you want to access data and camera results, this seems a possible way to go...

And, you can set up an IPC (Inter Process Communications) using a "mail box" folder/file(s) and semaphore on the SD Card that could communicate with a CHDK process on the camera (or perhaps a polling/read/write uBasic/Lua program).

From their website, they say:

Quote
The Eye-Fi Card currently supports JPEG photo uploads. Non-JPEG content can be stored on the Eye-Fi Card like a standard SD memory card, but only JPEG photos will upload.

However, that limitation may just be for their little server program that can automatically upload camera JPEG files to various photo sharing sites.

-Bill

There is nothing stated about the ability for the camera to read/write the card while the WiFi network is reading/writing the card... Hardware addressing conflicts can be real nasty problems to solve if hardware/firmware protocol locks were not properly implemented in the Eye-Fi card.
« Last Edit: 28 / April / 2008, 16:50:08 by BB »


Re: Microcontroller interface
« Reply #4 on: 29 / April / 2008, 11:38:24 »
Wow this really is an active community. Cheers for the replies all.

I don't know if anyone has tried an "Eye-Fi" card (2 GB SD card with WiFi interface):
Eye-Fi » Home

I missed this one, that truely is amazing and perfect for most robotics which normally remain within range of an access point. (also it looks as though theres a fair push to port linux to it too). The microcontroller interface I have in mind is for a UAV (unmanned aerial vehicle). The project's here uavdev.com
So I need low power and long range. The proceessor I intend on using for the camera controller wont have usb or ethernet so i probably wont go to far towards a generic mass storage device but could perhaps fake some simplified twain driver or pictbridge(ptp) to make it more generic. I dont have onboard wifi but i could use a wifi to spi oem module for $100-200 but it seems a bit wasteful to spend up to $300 on the interface (that would be more than the camera :) ) and i wouldnt be sure it'd work till the linux port is up and running for the wifi sd card. So essentially i want to do what that card is doing but transmitting and receiving via spi to the world.

This brings up another question (sorry im in the research stage for this) can I boot the camera and then remove the sdcard and put in one which doesnt use CHDK? i didnt think you could but then i found something in the forum saying that to reset the card back to factory default you needed to take out the batteries.

Quote from: fudgey
That said, emulating an SD/MMC card or spying on one in parallel would need less knowledge of the camera. I doubt you'll be able to use the SPI interface unless the camera already uses the cards in that mode but that's just a guess (it's been a while since I've played with those, am I right if I remember that SD/MMC cards perform significantly slower in SPI compared to the MMC interface?)
Yeah I'm running through cameras at the moment from friends trying to see if any of them can transfer using spi mode or 1-bit mode. what I'm doing is using a sd card and covering the 8 and 9 pins with cellotape to see if the camera can still transfer an image to it.

the SD card pins are numbered a little funny, they're labeled:

  /----------------------------\
/   [1][2][3][4][5][6][7][8] |
|[9]                                  |
|                                      |
|                                      |
|                                      |
---------------------------------

from the table available at Secure Digital (SD) card pinout and signals @ pinouts.ru you can see that what I'm trying to do is cover the pin 9 and pin 8 contacts. If the camera is transferring data to the card using the spi protocol then the pin 8 and 9 will not be used and therefore covering them wont effect its operation. If its using the SD mode then they will be used and the camera will report this as an error with the memory card.

If any one would like to help out:
try the above test and post your results along with camera type. I'll buy a camera once I find one that'll play nice, since a less parrellel bus will be easier to start with.

the sd card bus has a write/read success check each time so i might be able to request retransmissions and burst the data out.


Quote from: fudgey
believe you can. You should probably use a photodiode instead of a phototransistor for receiving as the latter may be too slow. AFAIK, there are watchdogs to worry during transmit but I'd think that just means that you need to pass control to the firmware every now and then. Of course, this way you only have output. Data input is limited to something like one bit per 10 ms or slower using the USB supply voltage method.
Has anyone actually achieved this (a full photo transmission through the led) I cant find it on the site  :-[.


Quote from: jetzt
No I assume not, cause in that case the camera is the controller, and this means that you will almost certainly have to change the firmware.
Nothing is impossible, but easier would be boring.
I'm looking at getting an A550 to have a go with the source code I'll try to return the A470 I brought before I found CHDK.

Thanks all, great replies.

I'll maintain a list here for the cameras that have been tested and what the results were from the above test:

Brand:     Model:     Chipset:    MemoryCardInterfaces:     MinDataLines:     SuspectedMode:    SPI?:
Cannon    A470       digicIII      SD/SDHC                             4                         SD mode                 No






*

Offline BB

  • ***
  • 164
Re: Microcontroller interface
« Reply #5 on: 29 / April / 2008, 12:48:37 »
I looked at your uavdev.com site, but I could not tell much about your processor motherboard...

Perhaps, the next generation could support an SD sized Wifi host card and attach to the Eye-Fi card...

Spectec Computer Co., Ltd. (don't know anything about the card or company)

Probably, the best result would be to reverse engineer the internal USB controller interface for the Canon cameras and attach to the CHDK code. Obviously, the camera can talk just fine across the USB interface--but for whatever reason, Canon has not released very many cameras that are capable of USB communications while the camera is operational--and that is probably only supported using Canon supplied software running on a PC.

Using the "flashing LED" to transfer data while the camera is otherwise in operation is probably not worth the trouble... The data rates are low and error rates are high. Look for the dumping firmware forum and see that this can take hours to dump a couple MBytes of firmware.

-Bill

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Microcontroller interface
« Reply #6 on: 29 / April / 2008, 15:17:16 »
This brings up another question (sorry im in the research stage for this) can I boot the camera and then remove the sdcard and put in one which doesnt use CHDK? i didnt think you could but then i found something in the forum saying that to reset the card back to factory default you needed to take out the batteries.
At least in my a570is this is supposed to be physically impossible (of course it isn't if you hack around a bit with the hardware) since to get the flash card out, the battery compartment has to be opened. I'm not sure what happens with an external PSU since I haven't tried one yet.

Quote
Yeah I'm running through cameras at the moment from friends trying to see if any of them can transfer using spi mode or 1-bit mode. what I'm doing is using a sd card and covering the 8 and 9 pins with cellotape to see if the camera can still transfer an image to it.

My camera (and a lot of the others I would think) support MMC cards as well as SD cards. It actually came bundled with a small 16M or 32M MMC since there is no internal memory. MMC cards lack these extra pins (and all that SD DRM crypto [admin: avoid swearing please] with its license fees). SD cards are supposed to support MMC mode as well as SD mode. So aren't you testing for MMC mode instead of SPI or 1-bit mode? Or is MMC mode the same as 1-bit mode?

Quote
Has anyone actually achieved this (a full photo transmission through the led) I cant find it on the site  :-[.

I don't know. For what I've let myself to understand, the only LED blinking support visible to the user in current releases is for ubasic scripting and that's slow. But it's probably not very hard to add such code yourself, I believe all cameras have at least one LED whose control is known to work.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Microcontroller interface
« Reply #7 on: 29 / April / 2008, 15:25:03 »
Using the "flashing LED" to transfer data while the camera is otherwise in operation is probably not worth the trouble... The data rates are low and error rates are high. Look for the dumping firmware forum and see that this can take hours to dump a couple MBytes of firmware.

I'm not sure but I would think that LED blinking speed is not the limiting factor in these firmware blinkers, but instead the typical receiver solution using a phototransistor (slow, a typical setup with a typical part only ensures you something like 9600 or 19200 baud) connected to a PC sound card input (in practice even slower than the phototransistor).


Re: Microcontroller interface
« Reply #8 on: 01 / May / 2008, 00:59:01 »
Spectec Computer Co., Ltd. (don't know anything about the card or company)

Well spotted Bill, thanks for that. I may use one of them initially just to get the rest of the system closer to completion. They also make a 1.3M pixel version which could do for now.

I do want to eventually create a simple microcontroller
-fat16 spi port (maybe hybrid sd/mmc mode),
-or usb port,
-or raw jpeg from the LED blinking,
out of the camera though for high res imagery. I'll go ahead and get an A550.


Quote from: fudgey
My camera (and a lot of the others I would think) support MMC cards as well as SD cards. It actually came bundled with a small 16M or 32M MMC since there is no internal memory. MMC cards lack these extra pins (and all that SD DRM crypto [admin: avoid swearing please] with its license fees). SD cards are supposed to support MMC mode as well as SD mode. So aren't you testing for MMC mode instead of SPI or 1-bit mode? Or is MMC mode the same as 1-bit mode?

Yes it seems its not as simple as blanking out the pins and having the camera fall back to the generic SPI mode unfortunatley (unless its just the cameras i've tested). There must be some form of enumeration of the memory bus to figure out which type of card it is and therefore which protocol to use. when you blank out even just the pin 9 (essentially making the sd card an mmc card) I'm always recieving an error. even on cameras which support mmc. Its a pitty that the mmc spec uses bidirectional signal lines. I'll possibly need to use a tri state buffer to switch between MOSI and MISO on the spi bus. and then just use two spi ports. Could be interesting.

cheers

 

Related Topics