Joystick servo control using BOE

2»

Comments

  • Tom:

    Just to be clear on the edits, can you summarize what I have to change in the program between the 2 responses you provided?

    Regards,

    Alex
  • Replace the RCTIME(s) with no joystick with a PAUSE 1. The corresponding axis will follow the joystick read previously.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • The problem with RCTIME with no joystick (or RC network) is that it takes a more or less arbitrary time to execute and returns a more or less random value. That confuses the rest of the program, as well as making it no longer real time responsive.

    So here is a version that enables axis 1 and 2 and disables axis 3 and 4. It also has the gain cranked up to 7.5. Note it is for bs2px, just change to bs2p.

    As it is, it should run axis 1 and 2 with your joystick just fine. You can modify AxnPSMid individually for each axis to center the servo with the joystick neutral, and you can modify AxnGain to get full limit-to-limit movement of the servo. Each axis has both values individually. If you have servo three and/or four connected, they should go to about mid-potion and stay there.

    Once everything is nice and smooth and you get your other joystick wired, you can fire up axis three and four. I would do this one axis at a time.

    For each of axis three and four, uncomment the RCTIME and comment out the PAUSE and the JoyValue = . When you have done this, they should look like axis one or two. Once they are working you can adjust the center position and the gain like you did for one and two.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Excellent! Thanks Tom, will give it a try!

    Regards,

    Alex
  • Hello Tom

    Everything worked very well! I got ports 14 and 15 working as well. I setup (2) slide pots as a substitute for the joystick until I receive it which should be early next week. I have attached a picture of the setup so far. I am using 23 turn 1K trim pots as well so I can match the speed of the thruster for parallel units (real fine tuning of speed). I will be replacing the servos with Phoenix EDGE HV60 ESC's which will be connected to the thruster motors for thrust control. I should have everything next week for testing with the actual ESC's and thrusters.

    The only question I have on the code (which is brilliant by the way) is adjusting the gain in Hex..is there a standard formula for changing the hex values? The gain you added is a VERY helpful feature and will allow me to fine tune the max thrust speed via this setup vs. the firmware on the ESC's.

    [img][/img]



    1328 x 747 - 313K
    1328 x 747 - 423K
    1328 x 747 - 441K
  • Glad to hear it is working.

    The AxnGain constant can be though of as a real number. The first two digits are an integer; the second two digits are a fraction whose denominator is 256. They are both hexadecimal. Thus $0780 is 7 plus 128/256 equals 7.5. $0781 would be 7 plus 129/256, $077F would be 7 plus 127/256. I'm thinking "cut and try" is how I would look for the best number.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Thanks Tom. I will try that. And thanks again for the great code :) I will test it next week with the thruster/ESC combo and report back. Have a great weekend.

    Best Regards,

    Alex
  • Hello Tom:

    I connected the Phoenix EDGE HV60 ESC to port 12, substituting the servo that was plugged into that port. Everything worked perfectly! :) I ran out of connecting clips to connect the other motors/ESC's to the other 3 ports to configure the entire thruster system but should pick up some in the next few days. Thanks again for your help Tom as I very much appreciate your time and effort with the coding. I will place progress reports here with pics as I progress the control system and UROV.

    Best Regards,

    Alex
  • :thumb:
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • ercoerco Posts: 18,306
    @tomcrawford: Way to dive in and git 'er done. You're a rock star!
    "When you make a thing, a thing that is new, it is so complicated making it that it is bound to be ugly. But those that make it after you, they don’t have to worry about making it. And they can make it pretty, and so everybody can like it when others make it after you."

    - Pablo Picasso
  • Hello Tom:

    I will be going into the build phase of the pressure vessel and start connecting all of the electronics into the vessel. I was wondering, at the present time I can control the 2 forward thrusters with a single parallax joystick using the X and Y axis. I can also control the 2 forward thrusters by having each controlled by its own joystick. I would ideally like to have a differential output on the Y axis of the joystick instead of the separate X and Y control of each motor as it is difficult to have both motors spinning evenly as you move the joystick forward and left (as an example) to move both motors so the ROV moves evenly forward.

    So the better control setup would be that when I move the joystick forward on the Y axis both motors are spinning equally (I have trim pots for trimming and matching) and then when I move left or right slightly, I can get one motor slowing down while the other spins at the same speed at its current position. Same would go for reverse. this would make control much easier.

    Any ideas Tom?

    Just some notes:

    Each motor has a dedicated brushless motor controller and port on the BOE
    The brushless motor controllers cannot share a motor and therefore need a dedicated port on the BOE

    Let me know of your ideas,

    Best Regards,

    Alex
  • tomcrawfordtomcrawford Posts: 705
    edited August 26 Vote Up0Vote Down
    Sounds easier to steer that way :smile:

    Should be doable. Lemme think.

    Edit: Okay, I thunk. Does this vessel have a rudder? And is the rudder controlled through this same BS-2? If so, would it make sense to control the rudder and the differential motor speed from the same joystick axis? Either the one now used for the rudder or control the rudder from the axis that controls differential. EndEdit
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Those are some serious ESCs!

    I'm looking forward to seeing this thing in action.
  • There are no rudders for the ROV. All steering is done thru the thrusters. There will be 3 thrusters, 2 for forward reverse and steering and 1 for up and down.

    Alex
  • msrobotsmsrobots Posts: 1,639
    edited August 26 Vote Up0Vote Down
    How about turning the joystick 45 degrees to the left?

    Then straight forward is full thrust forward (x:=+max y:=+max) -- forward
    Straight backward is full thrust backward (x:=-max, y:=-max) -- backward
    straight right is then (x:=-max, y:= zero)
    straight left is then (x:= zero y:= max)
    straight right is then (x:=+max/2, y:= -max/2) -- rotate right
    straight left is then (x:= -max/2 y:= +max/2) -- rotate left

    Just thinking out side of the box

    Mike
    I am just another Code Monkey.

    A determined coder can write COBOL programs in any language. -- Author unknown.

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • it would still be difficult to throttle them proportionally that way as the X axis is on a spring. I could release the spring but I like the spring as it brings it back to center on the Y axis. This is good for control and knowing where you are with joystick position.

    Alex
  • Okay, lets see if I have this correct:
    Joystick Axis 1 will return a value greater than midpoint when pushed forward (away from operator).
    Joystick Axis 2 will return a value greater than midpoint when pushed to the right.

    Then, if we are moving forward:
    Joystick to the right (greater than midpoint): Increase port, decrease STB.
    Joystick to the left (less than midpoint): Increase STB, decrease port.

    If we are moving backward:
    Joystick to the right: Increase port, decrease STB.
    Joystick to the left: Increase STB, decrease port.

    That sound right?

    Will have to have a multiplier that controls the magnitude of the increase/decrease or maybe two (forward vs backward)
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Alex,

    I am not sure how to ask this so I will just ask. One never knows what lurks on the internet.

    As Xanadu says, "Those are some serious ESCs!"

    Are you planning to use this vessel for any nefarious purpose?

    You can most easily convince me by briefly explaining how you plan to use it.

    With all best wishes and hoping my caution will be appreciated,

    tom crawford
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Alexander14Alexander14 Posts: 30
    edited August 28 Vote Up0Vote Down
    Hello Tom:

    Absolutely not! I am the X CEO of Crustcrawler Robotics (I did business with Parallax for a number of years selling our hex crawler to them (remember that kit?) I am building this UROV to explore several deep ponds and lakes called the Binniwaters in upstate N.Y. with it once it has been completed and tested. These lakes are limestone formations and are very deep and nobody has ever explored it before and I hope to become the first with the UROV. As for the ESC's, they are standard Castle Creations Phoenix EDGE HV60 units which are ideal to drive the larger 400W and 600W thrusters I have.

    Let me know if you have any more questions and thanks for asking :)

    Alex
  • Alexander14Alexander14 Posts: 30
    edited August 28 Vote Up0Vote Down
    Tom:

    Based on your joystick example, let me see if I can clarify to ensure we are on the same page:

    I want to move the joystick forward and have both parallel forward/reverse thrusters to operate at the same speed. A joystick deviation to the left or to the right while forward from center will slow one as opposed to the other to effectively turn the UROV left or right depending on whether I have the joystickk to the left or leaning toward the right. The same goes for reverse.

    Let me know if you need me to clarify anything else.

    Alex
  • Alex,

    I felt I had to ask. I'm afraid we are all a bit paranoid these days.

    Here is a program that, I think, does what you want. The joystick axis on pin 11 is forward/reverse; the axis on pin 4 is left/right.

    The left/right axis not only slows the appropriate thruster, it also speeds the other. You should be able to rotate in place!

    The constant YGain determines how much left/right is inserted. It is arbitrarily set to 1.5 which 20% of the forward/back gain. You can fiddle it to insert more or less. Remember, it is a real number.

    I do not know whether the increase/decrease in reverse has the correct sign. It is easy to fix if not.

    Axis three and four are unchanged. You will need to uncomment the RCTIME and comment out the PAUSE, etc as before.

    Let me know.

    tom
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Thanks as always Tom, will test this week and get back with you. Once this is solved, building of the UROV commences.

    Alex
  • Hello Tom:

    I have played around with some of the Xgain and Ygain values and all is working well. I adjusted the gain for both values and trimmed the pots to match the speed of the motors. One thing that I noticed was that when I deviate on the X axis when throttling forward on the Y axis the one motor cuts out pretty quickly with little left or right movement. Is there a way to adjust this so that it is a little more linear with more movement that cuts the motor slowly?

    Your code is always fantastic and works "out of the box" :)

    Regards,

    Alex
  • tomcrawfordtomcrawford Posts: 705
    edited August 30 Vote Up0Vote Down
    Make XGain smaller? What do you have it set to?

    YGain smaller.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Alexander14Alexander14 Posts: 30
    edited August 30 Vote Up0Vote Down
    Hello Tom:

    I adjusted the gain and that helped to give me more room on the X axis when differential thrusting is required. Currently, I have both values set to $0280. I have a unique issue with my current setup that maybe you can help me with....In order to match the thruster motors so that the speed of each forward thrusting motor is matching each others speed, I use a (2) 1k trim pots that are inline with the joystick resistance. I can adjust either one of the 2 pots to match the speed of either motor to each other. The issue is when I match the forward speed of both motors and simply reverse the throttle for reverse speed, the motors will not be matched and if I adjust again, the forward motor speeds become unmatched again. I can adjust the joystick left or right for differential adjustment but it would sure be nice if they where matched for both forward and reverse together.

    Also, I changed the gain to $0980 for both as well and I noticed that the differential in rotational speed is less noticeable for forward and reverse than at the lower $0280 gain value but at the sacrifice of the joystick being more sensitive to movement but it is well within operating limits.

    Any ideas?

    Regards,

    Alex
  • I finally got a Parallax joystick to fiddle with, connected to a BoBot. I am using a BS2p. I found that having the XGain and YGain the same doesn't work at all because it is much too sensitive to left/right control. I currently have XGain set to x0580 and YGain to x0080. That is a ratio of 11:1. I can drive it pretty well; maybe I'll even enter the erco figure-8 contest.

    I don't think fiddling the joysticks is the place to match the thrusters. I think you may have to set the gains separately for the two thrusters. Possibly for each direction. That would result in your having 8 gain constants. Starboard/Port times Y/X times forward aft. It might take a while to find to sweet spots but that would allow for the most flexibility.

    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Thanks Tom, I will give it a try. I actually got them pretty closely matched by increasing the gain both equally and then trimming one to match the other using the pot (it is only a very slight turning of the pot to match them). A slight change to the gain may be in order as you outlined to get an almost perfect match between the thrusters. I will work it thru with different values and update here.

    Thanks again for all of your help as I really appreciate it! :)

    Best Regards,

    Alex
  • Hello Tom:

    Have you thought about my proposal? What are your thoughts?

    Regards,

    Alex
  • Alex,
    I thought I responded but guess it didn't go through. I'm interested enough to ask for details. You can contact me at

    tango oscar mike charlie (at) victor foxtrot romeo (dot) november echo tango

    tom
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • e-mail sent
Sign In or Register to comment.