9 Replies Latest reply on Jun 20, 2014 7:28 AM by AllynH

    Using Galileo for IR remote control

    AllynH

      Hi there,

       

      I am trying to control my SLR camera using the Galileo as an IR remote.

       

      I have been following some projects on line, where the IR led is controlled by a sketch (or C++ code, included in the sketch).

      In particular, I've been following this project:

      http://sebastian.setz.name/arduino/my-libraries/multi-camera-ir-control/

       

      I've built the circuit and my code is compiling, I've also tested the code with a regular LED and I can see activity on the LED.

      So as far as I can tell, the code works - however I have been unable to snap a picture.

       

      A timing diagram of the command can be found here:

      SB-Projects: Projects: Nikon IR-Remote Control

       

      I'm pretty new to the Arduino scene and I don't fully understand how the pulse frequency is generated or any frequency differences between Arduino devices.

      Any help with the debug is appreciated!

        • 1. Re: Using Galileo for IR remote control
          SpiderKenny

          In order to successfully transmit IR codes you need to be able to generate a 38 KHz square wave (possibly 36 kHz for some devices) and then turn that square wave on and off at precise intervals.

           

          All PWM on galileo is done via the cypress chip, so it's slow and the timing is non-deterministic. Therefore the approach I'd take is to select one of the PWM channels and set it running at 38 kHz. Then I'd select and deselect the MUX on the selected pin to generate the mark/space (on/off) timings.

           

          I Can't test this for now, so its all theoretical.

          • 2. Re: Using Galileo for IR remote control
            AllynH

            Hi SpiderKenny,

             

            Sorry for the delay in my response

             

            So I think I have a better understanding of what needs to be done but I have a few more questions:

             

            • How do I know the frequency of the PWM pins?
            • Do all PWM pins have the same frequency?
            • Is it possible to test what frequency is being outputted?
            • Do I use digital write? Analogue write?
            • If using the PWM I assume I would be use analogueWrite() function?

             

            Here's what I'm thinking:

            For the first part of the command pulse, the signal is on for 2mS and off for 28mS.

             

            // Psudo code:

            // Set Frequency - assuming 62.5KHz:

            // (62.5 / 2) = 31250KHz

            setPwmFrequency(9, 2);

            :

            :

             

            digitalWrite(9, HIGH)

            delay 2mS

            digitalWrite(9, LOW)

            delay 28mS

            :

            :

             

            Let me know what you think and thanks again for the help!

            • 3. Re: Using Galileo for IR remote control
              AllynH

              Just to follow up on this:

               

              I didn't use the PWM for this project, I chose to use the GPIO 2 pin set up with pinMode(OUTPUT_FAST) to create a 477KHz clock.

              Using this clock I created a 38KHz square wave and generate the required pulse train needed to send the command to my camera.

              I borrowed a Saleae Logic Analyzer (which is a fantastic piece of gear!) and got the following results.

               

              GPIO output using pinMode(OUTPUT_FAST):

              Expt1_OUTPUT_FAST.png

               

              Square wave used to create 38.4KHz carrier wave:

              Clock Freq.png

               

              The following communities post is very helpful:

              Re: I/O speeds?

               

              Here is a full blog post about it:

              Intel Galileo – Getting to grips with GPIO speeds: | Allyn H

              I've gone through the example code given in the above post by deckard026354 and graphed the output of each.

               

              I'll update this thread with my results and give a full write up in the blog above.

              • 4. Re: Using Galileo for IR remote control
                SpiderKenny
                I borrowed a Saleae Logic Analyzer (which is a fantastic piece of gear!)

                Indeed it is, apart from the silly name. There is a new version of their software 'Logic' coming out tomorrow too.


                I'm intrigued... how did you create the 477 kHz Clock, and how did you then divide that down to 38.4 kHz?


                What will you use to switch on/off the 38.4 kHz carrier?

                • 5. Re: Using Galileo for IR remote control
                  AllynH

                  Hi SpiderKenny,

                   

                  I've created a blog post about creating the clock pulse:

                  http://allynh.com/blog/?p=33

                   

                  I intend to do a complete write up on the build process.

                  I may even be able to port this to other makes of SLR cameras.

                  • 6. Re: Using Galileo for IR remote control
                    SpiderKenny

                    Hi Allyn

                    I read your blog post - nice work, some great stuff there!

                    I think that the output frequency will suffer from a bit of good old fashioned jitter though, as the timing is non-deterministic.

                    That's because the galileo Sketch does not have exclusive access to the CPU, so the cpu may well (and in fact does!) suspend your thread to do other things many times a second.

                    The priority of your thread and it's timing cannot be calculated or determined, or relied on. The kernel may adjust your process's priority and schedule at any time.

                     

                    I wonder why you didn't just make use of PWM to drive a fixed frequency signal without any chance of jitter?

                    • 7. Re: Using Galileo for IR remote control
                      AllynH

                      Hi SpiderKenny,

                       

                      For the purpose of this project, reliability shouldn't be an issue - I'll only be sending a pulse train to capture a picture.

                      With regards to the PWM, I'm having a lot of trouble finding out how to program them correctly from the Arduino IDE.


                      But you've raised an interesting point: In more timing sensitive projects, should you be programming from the Arduino IDE, or directly controlling the GPIO / PWM in the Linux environment?

                      • 8. Re: Using Galileo for IR remote control
                        SpiderKenny

                        You can do both!

                        Since everything in Linux (pretty much) has a file interface you can use basic system() commands to do just about anything linux from within Arduino sketches.

                        You can set up PWM period and duty cycle, route the MUX to the correct pin and start/stop the PWM all from within Arduino, or directly from Linux.

                        • 9. Re: Using Galileo for IR remote control
                          AllynH

                          Hi all,

                           

                          I've got this running now and created a blog post about it here:

                          Making an IR remote control for a Nikon camera: | Allyn H

                           

                           

                          Using the GPIO information above, I was able to:

                          • Create a 38.4KHz clock pulse.
                          • Toggle the clock on and off to create a binary signal.
                          • Recreate the full command signal:

                          Command Pulse.jpg

                           

                           

                          I written the code in such a way, it should be easily portable to any other cameras, the command pulses are in the link in my OP.