Showing posts with label Remote. Show all posts
Showing posts with label Remote. Show all posts

Monday, 22 October 2012

Git - Getting started



1. Backup any existing ssh keys
     $ cd ~/.ssh/
     $ mkdir key_backup
     $ mv *.pub ./key_backup/

2. Generate private ssh keys
     $ ssh-keygen -t rsa -C "developer.rps@gmail.com"
     $ Enter file in which to save the key: filename
     $ Enter passphrase : *****

3. Add private ssh key to git.gitorious.org account
     $ sudo apt-get install xclip
     $ xclip -sel clip < ~/.ssh/filename.pub
   



       - go to account setting in the user page of git.gitorious.org     
       - Go to your Account Settings
       - Click ssh keys
       - Click "Add SSH key"
       - Paste your key into keyfield
       - Click Add key


4. Check whether ssh key is successfully added
     $  ssh -v git@gitorious.org


5. Clone the remote repo
     $ mkdir ~/workspace/
     $ cd ~/workspace
     $ git clone git://gitorious.org/project_name/repo_name

6. Adding files to remote repo
     $ cd ~/workspace/athena
     $ nano someFile.txt

7. Add some msg to it, save and exit
     $ git add someFile.txt
     $ git status
     $ git commit -a
     $ git remote set-url --push origin git@gitorious.org:athena/athena.git
     $ git push origin master #only for the first time,
     $ #next time onwards just use "git push")

   If the step 7 throws an error like this,
          $ Permission denied(publickey).fatal:The remote end hung up unexpectedly

  do the following, then try pushing
     $ ssh-add ~/.ssh/id_rsa.pub
     $ git push

8. Getting files from remote repo
     $ git pull

Friday, 22 July 2011

SIRC Part III - Encoding and Decoding


In this post, We examine sample codes for encoding and decoding using Arduino.
Encoding:
     The frequency of the carrier signal to be sent is 40 KHz. Hence, it takes 25 micro-seconds for one cycle. Each cycle consists of ON and OFF time. The duty cycle denotes the ratio between ON time and Time Period. The duty cycle recommended by SIRC protocol is 1/4 or 1/3. Here we use a duty cycle of 25% (1/4). Hence, the number of cycles required to complete each type of bit is listed below:
              Start bit: ( 2400(uS)/25(uS) ) = 96 cycles
               '1' bit : ( 1200/25 ) = 48 cycles
               '0' bit : ( 600/25 ) = 24 cycles
A sample program for encoding the signal is given below:

void setup()
{
           Serial.begin(9600);
           pinMode(14,OUTPUT);      // IR LED is connected to pin14
}
int sum=0;
void transmit(int command)
{
        // Here we dont add the start bit to the array
        //Array arr[] represents just the data bits
        // We create the start pulse manually using pulse(int) function
        // We declare an array containing all the data bits (arr[])
        // i--> index variable
        int arr[12],i=0;
        // Here we convert the decimal value of command to binary value,
        // And store it in the array arr[]
        // From LSB to MSB
        while(command>0){

                    arr[i]=command%2;
                    command/=2;                    
                    i++;
        }
        // Now we have converted the decimal to binary
        // But we need to fill the empty digits to '0'
       for( i ; i<7 ; i++ )

               arr[i]=0;

              //Adding the address bits
              // For testing purpose, we use TV, address for TV is 10000 (5 bit data)
              // Now value of i is 7
              // Which represents the 8th position
              arr[i]=1;
              i++;
             // Now value of i is 8
             // Which represents the 9th position (9,10,11,12)--> 4 iterations

            for( i ; i<12 ; i++ )
                  arr[i]=0;
                  // Last 5 bits now look like 10000 which denotes address of TV
                  //Manually pulsing the start bit (2400 uS)
                  pulse(96);              //96*25=2400;
                 //Pulsing all the data bits
                 for(i=0;i<12;i++) {
                       if(arr[i]) {
                              pulse(48);
                       } else {
                             pulse(24);
                       }
                 }
               //The total time of one set of data (one frame) is 45 mS (ie) 45000 uS                  
               digitalWrite(14,0);
               delayMicroseconds((45000-sum));
}

// The pulse function for pulsing bits
// 25% duty cycle
// followed by 600 uS space
void pulse(int dur)
{
               for(int j=0;j<dur;j++) {

                      digitalWrite(14,1);
                      delayMicroseconds(6);
                      digitalWrite(14,0);
                      delayMicroseconds(19);
               }
              delayMicroseconds(600);
}
void loop()
{
          transmit(21);
          transmit(21);
          transmit(21);
          delay(3000);
}


Decoding:
          Decoding is relatively easier than encoding. A sample coding which is self-explanatory is given below:


void setup()
{
          Serial.begin(9600);       //Setting Baud Rate
          pinMode(15,INPUT);    //IR TSOP receiver is connected to PIN 15                   
}

int remote()
{
            // i--> index variable
            // arr[]--> array that stores digital word
            // val--> stores the decimal format of arr[]
            int i=0,arr[8],val=0;
            //Checking the start bit
            if(pulseIn(15,0)>2000) {
                  //Storing the digital word in arr[]
                  for(i=0; i<7 ; i++,arr[i] = pulseIn(15,0)) ;
                  //Converting digital word into decimal value
                  //Storing it in val
                    for(i=0;i<7;i++) {
                           if(arr[i]>1000) {
                                   val=val+(1<<i);
                           }
                    }
            }
           return val;
}
void loop()
{
            int checkVal=remote();
            if(checkVal);
            Serial.println(checkVal);
}

Coming up next:

          * Practical model

          * Building a project ( An Universal Remote)


Tuesday, 21 June 2011

SIRC Part I

BASICS
  
Wireless infrared communications refers to the use of free-space propagation of light waves in the near infrared band as a transmission medium for communication. Signals sent are encoded using a an encoding algorithm in the transmitter circuitry and is decoded and the essential information is obtained at the receiver part. IR communication is a basic form of wireless communication. It's frequency range is 32-60 KHz. There are several protocols for IR communication. Some are Sony's SIRC, Phillips RC5 protocols.

 SIRC (Sony Infra Red Communication Protocol), is an IR communication protocol for controlling SONY equipment. It consists of three versions based on bit length (12, 15, 20 bit). For convenience, we here discuss about 12 bit version of SIRC. Here Pulse Width Modulation (PWM) is made use of.

  The 13 bits are divided into 12 data bits and 1 start bit. The start bit indicates the start of the information and the following 12 bits indicate the information itself. The data bits are further classified into address and command. The seven bits followed by the start bit represent the command (from LSB to MSB) (ie) in reversed manner. The following 5 bits represent the address in reversed manner. 


What is a command and address?

Command:
    It is more of a self defining term. It consists of a digital word that will server as a command to the receiving system. The following table gives the commands and their digital values in a Sony IR remote.


Command
Function
0
Digit key 1
1
Digit key 2
2
Digit key 3
3
Digit key 4
4
Digit key 5
5
Digit key 6
6
Digit key 7
7
Digit key 8
8
Digit key 9
9
Digit key 0
16
Channel +
17
Channel -
18
Volume +
19
Volume -
20
Mute
21
Power
22
Reset
23
Audio Mode
24
Contrast +
25
Contrast -
26
Colour +
27
Colour -
30
Brightness +
31
Brightness -
38
Balance Left
39
Balance Right
47
Standby



Address:
   It is a digital word that represents the address of the receiving system. Sony has unique address for its products. The following table gives the digital address for various Sony equipment.


AddressDevice
1TV
2VCR 1
3VCR 2
6Laser Disc Unit
12Surround Sound
16Cassette deck / Tuner
17CD Player
18Equalizer


How does a signal to be transmitted look like?

   The following figure gives a rough idea about how the signal looks like:


  The data bits to be transmitted consist of marks and spaces. The marks are the high regions in terms of voltage while spaces are the low regions. Digital high (1) is represented by a mark of 1.2 ms (milli seconds) and digital low (0) is represented by a mark of 0.6 ms ( PWM). The time period of a start bit is 2.4 ms. A space is always represented by 0.6 ms low with respect to voltage.


What is PWM?

       PWM (pulse width modulation) is an encoding process where variation of width of each pulse is used to show the variation in the actual data.


Basic materials for transmission:
      We use an IR LED to transmit PWM signal and an IR receiver to receive the transmitted signal. The receiver always inverts the signal after which the decoding process is done.


 Coming Up :

    * More parameters

    * A platform to move on

    * Encoding and Decoding codes

    * Practical model

    * Building a project ( An Universal Remote)

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More