Shop OBEX P1 Docs P2 Docs Learn Events
Create an ir code in spin — Parallax Forums

Create an ir code in spin

JkaneJkane Posts: 113
edited 2014-08-01 13:43 in Propeller 1
Hello,

does anyone know if there is spin code to create an ir code, there seem to be many Get_ir_code routines from remotes but I am having difficulty in finding a spin ir code creator and transmitter.

thanks in advance

regards

Jeff

Comments

  • RS_JimRS_Jim Posts: 1,766
    edited 2014-08-01 07:01
    Jeff,
    Check out the spin zone articles by Jonny Mac. I recall him doing an IR project for the Propellar in one of them.
    Jim
  • JkaneJkane Posts: 113
    edited 2014-08-01 07:29
    Ok,

    I'll check it out, the reason I need this is that I have multiple ir sensors in a confined area, i need to make sure the sender_X and receiver_X are coupled.

    regards

    Jeff
  • lardomlardom Posts: 1,659
    edited 2014-08-01 08:08
    In Spin "Get-IR-Code" means the parent object is requesting data from the child object. An important key to creating a transmitter, if that's what you want, is understanding how the child object decodes the signal.
    I'm working on a 'Bot' controlled by a remote that uses the SONY IR code. I also want to experiment with radio and computer control. As long as I can decode what the transmitter sends I'm OK. For example, "If you see a 'binary five' accelerate".
  • JkaneJkane Posts: 113
    edited 2014-08-01 08:19
    Yes, agreed,

    this is some code that receives, which seems the trend is to use remote, cool but my sender and receiver are both spin. in a small confined area, with multiple ir led's I need to make sure the ir led that sent the code is bound to the a specific receiver.

    this is the receiver code method, as an example
    PUB Get_IR_Code(pin, threshold) | temp, i
    ''
    ''  Parameters:
    ''  Pin = the IO pin which the IR receiver is connected to
    ''  Threshold = the number of pulse width counts that distinguishes between a 0 and 1, empircally determined
    ''
    ''  Returns:
    ''    -1 if the method timed out waiting for a pulse or the value of the code received.
    ''
    ''  Example call: newCode := Get_IR_Code(0, 25)
    ''  Expected outcome: if a code is being received, save the code received on pin 0 into the "newCode" variable
    ''
      
                              
      dira[pin]~                                            'set pin to input
      'zero out uninitialized variables
      i~
      result~
      if Wait_On_State(pin, 1, CODE_TIMEOUT) < 0            'is there a code to receive
        return -1                                           '  no code to receive, so bail
        
      repeat                                                'build the code loop
        Wait_On_State(pin, 1, CODE_TIMEOUT)                 'we dont care about the the high pulses, so just wait till they are out of the way
        temp := Wait_On_State(pin, 0, CODE_TIMEOUT)         'measure the low pulse length and save in temp
        if temp > 0
          result |= ((temp > threshold)&1) << i++           'build the code here, bit by bit
        else
          quit                                              'done, bail
    
    
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-08-01 08:28
    OBEX has a lot of nice objects for IR code, about three pages worth.

    For the longest time, I stayed with Sony 12bit devices because that was what I learned with the BasicStamp. I picked up a nice little Arduino kit with an NEC 32bit IR device and was very quickly able to determine that was its code and quickly found the means to use it.

    No shortage of software.
  • lardomlardom Posts: 1,659
    edited 2014-08-01 08:37
    @LKane, I'm going to have to learn from you. Binding a transmitter to a reciever is something I still have to learn.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-08-01 09:19
    Here is a Receiver and Transmitter that I wrote that breaks the SONY barrier and will work with all of the remotes I could find in our house at the time I wrote the code.

    http://obex.parallax.com/object/292

    "Uses Assembly to record the Mark and Space data of the IR signal. Fixed Mark, Fixed Space, and Manchester coding detection across several odd-ball remotes. Compression techniques applied for a smaller data representation footprint. Supports Pattern matching, and re-transmission of stored IR sequences."

    enjoy!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-08-01 11:08
    Linux has a very big IR project.. likely more than most people would care to know. But it can be helpful. http://www.lirc.org/

    I have mentioned before that some people are confused because a conventional 'universal remote' actually has several different behaviors. Knowing that there are a variety of behaviors coming from the remote really helps with programing.

    Some buttons are one-shot, others keep repeating as long as held down (Like the volume control). Another group does more exotic things, like remembers and recall your last channel selection. And some are intended to switch from a TV to another device.

    In sum, TV Remotes get overly complex. So I was happy to finally get something simpler.

    I have noticed that some of the IR code in the OBEX allows you to ignore the auto-repeats that occur and use all the keys as one-shots.

    Hopefully all this might help. There are hundreds of code formats and they seem to take roughly four different timing methods. That is why different remotes are ignored by other devices. I am not sure that I ever want to try and figure all that out, but the Linux information may help.
  • PublisonPublison Posts: 12,366
    edited 2014-08-01 13:43
Sign In or Register to comment.