Shop OBEX P1 Docs P2 Docs Learn Events
still need some help BS1 and servo! - Page 2 — Parallax Forums

still need some help BS1 and servo!

2»

Comments

  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-08 18:08
    I only want servo2 to work when the button is pushed each time and also want the pot to be able to work As needed. Servo1 with the code I have works like I have it ....right on the money! So what should the servo2 use other than GOTO?
  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-08 18:15
    So you want to push the button and have servo2 move while at the same time adjust servo1 using the pot?

    Rich H
  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-08 18:28
    Try this:
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    
    
    SYMBOL  scale     = 85
    SYMBOL  Potpin    = 0
    SYMBOL  ServoPin1 = 1
    SYMBOL  ServoPin2 = 4
    SYMBOL  ThisLong  = 15        ' May have to reduce this for Servo2 to run smoothly
    SYMBOL  level     = B2
    SYMBOL  pulse     = B3
    SYMBOL  counter   = B4
    
    Main:
    
      IF PIN3 = 1 THEN Servo2
      GOSUB Servo1
      PAUSE 18
      GOTO Main
    
    Servo1:
    
      POT Potpin, scale, level
      pulse = level MIN 50 MAX 250
      PULSOUT ServoPin1, pulse
      RETURN
    
    Servo2:
    
      FOR counter = 1 TO 15
      PULSOUT ServoPin2, 100
      GOSUB Servo1
      PAUSE ThisLong
      NEXT
    
      FOR counter = 1 TO 30
      PULSOUT ServoPin2, 200
      GOSUB Servo1
      PAUSE ThisLong
      NEXT
    
      FOR counter = 1 TO 15
      PULSOUT ServoPin2, 150
      GOSUB Servo1                  ' leave servo centered
      PAUSE ThisLong
      NEXT
    
      GOTO Main
    
    


    Rich H

    Post Edited (W9GFO) : 6/8/2009 6:49:25 PM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-06-08 18:35
    I think that would work Rich, good job!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-08 20:06
    Hey Rich,
    I'll try this when I get home from work!
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-11 03:30
    Thanks to everybody here who has reply with help. All my servo are working. I have now started to install the TX and RX to the two BS1 boards. Board TX·BS1 has only the button and pot on it. Board RX BS1 has servo only connected to pin 1 and 4. Can anyone look at these two codes for the TX file ·and RX file to see if·I'm missing something?

    Thanks, Jim
  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-11 04:25
    studiomagic1 said...
    Thanks to everybody here who has reply with help. All my servo are working. I have now started to install the TX and RX to the two BS1 boards. Board TX BS1 has only the button and pot on it. Board RX BS1 has servo only connected to pin 1 and 4. Can anyone look at these two codes for the TX file and RX file to see if I'm missing something?


    Thanks, Jim

    Glad you got it working.

    First off, the only part of your code that will execute is that which is between "Start" and "GOTO Start".

    Next, I'm guessing you want to send the servo pulses, or rather the values of those pulses to the RX BS1. I'm not sure what the X and Y variables are for, they aren't used for anything. I see you want to debug them but it doesn't look like you are sending them. Your SEROUT command has a B5 but it is not used anywhere that I can see.

    How far apart are the two BS1s? I'm wondering if you wouldn't be better off just extending the servo signal wires. Or maybe you are using an RF module?

    I'll try to put something together that makes sense to me in a little bit.

    Rich H
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-11 04:37
    Hi Rich,

    I'm using the Parallax RF TX #27980 and RX #27981. The manual I download from thier site. It kind of gives you example code so I just copied the code which was added to my code. I'm trying to control a puppets mouth and eyes via remote. I'm using two BS1's. The TX board has the pot on pin0, servo1 on pin1, push button on pin3, and servo2 on pin4. If you go download the PDF's on the TX and RX it may help you understand it better than me.
  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-11 05:00
    Ok this might be close. I haven't looked at the TX/RX manual yet so I don't know about that part of the code. I see on Servo2 you have changed the FOR counter = 1 to 15 to "10 to 10" and also made the pause longer. What exactly do you want the servo to do when the button is pushed? Is it for the mouth? If so then you probably only need two of those For counter... routines instead of three.

    Guessing, the SERIN command may take long enough so that no PAUSE statements are needed. I'll go take a look at those manuals now.

    Rich H

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    
    SYMBOL  scale     = 95      ' Pot
    SYMBOL  Potpin    = 0
    
    SYMBOL  ServoV1   = B1      ' Servo Value
    SYMBOL  ServoV2   = B2
    
    SYMBOL  Potlevel  = B3
    SYMBOL  counter   = B4
    
    Init:
    
      ServoV2 = 50                         ' Initialize ServoV2 so that the TX has a good value to send
      GOTO Main
    
    Main:
    
      IF PIN3 = 1 THEN Servo2
      GOSUB Servo1
      GOTO Main
    
    Send:
    
      PULSOUT 2, 300                         ' Sync pulse for receiver
      SEROUT 2, N2400, ("!", B1, B2)         ' Send ServoV1 & ServoV2 at 2400 baud, inverted
      RETURN
    
    Servo1:
    
      POT Potpin, scale, Potlevel
      ServoV1 = Potlevel MIN 40 MAX 250
      GOSUB Send  
      RETURN
    
    Servo2:
    
      FOR counter = 1 TO 100               ' The "100" is so that the servo will reach the set-point and stay there a bit
      ServoV2 = 200                        ' before moving back. Play with the set-point until you are happy with the 
      GOSUB Servo1                         ' amount of travel then decrease the "100" until the servo doesn't wait before
      NEXT                                 ' going back - unless you want it to of course. Should be the same value for both of 
                                           ' the "FOR counter.." loops.
      FOR counter = 1 TO 100
      ServoV2 = 50
      GOSUB Servo1    
      NEXT
    
      GOTO Main
    
    




    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    
    
    SYMBOL  ServoPin1 = 1
    SYMBOL  ServoPin2 = 4
    
    SYMBOL  ServoV1   = B1       
    SYMBOL  ServoV2   = B2
    
    
    Main:
    
      SERIN 2, N2400, ("!"), B1, B2
    
      PULSOUT ServoPin1, ServoV1
      PULSOUT ServoPin2, ServoV2
    ' Add PAUSE here if needed.
      GOTO Main
    
    
    

    Post Edited (W9GFO) : 6/11/2009 5:46:06 AM GMT
  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-11 05:39
    Ok I read it, a little bit anyway. I think it'll work.

    If I am correct about the button controlling the mouth, would it be better if the mouth stays open for as long as the button is held?

    Rich H
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-11 05:57
    Rich I.m going to try this in the morning before I go to work.

    Thanks, Jim
  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-06-11 19:46
    Jim-
    Not to dissuade you from seeking the advice of those who perhaps know more than you, but have you tried the your code to see if it works? Experimentation (as I'm learning myself) is a good teacher.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-12 15:04
    Rich I sent you a PM.
  • studiomagic1studiomagic1 Posts: 25
    edited 2009-06-13 23:48

    Hi Rich,

    I'm a cable tech and we have had one storm after another this past week. I worked very late every night last week trying to restore internet and phone service to our customers where I live. I just got the chance today (Saturday) to load the code you were helping me with on the TX and RX. It couldn't have worked any better!!!! I did go in to servo2 and change the numbers to fit my needs.

    I want to personally thank you for the amount of time you have spent working me through the BS1 project. Not only did you have to work on my very bad code you also had to teach me as well! I also wish to thank everyone else who gave their input on my project from this forum.

    I just signed up on the forum about two weeks back. At first I thought the forum was for people who already had good knowledge and understanding on the BS produces. Joshua @ tech support at Parallax·told me to posted my questions and someone would help.·So I created a thread and got some replies. At first I got discouraged because a few post ask me to read links I had already did but still didn't understand. I had no training or teaching to fall back on. I wished we had this stuff when I was younger in school. Please forgive me if I've been more trouble than most.



    Sincerely,

    Jimlol.gif

  • W9GFOW9GFO Posts: 4,010
    edited 2009-06-14 03:29
    studiomagic1 said...
    At first I got discouraged because a few post ask me to read links I had already did but still didn't understand. I had no training or teaching to fall back on. I wished we had this stuff when I was younger in school. Please forgive me if I've been more trouble than most.

    I'm just a little surprised that it worked - good deal! It was a fun problem to figure out, especially since I've never used a BS1.

    Chip graduated the same year as I did so it wasn't quite possible to have this stuff when I was in school. I'm sure my life would have taken a different path if we had BOE-Bots back then. I also have no background in micro-controllers. I messed with PICs a little but settled in with Parallax due to their excellent documentation that is freely available and geared toward those that are just starting out. It was unexpected then that the info on the BS1 wasn't easier to find. I found no BS1 manual, the info is mixed in with the BS2 stuff. The best resource (for me) was the Basic Stamp editor's help file, I finally downloaded the Basic Stamp editor and ran it in a virtual machine - I'm on a Mac. Thanks to you Jim, I now have a better understanding of the BS1.

    Rich H
Sign In or Register to comment.