Shop OBEX P1 Docs P2 Docs Learn Events
a lot of questions — Parallax Forums

a lot of questions

johnprokojohnproko Posts: 121
edited 2014-02-17 01:32 in BASIC Stamp
hello all, again. i have two simple questions still i cant manage to solve them.
first question is about servos. can i, using bs2, take from a servo a signal? what im trying to say is: using pulsout i can move a servo. can i use pulsin or some else command in order to get a signal from the servo and understand its position?
second i have a force button and some tact switches. for the force button i cant find how to program it. i have seen some examples in the forum but the dont work. probably it is the connectivity wrong. as for the tact switches i have the same problem. wiring one leg to pin, one to power and one to ground, does it need a resistor? i cant figure it out!

thank you all in advance :-)

Comments

  • piguy101piguy101 Posts: 248
    edited 2014-02-16 07:58
    As far as I know, it is impossible to get the position from the servo; you can only move it to positions, not read where it is at.
  • johnprokojohnproko Posts: 121
    edited 2014-02-16 08:29
    worth the question though. any ideas about the force button bs2 code or the tacts? thank you
  • johnprokojohnproko Posts: 121
    edited 2014-02-16 08:32
    another question that came up is has anyone tried to make a speedometer using bs2? thank you
  • johnprokojohnproko Posts: 121
    edited 2014-02-16 08:36
    how can i monitor the remaining battery? in propeller i know it can be done but in bs2?
  • piguy101piguy101 Posts: 248
    edited 2014-02-16 08:38
    I have never made a speedometer, but here is what I would do. I would attach a magnet to a wheel and a reed switch on the body of the vehicle to count the revolutions of the wheel. I would convert revolutions per second into speed and then to angle of the servo. I would then use a servopal http://parallax.com/product/28824 to control the servo position, so the BS2 would not be bogged down doing so many tasks.
  • GenetixGenetix Posts: 1,754
    edited 2014-02-16 09:43
    You should add 'BS2' to your thread title.

    R/C servos are not very precise but you can get close to the position you want if you vary the pulse width.

    You need a pull-down resistor if you want the switch to be active-high (down = 1) or a pull-up resistor if you want the switch to be active-low (down = 0). The resistor is usually 10K and it's a good idea to also place a 220-ohm resistor in series with the I/O pin to protect it.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-02-16 10:11
    One of the great things about the BS2 is the book "What's a Microcontroller?" I'm pretty sure it's available for free as a pdf (It is. Look under "Downloads" on the link I just posted). Another great thing about the BS2 is erco. He has done a lot of the work for you in figuring out how to use the BS2 in different ways.

    One frequently used method to measure the speed of a wheel is to use a quadrature encoder (or single channel encoder). Here are a few links on the topic.

    Reading Quadrature Encoders (Make sure and watch the videos linked to in post #25)
    Make Your Own Quadrature Encoders (Apparently real men make their own.)
    Sensors Used to Make Quadrature Encoders (Check out post #77 to see an encoder added to the inside of a servo.)

    I took the encoder inside a servo a step further and made a small PCB so I could mount a quadrature encoder inside the servo (post #13).
  • PublisonPublison Posts: 12,366
    edited 2014-02-16 10:15
    Moving to Basic Stamp Forum as it seems more appropriate there.
  • Mike GreenMike Green Posts: 23,101
    edited 2014-02-16 10:33
    There is some information here (http://www.emesystems.com) on using the RCTIME statement and a few passive parts to read battery voltage (and other voltages). Click on the "app-notes" link.

    One of the members here (JonnyMac?) posted a discussion on measuring approximate servo position by "starving" the servo of power to move, providing just enough to power the electronics, then measuring the current draw (by putting a resistor in series with the power lead and measuring the voltage across the resistor or the servo). When the control pulse is the proper width for the servo position, the current drawn will be at a minimum since the electronics is not trying to move the servo. You send a series of servo pulses and see which width causes the least current draw. You then send another series of pulses closer together centered at the position you've found and refine your detected position.
  • PublisonPublison Posts: 12,366
    edited 2014-02-16 10:40
    Mike Green wrote: »
    There is some information here (http://www.emesystems.com) on using the RCTIME statement and a few passive parts to read battery voltage (and other voltages). Click on the "app-notes" link.

    One of the members here (JonnyMac?) posted a discussion on measuring approximate servo position by "starving" the servo of power to move, providing just enough to power the electronics, then measuring the current draw (by putting a resistor in series with the power lead and measuring the voltage across the resistor or the servo). When the control pulse is the proper width for the servo position, the current drawn will be at a minimum since the electronics is not trying to move the servo. You send a series of servo pulses and see which width causes the least current draw. You then send another series of pulses closer together centered at the position you've found and refine your detected position.

    Is this the one Mike?

    http://forums.parallax.com/showthread.php/84991-Propeller-Application-Proportional-feedback-from-a-Standard-Hobby-Servo-(Upda?highlight=Servo

    I
    t was Beau.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2014-02-16 10:42
    Publison,

    That's it .... the method describe using a Propeller, but just about any micro (even the BS2) could be applicable here using the same method.
  • dgatelydgately Posts: 1,631
    edited 2014-02-16 10:55
    There was this modification for getting feedback from servos...

    http://forums.parallax.com/showthread.php/138101-Feedback-Servo


    dgately
  • FranklinFranklin Posts: 4,747
    edited 2014-02-16 23:08
    Also these from Adafruit. http://www.adafruit.com/products/1404
  • trookstrooks Posts: 228
    edited 2014-02-17 01:32
    The BS2 is a mighty good mule. All it takes to get more work out of it is to add the detectors/sensors for whatever you want done and give it the right instructions. By the time I get through adding stuff to my BS2 I will likely have to put a wagon behind it to hold extra batteries.

    One way to always know the position of the wheels will involve adding a simple circular disk to the inside of both wheels. There should be some system of timing marks around the outside edge of the disk. Then you add two LEDs and two photo resistors to read the marks on each wheel. It depends on the sensitivity of your sensor as to how much accuracy you can get. With the addition of a little bit of 'off board' logic hardware you could build a differential accumulator and hold the output until your mule needs it.

    Making an add-on for my BS2 'to do' just that is on page three on my list of things 'to do'. I am presently in the middle of a project with a friend to put together a system that has the potential of producing money. We are both buoyed by the knowledge of how much fun we will have giving demonstrations.
Sign In or Register to comment.