Shop OBEX P1 Docs P2 Docs Learn Events
Real Time control of multiple servos... — Parallax Forums

Real Time control of multiple servos...

JaxJax Posts: 10
edited 2008-10-11 19:50 in Robotics
Wow I haven't been here in ages! I gotta catch up on some of the current projects going on. Now I have a question about controlling multiple servos in real time using a Parallax Servo Controller. I saw the price and read the features and like what I see. But can it handle real time controlling of multiple servos from multiple signals?

The controller in question is this one:
http://www.robotstore.com/store/product.asp?pid=676&catid=1563

Basically I am constructing a number of sensors. Each sensor controls a servo. The idea is that if you move your hand near a sensor, the servo that is linked to the sensor will move according to how close your hand is. The faster or slower you move your hand, the faster or slower the servo moves! I have already made a circuit that does the job. The problem is if I put all those circuits together, it would make a rather big circuit board! It is a neat concept. I just want to be able to do it on a single chip. Now I can't code for the life of me. So the easier it is to make a program that works the better. If this board is not what I should be using, any ideas as to what will work? Keep in mind that I will need to have the board linked directly to the sensors and not a PC. I don't want to have to haul a PC tower and monitor around just to use it.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-30 17:13
    How do you propose to link the sensors to the servos?

    This board is made to connect to either a PC (via USB) or to some kind of microcontroller (like a Stamp via a logic level serial port). It responds to short commands sent in serial form that tell it to position a particular servo to a position given in the command. It's not programmable. Its control program is fixed.

    So, how many sensors do you have? What kind of outputs do they have? You're going to need to do some kind of programming to manage the sensors and transmit commands to the Parallax Servo Controller. If you have 8 or fewer servos and the sensors are easy to handle, you may be able to dispense with the Servo Controller entirely and control everything with a Stamp.
  • SRLMSRLM Posts: 5,045
    edited 2008-09-30 19:48
    The speed relation ship would probably be difficult to handle, a least with the BS2 (a little less so for the Propeller). How are you planing on doing the time-position relationship? To make a true relationship, you'll need some sort of function as a baseline, and then be able to calculate the function given by your hand in motion. Then you'll need to find a scale to fit the difference into the servo system. Of course, you could break the speed relationship into sections (fast, medium, and slow, for example) and simply choose one based on the speed. However, this would create a step in the speeds, and it might be noticable in the final product.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2008-10-01 00:44
    My question is, whats real time?. Are your sensors Ultrasonic, or some other type of sensor that will require some sort of milli-second delays. The performance of the Parallax servo controller with a Stamp or SX decays, when you start adding PAUSE·statements in your code.
  • JaxJax Posts: 10
    edited 2008-10-01 03:55
    As soon as something happens to one of the processors inputs, the processor instantly responds without delay. Hence it is "real time". Real time is useful if you need the processor to provide constantly updated information on a continuously varying flow of incoming information. The processor is constantly updating in "real time" so there isn't much delay from what goes into it.

    The sensors in question are light sensors. Otherwise knows as photoresistors. The circuit I made takes a timer circuit and uses the input from the light sensor to adjust the servo position. The idea is that if I position the light sensors in such a way, moving your hand over a spot on the floor will cause the leaves on a rigged plant to move out of your way. So moving your hand close to the plant will start to obstruct 1 sensor and the first leaf will move out of the way. Then the second and third servo will begin doing the same thing as you move closer and block more of the light hitting the sensors. Eventually all the sensors to the right and left of you will be blocked and all of the servos will pull all the leaves out of the way so you can go through. If you are wondering why I want to use multiple servos instead of just 2 beefy ones, it is because it will seem more alive with each leaf acting on its own. The planned number of servos is about 10 to 12.

    As for linking that many sensors to the servo controller... I would like to use some kind of a logic device that samples each light sensor and transmits the data to the controller itself. I'm thinking a multiplexer or some other device that can stream data through a usb port. Then the only thing I would have to do is configure the controller to update the servos based on this continuous stream of data. Does that make more sense?

    Jax
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-01 04:56
    1) Don't plan on using a USB port unless you want to use a computer. USB is very complex.

    2) There are a variety of ways to measure the resistance of photoresistors. You can use them to control a timer. You can use them to produce a variable voltage that you can measure with an analog to digital converter, some of which have as many as 8 inputs or more. You can use them to charge or discharge a capacitor and measure the time it takes. This last technique is similar to the use of a timer, but doesn't need the timer.

    3) You could certainly use something like a Stamp to measure the resistance of the photoresistors. One of the faster stamps (like the BS2px) could do the job using the RCTIME statement. You'd need a small capacitor and one I/O pin for each photoresistor. One I/O pin could transmit control information (servo position for each servo) to a Parallax Servo Controller using a logic level serial connection (not USB). There would be small delays since it takes some time to charge or discharge the capacitor through the photoresistor and to transmit new position information for the corresponding servo. Since there are 10-12 sensor/servo pairs, it would take 10-12 times the basic cycle to process all the sensor/servo pairs.
  • JaxJax Posts: 10
    edited 2008-10-01 05:30
    Thanks Mike! Didn't know that the USB's were so complicated. I'll keep away from them.

    I've measured LDR's via the use of a timer circuit. My goal was to avoid using multiple timer circuits and use a single chip to handle all the measurements and timing. The BS2px looks like something which will work very well for my application. I will probably get it and have a dozen I/O ports used just for sensors. Then interface it with the servo controller so that it will work together. But that would be something I will have to save up for. My goal was to do it in under 60 bucks with just 1 board. To use this and the servo controller will be a bit more expensive. Still, where space is concerned, this is wayyyy better than using multiple timer boards. While I can deal with some slight delays, too slow a response time will start to cause problems. But I might be able to compensate if I can figure out how to smooth out the servo speeds using one of the two boards.
  • SRLMSRLM Posts: 5,045
    edited 2008-10-01 07:05
    The PSC has a ramping function available with the serial port. You could use this to change the smoothness of the servo motion. So once the sensor trips, it sets the ramping speed to a slow value. Then if the next sensor in is tripped, the value for the first servo is increase (move out'a my way kind of thing). That way, you can get the servos to respond dynamically. And a bonus with the board: you can figure out how you want the leaves to move from your computer, then translate to the serial commands. That way, you get it perfect.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-01 14:15
    Given that cost is important and that you've already figured out how to do this with timers, you should seriously consider using timers to directly control the servos. The ICM7555 comes in a surface mount package and you'd only need a few passive parts per sensor. You could easily layout the basic circuit and just duplicate the same layout 12 times in a 3 x 4 matrix on a small PCB. This would be cheap and reliable and not require any programming. It would also be much less flexible.
  • JaxJax Posts: 10
    edited 2008-10-06 04:07
    Hey guys.

    I have decided (for now anyways) that I will make alot of timer circuits and just make them as compact as possible. However I am still planning on making all those servos work off of 1 or 2 control boards. So I'll eventually give the BS2 a try. Besides I still want to learn how to do some coding. And those stamps seem perfect for helping me learn how to do so. Thank you all for your help =)

    Jax
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-10-10 12:44
    Well, Jax, nothing happens "instantaneously", even in micro-processor world. There's ALWAYS some "latency" between when the event happens, and when the processor "notices" it, and even then there's some latency before the processor's "Interrupt Service Routine" can execute.

    So, what we need to do is characterize the latency, and determine how much latency you can tolerate. A BS2 with an external 'tick' generator can be extremely reliable with a 50 millisecond 'tick'. But 50 milliseconds can be a 'long time'.

    The SX boards made by Parallax ($10 board, $150 development system) run at about 50 MIPS, with latency around 20 to 50 nanoseconds. Now THAT'S "real time". You program them using the Parallax SX-Key and IDE, using the SX/Basic compiled language.

    Frankly, the BS2 family has a MUCH simpler programming language and is easier to use, but the SX-48 board give you MUCH greater performance.

    That $60 price point is a problem. Usually you can trade off money for experience, so if I had as little experience as you think you do, I'd first buy a BS2-BOE based solution ($150 or so), and try it out. If that works, you're good. If that doesn't work (as your timing requirements seem to imply) you may have to go to the SX-48 board (another $150). The good thing with the SX-48 is that the SX can be its OWN Servo-Controller.
  • ZootZoot Posts: 2,227
    edited 2008-10-10 19:07
    allanlane5 -- where are you getting $150 for SX based project? If an SX-Key is $50 (a one-time expense, or an SX-Blitz at $30) and SX protoboards are $10, then that is $60 -- about the cost of a faster Stamp. And the Key doesn't need to be purchased again. If the project is built out of separate components, the cost drops to more like $5 for the project (resonator + SX chip) itself, excluding the one-time cost of the Key or Blitz.

    ??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • bagus081bagus081 Posts: 1
    edited 2008-10-11 11:55
    hello,

    execuse me, i am a new member for this forum, my name is agus,i need your help, i want to design a six leg robot, where each leg contain 2 servo, i need i mechanical design , and a tutorial how to build it, thank u som much
    my email is :bagus081@gmail.com

    best regards,

    agus
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-10-11 19:50
    Bagus, start your own thread, please.

    Zoot, good point. http://www.parallax.com/Store/Microcontrollers/SXProgrammingKits/tabid/140/ProductID/364/List/1/Default.aspx?SortField=ProductName,ProductName

    That's $89, and a very good deal. While the "cost of raw hardware" is $60, it's still nice to have a 'proven' prototype board, which the $89 kit gives you. Add the $10 SX board, some time to read the manual, some prototyping time, and you're good to go.

    Perhaps you can download the manual, and so you could do it with just the board and SX-key and downloads.
Sign In or Register to comment.