Gamebuino IR remote

Modules, cases, buttons...

Gamebuino IR remote

Postby maesoser » Fri Aug 22, 2014 12:19 pm

I'm developing a remote trigger for my camera. The code works well on an arduino duemilanove with an Atmega 328P but when I try to execute it in the gamebuino the camera does not make the photo.

I think it is because the code emitted by the gamebuino is slightly slower than the code emitted by the duemilanove but I cannot understand why. The emission is done by one method so it shouldnt be delayed by any specific gamebuino routine...no?

Any clue?
maesoser
 
Posts: 13
Joined: Wed Mar 26, 2014 11:38 pm

Re: Gamebuino IR remote

Postby rodot » Fri Aug 22, 2014 5:19 pm

The Arduino UNO, Arduino Duemilanove and Gamebuino are clocked at the same frequency: 16Mhz.
Did you run the exact same code on the Gamebuino than on the Arduino?
You use the pins of the I2C port to drive the IR LED?
On the hardware side, there a few differences:
- Gamebuino runs at 3,3V while Arduino runs at 5V, you might have to adjust the resistor value.
- There is 4K7 pullup resistors on the I2C port of the Gamebuino, you can disable them by cutting the jumper "I2C pullup resistor"
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Gamebuino IR remote

Postby maesoser » Wed Aug 27, 2014 10:27 am

The mistery continues.

The code is exactly the same.

I have a visible led and I can see it blinking at the same way the duemilanove does. When I connect the IR led to the duemilanove and the Gamebuino and see them through a camera I can see them blinking too.

It is not the intensity, cause the duemilanove signal is able to go through a whole room and the gamebuino signal even at 0 cm doesnt trigger the camera.

I've built a circuit with a transistor too, but it doesnt work either.

The code is this:

Code: Select all
int shotcode[] = {
  1,0,1,1,0,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1}; // Code to send Shutter release command B4B8F
int shotcode_delayed[] = {
  1,1,1,0,1,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1}; // // Code to send 2 X delay Shutter release command ECB8F

void shot(int bits[]){
  gb.sound.playTick();
  for (int i=1; i <= 3; i++)  // Send Command 3 times as per Sony Specs
  {
    header();                    // Send the Start header
    for (int i=0; i <= 19; i++)  // Loop to send the bits
    {
      if(bits[i] == 1)  // Is Data_is_One to be sent ?
      {
        Data_is_One();              // Yes, send a Data_is_One bit
      }
      else                  // No, Data_is_Zero to be sent
      {
        Data_is_Zero();              // Send a Data_is_Zero bit
      }
    }
    delay(11);                  // Delay Padding to give approx 45mS between command starts
  }
}
// Routine to give the 40kHz burst signal
void burst()                   // 40KHz burst
{
  digitalWrite(IR_LED, HIGH);   // sets the pin on
  delayMicroseconds(10);       // pauses for 13 microseconds  (fudged to 10uS Delay)
  digitalWrite(IR_LED, LOW);    // sets the pin off
  delayMicroseconds(8);        // pauses for 12 microseconds   (fudged to 8uS Delay)
}

// Routine to give a quiet period of data
void quiet()                   // Quiet burst
{
  digitalWrite(IR_LED, LOW);    // sets the pin off
  delayMicroseconds(10);       // pauses for 13 microseconds   (fudged to 10uS Delay)
  digitalWrite(IR_LED, LOW);    // sets the pin off
  delayMicroseconds(8);        // pauses for 12 microseconds    (fudged to 8uS Delay)
}

// Routine to send header data burst
// This allows the IR reciever to set its AGC (Gain)
// Header Burst Timing is 96 * 0.025uS = 2.4mS
// Quiet Timing is 24 * 0.025uS = 600uS
void header()
{
  for (int i=1; i <= 96; i++){
    burst();                // 40kHz burst
  }
  for (int i=1; i <= 24; i++){
    quiet();                // No 40 kHz
  }
}

// Routine to send one data burst
// Burst Timing is 48 * 0.025uS = 1.2mS
// Quiet Timing is 24 * 0.025uS = 600uS
void Data_is_One()
{
  for (int i=1; i <= 48; i++){
    burst();                // 40kHz burst
  }
  for (int i=1; i <= 24; i++){
    quiet();                // No 40 kHz
  }
}

// Routine to send zero data burst
// Burst Timing is 24 * 0.025uS = 600uS
// Quiet Timing is 24 * 0.025uS = 600uS
void Data_is_Zero()
{
  for (int i=1; i <= 24; i++){
    burst();                // 40 kHz burst
  }
  for (int i=1; i <= 24; i++){
    quiet();                // No 40 kHz
  }
}


Hum, there is a small detail that could be useful... at the beginning of the shot function I make a call to playTick...and the tick never comes... mmm..maybe the speaker is responsible for that?
maesoser
 
Posts: 13
Joined: Wed Mar 26, 2014 11:38 pm

Re: Gamebuino IR remote

Postby rodot » Wed Aug 27, 2014 10:53 am

I don't think the speaker might be responsible of that.
Did you try running your code on the Gamebuino but without the Gamebuino library and functions?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Gamebuino IR remote

Postby maesoser » Wed Aug 27, 2014 6:09 pm

Oh, It works!!

But now...how can I fix it in order to work with Gamebuino?
Maybe I could create a Gamebuino library with only the buttons,the screen and the loader code... I still dont understand where could be the error...
maesoser
 
Posts: 13
Joined: Wed Mar 26, 2014 11:38 pm

Re: Gamebuino IR remote

Postby rodot » Wed Aug 27, 2014 6:22 pm

It's probably because of the sound library that generates interruptions. What you can do is to disable it be changing NUM_CHANNEL to 0 in settings.c
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Gamebuino IR remote

Postby maesoser » Fri Aug 29, 2014 12:41 pm

It works! I change that setting but it throws some errors related with sound creation methods so I decided to make an alternative Gamebuino library without the sound part.

I use the tone() function of the basic arduino library in order to make simple tones.

I've also change the library of another small sketch that was giving me problems (http://gamebuino.com/forum/viewtopic.php?f=8&t=1049)
and It works also.

thanks rodot!!
maesoser
 
Posts: 13
Joined: Wed Mar 26, 2014 11:38 pm

Re: Gamebuino IR remote

Postby rodot » Fri Aug 29, 2014 12:51 pm

maesoser wrote:It works! I change that setting but it throws some errors related with sound creation methods so I decided to make an alternative Gamebuino library without the sound part.

Thanks for pointing that out, I just fixed it and will commit that to the beta branch of the library.

The arduino tone() function only uses one timer while the Gamebuino sound library uses two timers to create advanced sound effect, so it's a solution if you need a timer and still want sound.

I'm glad you solved your problem :)
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France


Return to Hardware Development

Who is online

Users browsing this forum: No registered users and 82 guests

cron