This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Servo for rudder control.
#1
Hi all, 

I am a beginner and have been learning arduino and have recently built a small 60cm iot controlled catamaran boat using the arduino cloud. The gps position is tracked and displayed in google maps and i have 2 motors and a servo controlled rudder. 

For the next stage of the project i would like to try to make the boat semi autonomous, i was looking into the Ardupilot system for drones but then remembered opencpn and pypilot and i think that this would maybe  more suitable to control the catamaran via openplotter  using pypilot over wifi /internet using VNC.
 I have purchased a rasberry pi 4 b and i have a neo6m gps connected and a mpu9265 that pypilot can see so i have a position and heading being processed in opencpn. My problem now is the pypilot motor controller, as i am having understanding how to build and connect it. For the iot boat i just used a servo connected to the esp32 and am wondering if i could do something similar for pypilot.  It appears to me that much of the motor controller circuit is designed for overload and stall protection but as the rudder on my remote boat is so small i am wondering if these are necessary for my application and is it possible to just connect a small 5v servo to the arduino instead?  
My eventual goal is to build a small semi autonomous echosounder boat that can be piloted from the mothership to explore shallow anchorages etc and send back position and depth data.
 Any and all advice or guidance greatly received.

Thanks
Marty
Reply
#2
Just take an arduino nano, put motor.ino on it and pull D6 high. The arduino then outputs RC-style signals on D9, that I think you can feed to an RC-style servo. See https://github.com/pypilot/workbook/wiki...-motor.ino

I like your thinking! Don't forget to correct your soundings for the tide ;-)
Reply
#3
you can do this, but keep in mind that driving a servo on absolute position is different from driving it a relative speed.

You will have to change all the gains to compensate but otherwise it should work.
Reply
#4
(2022-05-10, 11:33 AM)ironman Wrote: Just take an arduino nano, put motor.ino on it and pull D6 high. The arduino then outputs RC-style signals on D9, that I think you can feed to an RC-style servo. See https://github.com/pypilot/workbook/wiki...-motor.ino

I like your thinking! Don't forget to correct your soundings for the tide ;-)
Ironman, Sean, Thanks for your replies, 

ok, so I flashed the nano with the motor.ino file after uncommenting the below to disable the alarms.

//#define VNH2SP30 // defined if this board is used
#define DISABLE_TEMP_SENSE    // if no temp sensors avoid errors
#define DISABLE_VOLTAGE_SENSE // if no voltage sense
#define DISABLE_RUDDER_SENSE  // if no rudder sense

and changed; 
#define pwm_style_pin 6
// pwm style, 0 = hbridge, 1 = rc pwm, 2 = vnh2sp30
uint8_t pwm_style = 1; // detected to 0 or 1 unless detection disabled, default 2

to set style 1 (RC). however I also, (mistakenly I think), a 5v onto pin 6 to pull it high. I since removed this 5v.

The Arduino connects to the pi via usb after I add a usb device in Pypilot, and the RX TX lights are flashing.

When I open the Pypilot control interface and connect the Arduino USB, it says "Arduino" in the top left, then very briefly in says "Engaged" but after about 1/2 a second switches to  "Disengaged", and next to that it says "Sync Overcurrent_fault". When I press the AP to engage nothing happens because I think the fault stops the engagement.

I looked through the Arduino code and I am a beginner but I can't see anywhere where overcurrent fault can be uncommented. Do you have any suggestions? 

I also read the following, 
  • There will be random error messages next to the word SYNC, and this can be expected. These error messages are called ‘flags’ in pypilot parlour, and at this point they are caused by the input pins on the Arduino being left open. Open input pins are bad practice in electronics; if they are left 'floating' they are susceptible to electrostatic influences and worse, damage.
but I am unsure how do I stop them "floating"? do I physically connect those pins to 0v or 5v or use  pinmode commands in the sketch.? 


I think I understand that by setting the D6 pin High via the Pwm_style=1 you get an output on D9 that is a PWM pulse of varying length that equates to servo position. I think this is similar to the servo.h library I am using in the IOT boat so hopefully it will work similar but see from the workbook wiki that its really untested. but first I think I need to get rid of the fault before proceeding.

Thanks for the help!

(2022-05-10, 01:17 PM)seandepagnier Wrote: you can do this, but keep in mind that driving a servo on absolute position is different from driving it a relative speed.

You will have to change all the gains to compensate but otherwise it should work.

Hi Sean,

I am not sure what this means, so I guess I have some googling about how servo's work and the differences of relative speed and absolute position.. this has all been a huge learning curve, but a rewarding one!

Are the Gains the sliders in the control interface?

Thanks
Reply
#5
Can you tie A0 to 0v? This should at least prevent overcurrent.

As far as setting pwm_style... changing it in code there will just get overwritten when the sketch starts (line 419) so it would be better to override it there instead, or just tie D6 to vcc.
Reply
#6
(2022-05-11, 01:10 PM)seandepagnier Wrote: Can you tie A0 to 0v?   This should at least prevent overcurrent.

As far as setting pwm_style...  changing it in code there will just get overwritten when the sketch starts (line 419)  so it would be better to override it there instead, or just tie D6 to vcc.

Hi Sean,

I have tied A0 to 0v and D6 to 5v, now next to sync, is "Overcurrent_Fault Saturated"

at least its not the same fault as before = progress! Smile

Should I be trying any other pins to either 0v or 5v? 

Thanks
Reply
#7
Sorry I meant A1.
Reply
#8
(2022-05-11, 11:28 PM)seandepagnier Wrote: Sorry I meant A1.
woohoo,

The servo is moving when I change the heading of the imu ! 

At first the web control wasn't connecting to the server, I installed the OpenCPN Pypilot plugin and it wouldn't connect. Then upgraded Pypilot using the following :

Code:
cd
sudo systemctl stop pypilot pypilot_web pypilot_hat pypilot_boatimu
sudo rm -Rf pypilot/ pypilot_data/
git clone https://github.com/pypilot/pypilot
cd pypilot
sudo python3 setup.py install
and now the plugin works, but the Pypilot icon has disappeared from the raspberry-openplotter dropdown menu. Should this have happened? 

Thanks for all the help so far, I guess I have some more exploring of the software to become familiar with all the functionality before mounting to the IOT boat for further testing.
Thanks once again!.
Reply
#9
yes it disappears, but you can add one, or run "pypilot_control" directly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)