Open Source Boat Controller Project

Discussion in 'OnBoard Electronics & Controls' started by MurphyLaw, Aug 7, 2018.

  1. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    This is an open source boat controller, that means the code is free BUT if you use any of the code and then modify or add to it, then you are expected to publish your modifications. I'm writing this as I go otherwise it will never get published after the fact, make sure you read to the end of the thread before you spend money on anything.

    I am going to use a Raspberry Pi Zero as the board because of its price of only $20, it has WiFi built in which means you can use a smart phone as the keyboard and monitor.

    Raspberry Pi Zero Wireless WH (Pre-Soldered Header) https://www.pishop.co.za/store/raspberry-pi-zero-wireless-wh-pre-soldered-header

    I have no associations with this company, I just buy from them, I am not paid for any publicity etc. I suggest you buy from a local supplier. Make sure you get the model with the connectors(headers) already soldered onto the board unless you are a whiz with a soldering iron.

    Here are some of the possibilities with this board and a few external components.

    1. Hydrofoil control.
    2. Wing -Sail control.
    3. Auto pilot and steering.
    4. Solar panel and battery controller
    5. Boat WiFi
    6. Boat Alarm

    You can plug this board into any HDMI display and use it as a browser for the internet. It has the same features and a lot more than what you will find on a smartphone.

    I intend to implement all of the above items, I am starting with Hydrofoil control.

    If you can operate a smart phone and customise the settings then you should be able to handle this project, it will use the programming language Python but nothing more complex than editing a text file and changing settings like "MaxSpeed=20"

    Here is what you need to get started.

    1. Raspberry Pi Zero Wireless with pre soldered header(If you can't solder well then make sure you get this model.
    2. SD memory card.
    3. USB cable adaptors.
    4. Power supply (it will work with ANY USB power supply or battery pack)

    Don't forget to order the USB and HDMI adaptors it use the latest tiny micro versions which don't fit standard keyboards or monitors.

    HDMI adaptor

    Pi Zero HDMI Adaptor White (Mini HDMI to HDMI) https://www.pishop.co.za/store/pi-zero-hdmi-adaptor-white-mini-hdmi-to-hdmi

    You will need 2 of these if you want to use a mouse and keyboard.

    Pi Zero USB Adaptor White (USB OTG Host Cable) https://www.pishop.co.za/store/pi-zero-usb-adaptor-white-usb-otg-host-cable
     
    Last edited: Aug 7, 2018
  2. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    For the hydrofoil controller I intend to use a 9 Axis sensor made by Bosch to give my position, acceleration, speed, roll and pitch. For the distance above the water an ultrasonic sensor. I also plan to use an auto windscreen wiper motor and gearbox to move the foil. They last longer than the vehicles they are fitted to and have lots of torque at the right speed the bracket and fittings and knuckle joints they come with are perfect to adapt, try and get the whole mechanism as those knuckles will be expensive if you buy new, you should get them for almost free from most breakers as they have thousands of them. The parts bill for the controller should come to less than $100, computer, sensors and motor.

    Here is the datasheet for the 9 axis sensor

    https://cdn-shop.adafruit.com/datasheets/BST_BNO055_DS000_12.pdf

    Lots of stuff on the sensor at Bosch

    BNO55 https://www.bosch-sensortec.com/bst/products/all_products/bno055#tab_module_16_1_0

    Here are the specs for the waterproof ultrasonic detector.

    https://www.pishop.co.za/store/dc-5v-waterproof-ultrasonic-module-distance-measuring-transducer-sensor

    1. Load the Rasberry Pi with the default software NOT the noobs version. If no lights come on when you start it up then 99% sure you have made an error copying the default software to the SD card. The first time you use the Pi will be with a monitor and keyboard connected to it, it runs Linux Windows. The best way to use it as a controller is to connect to it with WiFi, that way the Pi computer can be used for timing critical stuff without being interrupted by any other software running, you do this running the config program, enable remote logon and disable Windows at start up. I will write this up in detail later.
    2. Connect the Ultrasonic sensor as in the diagrams with a 2.2K resistor and 1K resistor.
    3. Open a new file called "distance.py" and paste the following.

    Code:
     #!/usr/bin/python
    #encoding:utf-8
    
    import RPi.GPIO as GPIO                    #Import GPIO library
    import time                                #Import time library
    GPIO.setmode(GPIO.BCM)                     #Set GPIO pin numbering
    
    TRIG = 15                                  #Associate pin 15 to TRIG
    ECHO = 14                                  #Associate pin 14 to Echo
    
    print "Distance measurement in progress"
    
    GPIO.setup(TRIG,GPIO.OUT)                  #Set pin as GPIO out
    GPIO.setup(ECHO,GPIO.IN)                   #Set pin as GPIO in
    
    while True:
    
      GPIO.output(TRIG, False)                 #Set TRIG as LOW
      print "Waiting For Sensor To Settle"
      time.sleep(2)                            #Delay of 2 seconds
    
      GPIO.output(TRIG, True)                  #Set TRIG as HIGH
      time.sleep(0.00001)                      #Delay of 0.00001 seconds
      GPIO.output(TRIG, False)                 #Set TRIG as LOW
    
      while GPIO.input(ECHO)==0:               #Check if Echo is LOW
        pulse_start = time.time()              #Time of the last  LOW pulse
    
      while GPIO.input(ECHO)==1:               #Check whether Echo is HIGH
        pulse_end = time.time()                #Time of the last HIGH pulse
    
      pulse_duration = pulse_end - pulse_start #pulse duration to a variable
    
      distance = pulse_duration * 17150        #Calculate distance
      distance = round(distance, 2)            #Round to two decimal points
    
      if distance > 20 and distance < 400:     #Is distance within range
        print "Distance:",distance - 0.5,"cm"  #Distance with calibration
      else:
        print "Out Of Range"                   #display out of range
    Save the file and then run it by typing " python distance.py"
     

    Attached Files:

    Last edited: Aug 7, 2018
  3. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    I setup and tested it above the water in my swimming pool and it worked fine, I will get my 9 axis sensor tomorrow and will cover setting that up and testing.
     

    Attached Files:

  4. JosephT
    Joined: Jun 2009
    Posts: 691
    Likes: 57, Points: 28, Legacy Rep: 218
    Location: Roaring Forties

    JosephT Senior Member

    Very interesting Murphy. I'll follow your progress here for items 3 - 6. One area I've seen onboard electronics fail is due to the installed location on the vessel. Suggest keeping them as high above the salon deck as possible. If water comes onboard some day the equipment will stand a better chance of surviving. Conversely, seal all areas of the deck above the equipment to prevent water from dripping down and shorting it out.

    I can't count the number of electrical equipment failures due to poor choice of installation location. Also, it goes without saying use waterproof connectors and housings if at all possible.
     
  5. BMcF
    Joined: Mar 2007
    Posts: 963
    Likes: 43, Points: 28, Legacy Rep: 361
    Location: Maryland

    BMcF Senior Member

    Very interested to see how that ultrasonic sensor performs when moving over the water at speed and, say, a height of 8 feet. We've always had to rely on microwave radar base sensors for flying height sensing because the vessel would "overrun" ultrasonic sensors we tried. That said....have not tried any more ultrasonic sensors for that role in many years.
     
    Doug Lord likes this.
  6. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    Before GPS aircraft and missiles would navigate on inertial systems alone, if you know your acceleration upwards and downwards then you can fix your position on this alone. I already mentioned that the way to control the foil is using measurements of inertia and to use the height above water as a reference. When you sense downward acceleration you increase the lift of the foil when you sense upwards acceleration of the foil you decrease the lift. Meanwhile the ultrasonic sensor senses height which you use to calibrate the inertial system. You will definitely get a refix on the water before you hit it that is for sure.

    Aircraft and missiles would usually take a refix on the stars for this recalibration but they are travelling around the world at 500mph, there is no need what soever for this level of accuracy on a 50mph boat, for profit adventures and budgets always drive you to the fastest solution and never the best. Open source software exists at this moment that could fix the height above the water using a video camera alone, the Pi computer has a video camera port that I could utilise but that would push the price up considerably by $50. I also have a Texas Instruments small board computer that is actually used in missiles that costs $200, I had to sign a bunch of paperwork to state that wasn't what I was going to use it for....but the point of this project is an open source foil controller that anyone can afford to make.

    All modern missile systems because of the weakness of GPS to jamming etc have now switched to inertia systems using light of some kind to map the land for their navigation.
     
    Last edited: Aug 9, 2018
  7. BMcF
    Joined: Mar 2007
    Posts: 963
    Likes: 43, Points: 28, Legacy Rep: 361
    Location: Maryland

    BMcF Senior Member

    We design, build and deliver hydrofoil and SWATH flight control systems; as currently configured, they must have real-time bow height data as a controlling variable while flying. Our systems must maintain the flying height, relative to local wave surface, to within plus/minus 0.2 ft at all times (maybe a bit more than that with the SWATHs), even in pretty rough conditions. I cannot imagine operating a craft in wave-surface-contouring mode without some type of reliable real-time height feedback... I'd still be interested in hearing more about the fidelity of the height data you get from that ultrasonic sensor; we're always looking for cheaper sensor options. The first bow height radars we used were $23,000 each..the ones we use now at about $4000 each...would love so find something that's less than $1000 that works.
     
  8. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    Thanks for the info. The thing is if you are talking about a craft that weighs thousands of kilograms then any inaccuracies need tens of thousands of newtons of force to put right, on small craft of hundreds of kilos those inaccuracies can become insignificant or offset by buoyancy or drag.
     
  9. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    Any increase or decrease in height will be sensed by an inertia sensor long before a meaningful measurable change in height above the water, why would you focus on height above the water ? The foil can be better controlled if you know the actual forces acting upon it than the forces you derive from the height the craft is above the water, by measuring the force on the foil you can eliminate the acceleration of the water from wave action, if you keep the foil an exact distance below the surface this does not mean the acceleration of the foil vertically will be zero. By knowing the acceleration of the foil you can more accurately predict where it will be in x amount of seconds than you can by measuring its height above the water.

    This is the approach taken in flying a wing in air why would it be any different to flying a wing in water, the consequences of a wing hitting the ground are far more severe than a hull hitting the water?
     
  10. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    I come from a military aviation background, we have always dipped the boards in epoxy resin, no components exposed to the air. Was tough repairing stuff then, you would have to chip the components you "thought"were faulty out before you could replace. Now it is easy because no repairs are done to component level.
    The sailing I enjoy there is no right way up of the boat so it goes without saying that anything electronic must be good below water which is the IP68 rating. The problem is not with the electronics it is with the switches and stuff we use to interact with them which is why I am using a Pi with WiFi, there will be no need for a physical connection between the computer and user.
     
    JosephT likes this.
  11. JosephT
    Joined: Jun 2009
    Posts: 691
    Likes: 57, Points: 28, Legacy Rep: 218
    Location: Roaring Forties

    JosephT Senior Member

    We come from the same backgrounds. Glad you're putting together a good spec and I wish you the best on this project. There have been many excellent improvements on instruments and equipment the last several years. Tomorrows sailing (and boating in general) stand to benefit.

    One follow-up question on your alarm: Will this be an anti-theft alarm, anchor alarm, shallow/depth alarm?
     
  12. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    OK great news I have the motions sensor nearly finished, I now have super accurate position, heading and acceleration in real world numbers at 2000hz which means I have a response time of 1/1000 of a second(your sampling speed must be double your operation speed). I have a couple, one is TDK that can do 8000hz which is 4 times quicker, I have the Bosch one running without a glitch for over 12 hours, so I am now going to hook my motor up. I am also testing with an Adruino CPU as well as a Raspberry Pi, whichever board is the most reliable I will go with. I have put some serious time into the software I can speak a new language called I2C fluently.haha

    Here is the TDK motion sensor that can do 8 kz readings a second MPU-9250 Datasheet | TDK https://www.invensense.com/download-pdf/mpu-9250-datasheet/


    I have a laser range finder specially developed for autonomous vehicles and drones that is accurate to within 1mm yeah ONE MILLIMETRE guaranteed laser accuracy and it has advanced processing on board to allow for looking through all weather conditions and materials of reflectivity, has been tested and is designed for drones. When the range of chips are called "Flight Sense" then you know this is the sensor for flying a foil. haha
    VL53L0X Time-of-Flight Ranging Sensor - STM | Mouser South Africa https://www.mouser.co.za/new/stmicroelectronics/stm-vl53lox-sensor/


    SWATH =61mm DIY = 1mm.

    I am going to show that DIY can beat SWATH any day hahahaha. Nah BMcF's input has helped us get a much better sensor than originally planned for less cost, he is on the DIY team now, don't tell his boss;)

    Best thing is it is only $5 and interfaces directly with the Pi Zero. Going to get this done for less than $100 if you use car wiper motors. Something kids can pick up on and go show the old farts how to design and build foiling craft.

    Only drawback it is only super accurate to 2m, but for small craft that is perfect, if you more than 2m above the water you are doing it wrong. I have sailed my Tornado in heavy seas at 20kt+, lifting the hull too high slows you down aerodynamically and it causes the hull in the water to dig too deep, and you have too much mass up high and you get epic into the wind pitchpoles, I will mount at the very bottom of the hull, it is a laser so it can be encased in optical resin, I have some about to expire, expensive stuff. If the very bottom of your boat is more than 2m above the water you only need your foil to do one thing. One mounted at the bow of the craft, giving 1mm accuracy of the water ahead will be enough for a small craft that can react fast. At 5$ a pop you can put them all over the boat which is how they are meant to be used on cars and drones. You place them around the vehicle so the computer has a 3D map of the world around it. It allows you to look through rain and snow you can select the reflectivity of what you are looking for.They are also up to 500mph accurate, limitless really. If it's already proven to be fast enough to stop a drone flying into the ocean at 60kts it will be fast enough to stop a boat. I will rig up something less accurate to read much further ahead of the boat, I have sourced a camera based accurate long range finder, I knew an infra red night vision camera solution was the way to go you can build a 100m bubble around your craft and identify objects, people, peoples faces, visual ID of boats, floating containers, ice bergs...........I have a lot of experience with infra-red vision capturing peoples faces in total darkness, waves will be a walk in the park, the secret to seeing in all conditions is to light the area up like you are on top of Everest, you haven't seen light until you have seen a 1000kW High Intensity LED light, but you use a high totally invisible wavelength of infra-red but with the same intensity and because it is you that is the major producer of this wavelength of light and not the sun, you can use the image you receive from your video camera for ranging of objects, you will be able to map all the crests of the waves and the exact distance of all of them, their motion and velocity etc etc It's the way to go because you get the quality of existing camera chips they are all capabable of capturing infra-red light you just remove a filter in front of the chip and it becomes an infra-red camera, and there is a wealth of open source software designed for object using video recognition, on a ship you could rig up a 10,000KW high intensity infrared light and the latest 20Megpixel Nikon camera with the blue filter removed from it and a computer with a few nice graphics cards inside and you have a kick *** system for a few thousand dollars. but later and the cameras I will use are $300 a piece, I just want to get a working foil within 4 weeks. I have the motors and gearboxes, everything.

    Future tech, the reason why DIY'ers can beat big corps, big corps have to order chips in advance and submit stuff for approval, tech moves a lot faster.
     

    Attached Files:

    Last edited: Aug 15, 2018
  13. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

    It will tell you what they had for breakfast.
     
  14. BMcF
    Joined: Mar 2007
    Posts: 963
    Likes: 43, Points: 28, Legacy Rep: 361
    Location: Maryland

    BMcF Senior Member

    "I am going to show that DIY can beat SWATH any day hahahaha. Nah BMcF's input has helped us get a much better sensor than originally planned for less cost, he is on the DIY team now, don't tell his boss;)"

    *chuckles*. Thanks for the "info"; we'll stick with the radar-based height sensors in our SWATH and hydrofoil control systems for now. I'll let my boss know. ;-)
     

  15. MurphyLaw
    Joined: Aug 2012
    Posts: 123
    Likes: 5, Points: 18, Legacy Rep: 10
    Location: Mars

    MurphyLaw Senior Member

Loading...
Forum posts represent the experience, opinion, and view of individual users. Boat Design Net does not necessarily endorse nor share the view of each individual post.
When making potentially dangerous or financial decisions, always employ and consult appropriate professionals. Your circumstances or experience may be different.