Shopping Cart

Posts

PTP support for USB Host Shield Library 2.0 released

PTP ver.2

PTP ver.2

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.

No related posts.

144 comments to PTP support for USB Host Shield Library 2.0 released

  • Hi,
    I’m trying to extend PTP_2 to be able to control CHDK PTP Extensions
    Basically, I guess that every needed is in libptp-chdk.patch
    So it’s “only” a work of translation based on 0×9999 CHDK Operation code:
    The first issue I don’t how how to deal with is “OperFlags flags”. What do they mean?

    • Just found out in ptp.h…
      struct OperFlags
      {
      uint16_t opParams : 3; // 7 - maximum number of operation parameters
      uint16_t rsParams : 3; // 7 - maximum number of response parameters
      uint16_t txOperation : 1; // I->R operation if the flag is set
      uint16_t dataStage : 1; // operation has data stage if the flag is set
      uint16_t typeOfVoid : 2; // 0 – NULL, 1 – PTPReadParser/PTPDataSupplyer, 2 – WRITEPARSER, 3 – buffer pointer
      uint16_t dataSize : 6; // size of data buffer (64 bytes maximum)
      };

  • Ben

    Hi Oleg, I try to compile NKRemote.pde and get the following error message:
    “psconsole.h:19: error: ‘Q_USER_SIG’ was not declared in this scope” Can you please help me out? Cheers, Ben

  • Ben

    Hi there,
    QP is installed. QP examples compile alright and PScapture compiles, too.

    • CamController has been developed prior to QP for Arduino; it uses generic QP package with modifications. The procedure of building the code is outlined in camcontroller article.

  • Ben

    Finally works now! Make sure your library folders are named correctly and name your files according to error messages: qep is not qp…

  • I have the exact same and the Problem I can not solve it. Tried everything. Examples QP compiled.

  • In file included from bsp.cpp:45:
    fsa.h:18: error: ‘Q_USER_SIG’ was not declared in this scope
    fsa.h:78: error: expected class-name before ‘{‘ token
    fsa.h:84: error: expected initializer before ‘*’ token
    fsa.h:85: error: expected initializer before ‘*’ token
    fsa.h:86: error: expected initializer before ‘*’ token
    fsa.h:87: error: expected initializer before ‘*’ token
    fsa.h:88: error: expected initializer before ‘*’ token
    bsp.cpp: In function ‘void __vector_7()’:
    bsp.cpp:108: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:108: error: expected type-specifier before ‘QEvt’
    bsp.cpp:108: error: expected `>’ before ‘QEvt’
    bsp.cpp:108: error: expected `(‘ before ‘QEvt’
    bsp.cpp:108: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:108: error: expected primary-expression before ‘>’ token
    bsp.cpp:112: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:112: error: expected type-specifier before ‘QEvt’
    bsp.cpp:112: error: expected `>’ before ‘QEvt’
    bsp.cpp:112: error: expected `(‘ before ‘QEvt’
    bsp.cpp:112: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:112: error: expected primary-expression before ‘>’ token
    bsp.cpp:119: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:119: error: expected type-specifier before ‘QEvt’
    bsp.cpp:119: error: expected `>’ before ‘QEvt’
    bsp.cpp:119: error: expected `(‘ before ‘QEvt’
    bsp.cpp:119: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:119: error: expected primary-expression before ‘>’ token
    bsp.cpp:123: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:123: error: expected type-specifier before ‘QEvt’
    bsp.cpp:123: error: expected `>’ before ‘QEvt’
    bsp.cpp:123: error: expected `(‘ before ‘QEvt’
    bsp.cpp:123: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:123: error: expected primary-expression before ‘>’ token
    bsp.cpp:130: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:130: error: expected type-specifier before ‘QEvt’
    bsp.cpp:130: error: expected `>’ before ‘QEvt’
    bsp.cpp:130: error: expected `(‘ before ‘QEvt’
    bsp.cpp:130: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:130: error: expected primary-expression before ‘>’ token
    bsp.cpp:134: error: ‘AO_Controls’ was not declared in this scope
    bsp.cpp:134: error: expected type-specifier before ‘QEvt’
    bsp.cpp:134: error: expected `>’ before ‘QEvt’
    bsp.cpp:134: error: expected `(‘ before ‘QEvt’
    bsp.cpp:134: error: ‘QEvt’ was not declared in this scope
    bsp.cpp:134: error: expected primary-expression before ‘>’ token
    bsp.cpp:147: error: ‘QF’ has not been declared
    bsp.cpp: At global scope:
    bsp.cpp:172: error: ‘QF’ has not been declared
    bsp.cpp:182: error: ‘QF’ has not been declared
    bsp.cpp:206: error: ‘QF’ has not been declared

  • Why? Recommend anything. I tried different versions of Arduino, follow the instructions to QEP. No results.

  • IDE 1.0.1 and QP version 4.5.02

    • Ian Drake

      Did you figure this out. Same problem here. Tried IDE version .0022 and QP version 4.5.02 and same exact problem too. For some reason the compiler isn’t finding the library…but it seems to be in the build directory. Strange.

  • Help me QP_VERSION 0x4502U

  • Frank

    Oleg, everyone, wonderful project. I am having encouraging signs but not quite there… I am running the “PTPCapture” example with a Nikon D40 (this is from the new 2.0 library, I also have the more recent USB Host Shield 2.0 libraries installed). It does connect to the camera successfully – upon uploading the sketch the camera takes one photo, this also happens when I start the serial monitor. However I believe this example was also supposed to keep snapping pics once every second? I will keep poking at this for resolution but thanks in advance for any advice you might have. -Frank

    • Try to increase the timeout between shots. Set it to 5 seconds.

      • Frank

        I’m having no luck with that. The best thing I have found is that if I put “ptp->CaptureImage();” multiple times back to back with a delay that it will take pics as many times as I do that specified by the delay I put in. If I only wanted to take a few shots after hitting the reset button on the arduino I might be happy but I am interested in getting into time lapse so I would have to have that possibly hundreds of times which is obviously not elegant… but its something. Its just not in the loop so it only runs once? (baby programmer here sorry)

        • Hmmm…, same problem with the Nikon Coolpix 5400, I only get “camera connected”, the first capture, then nothing. But, for me, even the multiple “ptp->CaptureImage();” statements do not get executed. I have tried extended delays (30 seconds) as well.

  • Kabir

    Hey,

    I am trying out the PSRemote example, got QP installed and qp_port.cpp replaced, but still keep getting

    psconsole.h:19: error: ‘Q_USER_SIG’ was not declared in this scope

    It is same for all the xxxRemote examples.

    • I got the same error recently compiling Nkremote. The issue is likely caused by the latest version of Arduino QP. I don’t know how to fix it – I simply downgraded to 4.3.00.

  • Thomas

    Are we able to grab images from the camera before uploading them to a PC?

  • Hi all, Hi Oleg,
    I have modified (added) your library to add support for color temp of White balance in manual mode.
    That’s works fine for read color temp but not for set it.

    This is the code that I have modified and my problem :

    ***************************************************
    Modification in file nkvaluetitles.h
    ************************************

    typedef uint8_t VT_COLORTEMP;
    .
    .
    .
    #define VT_COLORTEMP_TEXT_LEN 6
    .
    .
    .
    const ValueTitle ColorTempTitles[] PROGMEM =

    {

    {0×00, {‘ ‘,’2′,’5′,’0′,’0′,0} }, // 2500K

    {0×01, {‘ ‘,’2′,’5′,’6′,’0′,0} }, // 2560K

    {0×02, {‘ ‘,’2′,’6′,’3′,’0′,0} }, // 2630K

    {0×03, {‘ ‘,’2′,’7′,’0′,’0′,0} }, // 2700K

    {0×04, {‘ ‘,’2′,’7′,’8′,’0′,0} }, // 2780K

    {0×05, {‘ ‘,’2′,’8′,’6′,’0′,0} }, // 2860K

    {0×06, {‘ ‘,’2′,’9′,’4′,’0′,0} }, // 2940K

    {0×07, {‘ ‘,’3′,’0′,’3′,’0′,0} }, // 3030K

    {0×08, {‘ ‘,’3′,’1′,’3′,’0′,0} }, // 3130K

    {0×09, {‘ ‘,’3′,’2′,’3′,’0′,0} }, // 3230K

    {0x0A, {‘ ‘,’3′,’3′,’3′,’0′,0} }, // 3330K

    {0x0B, {‘ ‘,’3′,’4′,’5′,’0′,0} }, // 3450K

    {0x0C, {‘ ‘,’3′,’5′,’7′,’0′,0} }, // 3570K

    {0x0D, {‘ ‘,’3′,’7′,’0′,’0′,0} }, // 3700K

    {0x0E, {‘ ‘,’3′,’8′,’5′,’0′,0} }, // 3850K

    {0x0F, {‘ ‘,’4′,’0′,’0′,’0′,0} }, // 4000K

    {0×10, {‘ ‘,’4′,’1′,’7′,’0′,0} }, // 4170K

    {0×11, {‘ ‘,’4′,’3′,’5′,’0′,0} }, // 4350K

    {0×12, {‘ ‘,’4′,’5′,’5′,’0′,0} }, // 4550K

    {0×13, {‘ ‘,’4′,’7′,’6′,’0′,0} }, // 4760K

    {0×14, {‘ ‘,’5′,’0′,’0′,’0′,0} }, // 5000K

    {0×15, {‘ ‘,’5′,’2′,’6′,’0′,0} }, // 5260K

    {0×16, {‘ ‘,’5′,’5′,’6′,’0′,0} }, // 5560K

    {0×17, {‘ ‘,’5′,’8′,’8′,’0′,0} }, // 5880K

    {0×18, {‘ ‘,’6′,’2′,’5′,’0′,0} }, // 6250K

    {0×19, {‘ ‘,’6′,’6′,’7′,’0′,0} }, // 6670K

    {0x1A, {‘ ‘,’7′,’1′,’4′,’0′,0} }, // 7140K

    {0x1B, {‘ ‘,’7′,’6′,’9′,’0′,0} }, // 7690K

    {0x1C, {‘ ‘,’8′,’3′,’3′,’0′,0} }, // 8330K

    {0x1D, {‘ ‘,’9′,’0′,’9′,’0′,0} }, // 9090K

    {0x1E, {’1′,’0′,’0′,’0′,’0′,0} }, // 10000K

    };
    .
    .
    .
    #define VT_COLORTEMP_COUNT sizeof(ColorTempTitles) / (sizeof(VT_COLORTEMP) + VT_COLORTEMP_TEXT_LEN)
    ****************************************************************
    *
    *
    *
    ****************************************************************
    Modification in ptpconst.h
    **************************

    #define PTP_DPC_ColorTemp 0xD01E
    *****************************************************************
    *
    *
    *
    *****************************************************************
    and I have added a new function for the menu in psconsole.cpp

    void PrintColorTemp()
    {
    Notify(PSTR(“CCT:”));
    PrintValueTitle((PTP*)&Nk, PTP_DPC_ColorTemp, ColorTempTitles));
    Notify(PSTR(“\r\n”));
    }

    That’s works very fine for read the color temp when white balance is in manual mode

    but my problem is for set the color temp I use it but that’s don’t works :

    I have implemented a new function for change value (same as State PSConsole::ChangeWBMenu(PSConsole *me, QEvent const *e) but with value for Color Temp)

    StepUp((PTP*)&Nk, PTP_DPC_ColorTemp);

    or

    StepDown((PTP*)&Nk, PTP_DPC_ColorTemp);

    Have you an idea to set color temp ?

  • Tomas

    Hello! Very interesting project. I wonder, is there any chance to get the information from the camera about the lens that is mounted (mainly focus lenght)? Thank you.

  • ingo

    Hi Oleg,
    thanx for shareing your nice project.
    I started also a projekt and now there are some problems or better to say solutions missing.
    what i want to do is to contol camera in 4ways (slider+remotehead+focal length) save different positions and repeat the sequence… this is working

    But camera contoll???
    The focus and shoot with “normal cable” is fine just High/Low
    but i want to get more informations from the camera to us it in programm, to change ISO, aperture, EV.
    Is it possible to get the info with your shield also without a laptop via USB???
    How many pins are needed with the shield???
    Nunchuk and LCD is via I2C, but maybe it is needed to run also Steppercontol with I2C or your shield.

    Hope you can give my mind a clear view!!!
    THANK YOU

  • Felipe Marinho

    Hi all

    I’ve just downloaded this files (https://github.com/felis/PTP_2.0) and copied on arduino/libraries/PTP_2
    I’m using Arduino IDE 1.0.5 on a MAC with OS X
    I’m getting a lot of errors, different errors for each example.

    For example, EOSCamController i’m getting this errors:

    In file included from dataitem.h:5,
    from dataitem.cpp:1:
    /Users/felipe/Documents/Arduino/libraries/USBHS/canoneos.h:20:22: error: WProgram.h: No such file or directory
    In file included from /Users/felipe/Documents/Arduino/libraries/USBHS/ptp.h:29,
    from /Users/felipe/Documents/Arduino/libraries/USBHS/canoneos.h:21,
    from dataitem.h:5,
    from dataitem.cpp:1:
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptpdebug.h:24: error: expected unqualified-id before ‘void’
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptpdebug.h:24: error: expected `)’ before ‘void’
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptpdebug.h:24: error: expected `)’ before ‘void’
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptpdebug.h:43: error: redefinition of ‘template void PrintHex2(Print*, T)’
    /Users/felipe/Documents/Arduino/libraries/USBHS/printhex.h:64: error: ‘template void PrintHex2(Print*, T)’ previously declared here
    In file included from /Users/felipe/Documents/Arduino/libraries/USBHS/canoneos.h:21,
    from dataitem.h:5,
    from dataitem.cpp:1:
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptp.h:86: error: ‘EP_RECORD’ does not name a type
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptp.h: In member function ‘void PTP::Setup()’:
    /Users/felipe/Documents/Arduino/libraries/USBHS/ptp.h:124: error: ‘class MAX3421E’ has no member named ‘powerOn’

    Do anyone know how to solve that ?

  • Sandro

    Hi Oleg,
    When parsing an object info, how could we capture the picture filename directly to a variable?
    I’m talking about the nStage 31 from the parser in “ptpobjinfoparser.cpp”:

    case 31:
    E_Notify(PSTR("\r\nFile Name:\t\t"),0x80);
    arrayParser.Initialize(1, 2, &theBuffer);
    nStage ++;

    Thank you in advance!

  • Helmut

    Hello Oleg,

    nice work with the shield (which i am using). I got the most things to work. I tried to compile the NKRemote sketch but i failed with this (known) error:

    psconsole.h:20: error: ‘Q_USER_SIG’ was not declared in this scope

    so as you recommended i tried to use the qp version 4.3.0.0 but i cannot find the qp_host.cpp? I found it in the newest version but this will not work either. The 4.3.0.0 version that i got is from here:
    http://sourceforge.net/projects/qpc/files/QP-Cpp/

    is there a special trick that i don´t get? Or am i on the wrong way?

    Thanks and regards

  • Helmut

    Thanks i found it on some ftp just google: qp_arduino_4.3.00

    with this now i get:

    In file included from NKRemote.pde:6:
    C:\Users\Helmut\Documents\Arduino\libraries\qp/qp_port.h:3505: error: section attribute not allowed for ‘file’
    NKRemote:15: error: section attribute not allowed for ‘file’
    NKRemote:63: error: section attribute not allowed for ‘file’
    NKRemote.pde: In function ‘void Q_onAssert(const char*, int)’:
    NKRemote:66: error: ‘QF_INT_DISABLE’ was not declared in this scope

    Hopefully someone can point to a direction were i can fix this

    Thanks and regards

  • pcace

    Hi,

    i tried to get the lib to work for several hours now… the Problem is, that i cannot find an actual working qp library for Arduino 1.0.x. The is only a file for Arduino 1.5.x now online. Is it possible, that someone can upload this file: qp_arduino_4.3.00.zip somewhere?

    Would be awesome!

    Pcace

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="">