Shop OBEX P1 Docs P2 Docs Learn Events
Upgrating my Boe-Bot to propeller — Parallax Forums

Upgrating my Boe-Bot to propeller

jvrproductionsjvrproductions Posts: 61
edited 2012-01-23 17:11 in Propeller 1
Hello all thanks for reading and sorry for my english.... I am upgrating my boe-bot with a propeller quickstart... what its happening is that i created a 5 volt regulator to connect all the servos, lcd, etc (it's not connected to the quickstart) and went the program start the ping work perfect for about 5 sec and after that just go down (off no reading). I notice that if i conect the 5 volt - from my volt regulator to the - on the quickstart the ping work perfect but if there are not - conection just work for about 5 sec. Why this happen?
Thanks.
Jose

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-13 06:30
    Jose,

    I like your idea of using a QuickStart on your Boe-Bot.

    You mentioned you have a 5 Volt regulator. You want to make sure the grounds of all electrical systems are connected (it usually best it there is just on point where the grounds are connected).

    How are you powering your QuickStart board when you have this problem? You should be able to use 5V from your regulator and connect it to the QuickStart's Vin pin (pin "40") and power the QS with 5V.

    You want to use a resistor between the Ping's signal line and the QuickStart. I usually use a 10K Ohm resistor but 3.3K Ohm would also work. The 5V signal from the Ping can damage the Propeller without a resistor.

    If you are still having trouble, a sketch (or a photograph) of your setup would help us figure out your problem.
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-14 12:54
    thanks Duane.... i was using the 5 volts power supply for the servos, ping and lcd and the usb to power the board. i connect the 5 volts on pings 40 and 39and its working perfect thanks for your help....
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-15 07:39
    New problem..... Please help me.

    1- I am using one 7805 +5 Volt regulator. The regulator its rate to up to 1 Amp. it's conected to one 12 VDC 500mA. So far if i provide power to the 4 line parallax lcd, one ping and one servo for the ping (+ plus the quickstart) all work fine. but if i start using the two servos for the tires the regulator start heating a lot. It's normal?

    2- i am using the "Servo32v7.spin" object. I want two be available to control the object from two diferent PUB's one pub its working on the ping and the servo for the ping (One cog) and the second Pub at this point it's just running the 2 tire servos. The problem is that went i start using the tires, the ping servo work different (Stop and go). I was thinking that its a power problem but if i put the tires code on the same put that the ping servo work all work fine

    sensor code:
    PUB servos        
    
        SERVO.Start
        SERVO.Set(ServoCh1,1350)
        posicion := 1350  ''Center ping sensor
        
        WaitCnt(ClkFreq * 1 + Cnt)
    
    
    
    
        
        repeat
    
    
           if range > limite
    
    
    
    
           
              repeat posicion from posicion to derecha
                                    SERVO.Set(ServoCh1, posicion)
                                    WaitCnt(ClkFreq / 2000 + Cnt)
    
    
              repeat posicion from posicion to izquierda
                                    SERVO.Set(ServoCh1, posicion)
                                    WaitCnt(ClkFreq / 2000 + Cnt)
    
    
    
    
    

    testing tire servos
    PUB motores 
    
      repeat
    
    
         if range > 30 
            SERVO.Set(ruedader, 1000)  
            SERVO.Set(ruedaizq, 2000)
    

    thanks for any help
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-15 08:34
    New problem..... Please help me.

    1- I am using one 7805 +5 Volt regulator. The regulator its rate to up to 1 Amp. it's conected to one 12 VDC 500mA. So far if i provide power to the 4 line parallax lcd, one ping and one servo for the ping (+ plus the quickstart) all work fine. but if i start using the two servos for the tires the regulator start heating a lot. It's normal?

    The "1 Amp" rating of the regulator means it can supply 1 Amp but only if you can get rid of the heat. I believe a 7805 just dumps the power from the voltage drop (about 7V in this case) as heat. So if you're using 500ma of current, the regulator needs to get rid of 3.5 Watts of heat.

    You have a few options to fix the problem. One option is to use a better heat sink (maybe even a fan). Another option (better) is to use a lower voltage source. Six NiMH AA batteries would give about 7.2 Volts lowering the power given off as heat to 1.1 Watts. Another (best) would be to use a more efficeint regulator. Switching regulator don't don't just dump the extra voltage as heat but they cost more. I've used these in a bunch of my projects. The main problem I've had from the switching regultors is radio interference.
    The problem is that went i start using the tires, the ping servo work different (Stop and go). I was thinking that its a power problem but if i put the tires code on the same put that the ping servo work all work fine

    My first guess is the servos are drawing too much current as they start to move and might be resetting the Prop (this happens to me a lot). One thing I've done when using servos with my QuickStart board was to add a 1000uF capacitor across Vin and Vss. This has helped me a lot.

    In general servos need to be refreshed 50 times a second. I don't know if it would help much, but I'm adding a few lines to your code. It should at least save a little bit of power since the Prop can put some of its cogs in a low power state (but only for very short periods of time).

    Add three global variables.
    [COLOR=#ff0000]VAR
      long pingTime, wheelTime, servoInterval[/COLOR]
    

    PUB servos        
    
        [COLOR=#ff0000]servoInterval[/COLOR] [COLOR=#ff0000]:= clkfreq / 50
    [/COLOR] SERVO.Start
        SERVO.Set(ServoCh1,1350)
        posicion := 1350  ''Center ping sensor
        
        WaitCnt(ClkFreq * 1 + Cnt)
    
    
    
    
        
            repeat
    
    
           if range > limite
    
    
    
    
           
              [COLOR=#ff0000]pingTime := cnt
    [/COLOR]       repeat posicion from posicion to derecha
                                    SERVO.Set(ServoCh1, posicion)
                                    WaitCnt([COLOR=#ff0000]pingTime += servoInterval[/COLOR])
    
    
              [COLOR=#ff0000]pingTime := cnt
    [/COLOR]       repeat posicion from posicion to izquierda
                                    SERVO.Set(ServoCh1, posicion)
                                    WaitCnt([COLOR=#ff0000]pingTime += servoInterval[/COLOR])
    
    
    
    
    

    I'm doing the same thing with the wheel servos.
    PUB motores 
    
      [COLOR=#ff0000]wheelTime := cnt
    [/COLOR]repeat
    
    
         [COLOR=#ff0000]waitcnt(wheelTime += servoInterval)
    [/COLOR]  if range > 30 
            SERVO.Set(ruedader, 1000)  
            SERVO.Set(ruedaizq, 2000)
    

    I'm not sure if Servo32v7 would update the servos more than 50 times a second without the waits or not but I personally think it's a good idea to only update the servo positions at 50Hz.

    The above wait examples are covered on page 220 of the Prop Manual v1.2.

    If you're not sure a loop will be less than 20ms (1/50 s) you could do this.
    PUB motores 
    
      [COLOR=#ff0000]wheelTime := cnt
    [/COLOR]repeat
    
    
         [COLOR=#ff0000]if cnt - wheelTime < servoInterval
    [/COLOR]    [COLOR=#ff0000]wheelTime += servoInterval[/COLOR]
           if range > 30 
              SERVO.Set(ruedader, 1000)  
              SERVO.Set(ruedaizq, 2000)
    
        [COLOR=#ff0000] ' do other stuff in loop that might take longer than "servoInterval"
    
    [/COLOR]
    

    If you're still having trouble with your program, it would really help if you posted the entire program. Don't worry about changing variable names to English.

    You can use the "archive" feature under the "file" menu to include all the objects in your program.

    (Something strange is happening with the forum software, it wont let me fix the small formatting errors.)
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-15 17:46
    Thanks again Duane... :smile:
    this it's my robot so far.....
    IMAG0332.jpg
    1024 x 575 - 90K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-15 20:41
    That's a great robot! I really like it.

    I have a Boe-Bot chassis that's not doing anything. I think I'll add a QuickStart board to it. I really like this idea.

    Thanks for posting the picture.
  • RaymanRayman Posts: 14,665
    edited 2012-01-16 05:21
    Our new Merlin board makes it easy to upgrade your BoeBot to Quickstart.
    Check out this pic:
    Merlin_BoeBot.jpg


    It has a jack for the battery power cable, a 5V regulator, and servo headers...
    Merlin just plugs into the Quickstart, no soldering required...
    1024 x 768 - 136K
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-16 05:48
    the merlin look verry nice but i was unable to finded on your site for price, etc
  • RaymanRayman Posts: 14,665
    edited 2012-01-16 06:29
    I hope to have it ready to sell this Friday...
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-18 17:31
    New question.... i create a var named Nun. part of the code supposed to run only if nun it's == 0. for some reason the code still running after 0 its changed to 1,2,3,etc. some one may please check my code and tell whats wrong please? THANKS
    if  nun == 0
        repeat
    
    
            if (alarmposicion < 2150) and (alarmposicion > 1950)
               outa[16..23]:= %00000001
               nun := 1
    
    
      
            if (alarmposicion < 1950) and (alarmposicion > 1750)
                outa[16..23]:= %00000010
                nun := 2
    
    
    
    
                
            if (alarmposicion < 1750) and (alarmposicion > 1550)
               outa[16..23]:= %00000100
               nun := 3
    
    
    
    
                   
            if (alarmposicion < 1550) and (alarmposicion > 1350)
               outa[16..23]:= %00001000
               nun := 4
     
    
    
                   
            if (alarmposicion < 1350) and (alarmposicion > 1150)
               outa[16..23]:= %00010000
               nun := 5         
    
    
    
    
               
            if (alarmposicion < 1150) and (alarmposicion > 950)
               outa[16..23]:= %00100000
               nun := 6
    
    
    
    
                   
            if (alarmposicion < 950) and (alarmposicion > 750)
               outa[16..23]:= %01000000
               nun := 7
    
    
    
    
                   
            if (alarmposicion < 750) and (alarmposicion > 500)
               outa[16..23]:= %10000000   
               nun := 8
             
    
  • ratronicratronic Posts: 1,451
    edited 2012-01-18 17:55
    To get out of the repeat statement put this within it
    if nun <> 0
      quit
    
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-18 18:13
    thanks
    ratronic
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-19 19:01
    More help .... :-) It's almost done......

    i create the following code to set-up the limit for the ping with the qs button but some times work and others do not work.. I thinks it's my code..
    repeat         outa[19..21]:= %111
    
    
             
            if ina[3] == 1
              LCD.cls
              quit 
    
    
            
            elseif ina[4] == 1 
              limite := limite - 1
              LCD.gotoxy(16, 3)                                        
              LCD.dec(limite)
              WaitCnt(ClkFreq / 500 + Cnt)
              
            elseif ina[5] == 1 
              limite := limite + 1
              LCD.gotoxy(16, 3)                                        
              LCD.dec(limite)
              WaitCnt(ClkFreq / 500 + Cnt)
              
           WaitCnt(ClkFreq / 500 + Cnt)
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-19 19:09
    The QuickStart's touchpads don't work like normal buttons. You need some extra code to more reliably read if the pads have been touched.

    I've tried to gather some of the programs for the QuickStart board in this thread.

    I also have a servo tester program that uses the touchpads as inputs.

    Some programs that seem to read the touchpads reliably for one person don't always work for another person. I think the climate and one's skin moisture can affect how well the pads will respond to being touched.
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-19 19:12
    Duane Degn wrote: »
    The QuickStart's touchpads don't work like normal buttons. You need some extra code to more reliably read if the pads have been touched.

    I've tried to gather some of the programs for the QuickStart board in this thread.

    I also have a servo tester program that uses the touchpads as inputs.

    Some programs that seem to read the touchpads reliably for one person don't always work for another person. I think the climate and one's skin moisture can affect how well the pads will respond to being touched.

    uhhh thanks Duane i will check your thread and try otherwise i will try with push button.....
    Thanks.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2020-04-26 16:52
    Was Post # 15.

    Edit(4/26/20): Addington made a demo program using these techniques. The demo is a good place to start using touch pads.


    In the servo tester program, I use the object "TouchButtons111029a" to sense when a pad had been touched.

    To use this object you need a long and array of eight bytes in your variable section.
    VAR
    
      long delay
      byte button[8]
    

    You also need the object listed in the OBJ section.
    OBJ
    
      Buttons : "TouchButtons111029a"
    

    Near the beginning of your program you'll need to define "delay" and start the Buttons method.
    delay := clkfreq / 100
      Buttons.Start(@delay, @button)
    

    Once these sections of code have been added, you can test if a button has been pressed like this (assuming you want to check if pad #0 has been touched):
    if button[0] == 1
        ' do something when pad 0 has been touched
    

    If the pad isn't being touched it will equal 0.

    You can always write a small test program to make sure the pads are being read correctly.

    I just found a small example program I had previously written that uses the QS's touchpads to select portions of code to run. It's attached to post #4 here. It uses the same touchpad object as the servo tester program.
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-19 19:56
    Duane Degn wrote: »
    In the servo tester program, I use the object "TouchButtons111029a" to sense when a pad had been touched.

    To use this object you need a long and array of eight bytes in your variable section.

    ......

    Duane i was starting to put my push button. I did try your first post and did work perfect (Your demo) but i did not understand the code. Now with your new explanation it's working perfect.

    will be alive soon... (I hope)....
    Thanks
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-19 20:19
    Now with your new explanation it's working perfect.

    Very good. I'm glad it's working.
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-19 20:25
    It's alive.......
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-20 20:47
    Yesterday my Propeller robot was alive but only for 10 min. After see the robot just going and going i decide to try to program the propeller to do several programs..... now went as you reset the QS the lcd ask for what program you want to run. The 1st one its just try to avoid walls... the second one (Where i am working) its search for the nears object. So i create an array with 66 "slots" the servo go from a to b and the ping work perfect. the array have the 66 different distances from the ping. But i dont have any clue about how to compare and on what "slot is the smaller number... some one may please point me to an array tutorial? and how to compare? (Like always sorry for my english :-))
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-20 20:59
    Jose,

    I really liked your video. Super cool! Thanks for posting it.

    It looks like the QuickStart's touchpads are working okay for you. Good.

    I don't have time tonight to help with your array question but I'll ask a couple of questions for clarification.

    Do you want to find the smallest number in an array of 66 elements ("slots")? If so, this wont be hard. If someone hasn't helped you by tomorrow, I'll help with some suggestions.

    You might want to look at the modification I made to the Scribbler 2. I had it look for the farthest distances. The program might to too complicated to find where this comparison happens though.

    It looks like you doing great so far.

    Don't worry about your English. I'm sure it's better than my Spanish.

    Adios,
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-20 21:14
    Thanks Duane... The pad its working perfect after follow your recommendations.... :-)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-21 01:46
    Here's an example of looking for the smallest element in an array.

    I called the program "arraySearch.spin". I pre-loaded the array by using the DAT section.

    The program waits three seconds to give you a chance to open a terminal window. The program then waits for a key press from the terminal window before continuing.

    I highlighted in red the main logic parts of the code. Most of the code is just to display the data.
    CON
      _clkmode=xtal1+pll16x
      _xinfreq=5_000_000
      
      _ArraySize = 10
    VAR
      'long range[_ArraySize]  ' Use this if filling array a runtime.
    
    OBJ
      Pst: "Parallax Serial Terminal"
      
    PUB Main | localIndex, shortestRange
      
      Pst.Start(57600)
      waitcnt(clkfreq * 3 + cnt) ' Three seconds to opent terminal window.
      Pst.Str(string(13, "Press any key to start."))
      Pst.CharIn
      Pst.Str(string(13, "Stored Ranges = "))
      repeat localIndex from 0 to _ArraySize - 2
        Pst.Dec(range[localIndex])
        Pst.Char(",")
        Pst.Char(" ")
      Pst.Dec(range[_ArraySize - 1])
      Pst.Str(string(13, "Finding shortest range."))
      [COLOR=#ff0000]shortestRange := range[0]
    [/COLOR]  Pst.Str(string(13, "shortest range so far = "))
      Pst.Dec(shortestRange)
      [COLOR=#ff0000]repeat localIndex from 1 to _ArraySize - 1
        if range[localIndex] < shortestRange
          shortestRange := range[localIndex]
    [/COLOR]      Pst.Str(string(13, "shortest range so far = ")) 
          Pst.Dec(shortestRange)
      Pst.Str(string(13, 13, "shortest range  = "))
      Pst.Dec(shortestRange)
      Pst.Str(string(13, 13, "Program Over"))
      repeat ' keep program alive so the terminal window doesn't clear.
          
    DAT
    range         long 250, 300, 310, 290, 245, 246, 300, 305, 312, 313
    

    Here's the output fro the above program.
    Press any key to start.
    Stored Ranges = 250, 300, 310, 290, 245, 246, 300, 305, 312, 313
    Finding shortest range.
    shortest range so far = 250
    shortest range so far = 245
    
    shortest range  = 245
    
    Program Over
    

    This next version uses a generic search method. This program is named "arraySearchBetter.spin". It has the same waits as the first program.

    CON
      _clkmode=xtal1+pll16x
      _xinfreq=5_000_000
      
      _ArraySize = 10
    VAR
      'long range[_ArraySize]  ' Use this if filling array a runtime.
    
    OBJ
      Pst: "Parallax Serial Terminal"
      
    PUB Main | localIndex, shortestRange
      
      Pst.Start(57600)
      waitcnt(clkfreq * 3 + cnt) ' Three seconds to opent terminal window.
      Pst.Str(string(13, "Press any key to start."))
      Pst.CharIn
      Pst.Str(string(13, "Stored Ranges = "))
      repeat localIndex from 0 to _ArraySize - 2
        Pst.Dec(range[localIndex])
        Pst.Char(",")
        Pst.Char(" ")
      Pst.Dec(range[_ArraySize - 1])
      shortestRange := FindLeastElement(@range, _ArraySize)
      Pst.Str(string(13, 13, "shortest range  = "))
      Pst.Dec(shortestRange)
      Pst.Str(string(13, 13, "Program Over"))
      repeat ' keep program alive so the terminal window doesn't clear.
      
    PUB FindLeastElement(localPointer, localSize) : smallestElement | localIndex  
      
      Pst.Str(string(13, "Finding smallest element of a "))
      Pst.Dec(localSize)
      Pst.Str(string(" element array."))
      smallestElement := long[localPointer]
      Pst.Str(string(13, "smallest element so far = "))
      Pst.Dec(smallestElement)
      if localSize =< 1
        return
      repeat localIndex from 1 to localSize - 1
        if range[localIndex] < smallestElement
          smallestElement := long[localPointer + (4 * localIndex)]
          Pst.Str(string(13, "smallest element so far = ")) 
          Pst.Dec(smallestElement)
      
          
    DAT
    range         long 250, 300, 310, 290, 245, 246, 300, 305, 312, 313
    

    And here's the output.
    Press any key to start.
    Stored Ranges = 250, 300, 310, 290, 245, 246, 300, 305, 312, 313
    Finding smallest element of a 10 element array.
    smallest element so far = 250
    smallest element so far = 245
    
    shortest range  = 245
    
    Program Over
    

    It shouldn't be hard to change the size of the array to 66 elements. You'll also need to fill the array with data from the Ping sensor.

    If you want to search for the largest element, I'd suggest changing these parts. (Assuming all numbers are positive.)

    Instead of:
    shortestRange := range[0]
    

    Use:
    longestRange := 0
    

    Then start the comparisons one element earlier.

    Instead of:
    repeat localIndex from 1 to _ArraySize - 1
    

    Use:
    repeat localIndex from 0 to _ArraySize - 1
    
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-22 06:13
    Thanks Duane. The part of the code i used and changed was
    repeat localIndex from 0 to 66                    if mide[localIndex] < shortestRange
                             shortestRange := mide[localIndex]
                             alarmposition := 550 + (localIndex * 20)
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-22 11:18
    Jose,

    How many elements are in the array "mide"? Do you have this in your variable section?
    [B]VAR
    [/B][B]long [/B]mide[66]
    

    I don't know if you need longs or not. Words might be okay.

    If you have 66 elements you want your repeat loop to end with 65.

    Since you're looking for the smallest element, you need to set "shortestRange" to a number you know isn't smaller than the smallest element.
    You could either set it equal to a large number or, as I did, just set it equal to the first element of he array.

    What if shortestRange equalled zero before starting the loop and none of the elements equaled zero? You'd end up with shortestRange still equalling zero at the end of the loop (which wouldn't give you the correct answer).
    shortestRange := mide[0] 
      [B]repeat[/B] localIndex[B] from [/B][COLOR=#ff0000]1[/COLOR] [B]to[/B] [COLOR=#ff0000]65
    [/COLOR][B]    if[/B] mide[localIndex] < shortestRange
          shortestRange := mide[localIndex]
    

    Since we start counting with zero instead of one, the last element of 66 elements is element 65.

    When I first started programming, I thought it was a dumb idea to start counting with zero. After I had been programming for a while, I learned that it was a good idea and made math using memory locations a lot easier.
  • jvrproductionsjvrproductions Posts: 61
    edited 2012-01-23 09:37
    ohhh. Now i understood why your code at the end have -1..... I will do the change tonight.. i will also change the longs to word i try to use long at the beginning to avoid problems ( I understood it's using more memory but because the program its small i always check how the memory is....)
    Now what i don't understood at all is how to know how much stack i need to assign to each new cog. I know that it's base on how big its that part of the program but are there any way to check how much memory one cog it's using?
    Thanks..
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-23 09:59
    I doubt you need to worry about memory space yet.

    I usually stick with longs unless there's a good reason to use a word or a byte.

    I think there are some operations that only work correctly with longs (such as bit rotation).

    There is an object call "Stack Length" in the Propeller Tool's library folder. It's used to see how much stack space the cogs are using. Honestly, I've never used it. I usually use 100 long if I think there's a lot going on in a cog or 32 longs if the cog is running a simple method.

    Most of my projects don't come close to using all of the Prop's RAM so I just leave the stack larger than I think it needs to be.
  • jazzedjazzed Posts: 11,803
    edited 2012-01-23 17:11
    I am inspired by this thread and have started working on a similar QuickBot. Thanks.
Sign In or Register to comment.