Digital camera control code AKA PTP (Picture Transfer Protocol) compatible with USB Host Shield rev.2.0 Arduino library has been released and posted to GitHub. New code has all functionality of original camera control library and adds new elements, namely ability to control several cameras simultaneously and (finally!) support for Nikon DSLRs.
The code comes with numerous examples demonstrating various aspects of digital camera control. All examples were compiled using Arduino IDE rev.0022 with USB Host Shield 2.0 and PTP 2.0 libraries installed as usual (by copying the whole library directory in %arduino%/libraries
) and tested on Arduino UNO equipped with USB Host Shield. There are also several examples which require Quantum Platform state machine framework, they can be recognized by qp_port.h
header included in the text of the sketch. If you want to try one of those, install QP Development Kit for Arduino and then replace qp_port.cpp
with this file.
More detailed explanation of library examples will follow soon. In the mean time, play with the library and try the examples. Stay tuned for the updates!
Oleg.
I’m very confused about what to do with files I downloaded from github. I used Arduino IDE 0022 copied the unziped files to %Arduino%/libraries opened an example .pde and verified the build only to find many many, no such file or directory errors. When I put the .cpp and .h files named the same into a folder of that same name in /libraries I can reduce the errors, but i always end up with some .h files that I can’t figure out where to put. Where do all these files go?
Make a directory under ‘libraries’, call it, e.g., ‘ptp’ . Put ptp library files in there. Make another directory under ‘libraries’, call it, e.g., ‘usbhost’, put usb host 2.0 library files there. After that, close/open IDE and try to compile examples again.
Well, it wasn’t a cake walk, but I’ve got several example sketches compiled now and working with my 7D. Thanks for all your work.
From Arduino’s installation instructions you must make a file called ” libraries” first in your chosen “arduino sketches” directory.
Then extract the third party library to that new “libraries” directory.
I found that the “Host Shield Library 2 ” when downloaded and extracted would not be accepted by the Arduino IDE. I had to rename the library to “USBHost2” and then it would compile and load them.
First, let me thank you for all the work you have done on this already.
Thinking about how I might use these libraries, one of the questions that has popped up is whether you have looked into the functions by which images are transferred from the camera via USB? Clearly programs for the PC such as DSLR Remote Pro allow you to save the images to the controlling PC’s HDD rather than to the CF card of the Canon DSLR whilst it is controlling the camera, but it takes exclusive control of the camera during this process. What I would ideally like to do is find a way of writing the image data to an HDD or other storage media external to the camera whilst controlling it with an Arduino and your excellent libraries. I don’t mind if it is to an HDD in a laptop or to some kind of storage attached to the Arduino.
If you have any thoughts on this subject it would be much appreciated.
Thanks in advance,
Chris
File transfers using Arduino are going to be very slow; I don’t think it’s practical.
My alternative is to try to find a way for us to connect an HDD to the CF slot of the camera I guess.
Thanks anyway.
Am I right in assuming that when a PTP connection is established to a camera that it takes exclusive control of the camera?
It depends on a camera. For example, EOS and Nikon DSLRs continue reacting to button presses while PTP session is open. On the other hand, Powershots won’t react to button presses at all.
Sorry to bombard you with questions 🙂
So for example could you use a non-powered USB hub with two Arduino’s and an EOS 7D and use one Arduino to control the shutter speed and the other to control the apperture for example?
You can’t have more than one USB Host on a bus. Also, you can’t have more than one PTP session open to the camera.
While you can’t have 2 USB hosts on a bus, you could use the arduino to switch between USB hosts.
I haven’t looked at the new examples yet but looking at the old “Capture” sketch it seems to order the camera to do the capture and then waits a fixed amount of time. Is there a way to make it so the camera is polled or informs the Arduino when it’s ready? It seems like my camera can have quite a variation in write times to the SD card depending on how full the card is. I would like to automatically take a picture, wait just long enough for the camera to be read then take another, rather than set an arbitary delay that may be too long in most cases and risk it not being long enough in others.
((just long enough for the camera to be READY… sorry))
Hi Oleg, it’s way cool!
Now we just need the CHDK PTP to get a double rainbow across the sky, forever.
Hope you got that email with those start point infos.
Did you manage some time to take a look at them?
Cheers!
Yes, I’ve played a little with CHDK already. Don’t have much time at the moment but I’m planning to develop CHDK interface some time in the future.
Can these routines be adapted to work with the Mega ADK board?
It wouldn’t be slow to transfer a small thumbnail JPG over Xbee.
Thoughts?
Hi, Oleg
Thanks for the PTP. Great fun to be able to control the camera!
Now, I have a problem of using SwitchLiveView. When I set the value to be ‘true’. The camera (Canon 1100D) does switch to ‘Live View’, but also turning the camera screen off. I can’t seen anything either from the camera screen or the viewfinder. After some thoughts, I guess it’s probably becasuse the camera is on ‘computer connect’ mode.
Do you have any idea how i can see the view from the camera’s screen when it is connected to the USB Host Shield?
Thanks in advance!
LJ
You need to experiment with LiveView modes, there are several of them and they direct LiveView output to LCD, video out, USB, etc.
Hope to see more example for nikon DSLR soon! (^_^)
That’s nice Oleg,
I’m glad that you release the camera controller for lib 2.0
Does it support video mode? Like start stop video capture..
I remembert i can’t do start/stop video capture in the old version.
Thanks Oleg.
Have a nice day
There is some follow focus video code based on PTP 2.0 -> http://www.dslr-forum.de/showthread.php?t=942846&page=7
I’m working with your arduino usb host shield and need a little help. When I load any of the examples, USB.Init() instruction always returns -1. I’m lost, please give me a way to go.. Thanks!
Sure. Which shield is it (full size or mini) and which board revision (1.xx or 2.0)?
i have Arduino UNO with full size USB host Shield rev.2.0.. thanks in advance
do you have all included headers soldered in place – people tend to skip the small 2×3 one?
oks its seems to be a connection problem, I wanna use de extension connectors but the 2×3 is too hight for use with them. I hope to find a smaller 2×3 connector. Thanks, I’ll tell if it worked.
i will try and tell you, cause i don’t use the 2×3 one! My fault, i hope that the problem
Oleg,
Got the USB 2.0 Shield – runs like a charm connected to my Mega 2560!
Having some problems running the EOSHDRCapture sketch though… I’ve connected to my Canon 5D Mk II. The sketch trips the shutter 4 times, then repeats. Four shutter releases seems wrong. Also, every exposure is identical – no bracketing is happening. I get the output below on the serial console. Any ideas where I should look? Thanks!
Camera connected
Active
Q_INIT_SIG
SaveSettings
::PTP_RC_SIG
PTP_RC_OK_SIG
SelfTimer
PTP_RC_OK_SIG
Timeout
::TIMEOUT_SIG
SelfTimer
TICK_MILLIS_SIG
PreCapture
TICK_MILLIS_SIG
ExpCompSet
::PTP_RC_SIG
PTP_RC_OK_SIG
Capture
::PTP_RC_SIG
PTP_RC_OK_SIG
PostCapture
TICK_MILLIS_SIG
PreCapture
TICK_MILLIS_SIG
ExpCompSet
Transaction: Response recieve error: 2019
SetProperty error:: 2019
::PTP_RC_SIG
Timeout
::TIMEOUT_SIG
ExpCompSet
Transaction: Response recieve error: 2019
SetProperty error:: 2019
::PTP_RC_SIG
Timeout
::TIMEOUT_SIG
ExpCompSet
Transaction: Response recieve error: 2019
SetProperty error:: 2019
::PTP_RC_SIG
Timeout
::TIMEOUT_SIG
ExpCompSet
::PTP_RC_SIG
PTP_RC_OK_SIG
Did you ever figure this out? I have the same problem with my USB Host 2.0 and my Adruino Uno with my canon XTi
Thanks.
Will you start work on getting objects from Canon soon? Last I heard you said you do not see how it is useful. I explained it would be cool to get thumbnails to send via XBee. Don’t you think it would work?
hi,
Do u know what information can i obtain from canon live view? do they output any byte stream?
was thinking if i be able to transfer the byte stream from the dslr, through arduino and to a android phone, i will then be able to reconstruct back the live view images.
thanks!
Regards,
keith
IIRC it’s JPEG, about 250K per frame. I don’t think you’ll be able to transmit this via Arduino in real time at any decent frame rate.
You didn’t answer. Love the RAZR with your Host! If you can get objects from a Canon my friends will buy your board, at least 10 of them. Thumbnail image?
Can you give me some programming advice to get started?
How long do you think it will take you?
Get started with what? If you’re talking about image transfer, it’s really very generic operation supported by about any 10yo or younger camera. Take a look at gphoto source code to see how this is done.
Thank you! I would be happy to look. You don’t want to add this to your library anytime soon? I appreciate all your help with my CDMA V3M. It works wonderfully. So many times I almost gave up. Turns out in the end it doesn’t need it’s own power supply besides USB.
How do I get the RAZR to sleep while it’s physically plugged into your Host? Seems like it’s always drawing 200-300ma even when the battery is full. I tried running an empty sketch so your code does not initialize it. Is there an AT command for sleep? AT+CFUN doesn’t seem to work on mine.
What is the maximum value for +CFUN on your phone? Give me the output of ‘at+cfun=?’
The only value is Error! What am I doing wrong? Strange why would they disable that function for V3M? I’ve got many useful AT commands to work already! Receive SMS, Send SMS, dial, status…
Thank you oleg for all the work put into this devices and your dedication.
I’m working on my own version of the Yanis Controller, based on your UsbHost Mini board.
I would like to get a few info on the current state of the camera (like Aperture, speed, ISO, exposure compensation and so on) to display the current value on startup of the Android part. I know C pretty well, but am completely lost in C++. I tried to understand how you get those info in the EOSController demo but it’s too complicated for my understanding. I want to use the PTP 2.0 library but can’t figure out how to use Eos.GetProperty in canoneos.cpp, especially how to build a simple PTPReadParser object, like, for example, to get the actual Aperture.
Could you help me with that ?
First of all, thanks for the hard work on this library. I have a couple questions.
What is the purpose of replacing the qp_port.cpp file in the sketches that require it?
It’d be nice if the Sketches needing this change had some kind of comment at the top telling us to grab the file you link to in this post. I spent a good few hours trying to find this information, and was quite frustrated that I kept getting the same error, after changing the file it compiled fine.
2) Is there any detailed documentation for the library, or do we only have the examples to go by?
OK, so I just connected my Canon XTi and when I run EOSHDRCapture It does trigger the shutter, but the shutter speeds are the same. If I look at the serial output I get the following
Inactive
EOS Init
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Init complete
Camera connected
Active
Q_INIT_SIG
SaveSettings
::PTP_RC_SIG
PTP_RC_OK_SIG
SelfTimer
PTP_RC_OK_SIG
Timeout
::TIMEOUT_SIG
SelfTimer
TICK_MILLIS_SIG
PreCapture
TICK_MILLIS_SIG
ExpCompSet
::PTP_RC_SIG
PTP_RC_OK_SIG
Capture
::PTP_RC_SIG
PTP_RC_OK_SIG
PostCapture
TICK_MILLIS_SIG
PreCapture
TICK_MILLIS_SIG
ExpCompSet
Transaction: Response recieve error: 2019
SetProperty error:: 2019
::PTP_RC_SIG
Timeout
::TIMEOUT_SIG
ExpCompSet
Transaction: Response recieve error: 2019
SetProperty error:: 2019
::PTP_RC_SIG
Timeout
Ideas?
Are you trying to shoot in M mode? This sketch changes exposure by modifying Ev and Ev change is not available in manual mode.
Yes, I was in M mode. I guess that kind of makes sense, being in Manual mode would turn off any automatic functions like that,
So how would one use this sketch? P mode? Would I put it in P mode set the Av to where I wanted the center to be and then let it go? Does it keep the same aperture setting? What if I wanted more Depth of field? Can’t do that in P mode since I have no control over the aperture. Do we have control of those settings with the library? Sorry about all the questions, i’ve just been dying to do some HDR photography that isn’t limited to 3 exposures that my camera can do. Thanks
If you shoot in Av, Ev changes shutter speed. If you shoot in Tv, Ev changes aperture. If you want to change both shutter and aperture at the same time, you need to write another sketch. You can use EOSRemote as a reference.
OK I understand now. I have more questions, about how the setup loop works, but I’m going to read through it and try to figure that one out myself. Thanks for the help.
Oleg,
Is there some specific order I have to reset arduino, power on camera and connect usb for the focus functions to work? I have tried a few different sketches and the same thing happens. I have control over most camera functions except focus.
Any suggestions? I am using the Eos.MoveFocus commands.
thanks
jason
Which camera model are you trying to control?
Oleg, I am running a 5dmkII with a 70-200L lens. I have control over other functions. Does the camera have to be in manual mode? I occasionally get the dreaded error 80, but its rare. I can do live view, capture, do just about everything except focus.
Thanks in advance.
jason
It works on my 5Dm2. The mode is not important. Have you tried different lens already – I don’t have 70-200? Do you see any errors in serial monitor?
Oleg, No I dont see any errors in the serial monitor. I will try a few more lenses. Its strange how it works intermittently. There is no specific power up order?
Jason
The sketch should detect camera connect/disconnect. You can start a sketch, connect a camera, then turn the camera on – this is probably most straightforward way to do it.
Hi Oleg,
I’m trying to control a Canon PowerShot SD870 with the Arduino Pro Mini and the USB Host Shield. I’d like to do remote shooting, if it’s possible with this camera. However, the camera isn’t listed on GPhoto’s site and is listed as Not Compatible on Canon’s SDK FAQ site. When I try to run PTPDevInfo on the camera (or any of the other PS examples), I get Usb.Init() == -1.
As far as I can tell, everything has a good solid connection. All the indications are that this camera model doesn’t support remote shooting out of the box. However, I have CHDK installed and I think that should give me a way to do it since it has a PTP interface built in. Is there a way to interface your PTP code with CHDK and if there is, how do I go about doing it? Is my USB initialization problem likely a configuration issue or is it indicative of general incompatibility?
I’d be grateful for any help you can give.
-Aaron
CHDK is not yet supported.
Hi guys,
Firstly thankyou for the huge body of work you’ve constructed here. I’m really looking forward to putting it to good use to help justify your efforts.
But I’ve hit a problem from the start. I believe I’ve followed the instructions for copying the files to the libraries subdirectory, and I’ve also downloaded qpp and replaced the one library file there too. I’ve copied the examples into my sketchbook directory and they’re all showing up nicely.
However, when I compile any of the sketches I get loads of error message so I must have goofed somewhere. The first error for example in the PTPDevinfo sketch is Serial is not defined in this scope for a few files including hexdump.h, and devinfoparser.cpp also complains that Serial HEX and DEC are not defined in a long list of functions.
I’m running Win 7 Pro 64 bit and a nearly fresh install of the Arduino development environment if that helps. Other simpler sketches I’ve written compile fine, but this is by far the most complex thing I’ve compiled so I’m not sure that’s a deep test.
Hopefully this is a simple trap I’ve fallen into and the answer is obvious to anyone with experience. Thankyou for your help,
Geoff
what is your IDE version? 1.0 is not yet supported, you need to use 0022 or older.
Thanks Oleg you are of course correct. I’ve installed the 0022 IDE, moved all the libraries over to it, and the sketch now compiles fine. Just waiting for my USB host shield to arrive this week and we can start to play.
Thanks so much for spotting my newbie mistake, Geoff
Hi,
first of all: Great work and thank’s a lot for sharing it!
Though I can’t get the library to work – first tried on IDE 1.0 (ok, read afterwards on it), IDE 0.23 reports a ton of errors (even without code), so finally I took 0.22, which works fine for so far.
Trying to compile the PTPDevInfo, I get the following error:
Assembler messages:
Fatal error: can’t create usbhost/Usb.cpp.o: No such file or directory
I have no clue what this means, as there is no such file and it is nowhere mentioned in the code.
Working on a Mac, Uno Board and all libraries downloaded today.
Your help is very much appreciated!
austrian
— issue seems to be solved: redownloaded everything and now it works fine 🙂
this whole development is great – just – i still can’t get any camera to trigger 🙁
got a couple of usb-host-shields from oleg a while ago yet, but didn’t spend much time with it back then. now i just found these new versions and was hopeful since all sketches compile and upload fine, but all i get when hooking up a camera (eos20D) is
Start
EOS Init
PTP Init
no matter which sketch i try from the examples (most basic i suppose should be EOSCapture)
any hints for an arduino-noob?
thanks.
It seems 20D doesn’t support PTP.
oh well.. one can set it to PTP, but indeed – in gphoto it’s also triggered via the “normal mode”..
just to get things straight:
the examples coming with PTP_2.0 are split in folders Canon_EOS, Canon_PS, Nikon and ptpsketches – but they all work via PTP only, right?
PTP is a base protocol, also there are vendor-specific extensions. Consequently, there are generic PTP examples as well as vendor-specific ones. Try to run PTPDevInfo with your camera set to PTP mode -> https://github.com/felis/PTP_2.0/tree/master/examples/ptpsketches/PTPDevInfo and see if any interesting commands are supported.
but “normal mode” in gphoto-speak is not PTP-based, or is it?
as expected there’s no hint for “capture” in PTPDevInfo output, supposedly it’s for DPOF only..
i just found that you started marking cameras with ‘+’ and ‘-‘ in your http://www.circuitsathome.com/ptpusb-control-camera-data – but none of those i reported. anything i could do to complete this?
I put a minus against 20D and plus against A85 – thanks for letting me know!
so, next camera in reach, powershot A85. supporting capture via PTP, just confirmed with gphoto from laptop and indicated in PTPDevInfo output.
using PSCapture i (mostly) get this:
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Fatal USB Error
Transaction: Response recieve error: 0004
StartShootingMode failed: : 2002
Initialization error
Camera connected
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
… [seems to loop till camera hangs]
it looks like a timing-issue – like the program not waiting for the camera to be ready – very rarely it does capture once after being plugged in. also with the PSRemote-sketch i can capture once, but camera hangs afterwards with the seem loop of error-msgs..
You may have slow endpoint – try to add
delay(1);
after line 380 in https://github.com/felis/USB_Host_Shield_2.0/blob/master/Usb.cppdoesn’t really help 🙁 it captures once after connection but then gives similar errors again (see below). out of five tries it captured a second image once, inbetween spitting out these errors..
Start
Camera disconnected
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Camera connected
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Transaction: Data block send error.: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
Transaction: Command block send error: 0004
EOSEventCheck error: : 2002
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
Transaction: Command block send error: 0004
EOSEventCheck error: : 2002
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
Object Added: 00000013
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
Transaction: Command block send error: 0004
EOSEventCheck error: : 2002
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
Transaction: Command block send error: 0004
EOSEventCheck error: : 2002
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Focus Lock Error: : 2002
Transaction: Command block send error: 0004
Capture Error: : 2002
ode failed: 2002
are you able to change shooting parameters using PSRemote? Also, what happens if you set image size to the smallest one available – can you capture more than one image? I see you’re having focus lock errors – check that your camera is able to focus.
@PSRemote: yes. surprisingly i can set any available setting (not sure i was ever able to do this with gphoto2 with this cam)
as i had it running i captured from there (added some interaction info in [brackets]):
0.
1. Capture
2. View Settings
3. Change Settings
4. Viewfinder On
5. Viewfinder Off
[hitting ‘1’]
[camera focusses&triggers]
[t+0]
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
[t+10s]
Object Added: 00000015
Fatal USB Error
Transaction: Response recieve error: 0004
EOSEventCheck error: : 2002
Storage ID: 00010001
Object Format: 3801 EXIF_JPEG
Protection Status: 0000
Object Compressed Size: 0009DDE3
Thumb Format: 3808 JFIF
Thumb Compressed Size: 00001071
Thumb Pix Width: 000000A0
Thumb Pix Height: 00000078
Image Pix Width: 000008E0
Image Pix Height: 000006A8
Image Bit Depth: 00000018
Parent Object: 00000005
Association Type: 0000
Association Desc: 00000000
Sequence Number: 00000000
File Name: IMG_0215.JPG
Capture Date: 20120105T103851.0
Modification Date:
Keywords:
Capture complete.
this was the first time i got to see the capture&save confirmation. and i can even capture multiple times this way. but as you see there’re still those errors inbetween, and it indeed seems to be the time the camera processes&stores the image (~10s, but this doesn’t take that long when camera is used normally – there seems to be some delay at some point). tried setting the image-size to smallest, but this isn’t remembered for the tethered shooting it seems – just found that those files captured remotely still are ‘large/fine’. but i can’t set the size via PSRemote:
0.
1. Mode
2. Aperture
3. Shutter Speed
4. WB
5. ISO
6. Exp Comp
7. CamOutput
8. Zoom
btw – the focus lock error i think also is just a result of those timing-issues, the camera can and does focus fine, if it gets enough time to do it..
Oleg, is there documentation that shows all the commands that you can run with the Eos. library? I want to make sure there is a start and stop on video capture,not just take a still photo.
Thanks
jason
All commands and properties are listed in the source. There is a project which implements video start/stop, among other things -> http://crispconcept.com/android.php
When i try to compile EOSHDRCapture with the arduino 1.0 IDE i get the errormessage:
core.a(new.cpp.o): In function `operator delete(void*)’:
C:\Users\username\arduino\arduino-1.0\hardware\arduino\cores\arduino/new.cpp:10: multiple definition of `operator delete(void*)’
qp\qp_port.cpp.o:C:\Users\username\arduino\arduino-1.0\libraries\qp/qp_port.cpp:49: first defined here
I already copied your qp_port.cpp in the libraries/qp directory as you described.
I’m also getting this error, any ideas?
Marcus, I opened the qp_port.cpp file and commented out the code block referencing ‘operator delete(void*)’ and the sketch compiled…
I assume it was ‘defined’ in another file and caused a conflict? No idea, I’m not familiar with this stuff yet, but in any case, that seems to have done it.
Hi Oleg,
do you have some examples of using multiple cameras though the usb hub? can’t find any of them on the git hub 🙁
I don’t. You don’t need to do anything special – just create two instances of the camera and start feeding them commands.
oh, I see. it was so easy that I coudn’t imagine that!
I uploaded the PSCapture sketch and plugged in my old PowerShot A540 and get the output below. My camera isn’t recognized until it switch it into playback mode and disconnects when switched back to camera mode.
Should I assume that the A540 is too dumb to support capture control via PTP?
Thanks,
Tom
Start
Camera disconnected
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Transaction: Response recieve error: 2005
StartShootingMode failed: : 2005
Initialization error
Camera connected
Transaction: Response recieve error: 200A
Transaction: Response recieve error: 2005
Focus Lock Error: : 2005
Transaction: Response recieve error: 2005
Capture Error: : 2005
connected
: 2005
Transaction: Response recieve error: 200A
Transaction: Response recieve error: 2005
Focus Lock Error: : 2005
Transaction: Response recieve error: 2005
Capture Error: : 2005
connected
: 2005
Camera disconnected
What is the output of PTPDevInfo?
Hi Oleg,
I am desperately trying to find a way to trigger the shutters of 11x -Sony CyberShot DSC-H10 ‘s with one button press. While I was looking at the support page of the camera it mentioned PTP as a USB mode http://www.kb.sony.com/selfservice/documentLink.do?externalId=C208207 – In my camera’s menu system it lists it as “PictBridge” which I assume is Sony’s variant of the PTP protocol? PLEASE tell me that its possible for me to use your USB-Host-shield library to fire the shutters!?… I really do not want to hack apart all 11 cams to hard solder in a remote switch.
Anyone else have any experience with using the USB host shield for communicating with “PictBridge” devices? Seems like it should be possible. PictBridge actually uses PTP as the transport layer so should I just order the USB host shield and give it a go? Also if anyone is curious, here is the “white papers” for PictBridge http://www.cipa.jp/pictbridge/documents_e/WhitePaperE_Rev.2.0.pdf
I don’t think your camera supports capture command. Check to see if gphoto supports it – if yes, there is hope.
PictBridge is printing protocol, it has nothing to do with camera control.
Hi Oleg thanks for the reply.
Seems like my exact model is not listed on the libgphoto2 page- http://gphoto.com/proj/libgphoto2/support.php
However, there is something on there that gives me hope. Even though PictBridge is a printing protocol they list some cameras working with gphoto Using PictBridge.
Check it “Konica-Minolta DiMAGE A200 (PictBridge mode)”
“Konica-Minolta DiMAGE X21 (PictBridge mode)”
“Konica-Minolta DiMAGE Z2 (PictBridge mode)”
“Konica-Minolta DiMAGE Z3 (PictBridge mode)”
“Konica-Minolta DiMAGE Z5 (PictBridge mode)”
Is there nothing that can be done? I wish I could use other cameras but Im stuck with these. So it would be amazing if I could get this to work.
Ok, Plan B.
I am going to try and acquire some new cheap point and shoots cameras to build this instead of the Sony’s I have now. Any recommendations for a particular model that is cheap and DEFINITELY can have its shutter controlled by the Arduino + USB host shield?
Also- I noticed if I order the shield from your site it will be shipped from Europe.
Should I order this one from sparkfun since I live in Texas? ( I noticed Oleg’s name on there)
http://www.sparkfun.com/products/9947
Nikon Coolpix S3300 works very well; other Nikon P&S may work too.
I ship from the states. Sparkfun shield is not compatible with my code.
Thanks for the suggestion Oleg.
Because I will be buying 20 of the cameras- that coolpix is out of my price range.
After some research the Canon powershot a800 is the cheapest one I can find that supports PTP.
Would that be a safe bet to use with your shield and code?
also thanks for the spark fun info. I will def. buy from you. Just as soon as I decide on a camera to buy that works with it.
Any modern camera supports PTP. Only a few support shutter control AKA capture over PTP.
I don’t have any information about a800.
I need to decide on the camera’s as soon as possible or it might not happen….
Can I just refer to the list of cameras here: http://gphoto.com/proj/libgphoto2/support.php
and as long as it says PTP – it should work with your shield right?
Oleg, thanks so much for your prompt responses!
I am going to order my USB shield right now.
I will go ahead and take your suggestion and make them buy me some Nikon Coolpix S3300’s – because you said they will support capture.
What else can you do the S3300’s? what commands are supported?
This is the full list -> https://www.circuitsathome.com/ptpusb-control-camera-data#NIS3300
Does your example code work with the Nikon S3300?
PTPCapture works with this camera.
Hi! I’m trying to make an application in java to control a Canon Eos 600D. I’ve managed to make it work and have it capture images and get device info.
I’m trying to get it to do the other commands and I’m using your Arduino Camera Control code as a base.
Right now I’m stuck at understanding your transaction code. In ptp.cpp, there’s “uint16_t PTP::Transaction(uint16_t opcode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL)”
What does the OperFlags do? I’m looking at the PIMA pdf and the operation phase is Operation Code, Session ID, Transaction ID and Parameters if any.
Thanks!
I am on porting this code to ARM STM32 series. I am also confused about the mentioned uint16_t PTP::Transaction(uint16_t opcode, OperFlags *flags, uint32_t *params = NULL, void *pVoid = NULL) function in ptp.cpp. The data structure looks a bit different in that code, than in the PIMA standard. PIMA sais the command structure is OpCode,Session ID, Transaction ID and parameters. But in the PTP library code the used structure is Type, OpCode, Transaction ID. There is no Session ID, the offsets are different than in the PIMA standard, and there is a PTP_USB_CONTAINER_COMMAND as the Type. Can anyone explain me how it can work in this way? Is there some trick in the underlaying layers?
Thanks!
Now I found that the not the PIMA but the Still Image Capture USB specification defines the exact data structure for the USB medium, and the above mentioned function in ptp.cpp is consistent with that spec. As far as your question concerned Ash, OperFlag is for internal use only. You can find the details in ptp.h. It helps the Transacion function to pack the command, and calculate its length and so on. It is not related to the PTP protocol itself. By the way you also misunderstood the PIMA specs, and the USB Still Image Capture part of the documentation is relevant here.
Thanks GG! Hahaha.. Anyway I managed to make my Java program work to do a simple shutter release. Is there a special sequence for EoS600D to change the settings?
On this link: http://www.circuitsathome.com/canon-eos-cameras-principles-of-interfacing-and-library-description
Set to PC Connection. SetExtendedEventInfo. Then EventCheck. Is that right? So if i do that sequence of sending the commands it should work?
I’m coding this in Java. 🙂
Hello
I just bought your USB Host Shield 2 and mount it on my arduino UNO.
I installed the last versions of the libraries (PTP2 and USB Host Shield 2).
I tried with a powershot G6 and i get a lot of error and no way to shoot.
I join PSDevPropG6, PTPDevPropG6, DEVinfoG6.
Thanks for your help.
Here are DEVinfo and DevProp for powershot G6
DEVInfo for Canon G6___________________________________
Start
Camera disconnected
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Camera connected
00000000: 47 01 00 00 02 00 01 10 02 00 00 00 64 00 0B 00
00000010: 00 00 64 00 00 00 00 36 00 00 00 01 10 02 10 03
00000020: 10 04 10 05 10 06 10 07 10 08 10 09 10 0A 10 0B
00000030: 10 0C 10 0D 10 0E 10 0F 10 12 10 14 10 15 10 16
00000040: 10 1B 10 01 90 02 90 03 90 06 90 08 90 09 90 0A
00000050: 90 0B 90 0C 90 0D 90 0E 90 0F 90 10 90 11 90 12
00000060: 90 13 90 14 90 15 90 18 90 19 90 1A 90 1B 90 1C
00000070: 90 1D 90 1E 90 1F 90 20 90 21 90 22 90 23 90 24
00000080: 90 25 90 26 90 27 90 14 00 00 00 01 40 02 40 03
00000090: 40 04 40 05 40 06 40 08 40 09 40 0A 40 0C 40 0D
000000A0: 40 01 C0 05 C0 08 C0 09 C0 0A C0 0B C0 0C C0 0D
000000B0: C0 0F C0 12 00 00 00 01 D0 02 D0 03 D0 2C D0 2D
000000C0: D0 2E D0 2F D0 30 D0 31 D0 32 D0 33 D0 34 D0 45
000000D0: D0 46 D0 47 D0 48 D0 49 D0 4B D0 02 00 00 00 01
000000E0: 38 01 B1 06 00 00 00 01 30 01 38 0A 30 08 30 01
000000F0: B1 02 30 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
00000100: 49 00 6E 00 63 00 2E 00 00 00 13 43 00 61 00 6E
00000110: 00 6F 00 6E 00 20 00 50 00 6F 00 77 00 65 00 72
00000120: 00 53 00 68 00 6F 00 74 00 20 00 47 00 36 00 00
00000130: 00 0A 31 00 2D 00 31 00 2E 00 30 00 2E 00 30 00
00000140: 2E 00 30 00 00 00 00
Std.Ver.: 0x100
Vendor Ext. ID: 0xB(Canon)
Vend.Ext.Ver.: 0x64
Func.Mode: 0x8E2
Operations supported:
1001 GetDeviceInfo
1002 OpenSession
1003 CloseSession
1004 GetStorageIDs
1005 GetStorageInfo
1006 GetNumObjects
1007 GetObjectHandles
1008 GetObjectInfo
1009 GetObject
100A GetThumb
100B DeleteObject
100C SendObjectInfo
100D SendObject
100E InitiateCapture
100F FormatStore
1012 SetObjectProtection
1014 GetDevicePropDesc
1015 GetDevicePropValue
1016 SetDevicePropValue
101B GetPartialObject
9001 PS_GetObjectSize
9002 Vendor defined
9003 Vendor defined
9006 Vendor defined
9008 PS_StartShootingMode
9009 PS_EndShootingMode
900A Vendor defined
900B PS_ViewfinderOn
900C PS_ViewfinderOff
900D PS_ReflectChanges
900E Vendor defined
900F Vendor defined
9010 Vendor defined
9011 Vendor defined
9012 Vendor defined
9013 PS_CheckEvent
9014 PS_FocusLock
9015 PS_FocusUnlock
9018 Vendor defined
9019 Vendor defined
901A PS_InitiateCaptureInMemory
901B PS_GetPartialObject
901C Vendor defined
901D PS_GetViewfinderImage
901E Vendor defined
901F Vendor defined
9020 PS_GetChanges
9021 PS_GetFolderEntries
9022 Vendor defined
9023 Vendor defined
9024 Vendor defined
9025 Vendor defined
9026 Vendor defined
9027 Vendor defined
Events supported:
4001 CancelTransaction
4002 ObjectAdded
4003 ObjectRemoved
4004 StoreAdded
4005 StoreRemoved
4006 DevicePropChanged
4008 DeviceInfoChanged
4009 RequestObjectTransfer
400A StoreFull
400C StorageInfoChanged
400D CaptureComplete
C001 Vendor defined
C005 Vendor defined
C008 Vendor defined
C009 Vendor defined
C00A Vendor defined
C00B Vendor defined
C00C Vendor defined
C00D Vendor defined
C00F Vendor defined
Device properties supported:
D001 Vendor defined
D002 Vendor defined
D003 Vendor defined
D02C Vendor defined
D02D Vendor defined
D02E Vendor defined
D02F Vendor defined
D030 Vendor defined
D031 Vendor defined
D032 Vendor defined
D033 Vendor defined
D034 Vendor defined
D045 Vendor defined
D046 Vendor defined
D047 Vendor defined
D048 Vendor defined
D049 Vendor defined
D04B Vendor defined
Capture formats:
3801 EXIF_JPEG
B101 Vendor defined
Image Formats:
3001 Association
3801 EXIF_JPEG
300A AVI
3008 WAV
B101 Vendor defined
3002 Script
Manufacturer: Canon Inc.
Model: Canon PowerShot G6
Device ver.: 1-1.0.0.0
Serial num.:
______________________________________________
PSDevProp_____________________________________
Camera disconnected
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Fatal USB Error
Transaction: Response recieve error: 0004
StartShootingMode failed: : 2002
Initialization error
Camera connected
Transaction: Data block send error.: 0004
Mode:Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Transaction: Command block send error: 0004
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
Transaction: Command block send error: 000D
______________________________________________________________
PTPDevProp____________________________________________________
Start
PTP Init
Addr:: 0001
NI:: 0001
PTP configured
Session opened
Camera connected
Fatal USB Error
Transaction: Response recieve error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
Transaction: Command block send error: 0005
_____________________________________________________
thanks for your help
Simone,
I don’t have this camera to check; from the pictures I’ve found online it seems the camera has two modes – shooting and PC transfer. Have you tried Capture/DevProp sketch in both modes? My camera( A640 ) needs to be in PC transfer mode in order for PTP to work.
Oleg.
Hello,
I cannot make the example work. I get only 2005 and 200A errors. I was not able to find info here to help.
I am using :
– Arduino IDE 1.0.1,
– a USB Host Shield 2.0 for Arduino by Circuits@Home,
– an Iteaduino BT,
– a Canon PS sx230hs
Here is my PTPDevInfo: http://pastebin.com/DGYJ5RS4
PSRemote: http://pastebin.com/aF6zbzFt
PSCapture: http://pastebin.com/KNWNqnfa
PSDevProp: http://pastebin.com/VGAid495
Any idea?
It appears that your camera doesn’t support PTP control commands. Take a look here -> https://www.circuitsathome.com/ptpusb-control-camera-data . All capable Powershots (ones with ‘+’ next to the name) have 0x100e and 0x9008 operations listed. I don’t see those in DevInfo of your cam.
Thanks, that makes sense! I’ll try again using CHDK.
Hello,
let me first thank you for all your efforts, Oleg. What a great place here!!
Maybe anyone can give an hint, how to store File Name to a string variable:
In ptpobjinfoparser.cpp filename is displayed via
case 31:
Notify(PSTR(“\r\nFile Name:\t\t”));
arrayParser.Initialize(1, 2, &theBuffer);
nStage ++;
How could I save the arrayParser value to a string instead of displaying it on serial console?
(Sorry if that question is obvious, I’m quite a newbie)
_____________________________________________________
Thanks for your help
Hi Oleg. First of all I wanted to thank you for your amazing work. I’ve downloaded the USB library and used the HID example to read the entry of my generic Joystick. Then I’ve downloaded the PTP, which I’ve successfully used to automatize the shutter of my canon EOS 7D… What I want to achieve now, is to control the camera with the Joystick. Is this possible? Can I do it using a usb HUB? Can the Arduino UNO deal with this two devices at the same time? If you can point me in the right direction I would be thankfull, if not, I already am.
Just create an instance of a hub, an instance of a joystick and an instance of a camera then code as ususal. There is plenty of examples in examples folder. Whether UNO is capable of handling both is a matter of free memory – you may want to start with a bigger Arduino.