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
Reading rudder sense
#1
Hi,

I have successfully in installed opencpn with NOOBS and got my IMU sensor to deliver data to pypilot. My arduino acts like a controller (connected to USB port) and so far a small RC servo reacts when I move IMU and set AP course, great! 

In my boat I have a hydrualic pump with reversing motor that I would like to control via H bridge. Before I install it and try I need to be sure that I do not stall this pump and create damage, therefore I need to able read rudder angle and current but I cannot figure out how to get the reading i opencpn. I have attached a potentiometer to my arduino at adc5 and give it 5 V and ground.

Thanks for a great work!

Regards,

Joakim
Reply
#2
The pump can be prevented from stalling by using current measurement. It will only stall for 1/10th of a second, and doesn't usually cause harm, but it's a good idea to use rudder angle as well. I recommend measuring motor current like this as backup, and to prevent damage if there are other problems. I use a 500uOhm resistor with 50x amplifier.

You can also use end of travel switches to prevent the pump from stalling. This would be a magnetic reed switch at either end, and a magnet to trigger it in most cases, but you could possibly use a switch with a spring as well.

The rudder angle feedback was recently improved, and this change is not in openplotter yet. I recommend you upgrade pypilot from github, as well as the pypilot plugin in opencpn if you are using that.

Once you do, the pypilot_calibration script has buttons for calibrating the rudder. You need to center, and then set the range by moving hard over to starboard, and setting the angle. Once done, the rudder will stay within this range, as well as accurately report rudder angle over nmea0183 port 20220 in a connection to opencpn.

The rudder angle is normally read from adc4. Check the source code to motor.ino you have uploaded.

The rudder angle is normally in the range of 0 - 1.1 volts. You can modify the source code to read from 0 to 5 but this will change all the other adc measurements like voltage and current feedback. Changing the voltage reference for different readings causes other problems.

https://youtu.be/IMqUmcTbQOE
Reply
#3
Thanks for reply!

Since I'm new to this I need some hints on where to find motor.ino when running opencpn? I cannot find it in the file system.  Huh

/Joakim
Reply
#4
https://github.com/pypilot/pypilot/blob/.../motor.ino
in openplotter
it needs to be installed on an arduino then connected to the rpi board ..i use usb.
then it will show up in the serial tab, set it up there, and then pypilot tab will show it too..
Reply
#5
(2018-08-21, 05:25 PM)jim321 Wrote: https://github.com/pypilot/pypilot/blob/.../motor.ino
in openplotter
it needs to be installed on an arduino then connected to the rpi board ..i use usb.
then it will show up in the serial tab, set it up there, and then pypilot tab will show it too..

Thanks for reply. I hav e downloaded motor.ino and modified it and then upload it to Arduino. I can see that my changes takes effect. But I cannot get the H-bridge relays to work. I have changed row with code: uint8_t rc_pwm = 1;  to uint8_t rc_pwm = 0; but my relays does not operate when seting AP course and wiggle the IMU. Is there any other code that needs to be changed in order to get H-bridge to work?

I have no sensors for servo travel, temp et. connected. All my adc pins are grounded
Reply
#6
(2018-08-22, 02:23 PM)jodi001 Wrote:
(2018-08-21, 05:25 PM)jim321 Wrote: https://github.com/pypilot/pypilot/blob/.../motor.ino
in openplotter
it needs to be installed on an arduino then connected to the rpi board ..i use usb.
then it will show up in the serial tab, set it up there, and then pypilot tab will show it too..

Thanks for reply. I hav e downloaded motor.ino and modified it and then upload it to Arduino. I can see that my changes takes effect. But I cannot get the H-bridge relays to work. I have changed row with code: uint8_t rc_pwm = 1;  to uint8_t rc_pwm = 0; but my relays does not operate when seting AP course and wiggle the IMU. Is there any other code that needs to be changed in order to get H-bridge to work?

I have no sensors for servo travel, temp et. connected. All my adc pins are grounded

There is a digital io pin to detect rc output which sets the rc_pwm variable.  So the modification you made probably does nothing.   The code is not designed for actual relays the mechanical kind make a clicking noise.

If you cannot detect the end of travel, you will stall the motor, and this is a waste of power, and also hard on the mechanical system, it can eventually burn out the motor, but just to get started you could try it...


Grounding the ADC pins is not correct.   This will cause over temperature fault.   Maximum temperature is 0 volts.  Either connect these pins to 3v3 or 5v, or modify the code to not read temperature or fault from it.

I encourage building your own controllers, unlike all other autopilots available. I even provide source code and support for this, but I am concerned because, so far from feedback I have seen, everyone wants to cut corners.  This includes:

  1. Not using current measurement.   This can cause problems, as well as not giving the autopilot the ability to feel how hard to turn (weather helm sense) and no way to determine power consumption to monitor and tune the autopilot correctly.   You should have this, even if you have rudder feedback.
  2. Not using temperature sensors.  This could potentially burn out the electronics, and again, no way to monitor it.
  3. Using usb connection to arduino -  NOT RECOMMENDED!!  I know it seems nice but it's cheating.  This creates a ground loop, and can burn out the raspberry pi if there are any problems in the controller, maybe even if there aren't.   I use optical isolation, and have prevented killing raspberry already.   If you kill your raspberry and don't use optical isolation, it is not my concern.
  4. Using inferior drivers like relays or p-channel mosfets.   I use all n channel mosfets for maximum efficiency and reduced cost.  No one uses relays or p-channel mosfets anymore, this is obsolete technology.  Why it is being mentioned?   Relays are a really bad idea for a number of reasons.
  5. no fuse and reverse polarity, and ESD protection.   This is less important, but I recommend it.
I have all these features for my controllers available from http://pypilot.org/store/   I tried to keep the controller as simple as possible, but I also want good results.

So.. feel free, do what you want, but you may encounter problems.


Yesterday I sailed 20 miles up the winding nanticoke river in maryland completely on autopilot route following adjusting only sails.   I am sailing everywhere on autopilot, even tacking under autopilot against 25 knot winds.
Reply
#7
Hi again!

After many hours trying to figure out how to build my own motor controller I finally  surrendered and bought one labelled VNH3SP30. 

This controller should drive a brushed motor with PWM signal. But, when trying to get the controller to work with motor.ino I get stuck and I don´t know how to connect it. The controller has the following schematic VNH3SP30 Controller schematic.

To test the motor I wrote a simple python script I then needed to connect 5 wires from my Arduino (INA, INB, ENA/DIAGA, INB/DIAGB and PWM). I cannot figure out how to connect it when using motor.ino and if I need to re-program in any way?

I tried and have been partly successful in building a very simple course holding script using a H-bridge with "clicking" relays. This holds the course somewhat steady Smile

Thanks for your support!
Reply
#8
This board "VNH3SP30" does not use RC style signal pwm, so you would need to modify motor.ino to make it work. It uses completely different type of pwm.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)