Shop OBEX P1 Docs P2 Docs Learn Events
IR Boe bot — Parallax Forums

IR Boe bot

bee896bee896 Posts: 25
edited 2010-10-15 07:42 in Propeller 1
I am now doing a group project by using Boe Bot and spin language of Tool Propeller. We are required to do the Infrared and Bluetooth Communication. Yet, our coding for IR remote for the boe bot , cannot function.
I attached together with the spin code that I am currently using.

I dunno where the things went wrong so wanna ask for help from you.

Hope to get your reply asap... Thanks...
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-11 12:01
    This is a lot of code and not a lot of information.

    Where did you get the code? What have you done so far in terms of testing? What works? When it doesn't work, what happens? How do you have things connected?

    Normally with this sort of program, the pieces are tested separately. There are several levels to the IR remote detecting and decoding. Normally, you'd start with the lowest level and test and debug looking at the individual bits and their reception, then you'd add the assembly into bytes and check that, then the assembly into messages and check that. Until and unless you have that working reliably, you wouldn't move on to attempt to control something using IR.
  • bee896bee896 Posts: 25
    edited 2010-10-11 19:26
    I got the code from my lecturer. when the lecturer demonstrated to us, it did works. But after we tested in the lab, just the first time attempt, it already didn't works. even the lecturer's bot cannot works now.

    I attached the pictures of my board layout.

    we are required to use Ping Sensor,Line Sensor, bluetooth and infrared.

    our ping sensor can works currently. The main problem is the infrared for manually control.
    1600 x 1200 - 337K
    1600 x 1200 - 364K
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-11 19:38
    It's impossible to tell from your pictures whether there's a problem with your board. You really need to make a schematic diagram of the thing (and post it).

    It sounds like you need to simplify your program down to just the IR detection stuff and test (and understand) that first before you add anything else (like motion). That's what I would do in your place. I'd take the IR code in your program and add some debug display code that would display some of the variables in your program on the display, more than what's already in your program.

    I would probably combine the source code for irDecode with the IR BOE code so it's all in one source file. That makes it easier to add debug code to the irDecode routines. Later, when you've got the code working and you understand it, you can split it up again and add back in the motion code.
  • bee896bee896 Posts: 25
    edited 2010-10-11 20:32
    I actually never learnt how to draw a schematic diagram.
    I was basically thrown a boebot and needed to solder everything myself using a diagram my dear lecturer drew on the whiteboard.
    I'm forced to learn every spin basics in just 2 months time.
    That's why I can't provide you with every minute detail that you need. Sorry for that :(
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-11 21:02
    I'm sorry you're not getting the support you need. Unfortunately, it's still true that, given your story, there could be something wrong with the design or with the wiring and I can't tell from your pictures how things are connected. You don't have to make a formal neat clean schematic. A simple handwritten drawing will do or a connection list that lists what's connected to what. You don't have to show the stuff that's built into the Protoboard except for connections to it (like to the power busses). Often the process of making a schematic from the board will identify wiring errors.

    The best way to learn Spin and the Propeller assembly language is to work through relatively simple examples. Andy Lindsay's Propeller Education Kit tutorials are a good starting point. There's other tutorial information in the "Propeller: Getting Started and Key Thread Index" sticky thread on this forum. You may feel very pressed for time, but you'll learn more quickly and progress faster overall with the project if you invest some time up front to go through the tutorials.
  • bee896bee896 Posts: 25
    edited 2010-10-11 21:35
    Alright. I'll try to give you something so that you can understand.
    But in the mean time, do you know where I can get any coding samples for an IR Remote Controller assuming that the connections are all correct.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-11 22:09
    There are some objects in the Propeller Object Exchange that can encode and decode IR remote controls. Look at "IR Kit", "IR Remote", and "IR Transmit" for examples.
  • bee896bee896 Posts: 25
    edited 2010-10-12 04:46
    This is the circuit for the board......
    1600 x 1200 - 203K
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 09:15
    Thanks for the diagram. That's the sort of thing I was looking for. I assume you're using a standard IR detector like those that Parallax uses. In that case, the schematic looks correct.

    I would first debug the hardware and use either an oscilloscope or logic analyzer or the Propeller itself to tell me if the IR detector is seeing the remote control signal. You could write a simple program that lights an LED on an unused I/O pin when the IR detector output becomes low (it idles at high). You should see the LED blink when you hold a button on the remote control.

    Something as simple as this would do:
    con
       irRemote = 6   ' IR detector
       testLED = 11   ' LED indicator (with 330 Ohm series resistor)
    
    pub main
       dira[testLED] := 1   ' make I/O pin an output
       repeat
          outa[testLED] := ina[irRemote]   ' copy I/O pin to I/O pin
    
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 09:30
    Once you're sure the IR detector is working properly, I'd spend a little time with "IR Kit" from the Propeller Object Exchange (OBEX) and use it to examine the timing and format of the IR remote control signal.

    From what I can see, your irDecode object records the on/off times of the IR signal and saves that to a buffer until there's a long pause. It then goes through the buffer, decides which on/off times are zeroes and which are ones, then groups the information into bytes for the rest of the program to look at.

    As I said before, I would then probably combine your two objects into one for debugging purposes and use the video output to display the recorded on/off times so I could tell whether that's being processed properly. If everything looks correct at any given level of processing, I'd then move on to the next higher level.

    Since the code (and hardware) worked at some time, I suspect you've got a bad connection somewhere unless you've changed part of the code. In that case, I'd look at the part that you changed.
  • SapiehaSapieha Posts: 2,964
    edited 2010-10-12 09:45
    Hi bee896.

    If You add one LED and resistor to Yours IR receiver You can see activity on it in real time.

    IR.rec.out ---- Resistor ----|<-LED--- 3.3V


    bee896 wrote: »
    This is the circuit for the board......
  • bee896bee896 Posts: 25
    edited 2010-10-12 13:48
    I don't understand some parts of the coding in irDecode.spin
    PRI fill_buff | iron, iroff
    
      dira[ird_pin]~                 'input on ird pin 
      npairs~
      repeat while ina[ird_pin]==1   'wait any mark
      repeat
        iron~
        iroff~
        repeat while ina[ird_pin]==0  'time mark
          iron++ 
         [B] if iron > 10000           'this just balances mark/space counts[/B]
      
        repeat while ina[ird_pin]==1  'time space
          iroff++
          if iroff>_quiet           'end of sequence
            buff[npairs++]:=iron
            buff[npairs++]:=iroff   'save last pair
            return
           
        buff[npairs++]:=iron
        buff[npairs++]:=iroff
          
        if npairs => _maxbuff-2
          npairs -= 2               'don't overfill the buffer
    

    the bold part doesn't seem to do anything. in this case if iron is greater than 10000 then nothing done.
    it seems so strange.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 13:56
    I know you posted the source code earlier in this thread, but for others reading these messages, it's much more helpful to use the "code" tags around code that you've cut and pasted into a message. Use the "#" button above the message box to put these around selected text.

    In the routine you included:

    PRI fill_buff | iron, iroff
    
      dira[ird_pin]~                 'input on ird pin 
      npairs~
      repeat while ina[ird_pin]==1   'wait any mark
      repeat
        iron~
        iroff~
        repeat while ina[ird_pin]==0  'time mark
          iron++
          if iron > 10000           'this just balances mark/space counts
        
        repeat while ina[ird_pin]==1  'time space
          iroff++
          if iroff>_quiet           'end of sequence
            buff[npairs++]:=iron
            buff[npairs++]:=iroff   'save last pair
            return
            
        buff[npairs++]:=iron
        buff[npairs++]:=iroff
        if npairs => _maxbuff-2
          npairs -= 2               'don't overfill the buffer
    

    I don't think that line of code does anything. It may be left over from previous changes.
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-12 14:42
    The problem you have is that your main loop code is too slow to read the Toshiba IR codes
    before it disappears due to spurious receives.
    That is why it works earlier but doesn't work now because the main loop program is slower now because it needs to do
    other things like reading PING))) or move the servo motor.

    By adding this line to the irDecode.spin file,
     if code > $A0000000         ' accept only full values, not garbage
           ircode := code
    

    it will hold the received code longer to enable the main program to collect it at a later time
    See and use attached file.

    Good luck.
  • bee896bee896 Posts: 25
    edited 2010-10-12 15:12
    Mike: if that line of code doesn't do anything, so will the loop stop there? something like a premature stop.

    William:thanks for all the info. since the batteries needed recharge i'll try to update my current situation asap.
    if you can refer the first few lines of comments in "IR Boe.spin" in my first post, i guess my lecturer got the coding from you.
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-12 15:38
    The function of this line
    if iron > 10000           'this just balances mark/space counts
    
    is to balance the timing calculations between IR on and off.
    It is required to make the decoding accurate.

    Bee,

    Please pass the new irDecode.spin file to your lecturer and other students so they don't experience the same problem with timing.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 15:41
    Will the loop stop early there? No

    If you put "IF iron > 10000" at the end of the loop with nothing after it, it's like saying the following in Basic:

    IF iron > 10000 THEN
    REM do nothing
    ELSE
    REM do nothing
    ENDIF

    If you do want to quit the loop early, use the QUIT statement like
    IF iron > 10000
       QUIT
    
  • bee896bee896 Posts: 25
    edited 2010-10-12 16:11
    William & Mike:
    repeat while ina[ird_pin]==0  'time mark
          iron++
          if iron > 10000           'this just balances mark/space counts
    
    i still don't get it. Since nothing is done after an IF statement, where does the time balancing comes from?
    I'm interpreting it in terms of language like C++ where
    if iron > 10000           'this just balances mark/space counts
    
    won't do anything unless you type further instructions beneath the IF statement to run something right?

    William: OK I'll pass it to him after done testing
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 16:43
    The comment is misleading. Maybe whatever was there in the past "balanced the mark/space counts", but there's nothing there that would do it now.
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-12 16:45
    Bee,

    The code
    if iron > 10000           'this just balances mark/space counts
    

    just wastes time a bit so the IR decoding is accurate. This wasting of time is required.

    Are you using Boe-Boost?

    Here is a program I wrote that allows both PING)) and IR to work together on the Propeller Boe Bot.
    If you use the IR remote arrow keys, the bot just moves like remote control.
    But if you press the Prev Ch key, the bot becomes alive and moves around by itself.
    Make sure the IO pin assignments for IR, PING and Head Servo etc is correct before you download the program.
  • bee896bee896 Posts: 25
    edited 2010-10-12 19:43
    okok..i will try the coding you give...thank for the coding...

    i want to ask about remote control for IR...can i know the coding you use in IR work for all remote control??because as i know the coding used in IR is using the TOSHIBA code..how about if we use UNIVERSAL remote controller??does't it work same as toshiba code 613 or we need change the 613 code ??
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-12 20:17
    Universal remote control just means that the remote control can produce the IR control signals for most of the manufacturers out there. Usually the remote comes with a manual listing codes for the different manufacturers and devices. You look up the manufacturer and the type of device and model code and the manual tells you what code to enter in the remote. When you do that, the remote fetches information from a ROM about which signal goes with which button plus the format of the signal.
  • bee896bee896 Posts: 25
    edited 2010-10-12 20:34
    ok..thank..i try to look at it...
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-12 20:47
    Are you using Boe-Boost?

    If you are using Boe-Boost, you must make sure that the jumper is set to 5v and not Vin.
  • bee896bee896 Posts: 25
    edited 2010-10-13 02:02
    William, thanks a lot.
    Well I don't know what's the difference between a Boe-Bot and a Bot-Boost, so I can only assume it's 2 different bot but sharing some part of the coding which actually works.:)
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-13 02:32
    I am glad your Propeller robot is working now.

    Did you pass the new irDecode.spin to your lecturer?

    Are you using 4 batteries or 5 batteries for your Boe-Bot?
  • bee896bee896 Posts: 25
    edited 2010-10-13 05:59
    Not yet, I'll pass to him tomorrow since I don't have any classes today.
    It's a 4-battery Boe-Bot and very electric consuming
  • william chanwilliam chan Posts: 1,326
    edited 2010-10-13 06:16
    Ask your lecturer for the Boe-Boost so you can add one more battery to your robot.
    Then you can use rechargeable batteries.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-13 07:14
    The Boe-Boost is just a holder for another AA size cell that goes in series with the existing 4 x AA battery pack and fits nicely in place without cutting or splicing wires. It's designed so you can have 5 NiMH AA cells in series to get 6V Vin for the BoeBot instead of the 4.8V that you get with only 4 NiMH AA cells. You don't use the Boe-Boost with alkaline batteries since that would provide 7.5V which is ok for the BOE, but tends to shorten the lifetime of the servo motor brushes when they are powered directly from a Vin of 7.5V.
Sign In or Register to comment.