View Full Version : Servo control, but smooth?
01-02-2006, 06:03 PM
Hey Boys and girls!
My name is Jens and I`m a 18years old student in sweden, I`m at my last year at The Gothenburg Technical School called GTG. Since this is my last year I`m having a project work, where we can work with anything technical we want. I`m building a solorider, which is a boat that you can ride wakeboard or waterskies after, alone. The rider controls the boat. That make it possible to hit the water alone early in the morning when everybody else is asleep! http://forums.parallax.com/images/smilies/scool.gif http://forums.parallax.com/images/smilies/lol.gif
Chech out my project "website"! http://forums.parallax.com/images/smilies/idea.gifˇ http://www.bierbower.net/diytower/solorider/
To control the boat I`ve bought a BS2, servo-controller and two Parallax servo. I`m going to put a panel with four waterproof buttons in the handle. That makes it possible to Accelerate, slow down and turn right or left.
I`m a novice in programming and I have realized that I can`t solve this alone. I would be really greatfull if anyone would like to help me and I will dedicate a special thanks to you when I publish my finished work!
Since I`m not totaly lost, I know how to program the basic things in my program. What I don`t know is how to make the servo change up or down everytime I push one of the buttons, I don`t want it to return to zero. When I push accelerate, I want the servo to turn up until I stop pushing the button,ˇand stays there, until I push Accelerate or Slow down again.
I guess there must be somekind of loop for this? I`m very greatful for all kinds of tips or help! http://forums.parallax.com/images/smilies/smile.gif
Best regards Jens Grönberg
01-02-2006, 06:05 PM
Here is also a picture of the handle!
01-03-2006, 02:48 AM
1. To do what you want, you need to have a variable, with a routine that moves the variable up or down based on what button is pushed. You need to have a second routine, that reads the variable and sends the pulse out to the Servo.
2. You REALLY need a 'kill' or 'deadman' switch in your design somewhere. With your current list of controls, should you let go of the handle, the boat will keep going.
3. In robotic designs I've done, I've found robots can be amazingly stupid. Thus, having a control that can tell them to immediately stop WHATEVER idiocy they are currently doing is absolutely required. Especially if the robot is too large for you to just pick it up.
4. If you do this life size, you'll have a motorboat (a large, powerful, and dangerous object) being controlled at the end of a tether. You MUST insure the boat hits nothing, doesn't run over the rider or anybody else. This is a 'life-safety' application, so you must insure you take precautions to keep people from being hurt or killed.
01-03-2006, 05:10 PM
I know what your saying, I`ve been thinking about it alot and there are a killswitch which is not seen at that picture under the panel. But it will not stop the engine.
When the killswitch is "broken" the BS2 will get a 0 value and, pull engine servo to idle and steering servo to full left. This causes the boat to do a turnaround so that it slowly goes back to the rider. It`s a jetski engine so even if the boat does hit you, it shouldn`t be lifethreatning.
When the killswitch is broken, also a timer starts. When it has been 90seconds without putting the killswitch back to "active" it kills the engine. It also confirms that the engine is dead, or it tries to kill it immidetly again and again.
I must need a loop for this varibel?
01-03-2006, 11:45 PM
You didn't say, but I assume the 'kill switch' must be held down continuously, no? For it to serve its purpose, the 'kill switch' must auto-activate should the user let go, fall off, fall down, whatever. This can only happen if the user holds the switch down continuously. This won't always happen if the user has to 'decide' to press a kill switch.
It doesn't have to stop the engine, as long as it puts the vehicle in some 'safe' mode -- which it sounds like you have done.
Note also that this 'kill' code is highly critical -- so it should be very simple, and very well tested. Nothing is worse than a bug in 'kill' code, which is supposed to 'safe' your vehicle, that instead makes your vehicle into a death trap.
Otherwise, it sounds like you're taking a responsible approach so far.
01-04-2006, 01:15 AM
Yes it is a continuosly killswitch, the button is pressed down by a latch. This latch is connected to your body through a elastic string, so when you fall it pulls of the latch. These things are made for small outboardengines and is 100% waterproof. So is everyting that will contact water in this project.
IF IN5 >= 1 THEN EngineCut: 'Confirms that engine is dead
LOW 7 'Engine is dead, and is now able to be restarted
IF IN6 = 0 then Idleturn: 'The ride falls and Killswitch IN6 is set to 0, the boat should now idle
'and turn around for the rider
'Turn Throttle-servo to zero
'Turn Steering-servo to max left
FOR Loop = 1 to 9
This is how I have planned it, if you have any suggestions I`m very grateful!
01-04-2006, 02:02 AM
Well, I think you need a 'state machine' approach for this.
As an example, I'll attach a 'wrapper' BS2 program, and an excel spreadsheet of one suggested set of state transitions.
Oh, and the reason you need a 'state machine' is that in your "pause 10000" above, the BS2 would do NOTHING for 10 seconds -- really not what you want, since you need to refresh those servo's every 20 mSec.ˇ Well, with the servo controller you don't need to, the servo controller will refresh the servo's, but you STILL don't want the BS2 ignoring you for 10 seconds while running through the water.
01-04-2006, 03:10 AM
I`m sorry, but this is way out of my understanding. I´ve tried to understand the program but I can`t really get a good grip of it.
I`ve attached my whole program, and I don`t know if I`m even in the right direction by looking at how you write?
Though I`m very thankful for your help!
01-04-2006, 04:18 AM
Okay, I've modified your program a little to make it work.
1.ˇ I've added a 'MainLoop' routine, to loop through the subroutines.
2.ˇ I've converted all your direction modify code into true subroutines.
3.ˇ I've created the 'SteerPos' and 'ThrottlePos' variables.ˇ These hold the current settings of the Steering and Throttle servos.ˇ These are the key to your original question -- the goal is to have the 'buttons' modify the VALUES of these two variables.ˇ THEN, once per loop, these values are sent to the Servo Controller.ˇ This 'decouples' reading the buttons from updating the servo positions.
4.ˇ I've added an "UpdateOutputs", to send the SteerPos and ThrottlePos values to the ServoController.ˇ You'll need to modify this so it sends the right values.
5.ˇ I've added the "PBasic 2.5" directive to your code, so you can use the multi-line IF...ENDIF.
01-04-2006, 10:28 AM
You may also want to keep in mind, if the stamp fails (ex, it loses power for some reason like low battery). The servos will remain in their position (even if the servos have lost power). It might be a good idea to have the controls spring-loaded to their off position.
01-04-2006, 05:09 PM
Yes, I actually have the solution to power failure!
By using two relays, the first relay controlles the ignition of the engine, this relay needs power to keep that ignition going. The second realy controlles the first relay, if I send a signal to the second, it will cut off the first and thereby kill the engine.
I can kill the engine with a small signal
If power failure engine will also be turned off.
Thank you AllanLane5 and Bulkhead for your help! I will do my best to finish this program!