Shopping Cart

Posts

Digital camera control using Arduino USB Host Shield. Part 1 - basics.

Arduino taking picture of itself

Arduino taking picture of itself

I’m starting new series of articles describing exciting field of digital camera control. In modern cameras, USB port can be used not only for transferring images to a PC, but also for sending control commands to the camera. It is often possible to send commands which “press” the shutter button, modify shutter and aperture values, some cameras are even capable of doing focus control. At the same time, new shooting techniques, such as HDR and stacked focus, require that a photographer makes several shots, slightly modifying one or several shooting parameters from shot to shot. Even age-old time lapse technique could use some automation. Since camera manufacturers are, as always slow to implement there cool features, Arduino comes to the rescue.

I am announcing new code developed for Arduino USB Host shield which implements digital camera control functions via PTP. Alex Glushchenko, a developer from my native Russia, recently joined camera control project and code shown here and in the future articles is mainly his. He did most of reverse engineering and code development and my contributions to this project were mainly code testing, camera borrowing, and blogging. Code is hosted on github separately from USB Host library. Be warned – this source is preliminary and will be changed many times before it becomes stable! It is also expected to grow quite a bit – different cameras use different commands and developing universal code supporting all manufacturers (or even every camera from one manufacturer) is not possible due to the modest resources of Arduino platform. Therefore, several libraries have been developed, each covering specific set of cameras. The cameras supporting functions of a certain library are listed in library’s header file. The list of cameras is currently quite small but I’m hoping to get more cameras supported in the future.

Digital camera as USB peripheral is much more complex and less standard than a keyboard. The complexity starts at the very first level – device configuration. Very often , several different configurations are supported on a device and the default configuration is not the one we need. Therefore, the first step would naturally be learning how to recognize configuration which supports camera control commands.

There are 3 specifications describing USB digital camera works. Still Image Device specifies USB requests, descriptors and endpoints. The protocol structure is described in Media Transfer Protocol (MTP), which is better known by its previous name, “Picture Transfer Protocol” (PTP). The most interesting document, which actually lists commands supported by camera class, is known as “PIMA 15740-2000″. It is available for a fee from I3A, however, second-hand pdf copy can be obtained for free after some googling. Camera manufacturers implement their own functions, expanding PIMA definitions. In addition to that, some older cameras use their proprietary protocols instead of PTP; support for such cameras will be added eventually.

USB specification defines a class called “Still Image Capture Device”. According to it, such device has ’06′ in “Class” field of interface descriptor of the configuration. Therefore, one way to find necessary configuration is to look at configuration descriptor contents. Let’s take a look at the device descriptor (in case you are curious, it’s an iPhone). When we look at the last line, the number of configurations is 4. Older cameras may have 2 configurations and the first one is often a disk drive – this arrangement was made in pre-PTP times so you could offload pictures to a PC even if you didn’t have a driver for the camera installed. Modern cameras rely on PTP to transfer files to PC and often come with just one configuration – so far, all cameras used so to check the PTP code for the shield were of this variety.

Device descriptor:
Descriptor Length:      12
Descriptor type:        01
USB version:            0200
Device class:           00
Device Subclass:        00
Device Protocol:        00
Max.packet size:        40
Vendor  ID:             05AC
Product ID:             1292
Revision ID:            0001
Mfg.string index:       01
Prod.string index:      02
Serial number index:    03
Number of conf.:        04

A sketch which prints device descriptor was posted several articles back, make yourself a copy of it if you haven’t already. A sketch printing configuration descriptor was also posted not long ago; however, it was written to output only first configuration of the device – don’t use it. Instead, download this multiple configuration capable sketch from examples section of USB_Host_Shield repo. The following table shows all four configurations of the iPhone:

Configuration: 0

Configuration descriptor:
Total length:     0027
Num.intf:         01
Conf.value:       01
Conf.string:      05
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40
Configuration: 1

Configuration descriptor:
Total length:     0095
Num.intf:         03
Conf.value:       02
Conf.string:      06
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        00
Class:            01
Subclass:         01
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           09
Type:             24
Contents:
0100011E0001010C24

Unknown descriptor:
Length:           0C
Type:             24
Contents:
020101020202030000000924

Unknown descriptor:
Length:           09
Type:             24
Contents:
030201010101000904

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        00
Class:            01
Subclass:         02
Protocol:         00
Intf.string:      00

Interface descriptor:
Intf.number:      01
Alt.:             01
Endpoints:        01
Class:            01
Subclass:         02
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           07
Type:             24
Contents:
01020101002324

Unknown descriptor:
Length:           23
Type:             24
Contents:
020102021009401F00112
B00E02E00803E00225600
C05D00007D0044AC0080B
B000905

Endpoint descriptor:
Endpoint address: 81
Attr.:            01
Max.pkt size:     00C0
Polling interval: 01

Unknown descriptor:
Length:           07
Type:             25
Contents:
01010000000904

Interface descriptor:
Intf.number:      02
Alt.:             00
Endpoints:        01
Class:            03
Subclass:         00
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           09
Type:             21
Contents:
110100012260000705

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 01
Configuration: 2

Configuration descriptor:
Total length:     003E
Num.intf:         02
Conf.value:       03
Conf.string:      07
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        02
Class:            FF
Subclass:         FE
Protocol:         02
Intf.string:      00

Endpoint descriptor:
Endpoint address: 04
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 85
Attr.:            02
Max.pkt size:     0040
Polling interval: 00
Configuration:    3

Configuration descriptor:
Total length:     005E
Num.intf:         03
Conf.value:       04
Conf.string:      08
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        02
Class:            FF
Subclass:         FE
Protocol:         02
Intf.string:      00

Endpoint descriptor:
Endpoint address: 04
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 85
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Interface descriptor:
Intf.number:      02
Alt.:             00
Endpoints:        00
Class:            FF
Subclass:         FD
Protocol:         01
Intf.string:      00

Interface descriptor:
Intf.number:      02
Alt.:             01
Endpoints:        02
Class:            FF
Subclass:         FD
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 86
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 05
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

The key here is Class field in interface descriptor – we know that still image capture device is identified by class 6. As we can see, configurations 0, 2 and 3 have potential. However, after much testing I found that none of these configurations support camera control commands. Here is another example of “Class 6 device” configuration, taken from Canon XSi camera – :

Configuration: 0
Configuration descriptor:
Total length:     0027
Num.intf:         01
Conf.value:       01
Conf.string:      00
Attr.:            C0
Max.pwr:          01

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0008
Polling interval: 20

Number 6 in interface Class field doesn’t guarantee functionality but at least this configuration can then be activated and checked with PTP queries. It’s worth mentioning that in some cameras different configurations can be activated via camera menu and very often configuration which has “PTP” in it’s name is not the one we need. For example, Canon 5D has “PC Connection” configuration containing FF in interface class field and “PTP/Print” one with class 06. Even though both configurations talk PTP, PC Connection configuration is the one that supports remote control. This strangeness can be explained by the fact that Canon had proprietary camera control long before PTP and their first PTP implementation was written in order to be able to interact with third-party picture printers.

Let’s talk briefly about PTP protocol. A unit of information exchange in PTP protocol is called a transaction. Camera commands, requests and responses travel inside transactions. In turn, transactions are exchanged within sessions – to send something to the camera, a session would have to be opened first (one exception being “Get Device Info” request, more about it later). Many times several responses are given to a single request, the first one meaning camera understood the request, the second one generated when requested command has been executed, and then another one reflecting camera changes resulted in command execution, like image file apperared after a picture has been taken. Some types of responses have specific meaning and are called events. In order to make a shot, program needs to open a session to the camera, set PC connection mode, send shutter release command, wait for “Shutter released” event, then wait until a new file appears on the memory card (another event) and only after that consider the job done and close the session. Data flow of other commands is similar; to change aperture we need to send aperture value and wait for “aperture changed” event. Skipping commands or requests for new events in the sequence usually causes camera to hang – it would execute a command or two and then become unresponsive and would have to be power cycled. Hanging of the camera is harmless and shall be anticipated during development.

Another piece of PTP device is properties. In digital camera, most properties contain shooting parameters. Typical example of a property is shutter speed value – this property can be changed. Another property is battery level. We won’t be able to change it directly but can request it’s value. There are also properties which both change by itself and can be changed externally; one good example is camera’s real-time clock.

Lastly, there are objects contained in storages. For cameras, this is mainly files on memory card and their significance in Arduino-based applications is minor.

It’s now time to start controlling our cameras. The very first piece of software is a sketch that queries PTP device and prints out it’s capabilities. It uses GetDeviceInfo command (or operation) to output device capabilities. GetDeviceInfo is the only PTP operation which can be sent to the device without opening a session first. You will need al 3 files from this directory as well as files from ptp directory copied into %arduino%/hardware/libraries/ptp directory. This sketch is not camera-specific – it shall work with any class 6 device (as well as some proprietary ones, see note about Canon 5D above). Regretfully, this sketch won’t fit into 16K Arduinos – parser strings eat too much memory and more strings will be added in the future when more vendor-specific commands become known.

Here is PTPDevInfo output of an iPhone:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
iPhone
Start
 
Device configured.: 0x0000
 
0000:ED 00 00 00 02 00 01 10 01 00 00 00 64 00 00 00
0010:00 00 00 00 20 44 00 65 00 76 00 69 00 63 00 65
0020:00 20 00 68 00 61 00 73 00 20 00 6E 00 6F 00 20
0030:00 76 00 65 00 6E 00 64 00 6F 00 72 00 20 00 65
0040:00 78 00 74 00 65 00 6E 00 73 00 69 00 6F 00 6E
0050:00 73 00 00 00 00 00 0E 00 00 00 01 10 02 10 03
0060:10 04 10 05 10 06 10 07 10 08 10 09 10 0A 10 0B
0070:10 14 10 15 10 1B 10 01 00 00 00 06 40 00 00 00
0080:00 03 00 00 00 01 38 0B 38 0D 38 03 00 00 00 01
0090:38 0B 38 0D 38 0B 41 00 70 00 70 00 6C 00 65 00
00A0:20 00 49 00 6E 00 63 00 2E 00 00 00 0D 41 00 70
00B0:00 70 00 6C 00 65 00 20 00 69 00 50 00 68 00 6F
00C0:00 6E 00 65 00 00 00 06 33 00 2E 00 31 00 2E 00
00D0:33 00 00 00 0C 38 00 36 00 38 00 33 00 30 00 50
00E0:00 45 00 32 00 59 00 37 00 48 00 00 00
 
Std. Ver.:  0x100
Vendor ID:  0x0(Unknown)
 
Vend.Ext.Ver.:  0x0
Device has no vendor extensionsFunc.Mode: 0x8C7
 
 
 
Operations supported:
 
1001  GetDeviceInfo
1002  OpenSession
1003  CloseSession
1004  GetStorageIDs
1005  GetStorageInfo
1006  GetNumObjects
1007  GetObjectHandles
1008  GetObjectInfo
1009  GetObject
100A  GetThumb
100B  DeleteObject
1014  GetDevicePropDesc
1015  GetDevicePropValue
101B  GetPartialObject
 
Events supported:
 
4006  DevicePropChanged
 
Device properties supported:
 
Capture formats:
 
3801  EXIF_JPEG
380B  PNG
380D  TIFF
 
Image Formats:
 
3801  EXIF_JPEG
380B  PNG
380D  TIFF
 
Manufacturer: Apple Inc.
 
Model:  Apple iPhone
Device version: 3.1.3
Serial number:  86830PE2Y7H

The output starts with hex dump of the response and device operations start at line 31. The first operation, 1001 or GetDeviceInfo, it the very operation that was used to retrieve this information. The “OpenSession” and “Close Session”, as you may have guessed, are used to open and close a session with the device, the rest are used for file manipulation – not very useful. Let’s now take a look at GetDeviceInfo of a real camera, in this case, Canon 400D:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Canon 400D
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:5D 01 00 00 02 00 01 10 02 00 00 00 64 00 0B 00
0010:00 00 C8 00 00 00 00 38 00 00 00 14 10 16 10 15
0020:10 01 10 02 10 03 10 13 90 04 10 05 10 06 10 07
0030:10 08 10 0A 10 09 10 1B 10 0C 10 0D 10 0B 10 01
0040:91 02 91 03 91 04 91 07 91 05 91 17 91 18 91 16
0050:91 0F 91 15 91 10 91 14 91 13 91 06 91 0A 91 0B
0060:91 0C 91 0E 91 1A 91 1B 91 1C 91 1D 91 08 91 1F
0070:91 09 91 1E 91 20 91 21 91 0F 10 01 98 02 98 03
0080:98 04 98 05 98 FE 91 FF 91 1F 90 04 00 00 00 09
0090:40 04 40 05 40 01 C1 06 00 00 00 45 D0 02 D4 07
00A0:D4 06 D4 49 D0 4A D0 01 00 00 00 01 38 09 00 00
00B0:00 01 30 02 30 0A 30 08 30 01 38 01 B1 03 B1 02
00C0:BF 00 38 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
00D0:49 00 6E 00 63 00 2E 00 00 00 17 43 00 61 00 6E
00E0:00 6F 00 6E 00 20 00 45 00 4F 00 53 00 20 00 34
00F0:00 30 00 30 00 44 00 20 00 44 00 49 00 47 00 49
0100:00 54 00 41 00 4C 00 00 00 08 33 00 2D 00 31 00
0110:2E 00 31 00 2E 00 31 00 00 00 21 30 00 30 00 30
0120:00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30
0130:00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30
0140:00 30 00 30 00 30 00 30 00 30 00 31 00 39 00 61
0150:00 33 00 32 00 37 00 66 00 39 00 00 00
 
Std.Ver.:	0x100
Vendor Ext. ID:	0xB(Canon)
 
Vend.Ext.Ver.:	0xC8
 
Func.Mode:	0x8C7
 
Operations supported:
1014	GetDevicePropDesc
1016	SetDevicePropValue
1015	GetDevicePropValue
1001	GetDeviceInfo
1002	OpenSession
1003	CloseSession
9013	PS_CheckEvent
1004	GetStorageIDs
1005	GetStorageInfo
1006	GetNumObjects
1007	GetObjectHandles
1008	GetObjectInfo
100A	GetThumb
1009	GetObject
101B	GetPartialObject
100C	SendObjectInfo
100D	SendObject
100B	DeleteObject
9101	EOS_GetStorageIDs
9102	EOS_GetStorageInfo
9103	Vendor defined
9104	Vendor defined
9107	EOS_GetObject
9105	Vendor defined
9117	Vendor defined
9118	Vendor defined
9116	EOS_GetEvent
910F	EOS_Capture
9115	EOS_SetExtendedEventInfo
9110	EOS_SetDevicePropValue
9114	EOS_SetPCConnectMode
9113	Vendor defined
9106	Vendor defined
910A	Vendor defined
910B	Vendor defined
910C	Vendor defined
910E	Vendor defined
911A	Vendor defined
911B	Vendor defined
911C	Vendor defined
911D	Vendor defined
9108	EOS_GetDeviceInfo
911F	Vendor defined
9109	EOS_GetObjectIDs
911E	Vendor defined
9120	Vendor defined
9121	Vendor defined
100F	FormatStore
9801	GetObjectPropsSupported
9802	GetObjectPropDesc
9803	GetObjectPropValue
9804	SetObjectPropValue
9805	GetObjectPropList
91FE	Vendor defined
91FF	Vendor defined
901F	Vendor defined
 
Events supported:
4009	RequestObjectTransfer
4004	StoreAdded
4005	StoreRemoved
C101	Vendor defined
 
Device properties supported:
D045	Vendor defined
D402	Device_Friendly_Name
D407	Perceived_Device_Type
D406	Session_Initiator_Version_Info
D049	Vendor defined
D04A	Vendor defined
 
Capture formats:
3801	EXIF_JPEG
 
Image Formats:
3001	Association
3002	Script
300A	AVI
3008	WAV
3801	EXIF_JPEG
B101	Vendor defined
B103	Vendor defined
BF02	Vendor defined
3800	Undefined
 
Manufacturer:	Canon Inc.
Model:		Canon EOS 400D DIGITAL
Device ver.:	3-1.1.1
Serial num.:	00000000000000000000000019a327f9
 
Closing session #: : 0x0001
Session closed.: 0x2001

This output lists many vendor-specific functions, some of which are used for camera control. Even though standard PTP contains many camera control commands, vendors tend to write their own, sometimes duplicating even non-camera control functions. The functions which name starts with “EOS” are Canon-specific.”Vendor defined” functions are also Canon-specific functions whose purpose is yet unknown.

GetDeviceInfo is a powerful tool to compare functionality of different cameras from the same vendor. Functions with the same number often perform identical actions. For example, the following output taken from Canon xSi camera shows the same EOS_Capture command as in 400D (910f, line 64 in 400D output, line 75 in xSi output). Indeed, shutter release code for 400D works identically on xSi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Canon xSi
Start
 
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
 
0000:7B 01 00 00 02 00 01 10 02 00 00 00 64 00 06 00
0010:00 00 C8 00 00 00 00 41 00 00 00 14 10 15 10 16
0020:10 01 10 02 10 03 10 06 10 04 10 01 91 05 10 02
0030:91 07 10 08 10 03 91 09 10 04 91 0A 10 1B 10 07
0040:91 0C 10 0D 10 0B 10 05 91 0F 10 06 91 10 91 27
0050:91 0B 91 08 91 09 91 0C 91 0E 91 0F 91 25 91 26
0060:91 15 91 14 91 13 91 16 91 17 91 20 91 F0 91 18
0070:91 21 91 F1 91 1D 91 0A 91 1B 91 1C 91 1E 91 1A
0080:91 53 91 54 91 55 91 57 91 58 91 59 91 1F 91 FE
0090:91 FF 91 01 98 02 98 03 98 04 98 05 98 07 00 00
00A0:00 09 40 04 40 05 40 03 40 02 40 07 40 01 C1 03
00B0:00 00 00 02 D4 07 D4 06 D4 01 00 00 00 01 38 0A
00C0:00 00 00 01 30 02 30 06 30 0A 30 08 30 01 38 01
00D0:B1 03 B1 02 BF 00 38 0B 43 00 61 00 6E 00 6F 00
00E0:6E 00 20 00 49 00 6E 00 63 00 2E 00 00 00 1C 43
00F0:00 61 00 6E 00 6F 00 6E 00 20 00 45 00 4F 00 53
0100:00 20 00 44 00 49 00 47 00 49 00 54 00 41 00 4C
0110:00 20 00 52 00 45 00 42 00 45 00 4C 00 20 00 58
0120:00 53 00 69 00 00 00 08 33 00 2D 00 31 00 2E 00
0130:31 00 2E 00 30 00 00 00 21 62 00 36 00 32 00 31
0140:00 30 00 66 00 66 00 64 00 31 00 32 00 37 00 39
0150:00 34 00 66 00 32 00 63 00 61 00 33 00 61 00 64
0160:00 32 00 33 00 64 00 31 00 32 00 39 00 36 00 63
0170:00 32 00 31 00 35 00 38 00 00 00
 
 
Std.Ver.:	0x100
Vendor Ext. ID:	0x6(Microsoft)
 
Vend.Ext.Ver.:	0xC8
 
Func.Mode:	0x8C7
 
Operations supported:
 
1014	GetDevicePropDesc
1015	GetDevicePropValue
1016	SetDevicePropValue
1001	GetDeviceInfo
1002	OpenSession
1003	CloseSession
1006	GetNumObjects
1004	GetStorageIDs
9101	EOS_GetStorageIDs
1005	GetStorageInfo
9102	EOS_GetStorageInfo
1007	GetObjectHandles
1008	GetObjectInfo
9103	Vendor defined
1009	GetObject
9104	Vendor defined
100A	GetThumb
101B	GetPartialObject
9107	EOS_GetObject
100C	SendObjectInfo
100D	SendObject
100B	DeleteObject
9105	Vendor defined
100F	FormatStore
9106	Vendor defined
9110	EOS_SetDevicePropValue
9127	Vendor defined
910B	Vendor defined
9108	EOS_GetDeviceInfo
9109	EOS_GetObjectIDs
910C	Vendor defined
910E	Vendor defined
910F	EOS_Capture
9125	Vendor defined
9126	Vendor defined
9115	EOS_SetExtendedEventInfo
9114	EOS_SetPCConnectMode
9113	Vendor defined
9116	EOS_GetEvent
9117	Vendor defined
9120	Vendor defined
91F0	Vendor defined
9118	Vendor defined
9121	Vendor defined
91F1	Vendor defined
911D	Vendor defined
910A	Vendor defined
911B	Vendor defined
911C	Vendor defined
911E	Vendor defined
911A	Vendor defined
9153	EOS_GetLiveViewPicture
9154	Vendor defined
9155	EOS_MoveFocus
9157	Vendor defined
9158	Vendor defined
9159	Vendor defined
911F	Vendor defined
91FE	Vendor defined
91FF	Vendor defined
9801	GetObjectPropsSupported
9802	GetObjectPropDesc
9803	GetObjectPropValue
9804	SetObjectPropValue
9805	GetObjectPropList
 
Events supported:
 
4009	RequestObjectTransfer
4004	StoreAdded
4005	StoreRemoved
4003	ObjectRemoved
4002	ObjectAdded
4007	ObjectInfoChanged
C101	Vendor defined
 
Device properties supported:
 
D402	Device_Friendly_Name
D407	Perceived_Device_Type
D406	Session_Initiator_Version_Info
 
Capture formats:
 
3801	EXIF_JPEG
 
Image Formats:
 
3001	Association
3002	Script
3006	DPOF
300A	AVI
3008	WAV
3801	EXIF_JPEG
B101	Vendor defined
B103	Vendor defined
BF02	Vendor defined
3800	Undefined
 
 
Manufacturer:	Canon Inc.
Model:		Canon EOS DIGITAL REBEL XSi
Device ver.:	3-1.1.0
Serial num.:	b6210ffd12794f2ca3ad23d1296c2158
 
Closing session #: : 0x0001
Session closed.: 0x2001

Modern Canon EOS cameras have function set similar to the one above. However, if we look into older cameras, they give very different output. Below is GetDeviceInfo output from my old trusty Canon 5D. As you can see, it has no resemblance to xSi or 400D. In fact, it looks like Canon Powershot A640 output, which is posted just below this one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Canon 5D
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:0B 01 00 00 02 00 01 10 02 00 00 00 01 00 0B 00
0010:00 00 64 00 00 00 00 1D 00 00 00 14 10 15 10 16
0020:10 17 10 01 10 02 10 03 10 13 90 04 10 05 10 06
0030:10 07 10 08 10 09 10 0A 10 1B 10 0C 10 0D 10 0B
0040:10 01 90 02 90 06 90 0E 90 1B 90 1C 90 1E 90 21
0050:90 0F 10 1F 90 16 00 00 00 01 40 02 40 03 40 04
0060:40 05 40 06 40 07 40 08 40 09 40 0A 40 0C 40 0D
0070:40 01 C0 05 C0 06 C0 07 C0 08 C0 09 C0 0A C0 0B
0080:C0 0C C0 0D C0 10 00 00 00 45 D0 02 D0 03 D0 2C
0090:D0 2D D0 49 D0 32 D0 31 D0 34 D0 33 D0 2E D0 2F
00A0:D0 46 D0 47 D0 30 D0 4A D0 01 00 00 00 01 38 08
00B0:00 00 00 02 30 06 30 0A 30 08 30 01 38 01 B1 03
00C0:B1 02 BF 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
00D0:49 00 6E 00 63 00 2E 00 00 00 0D 43 00 61 00 6E
00E0:00 6F 00 6E 00 20 00 45 00 4F 00 53 00 20 00 35
00F0:00 44 00 00 00 0A 33 00 2D 00 30 00 2E 00 30 00
0100:2E 00 30 00 2E 00 31 00 00 00 00
 
Std.Ver.:       0x1
Vendor Ext. ID: 0xB(Canon)
 
Vend.Ext.Ver.:  0x64
 
Func.Mode:      0x8C7
 
Operations supported:
1014    GetDevicePropDesc
1015    GetDevicePropValue
1016    SetDevicePropValue
1017    ResetDevicePropValue
1001    GetDeviceInfo
1002    OpenSession
1003    CloseSession
9013    PS_CheckEvent
1004    GetStorageIDs
1005    GetStorageInfo
1006    GetNumObjects
1007    GetObjectHandles
1008    GetObjectInfo
1009    GetObject
100A    GetThumb
101B    GetPartialObject
100C    SendObjectInfo
100D    SendObject
100B    DeleteObject
9001    PS_GetObjectSize
9002    Vendor defined
9006    Vendor defined
900E    Vendor defined
901B    PS_GetPartialObject
901C    Vendor defined
901E    Vendor defined
9021    PS_GetFolderEntries
100F    FormatStore
901F    Vendor defined
 
Events supported:
4001    CancelTransaction
4002    ObjectAdded
4003    ObjectRemoved
4004    StoreAdded
4005    StoreRemoved
4006    DevicePropChanged
4007    ObjectInfoChanged
4008    DeviceInfoChanged
4009    RequestObjectTransfer
400A    StoreFull
400C    StorageInfoChanged
400D    CaptureComplete
C001    Vendor defined
C005    Vendor defined
C006    Vendor defined
C007    Vendor defined
C008    Vendor defined
C009    Vendor defined
C00A    Vendor defined
C00B    Vendor defined
C00C    Vendor defined
C00D    Vendor defined
 
Device properties supported:
D045    Vendor defined
D002    Vendor defined
D003    Vendor defined
D02C    Vendor defined
D02D    Vendor defined
D049    Vendor defined
D032    Vendor defined
D031    Vendor defined
D034    Vendor defined
D033    Vendor defined
D02E    Vendor defined
D02F    Vendor defined
D046    Vendor defined
D047    Vendor defined
D030    Vendor defined
D04A    Vendor defined
 
Capture formats:
3801    EXIF_JPEG
 
Image Formats:
3002    Script
3006    DPOF
300A    AVI
3008    WAV
3801    EXIF_JPEG
B101    Vendor defined
B103    Vendor defined
BF02    Vendor defined
 
Manufacturer:   Canon Inc.
Model:          Canon EOS 5D
Device ver.:    3-0.0.0.1
Serial num.:
 
Closing session #: : 0x0001
Session closed.: 0x2001
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Canon Powershot A640
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:AD 01 00 00 02 00 01 10 02 00 00 00 64 00 06 00
0010:00 00 64 00 00 00 00 3E 00 00 00 14 10 15 10 16
0020:10 17 10 01 10 02 10 03 10 13 90 1F 90 04 10 05
0030:10 06 10 07 10 08 10 09 10 0A 10 1B 10 0C 10 0D
0040:10 0B 10 0F 10 12 10 01 90 21 90 1B 90 1E 90 19
0050:90 06 90 1C 90 02 90 2C 90 2D 90 2E 90 24 90 25
0060:90 0E 90 0F 90 10 90 11 90 28 90 23 90 29 90 2A
0070:90 2B 90 34 90 0E 10 08 90 1A 90 09 90 0B 90 1D
0080:90 0D 90 0C 90 14 90 15 90 18 90 12 90 01 98 02
0090:98 03 98 04 98 05 98 1A 00 00 00 01 40 02 40 03
00A0:40 04 40 05 40 06 40 07 40 08 40 09 40 0A 40 0B
00B0:40 0C 40 0D 40 0E 40 01 C0 05 C0 08 C0 09 C0 0A
00C0:C0 0B C0 0C C0 0D C0 0E C0 0F C0 11 C0 13 C0 13
00D0:00 00 00 45 D0 4A D0 2E D0 2F D0 02 D0 03 D0 34
00E0:D0 47 D0 46 D0 2D D0 48 D0 2C D0 30 D0 49 D0 32
00F0:D0 33 D0 31 D0 02 D4 07 D4 01 00 00 00 01 38 08
0100:00 00 00 01 30 02 30 06 30 0A 30 08 30 01 38 01
0110:B1 01 BF 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
0120:49 00 6E 00 63 00 2E 00 00 00 15 43 00 61 00 6E
0130:00 6F 00 6E 00 20 00 50 00 6F 00 77 00 65 00 72
0140:00 53 00 68 00 6F 00 74 00 20 00 41 00 36 00 34
0150:00 30 00 00 00 0A 31 00 2D 00 33 00 2E 00 32 00
0160:2E 00 31 00 2E 00 30 00 00 00 21 46 00 32 00 31
0170:00 44 00 42 00 35 00 38 00 31 00 44 00 46 00 37
0180:00 44 00 34 00 38 00 30 00 43 00 39 00 41 00 34
0190:00 32 00 33 00 37 00 37 00 39 00 43 00 39 00 38
01A0:00 46 00 33 00 39 00 38 00 32 00 00 00
 
Std.Ver.:       0x100
Vendor Ext. ID: 0x6(Microsoft)
 
Vend.Ext.Ver.:  0x64
 
Func.Mode:      0x8C7
 
Operations supported:
1014    GetDevicePropDesc
1015    GetDevicePropValue
1016    SetDevicePropValue
1017    ResetDevicePropValue
1001    GetDeviceInfo
1002    OpenSession
1003    CloseSession
9013    PS_CheckEvent
901F    Vendor defined
1004    GetStorageIDs
1005    GetStorageInfo
1006    GetNumObjects
1007    GetObjectHandles
1008    GetObjectInfo
1009    GetObject
100A    GetThumb
101B    GetPartialObject
100C    SendObjectInfo
100D    SendObject
100B    DeleteObject
100F    FormatStore
1012    SetObjectProtection
9001    PS_GetObjectSize
9021    PS_GetFolderEntries
901B    PS_GetPartialObject
901E    Vendor defined
9019    Vendor defined
9006    Vendor defined
901C    Vendor defined
9002    Vendor defined
902C    Vendor defined
902D    Vendor defined
902E    Vendor defined
9024    Vendor defined
9025    Vendor defined
900E    Vendor defined
900F    Vendor defined
9010    Vendor defined
9011    Vendor defined
9028    Vendor defined
9023    Vendor defined
9029    Vendor defined
902A    Vendor defined
902B    Vendor defined
9034    Vendor defined
100E    InitiateCapture
9008    PS_StartShootingMode
901A    PS_InitiateCaptureInMemory
9009    PS_EndShootingMode
900B    PS_ViewfinderOn
901D    PS_GetViewfinderImage
900D    PS_ReflectChanges
900C    PS_ViewfinderOff
9014    PS_FocusLock
9015    PS_FocusUnlock
9018    Vendor defined
9012    Vendor defined
9801    GetObjectPropsSupported
9802    GetObjectPropDesc
9803    GetObjectPropValue
9804    SetObjectPropValue
9805    GetObjectPropList
 
Events supported:
4001    CancelTransaction
4002    ObjectAdded
4003    ObjectRemoved
4004    StoreAdded
4005    StoreRemoved
4006    DevicePropChanged
4007    ObjectInfoChanged
4008    DeviceInfoChanged
4009    RequestObjectTransfer
400A    StoreFull
400B    DeviceReset
400C    StorageInfoChanged
400D    CaptureComplete
400E    UnreportedStatus
C001    Vendor defined
C005    Vendor defined
C008    Vendor defined
C009    Vendor defined
C00A    Vendor defined
C00B    Vendor defined
C00C    Vendor defined
C00D    Vendor defined
C00E    Vendor defined
C00F    Vendor defined
C011    Vendor defined
C013    Vendor defined
 
Device properties supported:
D045    Vendor defined
D04A    Vendor defined
D02E    Vendor defined
D02F    Vendor defined
D002    Vendor defined
D003    Vendor defined
D034    Vendor defined
D047    Vendor defined
D046    Vendor defined
D02D    Vendor defined
D048    Vendor defined
D02C    Vendor defined
D030    Vendor defined
D049    Vendor defined
D032    Vendor defined
D033    Vendor defined
D031    Vendor defined
D402    Device_Friendly_Name
D407    Perceived_Device_Type
 
Capture formats:
3801    EXIF_JPEG
 
Image Formats:
3001    Association
3002    Script
3006    DPOF
300A    AVI
3008    WAV
3801    EXIF_JPEG
B101    Vendor defined
BF01    Vendor defined
 
Manufacturer:   Canon Inc.
Model:          Canon PowerShot A640
Device ver.:    1-3.2.1.0
Serial num.:    F21DB581DF7D480C9A423779C98F3982
 
Closing session #: : 0x0001
Session closed.: 0x2001

When analyzing output posted above, we can see that this camera actually supports standard PTP “Initiate Capture” command (100E, line 87) as well as “Capture Complete” event (400D, line 118).

Here is a bonus for those who managed to get to this point – a sketch that performs shutter release on Canon EOS camera. It had been tested on 400D and xSi and will most likely work on cameras with the same 910f EOS_Capture command listed in GetDeviceInfo output. The sketch is available in the PTP examples on github, and copied below for your viewing pleasure:
[EDIT] This code doesn’t work with current PTP/EOS library. The correct code is here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* EOS Capture Example. Works on cameras listed in canoneos.h */
#include <inttypes.h>
#include <avr/pgmspace.h>
 
#include <spi.h>
#include <max3421e.h>
#include <max3421e_constants.h>
#include <max_LCD.h>
#include <usb.h>
 
#include <ptp.h>
#include <canoneos.h>
 
#define DEV_ADDR        1
 
// Canon EOS 400D
#define DATA_IN_EP      1
#define DATA_OUT_EP     2
#define INTERRUPT_EP    3
#define CONFIG_NUM      1
 
#define MAX_USB_STRING_LEN 64
 
void setup();
void loop();
void ptpmain();
 
CanonEOS  Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, (PTPMAIN)&ptpmain);
 
void setup() {
  Serial.begin( 9600 );
  Serial.println("Start");
  Eos.Setup();
  delay( 200 );
}
 
void loop() {
    Eos.Task();
}
 
void ptpmain()
{
    if (Eos.OpenSession() == PTP_RC_OK)
    {
                Eos.Initialize(true);
                Eos.Capture();
                delay(2000);
                Eos.Initialize(false);
		Eos.CloseSession();
    }
}

As you can see, the sketch is quite short for the amount of work it is doing and simple to understand thanks to Alex’s library structure design. Main functionality is presented on lines 41-51 – Open Session, Capture, Close Session. Delay is inserted to give camera time to save captured image; in real life applications it’s necessary to poll camera for “Object Created” event instead.

Due to the amount of material, writing about camera control can be challenging. Many things are much easier to the writer to present rather than explain; presentation style is also easier for the reader to digest. I’m currently working on simple camera controller design consisting of USB Host Shield, LCD display, rotary encoder plus a button or two and will be using it to present ways to use the library in various automatic shooting applications. I’m hoping to finish it in the next week or two, weather permitting, and publish the next program. Stay tuned!

Oleg.

Related posts:

  1. Digital camera control from Arduino-hosted webpage
  2. PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 3
  3. Arduino USB Host – USB Descriptors.
  4. PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 2
  5. Arduino USB Host – Peripherals.
  6. PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 1
  7. Arduino USB Host Shield build log. Part 2.
  8. Arduino USB Host Shield build log. Part 4.
  9. USB Host Shield for Arduino – first prototype.
  10. Arduino USB Host Shield build log. Part 1.

124 comments to Digital camera control using Arduino USB Host Shield. Part 1 – basics.

  • nolan

    Hello all, I’m using an UNO and a sparkfun shield. I am returning this “Start
    Error: OSCOKIRQ failed to assert” in the serial monitor. I know this error is associated with the use of the VIN pin instead of the 5V. I tried connecting the UNO to a 9 volt and I am still returning this error. Could someone post the proper pin set up for this unit. I can see in the forum that some people have incurred this problem and solved it.
    A side note, I already switched the 7 and 8 pin in the code. Thank you for any help in advance.

    • lenny4d

      Had the same problem with the brand new usb2.0 hostboard on my Mega. As I was using the standard config and the board was brand new I knew had to be something simple. After some troubleshooting with a multimeter I found I hadn’t soldered the 3.3V pin well enough and it didn’t get to the board. Fixed it, problem solved, works like a train now :-)

  • karsten

    Hello nolan,

    I had the same error at first due to an insufficient soldering of the headers, if I had to remember I’d say pin 13 in my case …

  • lenny4d

    Awesome work, both the hw and the usb/ptp libraries! Got my usb2.0 board a week ago and started tinkering trying to control my D500 camera for a start. Controlling aperture, mode, shutter etc all fine :-) but struggling with bulb mode, like some others above. Eos.StartBulb() works fine, camera starts taking image in bulb mode. But Eos.StopBulb is just ignored, nothing happens. After this the camera usb interface just hangs, getting errors on getevent etc. Any ideas? How to troubleshoot this?

  • lenny4d

    Following on from prev post – I also got the MoveFocus to work on my D500, as others mentioned I have to turn on Liveview manually. Works with focus switch in Manual or Auto which is good as I normally need Manual. At the smallest step 0×0001 (decreasing focus distance) or 0×8001 (increasing focus distance) on my EFS17-55mm lens it takes about 95 steps from 0.35m to 3m that’s just perfect. I am making timelapses, and this is going to be awesome. Totally awesome. Thanks to Oleg/Alex for the hard work behind the scenes. Now I just need to get Bulb to work and read out the exposure value in some way. This is going to be more difficult.

    • Alex

      Bulb functionality may or may not be available via PTP on EOS cameras such as EOS400D for example. You should check this by running EOSEventLab.pde sketch first and checking shutter speed values. Bulb is 0x0C. All device properties such as shutter speed and aperture are available from EOS cameras as events. When the camera is initialized and events are enabled the first event you receive is a huge bunch of current device property values and their acceptable values or value ranges (you should see EOSCamController sketch for more details). Then you have to monitor device property value changes polling events from the camera. That’s how it works in EOSCamController sketch.

      • lenny4d

        I can set bulb via Eos.SetProperty(EOS_DPC_Shutterspeed,0x0c) allright (in manual mode, lcd display changes to “BULB”) and Eos.StartBulb() starts bulb mode capture, but then I can’t stop it with Eos.StopBulb(). I have not been successfull with EOSEventlab, it hangs the camera after the first big packet (USB Fatal Error). Generally I don’t have any/much success with Eos.Eventcheck. This blog/documentation suggest lots events should be generated after image capture but none in my case (but an image IS taken). I guess it’s just a learning curve :-)

        • Alex

          Unfortunately, I don’t have the same camera at hands to find out what is wrong. There might be either a bug in the code or your camera behaves differently then other Canon models I tried the code on. If you could install Snoopy Pro sniffer and make a dump of USB session during bulb capture with Canon or some other software, properly working with your camera, and send it to me, I would probably find what the problem is and fix the code.

        • My XSi also breaks EOSEventLab. The trick is not to parse this first packet, but start parsing and printing all subsequent packets.

  • lenny4d

    Ok, I made a lot of progress with my D500 – this is all pretty awesome. I added an EOS.EventCheck(NULL) in the startup initialisation (e.g., eventmonitor example) that skipped the first big packet. But it still bombed on changing the mode dial… Later I changed to your eventparser function, which seems more robust, it never bombs. Cool because this gives me access to the settings (I am not great with C++ so would not be able to write this myself). Then in order to get bulb and half-push-release-button to work I had to resort to SnoopyPro usb sniffer to figure what packets the EOS Utility programme sends to the camera for these functions. Since I am a newbie to USB it tok me some time to figure it all out. It’s the out.down packets that need to be studied. From there it was easy, now it works like a train (tested). The code that works for a D500 is below, it’s generates an exact copy of what EOS utility sends to the camera. In canoneos.cpp:

    uint16_t CanonEOS::StartBulb() // tested on D500
    {
    uint32_ params[2];
    params[0] = 0×00000001;
    params[1] = 0×00000002;

    Operation(0×9128, 1, params );
    Operation(0×9128, 1, params+1);

    return PTP_RC_OK;
    }

    uint16_t CanonEOS::StopBulb() // tested on D500
    {
    uint32_t params[1];
    params[0] = 0×00000003;

    Operation(0×9129, 1, params);
    return PTP_RC_OK;
    }

    uint16_t CanonEOS::HalfPush() // tested on D500
    {
    uint32_t params[2];

    params[0] = 0×00000001;
    params[1] = 0×00000000;

    Operation(0×9128, 2, params);
    delay(500);
    Operation(0×9129, 1, params);
    return PTP_RC_OK;
    }

    You will also need to add uint16_t HalfPush() to the CanonEOS class in canoneos.h HalfPush generates an event with the desired aperture (in T mode) or shutterspeed (in A mode). The delay will make the values appear on the LCD of the camera, if you leave it out you get the same response but won’t see the values on the camera’s LCD.

    I hope this is useful to someone. This all very great stuff. Now I will move to getting my Canon G6 to work as well :-)

    ~lenny4d

    • When you change mode dial you’ll get the same large packet again since all property values change (like in Av you don’t have property value for shutter speed). Good find about Event Parser and Bulb settings, I need to check it on my cameras. Let me know if you have any issues with G6.

  • muthm

    Hi oleg – sorry for naive questions but i wanted to get your insight:
    I am trying to do the following:
    Move the focus to a starting position
    Shoot
    Wait for thr shoot to complete (can be worked out by the tv set)
    Move thr focus one step up
    Repeat from shoot until a set focus position
    Wait a set time and repeat fro. Step 1

    I know about the missing ack after the focus move, but i am looking for how i would code this (sry complete new) i use a 5d mk ii

  • Sai

    Hi,

    Is this possible to implement only when the camera is capable for USB based controls?

  • Jason

    I have a few questions….

    1) Anyone have any luck trying to set the ShootingMode property? My 60D always reports back as busy. I am guessing that it’s not possible since the EOSUtility application won’t even allow changing of the mode dial. Do I really have to manually rotate the dial to go between auto and manual?

    2) I can’t seem to get anything back from operation code EOS_OC_GetDevicePropValue on my 60D. Anyone else note this?

    3) When using EOS_OC_GetDeviceInfoEx and PTP_OC_GetDeviceInfo I get two completely different sets of data. The PTP_OC_GetDeviceInfo operation code returns something similar to what you have here ( https://www.circuitsathome.com/?s=60d#EOS60D ) but your canoneos.cpp sends the EOS_OC_GetDeviceInfoEx which returns data nothing like what you report on the page noted above. Can you explain the difference?

    Thanks!

  • Alex

    1) You can set shooting mode on your 60D only by turning mode dial manually.
    2) The only correct way of getting device property value is to obtain it from the first event packet and monitor its changes later checking events. There is a class EOSEventParser in the second version of PTP library written to handle different events, especially events dealing with device properties. Check latest version of EOSRemote sketch to get the idea of how you can use it. If you have questions feel free to ask me.
    3) EOS_OC_GetDeviceInfoEx is the Canon proprietary method of getting device information. It works only for Canon EOS cameras. PTP_OC_GetDeviceInfo is PTP-standard method supported by absolutely every PTP capable camera. I suggest you to use EOS_OC_GetDeviceInfoEx only when it’s absolutely necessary for your application.

    • Jason

      Thank you very much for the prompt response. Your answers are very helpful… unfortunate (with respect to manually turning mode dial) but helpful!

    • Jason

      I just had a thought…

      Is there any exposure metering data contained in events? I am trying to accomplish both manual and automatic exposure control with the EOS series. If I left the dial in manual shooting mode AND I could obtain some exposure metering data then I could intelligently set the exposure settings (f-stop, shutter, iso) in manual mode. Definitely not as good as having control over the shooting mode but a very good workaround for my purposes. Any thoughts?

      • Alex

        It could be true for some newer models. Old EOS cameras, such as EOS 400D, don’t send any exposure metering data in events. I am not sure about 60D because I had no chance to test it with the PTP code. the workaround could be keeping EOS in manual mode while measuring exposure with some extra circuit connected to Arduino and then set the exposure settings programmatically.

  • Jason

    I assume these device property values would be in the canoneos.h file if they were known but I thought I’d ask anyway as they may just not be present because they aren’t commonly used. Any idea what 0xD1D3 and 0xD1C0 represent? They are both device properties changed events (0xC189). They seem to be common after a half push or release event.

    Thanks!

    • Alex

      0xD1D3 seems to represent focus info. About 0xD1C0 I have no idea. I will probably be able to make some assumptions if you send me a dump taken by EOSEventLab or EOSEventMonitor with a short description of what had initiated the event.

  • Karl

    I am currently basing a project of mine with this project as a skeleton.
    When the camera takes a picture acre you able to direct where the photo goes? Like can you command it to save into a specific folder?
    I’m sorry if my question sounds stupid but i am trying to create an interface to be able to view, sort,delete and etc. the photos.

  • meilenstein

    Hi
    Where can I buy this USB-Host-Shield in Europe ? ( Germany )

  • ricky

    hi oleg
    I have read source code of arduino camera control on https://github.com/felis/Arduino_Camera_Control , I cannot find the source code of 3 focus move speed, where is it?
    For example:
    felis-Arduino_Camera_Control-4f5b1bf\examples\EOSFocus\EOSFocus.pde
    row 71 to 81
    if (i > 4)
    Eos.MoveFocus(3); //question: what is the meaning of number 3?
    else
    Eos.MoveFocus(0×8003); //question: what is the meaning of 0×8003?

    Thanks for your reply
    ricky

  • Chris

    Hi Oleg,

    probably you can help me with my problem. I am playing around with arduino controlling my 7D. Communication from Arduino to 7D works great – but in the other direction 7D -> Arduino I have a lot of problems.
    How can I read for example the current Shutterspeed?

    regards
    Chris

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">