Servo control, but smooth?
Leticia Project
Posts: 30
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!
Chech out my project "website"! · 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!
Best regards Jens Grönberg
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!
Chech out my project "website"! · 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!
Best regards Jens Grönberg
Comments
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.
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?
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.
EngineCut:
'====================
HIGH 7
pause 10000
IF IN5 >= 1 THEN EngineCut: 'Confirms that engine is dead
LOW 7 'Engine is dead, and is now able to be restarted
TurnAround:
'===================
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
IdleTurn:
'===================
'Turn Throttle-servo to zero
'Turn Steering-servo to max left
goto EngineLoop
EngineLoop:
'===================
pause 10000
FOR Loop = 1 to 9
Next
goto EngineCut
This is how I have planned it, if you have any suggestions I`m very grateful!
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.
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!
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.
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!