On the analog throttle output, you could connect a capacitor to ground together with a proper resistor. In this way youcan overcome fast voltage changes of the throttle and hence smoother motor rpm. Well done on this throttle project 😊
Aye, a patreon made the same suggestion, and I think it's a good one. I'm still going to add some ramping logic, but the smoothing cap might also help with the "jitteriness" of the discreet voltage steps, too. I'll certainly be trying that out down the road.
Oh, Madi... The smile on your face when The Thing comes alive sent me back to my first programming success a *long* time ago. Priceless. That feeling is ultimately why I ended up in a 40 year career in computer engineering. It never gets old. I had a suggestion, but @johnhayes3314's comment about not needing so much reverse as forward made me stop and think again. But I'll suggest it anyway. The thought was that since the motor controller already has a well defined neutral "dead zone" (2.4v - 2.6v), there's no need to model that in your software. Just map the potentiometer end-to-end to 0-5 volts, and neutral should automatically fall in the middle. Mapping the dead zone in your software is kind of fighting what the motor controller already does, making your code more complex than it needs to be. Complexity leads to bugs, often subtle ones that are hard to find. But, given that you do have a full mapping of the input to output (including neutral), you definitely could customize the throttle position-to-power curve in any way you choose. That includes a non-linear one, where the controls are more finely grained (smaller resolution factor) near neutral and larger at the ends. Or maxing out to 50% or less power if in reverse. Lots of ways to tweak things. You've already been given good suggestions about smoothing the inputs and outputs. Control the noise (jitter) and slew rates. I expect there is some of that built into the motor controller already, as it appears to be designed to be driven directly from a pot, but it's wise to be careful. Electronic things don't mind going from zero to max in an instant, but mechanical ones tend to object strongly. You know, Physics. Keep up the good work! It's fun to watch.
Great post from a mature gentleman like myself! Well written, complimentary to Madi, and with some great suggestions. I usually don't read long posts but I enjoyed yours.
This is something I try so hard to get across to folks; The joy of learning. It doesn't even really matter what you're making; Sewing, cooking, programming, woodwork... Whatever it is that strikes your fancy. They key thing is that each time you understand something or the first time an ideal becomes real, even if crudely, it's an excitement and happiness that I've never found elsewhere. It's honestly why I do this. ^_^
Excellent points. Is this for a scooter, or half of a wheelchair? If a wheelchair, I think one would want full forward on one side and full back on the other to go the same speed, to rotate on the spot. Just a (probably irrelevant) thought.
Hi Working on throtels and ship\boat control from the 70th and 80th. The boats in the range of 200tons to 10000tons had pneumatic throttle and control systems. A few design rules: 1. There use to be a switch valve that drains the speed control pressure when in stop mode- for you it is a micro switch that holds 0 on the throttle output when in neutral. 2. A switch\valve system that does not allow to increase rpm till forward or backwards gear shift or peach change or in your case current pick was reached. 3. When moving from full speed ahead to full speed astern vice versus the motor will have to reach idle speed before changing direction and will have a speed limit for the direction change. I do not like the motor stop at 2.5V, it is hardware problematic. Because if from any reason you lose 5V on that line, you will start full speed astern.
The "oh poo" switch sets the voltage to 2.5, regardless of throttle position, which commands neutral. If somehow that failed also, there's going to be an e-stop switch that will open the contactors to the motors, bypassing the controllers entirely. Now that said, I will absolutely test what happens if the cables get unplugged, that's a very good failure mode to test!
60V power supply is a very nice gift indeed. I've been thinking of getting prebuilt 48V batteries for backup power, with various ways to recharge them, so figured I'd need a 60V+ adjustable power supply to add to my collection. Cool project. I easily understood pretty much everything you said and demonstrated. I did basic arduino projects, and watched other videos, or read about most topics you mentioned. Don't know enough to give any solid suggestions. I never played around with one of those potentiometer pads, I don't think I'd trust that they are anywhere near as reliable as a purpose built one. Looks to me like it's primarily intended to help you easily see how sliding across and element changes resistance while learning arduino.
I figured all this would be child's play for you. :) Ya, the bench supply was suuuuper generous, I can't wait to play with it! The Softpot claims to have a pretty high life span, and being entirely sealed is appealing for being up in the cockpit. We'll see how it works in practice though.
Did a quick google check and landed on Mouser, who I respect as a component dealer even though I haven't bought from them yet because Digikey worked out better so far. And it does look like they recommend rotary soft pots for industrial applications, so that's good to know. Will have to look at how they are used more. @@TheDigitalMermaid
Congrats on reaching 10K subscribers! You and Andy have been an inspiration for me. I'm in the process of building my own home solar installation, and I've been catching up on all your videos for the past few weeks! I've probably watched a third of Andy's and I'm at Ep. 29 of your build, starting from the very beginning. Quite a lot more catching up to do, so much valuable stuff and just overall fun projects to follow. I've also been watching a lot of camper van builds as well, as this is something I might be interested in in a late future. After all, it's all similar systems as well, just like your boat setup too. I'm from Reunion Island. Unfortunately most of the stuff I have to order online. I was able to get an acceptable enough deal on the MultiPlus II 48/5000/70 locally last month, so that helped a lot as it's so heavy. First big part of the project! The rest of the Victron stuff is way overpriced at the local shop, so it's all ordered from France. Fun fact I got the same 200A breakers (just 1 for now) Andi uses for each of his battery packs, and I ordered that one from Australia. For the batteries it was the most difficult. I chose to get 20x EVE LF280K cells (for now, will add more later), so I have spares just in case. If I don't need any spares I will have a small 12V battery as well for side projects! I ordered them from Qishou, and had to get them shipped to France as Reunion is pretty much never an option no matter where I choose to order anyways. It was sent to a package forwarder there, and then the cells took a maritime freight transportation service. I'm currently still waiting on the delivery, it's been a couple months now. Hopefully it will arrive without issues, I'll give it another month or so hopefully not much more than that. I already got both JK 16s inverter BMS and 4s smaller model for the cells. Really hoping nothing will go wrong with the delivery of the cells, as everything depends on that, and I was a bit too quick ordering everything beforehands. For the solar I plan on going for 510W panels locally, once again here I could get a much better deal ordering online, but the hassle of going with maritime freight and not being able to stagger the purchases, getting 1 or 2 pannels at a time, months after months. I decided to get those locally it's a much more flexible experience, and I'll start with only two pannels. Now I'm in the process of gathering all the most important parts so I can get to the build when my cells arrive. Trying to figure out all the tools I need like crimpers and such. Eager to get everything delivered, finally starting to work on the build, and get to power up my MultiPlus for the first time! I also 3D modeled the whole system in CAD (can't show it here unfortunately), I'm so glad Victron provides 3D models of all their products, it's really of great help! In the meantime I set up a Raspberry Pi with Venus OS, and run a tiny 115W panel on a 100/20 MPPT with a couple random 12V AGM batteries I had sitting around in parallel. Just doing some testing and watching with a lot of curiosity everything working together and producing just enough power for some LED lights. Very very cool stuff! Oh also, I see you got a iCharger in earlier episodes, to charge your cells. At first I was thinking about getting the big ZKETech EBC-A40L tester Andy and a lof of people are using. But I thought it's not flexible enough, as I would like to use it for some other types of batteries as well at some point in time. So I decided to go for a iCharger, and went all out on this one with the DX8 DUO. I'm very curious about it's ability to discharge one cell (or pack) and use the power to charge another. Plus I seem to understand it logs all data and can be used to draw graphs, so it should allow me to test my cells nicely. I just received it and didn't get to test it yet. Really curious about all those features! PS: I also happen to have an IT background!
Thanks, Slay! ^_^ Kinda trippy to be at 10k... wow. I appreciate you going back and watching from the start, thank you! I really hope you do find useful info from them. There's a lot of overlap between RVs and boats, except RVs and use for a square. :) I remember waiting for my batteries, it was during the supply chain issues and it took a solid month after they got on the boat. I was watching for updates every day. haha. For tools, I think there's a rule that once you think you've got all you need, you will always find one more tool you need.
Have you considered to use commercial available levers like an UFlex Power A Mark II Single Engine Control Head ? They have can-bus output, which should be possible to interpret and then send to the controller. It's cool making it ground up as you do, but with the environment this is going to be used, I'm a bit worried on how long it will work. Even the commercial available solutions have a tendency to fail in harsh environments. At least you should consider an "emergency" mode with some switches that overrides this input to get to land safely.. (with 30-40% power on/off forward and reverse)
I did look at commercial throttles, but I didn't like the looks of any of them. I know that might be a silly reason not to use one, but I really wanted a certain look. Also, it's just really fun to learn and make! The current plan is to have a second throttle ready to use in storage, so if one faults, I can quickly swap them out. There's also going to be an "oh poo" button that forces the controller to neutral, ignoring the actual throttle position, plus a secondary e-stop switch (required by ABYC) that will cut the power to the motors directly.
@@TheDigitalMermaid Well horses for courses, but when you've finished playing (I don't mean to be facetious as I understand your channel's raison d'être) you _will_ become concerned with EMC and at that point I expect a better informed design choice. Despite this criticism, keep going because we all know you will get there.
Smoothing out your "system" is easy peasy in the analog domain. For instance you value of the potentiometer is 10K, you take a 100K from wiper to one side, and a 100K to the other side of the control. add a capacitor from wiper to ground and you are done. Wat does this (most reliable) do? When contact would be lost with the wiper for longer time the motor would stop. Also it smoothing out noise & cracks from the potentiometer. Besides that you could use a simple RC network to smooth things out from the output of the DAC to the input of the motorcontrol that regulates the speed. I am an analog designer so if you have any questions be my guest. This all may seem details, but they aren't. They are essential for a goo designed and working set-up.
Aye, a few folks have already suggested a cap to smooth the DAC output. I think I'm still going to add a ramping algorithm, but adding a cap anyway to double the benefit.
@@TheDigitalMermaid All depends on the time constant you use. A relative small time constant is smoothing the digital steps out, a large time constant does the same as an algorithm. You have to realize one thing: the analog version works every time in the most reliable, so superior way. It also serves as a filter for EMC junk. Think about it!
@@airgead5391 I'll be experimenting with how frequently I loop, if that's what you mean by time constant. I slowed it to 0.5sec mostly just the make the serial output smoother while I debugged. Having the cap on the output is going to happen (though not right away, need to figure out the ideal capacitor size and order it).
@@TheDigitalMermaid No, that is not exactly what I meant. I meant the RC time. (R= series resistor, C = capacitor connected after the resistor to ground) I think your 0.1 second probing is a good value to use. (of course you can tweak the analog filtering and digital probing frequency at the end for the best feel)
You could also read the ADC and keep an average and act on that instead of each raw value. This will essentially filter out the crazy jumps. Smoothness will depend on the window size.
As someone that worked in a WET paper making plant, I'd avoid the pot it will be prone to corrosion from the salt air and wet environment. I would use a sealed encoder A pulse leads B they you go forward B leads A you go reverse use the Z pulse for stop home position with a dead band. Count the pulses in a register to determine the speed reference higher number faster. Fairly simple in a plc world from my 45+ years as an electrician and programmer
I might be switching to a hall effect sensor, so this is probably moot now, but the Softpot is IP65 rated, better than any of the rotary pots I found (that weren't silly expensive). It's a fully sealed unit.
When you send a value of a variable to a 12bit dac, make sure the variable is unsigned so that it cannot become negative. As that would cause a sudden "jump" (as the dac know nothing about negative numbers). Also as a safety net you can use the constrain() function to make sure you are within spec when sending the value. Another tip when reading a value is to code a "low pass filter", which mean that you take for example the previous value * 0.9 + new value * 0.1 to get the new value. This will create a smooth transition of the analog read value. You can play around with those decimal multiplyers but make sure the sum of them is always 1.0
The sudden jumps was indeed from going beyond the usable input value range. Thanks to folks who contributed PRs, map() and constraint() should keep that from happening again.
I am a new subscriber and thoroughly enjoying what I have seen so far. I love the "learn as you go" philosophy which is the way I have done most things all of my life. "We are HERE and we want to be THERE. How do we get there? I have no idea, all I know is that WE WILL DO IT!" Is there anything more satisfying than those "proof of concept" moments, when we have put together our newly discovered scraps of knowledge and it just works! Keep up the great work Madi.
It is such an amazing feeling! I really want to help encourage others to try whatever it is they've been thinking about building. Doesn't matter what it is, it'll be so rewarding. ^_^
Hi Maddy, I like your videos, and I truly understand your enthusiasm for building and learning. I'm an electroengineer working in motorsport, so I know something about the importance of reliability. That is why I have some concerns about your solution for controlling your throttle input with Arduino. Don't get me wrong, I build tons of stuff with Arduino, and if you build it right, it can be very reliable. So I will never put them outside, especially in a harsh, salty environment like you will see on the boat. Salty water is a b***, and it will get everywhere and corrode every connection (tinned or not). Basically, you want everything with the highest IP rating (IP67 and better). And conformal coating on the boards, even if they are inside an encloruse. And also properly sealed connectors. We use only Deutsch (DT and DTM series) or Amphenol (AT or ATM series)-same thing. They are super reliable, water-proof, and easy to use. Then try to avoid connecting or extending wires with just heatshrink over joints; water will get under the heatshrink (even under heatshrink with glue) and over time corrode the connection; there are better solutions. My suggestion is to connect the throttle directly to the Kelly controller (you can even use your homemade solution with a pot) and use the foot switch input of the controller as an "o sh*t" switch. It will basically disable any throttle input. It supports a variety of throttle inputs. 2-20k pots or hall sensors. And you can adjust boundaries inside the controller (TPS Low Err, High Err, Dead Low, Dead High, etc.). So the controller will automatically detect if there is anything wrong with the throttle. And even better will be to use some properly sealed hall effect throttle. I just did a quick Google search for "miromax speed throttle for boat". I would use Arduino and the red display you got only for monitoring. I hope you have a controller with CAN-bus; then you can simply monitor anything over CAN-bus. Because if you want to see the throttle value on the display, in my opinion, the most important value is what the controller sees-he controls the engine. I just took a quick peek into the user manual, so maybe I've got something wrong, but I believe that the throttle connected directly to the controller is way more reliable than doing basically the same thing with Arduino. You are just adding another failure point. I hope this helps, and you will be safe out there :)
Thanks for all this! I've had a couple folks suggest the hall effect sensor, and I like that it's totally sealed. The softpot is IP65, which was better than I could find in rotary pots. I really like the idea of putting the "oh poo" switch down below, though there's lots of water in the cockpit, so that will require some extra thought. I will also be adding an e-stop that will probably cut the motor(s) off by opening the contactors, need to check the exact wording of the ABYC requirement. Note that the Arduino was to make my entry into dev less jagged, and the plan is to switch to a proper STM32 (already have a dev board to move to shortly). When I make any custom boards, they'll absolutely be conformally coated, as well as being all tinned copper parts. I do plan to use something like Deutsch connectors, I want to be able to swap out parts quickly (like the throttle, I plan to have a second stowed away for quick swapping). The Kelly controller does have the CANbus option, paid a bit extra for that. I'll be using a fair bit of CANbus and NMEA2000 through the boat, I expect.
On commercial systems there is also a button control system so that if the lever fails you can adjust the rpm up and down with buttons. You wouldn't adjust 1% at the time but like 5%-10% per press, just to get you out of there or to a safer space.
So, well down the road, part of the reason I am making this a digital system is to enable alternative controls (think remote for when I'm on the bow dealing with the anchor solo). So eventually there will be standy-backup controls available. :)
Normally in machines, when running forward or reverse, after pushing and releasing the neutral/stop-button, you don't want the machine to continue at the old speed. I recommend keeping the neutral output signal even after releasing the neutral button, until the input signal reaches the neutral position. Only after that the output should start to follow the input signal.
That's an interesting idea... My plan when I added the "oh poo" button was to have it being a really fast "oh crap" neutral, and I don't imagine restarting after that. However, holding it in neutral until the throttle is itself returned to throttle is an interesting idea. I could throw a "please return the throttle to neutral to restart" message on the display once it's up and working.
This suggestion is a very wise idea. Build in this safety feature to prevent human error from accidentally letting the motors instantly start at the previous speed if the button is unpressed. Just eliminate the risk. .. During the "oh poo" moment the operator might not be thinking clearly. Like, what if you let someone else pilot the boat. Anyway, I am enjoying watching how things come along. I am excited to see the motor running! My dad had a motor boat when I was a kid so in that way many elements of your channel are nostalgic. And I've played around with Arduinos for a few years so I am following your electronic setup and coding. What you have accomplished so far took me a lot longer to learn :) Great work!
Add some safely taps. 900 stop to protect against open wires at either end of the pot. Average out many readings over a 50ms time to settle the output a bit. It would be worth having a calibrate mode where you swing from end to end with no output to find the actual min and Max off the control. Of that's done with a key switch it's also a disable function to reduce theft? Or force a min>max>min>mid swing at power on to enable output. Forces a calibration at key on and ensures no control until safely calibrated and centered.
I'll be speeding up the polling for sure, and there's already limits to ignore any value outside of bounds. One feature I really want to add is unlocking the boat with my phone, like my car does. I'm hoping to have a simple whitelist of bluetooth MAC addresses that, if the device can be seen, enables the controls. There will be a hidden override somewhere of course, but the idea of walk up, unlock, walk-away, lock is really appealing.
+1 to decoding "out of expected range" ADC values as error condition. (Which I saw you have) E.g. if you wanted 180deg of travel, a 180deg pot wouldn't leave room for error detection since the full analog range is "valid". To add to this, there should be an analog "default" - if your sensor becomes disconnected (or in this case no pressure on the pot) - a simple large resistor to ground at the ADC can ensure you get the error condition, instead of the random readings you were getting when floating.
@@electrowizard2000 Cable out / cable break fault testing is certainly getting added to my testing! I wonder if that's something that can be coded into he Kelly controller itself? In any case, I'll also have that e-stop to cut the motors off directly in a real pickle, but ya, graceful failure needs to be insured.
If your potentiometer resolution is too bad making unsmooth pot-movement, you can filter the signal digitally. Taking an average of the last 4 samples (upscaling). If you want to reduce the risk of unstable rpms at constant pot-input, due to analog noise, you can add some hysteres/deadband. So that the input signal must move at least +2% or -2% of full scale for the output to start following the input signal.
Aye, and also adding a smoothing cap as others suggested could help, also. I've gotten a few good ideas that, if when I spin the motor it proves too jerky, I can experiment with. :)
Hey Madi, you will not notice with that step. I work on a line of lift trucks that have a model of truck that uses magnetic reed switches for speed controls I think the resolution is like 12 steps. It has the worst creep speed haha especially compared to it's competitor who uses a 10k pot and spits that in half using a 5v reference. In my line of work, you need a deadman and you want directional switches and not simply relying on voltage to determine intent of direction. I had a machine once that only relied on voltage input to turn on and off relays that turned on and off hydraulic solenoids. The relays were junk, latched shut and the hydraulics would send pressure and the unit traveled out of control. We used the directional switches that were in the control handle but not used to break the feed voltage for the relays as a backup because; redundancy. in DIY, I would strongly encourage redundancy... deadman pedal... yes you may need to step away from the helm... sure motored boats can drive off without you if you fall off. But I would plan some sort of kill/e-stop for if you fall off the boat or who knows..... a remote kill switch? haha ok just brain storming. love this.
My little bit of experimenting already has me convinced that this is good. I can't move the controller manually with enough accuracy to make a difference. So it was a concern that wasn't a concern in the end. heh. I've been thinking about a dead-man switch, but I need to be more creative about it. It's entirely normal on passage to tie the wheel and walk away for a few minutes (hit the head, grab a snack, etc). I've got a plan to add an ESP32, I want to use my phone's bluetooth address as a wireless key. I was thinking I could add a safety where if a PLB or whatever to my life jacket, so that if the esp32 lost contact with the beacon it would stop the boat. Obviously that's an oversimplification, but ya, it's something I've already started thinking about.
Fabulous Mad as always. keep on as you are I could sit and watch you leap from success to success via the inevitable by-roads all day. Like I do lol. I taught myself C# and created a document management system at the You Tube university, and in my case the understanding lagged WAY behind lol Tom
HOWdy T-D-M, ... Glad to SEE You today Thursday 02/01/2024 = the 1st SUNNY Day in a WEEK my BATTERIES are Smiling 🙂 Thanks for the VIDEO COOP the WiSeNhEiMeR from Richmond, INDIANA ...
First of all, great video as always! Second of all of you need / want any arduino help, you know how to get in touch - and if you need Aliexpress stuff much faster, I have a lot of stock on common arduino-ey stuff here! Also, you will LOVE that Riden power supply, I have 2 on my bench - the RD6024 and the RD6018, both are amazing!
I am extremely fortunate to have help from folks like you, Andrew and others. It's the only reason I'm so confident that I can make this project work. ^_^
@@TheDigitalMermaid Next time you go up to Mermaid's Rest I would appreciate if you took a good look at her and realize how arduous the journey was from purchase to home - once what you've accomplished so far starts to sink in, you'll understand why we don't doubt your ability to make things work. Keep it up!
@@SimpleElectronics It's a staggeringly big project, and it blows my mind that I started it back in August of 2019... It feels at the same time so recently and so long ago!
Hi Maddy, you could multiply the 512 times 2 or 3 to have a more granular, but jerkier helm. And also you could use a swelling mechanism software to make it less jerky. You might make this programmable via a button. That's the beauty of developing yourself. You might even do a logarithmic swell of your calculated values so sweeping the helm gives a lot of extra thrust to the boat. That makes sailing into harbors more finesse and in open see you cpuld just push the throttle. Just a way to maybe workaround your options
The idea of a button to add a "low" and "high" range is interesting. That said, soon I'll be switching to the STM32 and that has a 12-bit ADC so it'll be 1:1 with the DAC. In any case, I'll worry about jitter/jumpiness if it comes up as a real issue. On the whole "DIY"ing this, the idea that I can get on the water, and then tune how it works after real-world experience is a MASSIVE bonus for me. ^_^
@@TheDigitalMermaid hi Maddy, that's the positive thing about DIY, you can tinker ad tweak. Probably a linear scale might work, but the force needed to move your boat through the water might not be linear, there maybe a member of your channel who might know this. But great to see the variable resister solution with the ball, never seen this and it should be more moist resistant than a normal resistor package.
@@edwardvanhazendonk The power band is not at all linear, and someone else suggested a logarithmic throttle, which I quite like as well. There's going to be a lot of experimenting once I'm on the boat!
Look up the map() function. It will help you quite a bit. Also, constant pressure in one place on that type of potentiometer, like when you aren't using the boat, may damage it over time. You should probably look into a regular rotary pot for better reliability. Much better, IMO, would be an absolute optical encoder, but those are very expensive. Would you consider a magnetic 'encoder'? They're Hall Effect sensors that precisely measure the angle of a nearby magnetic field. The AS5600 is one example, but they're very durable and you can seal the electronics entirely to protect from dirt,water, salt, and humidity. You'll need a sanity check in the code, no matter how you do anything else, to detect sudden large changes in the position. This will protect from mechanical and digital failures, and hopefully protect from getting thrown off the boat if it somehow jumps to max, or worse from forward to reverse, for example. Upon detection, it would shut the motor off until you either hold a reset button for a few seconds or move the throttle to neutral again
I had a few very kind folks send me pull requests that added better smoothing, map(), constraint() and const to the code. It's already so much better! I'm looking forward to making the next DIY helm video!
I actually remember this potentiometer range issue being one of the exam questions in my finals :D. The solution (which is purely theoretical but I had to math it out and write some pseudo code) in my case was a bit of opamp circuitry. I generated a virtual ground at 2.5V (half of the input voltage can easily be generated with a resistor divider) which was used in a opamp circuit that doubled the voltage range. Since most microcontrollers have differential measurement capability I them just measured between the virtual ground and the output of the opamp, while setting the AVRs reference voltage also to 2.5V (sometimes this can actually be done in software if the controller has a internal reference generator) This actually has 2 benefits because if you use a trimpot for the virtual ground reference, you can adjust the center point and the microcontroller will measure it as a positive and negative voltage (which also most controllers can do in differential mode)
Correct me if I'm wrong, but this approach is an analog solution, right? If so, then I can see how that would be nice and elegant. I need digital control for future projects I've got in mind. :)
Welcome to the world of MCUs, ADCs and DACs! Great work and love seeing you tackle and learn. I do not really do much with Arduino. Most of my projects I use Microchip PIC MCUs, though the concepts are pretty similar, just different compilers and some quirks. A form of C is used, though there are some differences with MCU coding vs PC app coding. It certainly is more cleaner and streamlined then the old assembly language of yesterday's MCUs. Some thoughts (you've done well already in finding some of these). *********************************************************************************************** *********************************************************************************************** ADC/DAC binary values vs actual voltages depends on what voltage references they use. Using external high precision references and stable power supplies will improve stability and reduce wandering values. Reference voltage divided by steps will give you your step voltage. Using a 4.096V precision external voltage reference with 12 bit ADC/DACs makes maths easy - ADC/DAC binary value is 1:1 with voltage, aka 1mV steps. Using a smaller reference voltage on an ADC will improve your resolution (for instance, 1.024V applied to the pot and as an external reference to ADC, equals 1mV steps with 10 bit ADC, vs 5V ref that would be 5/1024 or ~4.88mV per step). Though in your case with the pot input, voltage is not a concern, your just looking at steps, so this wouldn't matter so much. *********************************************************************************************** Integer variables are whole numbers only, any maths that result will be rounded to nearest whole number. Float (decimal) variables consume resources on MCUs, best to avoid if possible. *********************************************************************************************** debounce (control switches, push button inputs) * Read control switch and store in temporary variable #1 * Delay 25ms * Read control switch and store in temporary variable #2 * Compare temp var #1 against #2 Does temp #1 match temp #2? YES: Set control switch variable to temporary variable value NO: Do nothing (do not change control switch variable's current value) Using your variables (plus two new variables "mainSwitchTemp1" and "mainSwitchTemp2"): int32_t mainSwitchTemp1 = 0; // Default safe start state int32_t mainSwitchTemp2 = 0; // Default safe start state int32_t mainSwitchVal = 0; // Default safe start state mainSwitchTemp1 = digitalRead(mainSwitchPin); delay(25); mainSwitchTemp2 = digitalRead(mainSwitchPin); if (mainSwitchTemp1 == mainSwitchTemp2) { // Switch state returned the same on two separate reads with a delay between, set switch status to match mainSwitchVal = mainSwitchTemp1; } *********************************************************************************************** Throttle control - On many electronic throttle inputs, often 2 or 3 individual inputs are used for redundancy and validation. You already mentioned it, but going with enviromentally sealed encoders is good. Hall effect units are amazing. *********************************************************************************************** If 2.5V is required by the motor controller to keep operation in Neutral, using a resistor divider as a safety catch could help (does the controller have a 5V reference output?). Maybe a seperate 5V supply just for that (stable and harsh environment rated). Resistors would have to be high value enough that the DAC output can still swing and not have its voltage output effected. *********************************************************************************************** Those character LCDs are an industry standard. Hitachi 44780 IC for parallel bit operation, though you can buy some with a little circuit board that adds SPI or I2C. I use I2C, simplifies wiring. You will find out however, that coding text can be quirky, because of the string vs integer and etc etc. I think if you are using Arduino, the libraries and such make this much easier. I had a hell of a time with PIC, having to write a lot of code to do proper formatting, conversion and such. Effort that beared great fruit tho! *********************************************************************************************** Throttle mode hysteresis Thermostats for HVAC typically have hysteresis programmed. This is to help stop sporadic changes/cycling in status when your input is right at the changeover point. For example, your neutral range is between 466-549. When the pot ADC value is around 465 or 550, if there is any voltage fluctuations, noise, etc, that value may bounce a bit up or down, changing status. One way to combat this is to apply hysteresis. For example, a 5 step hysteresis could be applied. Start value is 500. Do not change to reverse until value is 5 below the changeover point (465 - 5 = 460). To get back into neutral, do not change to neutral until value is 5 above the changeover point (465 + 5 = 470). Start value is 500. Do not change to forward until value is 5 above the changeover point (550 + 5 = 555). To change back into neutral, do not change to neutral until value is 5 below the changeover point (550 - 5 = 545). *********************************************************************************************** Speaking of throttle, in addition to hysteresis, rate of change is important too. One way you can control how fast the motor controller responds to changes in the throttle is to use a timer function. In the timer subroutine, you can do your DAC changes there. You can set the interval for the timer, and how much you want the DAC to change to try to match the commanded throttle (pot ADC) request. Timer subroutine * Is main switch on & does the current DAC value differ from the commanded value? Exit if not true * Compare DAC to commanded, decrease or increase by desired interval This will cause the DAC value to only be changed if the main switch is on, AND the current value of DAC is not equal to the commanded value. The effective rate of change is set by choosing the timer interval and how much you want to change the DAC value on each timer tick. So a 25ms timer tick, with a inc or dec of 1, would cause a rate of change of 1 per 25ms. To go from neutral to full reverse would take ~5000mS (465-265 = 200... 200 x 25ms = 5000ms) This is approx, I did not count the instruction times, and etc. Keep in mind though, the inc/dec amount must be taken into consideration on the conditional if statement. Basically, with the above timer routine, it will only take action if the switch is on AND the current DAC value differs from requested DAC value. If current DAC is say 576, requested DAC is 577, and your inc/dec is say 2... You will never get 576 to eaual 577, and the loop will constantly go back and forth from incrementing by 2, then decrementing by 2. Using an inc/dec of one, and just changing the timer interval is easiest. Otherwise, you will have to use a greater/less then statement. In the example of inc/dec being 2, you would want something like (is current DAC value greater then 2, or less then 2). *********************************************************************************************** I've also had two shots of my fav whiskey during writing this, so hopefully I didn't mess up. Just kind of speaking outloud in the sense of a brainstorming session. Will be interesting to see you come along with the project!!! Sure, you can buy such a control from a boat shop or etc... But then you don't get the fun and learning excitement of engineering your own! Great work as always Mad!
Thanks for all that! I've been working on the code, and with the help of a few generous PRs over on github, the code is much better now. I just finished implementing a ring buffer to smooth out the throttle inputs, also (digimer/Mermaids-Rest over on github if you want to see the current code). I believe the Kelly controller does have a 5v reference. Given that the main throttle logic is sorted out, I'm about to move on to reading the other signaling requirements next and add that to the controller. The LCD I got is a simple I2C / SPI type, but it's red which will help on the night vision. That'll get bolted on a little later though. Soon (probably very soon) I'll be switching to an STM32 board, which also has a 12-bit ADC so I'll get the 1:1 resolution I wanted. Anyway, that's coming, first I need to spin the motor. :) Also, two notes on the throttle; I'll be adding a second pot with a toggle switch. So if the active pot starts misbehaving, I'll have a slider to switch over to read the backup pot. That should cover things breaking at bad times, and I'll have an entire second throttle ready to swap out once it's safe to do so. There's also going to be a separate e-stop button that will open to contactors feeding the motor in case of really bad behaviour from the controller. Lastly, I looked at the hall effect options, and I can't say I'm entirely sold. The Softpot is IP65 and totally sealed, save for the pins. The hall effect sensor has two issues I see; One is the incredible quick fall-off of the magnetic field (inverse square law), so it wouldn't take much for the magnet in the handle to move away from the sensor. Also, it requires a full circuit board on the receiver, which would need to be potted in resin or similar. Seems like I'm trading one problem for two others. I'm not saying no to a hall effect sensor, just that I'm not yet sold on it being over all better. Cheers!
Later in the boat you want to reserve 95-100% and 0-5% for safety. Meaning 5% input signal results in 0% output signal. This is due to the risk of shorts on the signal wire. Short to ground or short to 5V should trigger an error in the Arduino code. You don't want a short to give you full speed....
I think for safety it is worth avoiding the values of the 0-10 and 4085-4095 (break and short circuit in the circuit). Activation of the system should only be possible in the central position of the lever. Recalibration of the lever position should be possible without the need to reflash the Arduino. Arduino has function map() for re-maps a number from one range to another. A function is needed to prevent reverse without the lever passing through the neutral position!
I'll certainly test pulling / breaking the cables, but if there's a truly catastrophic fault in the controls, I'll hit the e-stop that will open the motor's contactors.
@@TheDigitalMermaid This can happen when the e-stop button is out of reach, for example, during anchor operations or single-handed mooring. I recommend creating a table with columns for "what I want," "how it should work," and "what if."
All potentiometers have a risk of failing due to oxide. Especially on a boat. I recommend using a hall effect sensor or hall effect angle sensor instead. These can be sealed with silicone. Or an optical sensor...
I've been looking at the hall effect, and it's an interesting idea and I might well try building the backup throttle using one. That said, I think it's a question of trading one set of risks for another... The Softpot is IP65 rated and sealed, the hall effect is a circuit board.
advise is to measure multiple times and maken an average. You will see situations the values will jump somewhere or strip out the max and the min value
Hello Mermaid, despite the fact that I hate electric driving I admire your electric boat project. What is a point of attention for me is that you keep a close eye on how you are going to place the batteries in the longitudinal direction of your ship. It is quite a bit of extra weight and I hope you are not supposed to build a "wave splitter" instead of a nice running sailing ship. Keep up the good work and greetings from the Netherlands.
Hiya! Every time I go to check on the boat, I spend time sitting there thinking about where to put the batteries for weight distribution. The raw added weight itself will hurt performance, but I don't think by much. What worries me more is trim... I can put a couple batteries forward, but then I might introduce hobby-horsing. I think at this point, I just have to install them and see how she sits in the water, and then experiment on how to trim her. Then see how she sails, and tune again. It'll be a whole thing though, for sure.
Love the format of your vids!! Looks like your motor controller is a variable power supply. It reminds me of a project I did in uni, wayyyy back. I think the task was to convert a digital output of a Z80 (showing my age there) to a variable voltage. My initial design was to rectify a digital output pulse stream and vary the pulse width with code to produce a variable output voltage (ie PWM). Anyway long story short, i changed my design after I found a useful chip, a frequency to voltage converter which was a bit more elegant. (LM2907]. I coded a simple oscillator output and varied the frequency to vary the voltage. This way you kind of have infinite variability of voltage. No DAC required..I also concur with some of the others about reliability. I think your worst credible risk is when motoring close to hard stuff, like in a narrow channel with current or in a busy Marina. You don’t want your controls messing up and a stop function is not much help in that situation. All the best. Looking forward to the next….
Aye, from the comments I've gotten, I've started pondering a new throttle setup (for later, what I have now works for dev). I'm thinking of a pair of hall effect sensors in one throttle handle, and a simple switch. So if the inputs suddenly went wonky, flip the switch to the backup sensor. Not yet entirely sold on the hall effect, but I'm certainly going to give it a fair shake.
Love what your doing :) I put in a 10kv gm motor in my 36 foot about 3 years ago and intended to build a throttle.. Still using a bike thumb with reverse button :( motor works great though . Your vids inspire me to finish it off . Great work
Glad the motor is treating you well! I'll be sharing all the parts and source code, so if I get this working, you'll have a template to copy if you like. :)
BTW... Dont prerecalibrate... Add a neutral point switch oe a switch that invokes a calibrate routine. Psh a buttom, request nutral, push again, set nutral position... Pretty sure the rest is self explanatory.
Use a 3d Printed 1:2 planetary gear to 'expand' the throttle's 175 degrees (steal a few degrees from each end so you never hit the dead zone) to 350 degrees. It'll give you a Lot more range on the pot. For the DAC calculations, don't bother with the minimums - let the controller do that for you. Your only concern is that the center of the range is as close to 2.5 volts as possible.
Aye, someone else made a similar suggestion, and it's a brilliant idea! I hope to avoid it only because "more moving parts", but if I need more range, that's a great idea to have to fall back on.
Seriously, that "potentiometer" like thing is a disaster. Might be a good idea at the boat due to salt getting to standard pot, but I would 100% go with magnetic angle sensor (AMS as5600). You can get it as a module for few bucks and it is 100% reliable, not impacted by salt water, fully digital, etc.
I can't help thinking - you'll have a piece of dirt or something falling into the pot-like thing, making it unusable and your life a nightmare - to reverse engineer that SOMETIMES a piece of dirt engages with the angle of the pot and sometimes not...
Someone else recommended the same system, and it's something I've started looking at. I might well try that in another throttle later, as much because I think it's fascinating as anything else. For now, I'll use this because I have it. The plan for the real throttle though will completely enclose the softpot, so debris being a problem isn't likely. That said, that's what the "oh poo" button is for, and I'll have the throttle itself setup to unplug / be replaced quickly with a spare. Always happy for folks to reach out, my email address is under the About tab. I'm very fortunate to have help already from Andrew and a couple others, but I'm always happy for more advice, never know where the next great idea will come from. :)
@@TheDigitalMermaid If you change your mind, don't hesitate to get in touch, I'll be happy to help. I know how pots are in sea water and how quickly they die. This "push-through" might be better isolated against salt and minerals, so it might be less of a problem. But for version #2, I absolutely recommend going with AS5600 - if for nothing else than for the fact it can be completely covered and isolated from its magnet - as long as it's close. But overall great video - happy to see you in positive mood again! :)
@@rklauco Very much appreciate it, and also the code is up on github (as simple as it is at this point). So if you ever have suggestions, advice or whatever, I'd very much love the feedback and even more, PRs! And yes, the more folks suggest going hall effect, the more I am leaning towards it for the real throttle.
Hi Maddy. I love the progress you’ve made so far. It’s fascinating to watch all of these parts start to come together. If I may, I have a suggestion that may be of use before things like your helm control become more fixed. I was an Audi and am now a Tesla mechanic by trade and a common failure I find in electrical system’s is 0v when there should be something. I don’t know what options there are on the Kelly controller for voltage range and I know that I for one would rather stick to the joystick mode but is it possible to program in a fail safe voltage range? In a lot of 5v systems I work with, the operating range is actually 0.5 to 4.5. Yes this limits the available voltage sweep but it will stop the risk of 100% throttle in the situations where the arduino may hang, dac failure, IO faults, harness wear/corrosion or even if any power issues occur to the helm control causing it to turn off. Just a thought to ponder. We all hope that faults won’t occur but I wouldn’t have a job if they didn’t. Much love and good luck.
Hi Will! Thanks for the kind words. ^_^ I've not yet started playing with the controller, hoping to start that tomorrow. That said, I will try cable-out tests to see how it reacts. I'll also be adding (later) an e-stop that will cut the power to the motors using the motor's contactors at the helm, completely bypassing everything if all hell really breaks lose. Once I know what options are available in the Kelly, I'll be sure to share them on the next video. I'm hoping there's a way to say "stop the motor is X is lost", but we'll see. :) Also, I work in high-availability, it's also my job to constantly ask "ok, but what if this happens?" so I super appreciate the insight. Unlike HA in servers, this is all new to me. :)
HEEEEEY!! I dont understand a lot of it but I like that you are real about you learning some of it too and explaining as best you can. I hope when I get ready (and have my boat) we can work on it together :) Miss your face!
The one thing I'm trying to show here is that whatever it is you (or anyone) might not know anything about, but want to try anyway, is to just go for it. Have faith in yourself that you can figure it out as you go. When you get your boat, we'll certainly get ya sorted out!
So I misspoke in the video, it is an I2C interface, which is what I plan to use. It also does SPI, and RS232 even. If you're curious, it's a Newhaven NHD-0216K3Z-NSR-FBW-V3.
You might want to considder RPI and node Red... Super slow, in absolute terms, but several orders of magnitude faster than you need and several orders of magnitude to impliment.
Aye, I suspect you're right, though I also would like it to be smooth for the motor when not loaded, too. Some folks have suggested using a cap to smooth the output also, which I really like and will try to use along with a ramping algorithm.
So is that pot two conductive sheets relying on a pressure point to make contact between them? If so, wouldn’t it be possible for salty humidity to get in there and eventually cause excess noise?
That's how it works, yup. It seems to be completely sealed though, so I think it'll actually hold up better than a rotary pot. Of course, time will tell, but that's why I'll have at least one full spare throttle in storage, and parts to rebuild one. If it proves unreliable, switching out for a rotary pot down the road shouldn't be too hard.
You need an amplifier.... With an offset. Asume pou pot give you a rail to rail swing and your physical implimentation limits you to the middle 50% of that. a simple OPAMP can translate that in to a rail to rail swing of the imput signal to the arduino. OPAMP's compare two voltages... So if your pot can give you 0v to 5V and max deflection is 2v to 3V you need an amp that outputs 0V at 2V input and 5V at 3V input. Look for instrument amplifier circuits wit an offset.
My friend Andrew who has been helping me has his background in audio equipment design, so we're often talking about noise and whatnot. If an opamp will help, I am certain he'll suggest it. As of now though, the biggest limit is the pot input, but switching to the STM32 will switch that from 8-bit ADC to 12-bit, making it 1:1 for the DAC.
You need a microphone at the bottom of a steam-era voicepipe and voice recognition so you can shout engine orders at it. ...And now for our regularly scheduled sincere suggestion: Diversity in your new BMSs so they don't all go down for the same reason.
If I was during a restore on a century boat, I would soooooo do that! On the BMSes, in a real pickle, I could bypass the BMS. (Not a great idea, but it'd work in an emergency).
You can change the pot values to a smaller range. Also, negative values using the map() function. example: -10 to -1 are reverse speeds 0 is neutral and 1 to 10 are forward speeds. example:potValue = analogRead(potPin); // Read the potentiometer value // Map the potentiometer value from 0-1023 to -10-10 mappedValue = map(potValue, 0, 1023, -10, 10); // Print the mapped value to the Serial Monitor Serial.println(mappedValue); delay(100); // Delay for a bit to not overload the serial port
@TheDigitalMermaid The benefit is readability, which means maintainability. You should be able to look at the code after a year and pick it right back up. Map with a comment or two should be simpler to maintain than the "complex" if else block.
@@TheDigitalMermaid If you swap to a different potentiometer you don't have to redo your calculations. Just measure and punch in your new min and max values.
I know 100% why it's got a bad reputation for being a "write once" language, but it's the most flexible language I've found. I love how unrestrained it is, and how creative it lets you be.
@@TheDigitalMermaid mate everything gets a bad reputation these days as everyone has opinions on why something looks worse than something else I use JavaScript almost exclusively because of exactly the same reasons as you, it just gets out of my way and lets me do cool things They are all tools at the end of the day
I'm waiting on insurance and a closed marina... There's no sailing happening for a while, so I'm working on other parts of the project so that once I can get underway, as much is already done as possible.
@@TheDigitalMermaid oké, but keep in mind please, it has to be monkey proof, because it can be very rough out side sometimes,and than you must can rely on it.
@@caroleen2000 One of the appealing things of the Softpot is that it's IP65 rated, and I'll either pot or conformally coat any of the electrics that will be up in the cockpit.
// Define the potentiometer pin const int throttlePotPin = A0; // Assuming the throttle potentiometer is connected to A0 const int motorControlPin = 3; // Example pin for motor control (PWM capable) void setup() { // Initialize serial communication for debugging Serial.begin(9600); // Initialize the motor control pin as an output pinMode(motorControlPin, OUTPUT); } void loop() { // Read the potentiometer value (value range is 0 to 1023) int potValue = analogRead(throttlePotPin); // Map the potentiometer value to degree (0 to 180) int degree = map(potValue, 0, 1023, 0, 180); // Now map the degree to motor speed values (-255 to 255) // Assuming at 90 degrees, the output is 0 (stop) int motorSpeed; if(degree == 90) { motorSpeed = 0; // Boat is stopped } else if(degree < 90) { // Reverse motorSpeed = map(degree, 0, 89, -255, 0); } else { // Forward motorSpeed = map(degree, 91, 180, 0, 255); } // For an actual motor controller, you might need to adjust how you apply motorSpeed // This example directly writes the speed to a PWM pin for simplicity analogWrite(motorControlPin, abs(motorSpeed)); // Debugging: Print the values to the Serial Monitor Serial.print("Potentiometer Degree: "); Serial.print(degree); Serial.print(", Motor Speed: "); Serial.println(motorSpeed); // Small delay to reduce noise/jitter delay(100); }
Thanks, Rupert! With the help of some kind folks who created PRs, I've got constants, map() and constraint() now working. I also got time today to add a ring buffer to the throttle input to smooth things out. If you're curious, the updates are in the main branch in the github repo in the description. :)
Nice job on getting your Arduino up and running! As for the resolution issue, if you find you really need more resolution, you might consider using an external ADC like the ADS1115. I honestly expect you need a lot less resolution than you think, though. My guess is that you just won't have that much mechanical resolution due to friction of the rubbing surfaces producing a skip like motion, but that is the sort of problem you can solve with lubricants if you decide you need to. It also strikes me that you might be able to replace this whole arduino + DAC with an analog circuit if you wanted to (presumably this could be more reliable). I believe the circuit you are aproximating is called a Differential Amplifier, which is a circuit you can build using an op-amp. If I understand correctly, you need to scale the output from the potentiometer and subtract an offset, and that is something you can do with a differential amplifier circuit with no code involved at all.
I'm starting to think the 200 steps is going to be fine, and some folks recommended adding a smoothing cap on the DAC's output as well. I suspect that'll be good to prevent "jitter" in the motor. In any case, I'll get the motor spinning and then see if it's really even a problem. As for the digital control; I've got longer term goals that will require digital control, hence why I didn't go analog from the start. :)
Hi Madi, Any insurance news yet? My guess is that the resistance disk days are over. It would require a lot of mechanical stability which would be expensive to print/cnc/mill etc.. Next to that, you had on hand experience (nav lights) how corrosive the environment is on sailboats, which slowly adds in time to an unknown amount of voltage drop. Even with a 100% connection, the cabledistance alone would already require an output compensated input voltage. So maybe Hall effect sensor, stepper pot, etc might be a better option and mechanical more easy (cheaper) to work with and electrical much more stable. Hall effect sensors are often used as input for a controller for DC motors, as 3D printers, crankshafts rpm and positions, ev vehicles etc. The thingy about them though is that they are linear. Ideally you want to set or control torck as well as speed and those not linear way. Since the whole contraption....aka all physics and mechanics, aka your boat:)) will have a non linear speed aka movability response to a linear power input. if done right should/could/might be:)) compensated. For sure with a nice user adaptable graphical curvy interface, on my phone and a switch at the helm. And when i going to dock i click a manual button or a pull a handle to to choose the ideal speed/torck config for docking. How nice would that be:) Good luck with exploring, discovering and creating!!
Unfortunately, no, nothing new on the insurance front yet. I'm staying hopeful though. What do you mean by "resistance disk"? In the final design, I might well move the output dac to be very close to the motor controller so that it's a digital signal for the majority of the length on the wire, and have the output voltage only for a very short run into the pin.
Ai, thats frustrating. Since basically your boat is "physical" and electrical the same, just pull out the motor to be able to sell it. Call/mail the insurance company with the question to lower your policy price because of the planned removal of the motor:))) (mail or record this) Simply because you do have an information duty if a significant change to the goods insured happens. Which is in that question. And just keep the old insurance until the conversion is done and checked, another significant change to insured goods. With resistance disk, i ment the Spectra Symbol "hot pot". Another possibility regardless of electronics used might be to keep the throttle handle fully mechanical. The morse cables are now already running waterproofed to the dry motor compartment can be used. There they connect to a box with the hot pot, dac etc inside and some metal parts (quadrant ) to attach the morse cables to. Think of it as the helm that move by cables a quadrant that controls the rudder. That way you have all the strength and a lockable neutral and are all electronics inn a nice dry close by environment.
Considering this is a rather critical control element on the boat, I’d strongly suggest using a purely analog design. Imagine how disastrous it would be if the arduino crashes or goes haywire while doing a critical manoeuvre! A few op-amps could do the required translation very reliably. You could also easily add offset and gain trim pots, using multi-turn potentiometers so that it can easily be calibrated to the final lever mechanism. Using rail-to-rail op-amps, powered by the 5V from the motor controller, it’s also impossible to damage the input. Finally, no worries about resolution. I love microcontrollers by the way, and use them a lot, but in this case it just seems like an overcomplicated liability, IMHO at least.
There's some features I've got planned that require I have digital controls, but that said you point is very valid (and partly why the "oh poo" button is there from literally day 1). A couple changes I'm already leaning towards is switching to dual hall effect sensors, and have a switch in the throttle so that if the controls act up, I can switch to the backup encoder. (As well as having a spare throttle assembly ready to go for quick swaps).
I believe a hybrid is possible. Use a pure analog design for the throttle. Then mix in the DAC output for the digital features. Digital features only available when mechanical throttle is in neutral. Or something like that anyway 😂
love the energy and style of your video`s. Maybe a ADC (12 or 16 bit) would be helpfull to get more resolution. Also are you familiar with the map function could also be an solution. greetings from the Netherlands.
@@TheDigitalMermaid that would help. Unfortunally i live in the netherlands, but i would like to offer help with 3d printing or electronics. I am by no means a professional but as i like to call a fanatic hobbyist. I do al shorts of projects for the last 15 years and love to see other people do that as well.
@@wouter481 I really want to get over there and do a winter in Denmark. I'll certainly be visiting Neatherlands then, so who knows! I might well have a need for some help printing stuff then.
Is your arduino measuring the resitance? Or is is measuring the voltage at the wiper? If it is measuring the voltage, as I suspect is the case, and 0-5 volts gives 0-1023 (10 bits) of value, there is a very analog way to get the full 1024 count range with less than full rotation of the wiper on the track of the potentiometer. If you are willing and able to create some extra (regulated) power supply voltages, you could put, for example, +8 volts at one end of the pot, and -3 volts at the other end of the pot. With 11 volts in total across the pot, the middle point would be 5.5 volts positive with respect to the - 3 volts end, which puts it at 2.5 volts, exactly what you want it to be. The zero voltage point would be at some point partway toward the - 3 volt end, and the the +5 volt point would be at some point partway towards the 11 volt end. Second solution, which does not require any extra supply voltages: use another analog method. An op-amp and a few resistors could be used to amplify the voltage change from say 1 volt to 4 volts (as the pot moved over less than its full mechanical range) into a swing from zero to 5 volts. Third solution: purely mechanical. Use a pair of gears, or a pair of sprockets and a chain, to change some modest degree of motion in the throttle into whatever is the full range of the potentiomenter (typically 270 degrees.) I actually like the third choice best. It is very obvious and intuitive to design,, It is simple, and adds no electronic parts to possibly fail. It also works even if the Arduino is measuring the resistance, and not a voltage. Last thought - I doubt you would like a throttle lever that moved 180 degrees. Straight up for neutral, forward 45 degrees for all ahead, and back 45 degrees for full astern is what I would expect. With gears or sprockets and a chain you could turn that 90 degrees into whatever the pot needed to get end to end...
The Seeeduino has an 8-bit DAC iirc, so that's what's reading the pot. When I switch to STM32 or ESP32, that should bump up to 12-bit. For now, the current resolution works.
Have not read all messages, I first say. Have you tried to use the "map" function or/and function , for more stable results... (in Arduino IDE for esp32 or Arduino, Seeduino mm)? I also would consider to try and IMU (bno055) and compensate for the waves to a horisontal plane, then use the Output (smooth it first and Map it to a Output V/A)). Haven't tried it, no boat person. Good luck!
Have you considered the failure mode where the helm throttle control loses power and puts out 0.0v and the motor controller decides to go FULL REVERSE with no throttle control? I'm not sure if you have control over how the motor controller deals with its inputs but it would be a good scenario to at least be aware of!
That's what the switch was for, the "oh poo" button. If I flip that, the throttle position is completely ignored and the DAC sends out 2.5v. There's also going to be an e-stop later that will disconnect the motors (probably at the contactors), as per ABYC requirements.
@@TheDigitalMermaid I think what the comment was saying is that the "oh poo" button needs to ne independent of the circuit. If you loose power there won't be a uConteoller to set the DAC to 2.5. Depending on the DAC the output might look like a pull-down to 0v or full reverse. Could be bad...
@@coryfrey5040Ah, there's going to be an e-stop button (required by ABYC) that will cut the power to the motors (via the contractors) as a last line of defence.
Did you ever look into e-moped throttles? they're based on a hall sensor, so no contacts that can corrode, and they're about 90° 0-100%. Plus the rotation mechanism is already there...
Great video! You mentioned porting to STM32 eventually. I haven't used STM32, but I transitioned to ESP32 a couple years ago. I believe both ESP32 and STM32 have 12-bit depth on their analog inputs, so you'll have 4X as many throttle steps as soon as you port over. In my experience, when driving a motor w/ Arduino, the steps are quite audible bc 1024 steps isn't quite enough, but it should be nice and smooth at 12-bit.
Oooooh, I'll ask Andrew about that. If I can step up the analog inputs on the STM32, that would be fantastic. I'm almost out of memory on the seeeduino, so I might well be switching to the STM sooner than later (but not until after I spin the motor! ^_^ ).
I've recently transitioned from Arduino to ESP32 and they're amazing. My intention is to build a bunch of DIY sensors, controls and displays for my boat (doing a full refit) and those things are wonderful.
@@dquixote0980 This is exactly my plan, also. The throttle is just the first "gentle" project to start learning with. My end goal / dream is to create a bunch of boat related things that are all open hardware/software. I'm really keen to make everything on the boat hackable if I can. Obviously, some stuff will have to be commercial, but hey, I'll see how close I can get. What kind of projects are you working on for your boat?
@@TheDigitalMermaid I would likely use an ads1115, put it in diff analog mode. I would also plan for failure, since the speed controller could be connected directly, make the wire plug compatable so you could bypass the arduino logic and go direct incase you need to. Have a backup plan for controlling the motor speed.
@@patrickdk77 From what I understand, the STM32 should have a 12-bit ADC, which is good enough given the DAC is 12-bit also (1:1). Is there another reason I'm missing to look at the ads1115 for?
As a long time user of joysticks for decades, never met a potentiometer thats lasted a few years without drift or generates a noisy signal. Any love for swapping to using a hall effect sensor?
Weird, I replied but it looks like youtube ate the reply. Sorry if this ends up being a duplicate message. Annnnnyway; Ya, a few folks now have pointed me at hall effect for throttle position, and I might well do that when I build the real throttle. For now, this works and it'll let me move on, but the idea of magnets and totally sealed parts is appealing.
@@TheDigitalMermaid What electric vehicles do, I believe, is to use a pair of pots, mechanically hooked together, for the throttle. Take readings from both and compare. If they're substantially different, throw some sort of alert and go into limp mode. Or at least, only use the sane one, however 'sane' is determined. I'd even consider doing that with Hall sensors too, for redundancy.
@@tubeuser2350 If I was going to do that, I'd follow the aerospace model have have three, discarding the outlier and averaging the other two. I might do it because it sounds really fun, but it's overkill for an auxiliary power on a sailboat.
I didnt hear/remember it mentioned (whether in this episode or previous episodes), but why aren't you using a rotary encoder instead? To me it's seems like it would alleviate a lot of the problems you're experiencing with dodgy-contacts/connections?
The Softpot is IP65 rated, and the rotary pots I found (that weren't super expensive) were lower rated. So I trust the Softpot to hold up better over time against corrosion, being a sealed system. That said, several comments have suggested I look at hall effect sensors, so when I get closer to making the real throttle, I might experiment with that also.
As far as I know there is no Arduino lib rary for STM32. So porting the code might be a bigger task. Might be easier to go to one of the ESPSeries (the S3 and C6 are nice) or a Pi Pico. For all of them there is an Arduino library available. And in fact, the ESPs have a 12 bit ADC, which might make your life easier.
Given I'm already running low on memory, I"m probably going to be switching over to the STM32 sooner than later (but not until after I spin the motor!). The code I have now is pretty simple, so even if I have to rewrite it, it's not the end of the world.
@@TheDigitalMermaid you can reduce your memory footprint significantly by declaring all global variables as 'static const' because in fact they are constants. I'll try to prepare a pull request for that.
I thought about this, it's a common suggestion, but I think I'd be trading one problem for another one. I can fairly easily adjust the set screw with the acrylic ball that pushes onto the softpot, where the magnetic field needs to be pretty close to the sensor. Also, and more importantly, I'd be replacing a passive, IP65-rated device with a device that has a circuit board on it. Sure, I could conformally coat it, but six of one, half dozen of the other.
Ya, there's two morse cables (forward/neutral/reverse) and throttle. They're SUPER inconvenient being almost astride the hub of the wheel, and often I find myself reaching in through the wheel to reach them. Even if I was staying diesel, I'd replace them. I _really_ don't like them. :)
Also, the panic button for 2.5V, why a seperate control? Your hand is on the throttle while trying to control it. Larger, more intuitive interface to react with compared to finding a switch/button. Why not keep intergrate the 2.5V trigger into a physical part of the throttle lever? If you have it physically gated in neutral, say... a small handle which drops into position and keep it in neutral, it could close and force the 2.5V for you without needing to determine range and lose further angular resolution for your forward and reverse ranges? The physical gate means you can panic slam it to neutral and it wont overshoot into the other direction of travel. Just thinking as I watch this. The only good example i can think to demonstrate the physical gate with an handle on an arc thats internationally proven in a safety critical environment for panic and assuredness of selection - boeing 737 flap lever. Theres some great examples on Honeycomb Bravo throttle quadrant modification kits. Food for thought. :)
The idea behind the "oh poo" button is to override the throttle in case it screws up. If I put it to neutral but it's still reading full forward, I want to be able to force it back to neutral, ignoring the pot entirely. Where that button goes, that's not decided and putting it into the handle is entirely possible. That said, I do plan to have detents in the real throttle to make it easier to "feel" neutral without actually looking at the handle.
Unfortunately I don't have anything to add about the controller. But when it comes to the motor, you don't have to stress about cooling. With no load it won't generate much heat. To be on the safe side and the fun of building, it's ok to get inspired by overpriced PC cooling, but look elsewhere for parts. Unless there are water cooled servers...
I originally planned to use a car's heater core as the radiator, but the pipes for the motor and controller are in the 1/4" size, and the only radiators I could find with similar sized fittings were the PC ones.
Aye, another commenter pointed me to map() also. I'm curious if there are other benefits to it, given that I've got the logic sorted now. Is it faster / more efficient?
@@TheDigitalMermaid Not sure about the faster / more efficient benefits but the function sure makes it a lot easier for me. Just remember the function uses integer maths so some accuracy/precision will be lost.
@@georgef7754 It might already be an ESP32 I've got, I'm not yet sure what the difference is, but the demo board my friend sent me has wireless on it already. I said STM32, but maybe I've got that backwards.
your throttle mapping, do you need that much reverse? I know nothing about 'driving' a boat just i've never seen a car setup that way to do full speed in both directions. .
A couple others made the same suggestion, and if I find the resolution is not fine enough, I might well cut into the reverse to give more to forward for just that reason.
@@TheDigitalMermaid i must admit to being puzzled by the need for the resolution, my big white van throttle has 3 positions lol, idle waiting for the green light, full when there's green light and open road, middle in town traffic....... (Also For three years I was an overnight to 7am intoxicated human delivery vehicle, get em in, get them home, fly back for the next ones)
@@lezbriddon Partly it's because I don't want jerky movement, but I'm starting to think that 0.5% throttle changes on a boat will be fine. A bigger reason has to do with future project planning... I have a longer term goal of measuring several parameters (motor power input, rpm, throttle position, wind sensors, speed over ground, speed in water, etc) and start calculating what the optimal throttle position is to maximize range. The more resolution I can get from the throttle, the more I can dial in that math.
@@TheDigitalMermaid ahhh yes being more granular will allow for better fine tuning the economy/efficiency. (Although I do think the fine steps Vs more course (2.5%?) Would not be that jerky with the elasticity of the prop in water Vs boat mass, although would be a bummer if it was)
I've been thinking about it as I think about how to do the ramping logic, ya. I'm leaning towards immediate neutral if the "oh poo" switch is hit, as it could be needed if something fouls the prop or someone falls in near the aft of the boat. In other words, if I hit the "oh poo" button, stopping the motor is more important than the health of the motor. I _might_ still ramp it, but maybe more aggressively? I'll have to see how the motor reacts in the real world and then I'll decide.
Can you do some mechanical work ? Maybe use a 2:1 gearing. If you have access to a laser cutter this can be done. However 256 steps forward and 256 reverse might be okay.
Oh now that's an interesting idea... Obviously I'd rather avoid the complexity, but if I just can't get the resolution I need from the available range of motion, that could be a solution. THanks!
If your Arduino 5V supply does not have the same voltage as the Kelly controller, there could be some issues. Like neutral input is not interpreted as neutral by the Kelly controller. Can you let the Arduino measure the 5V of the Kelly controller to calibrate/adjust the dac output with some maths in your code...
I've not shown it yet, but I've got chips to specifically provide the 5v signals to the Kelly. Not sure how they work yet, but Andrew had me pick them up and I'll be sorting that out soon.
I could yes, but it wouldn't suit the helm controls of the sailboat. They're generally worked quite differently from a motor vessel. Also, I really want to come up with a design that, when it's done, would look like it could have existed in 1981. :)
@@TheDigitalMermaid Just need to hack saw out the sensor portion, then add the a handle to suit. At PWC we used boat throttles modified adding multiple RVDTs to control our experimental jet engines.
@@universeisundernoobligatio3283 Aye, but at that point, I figure I may as well start from raw parts and not have any gaps in my understanding on how things work. :)
@@TheDigitalMermaid Always good to learn new things. MG chemicals has a silicon conformal coating. I use on any exposed copper to keep moisture away and slow corrosion.
Hrm, now that's an interesting idea.... If I find the 200 steps isn't enough for a smooth transition, then sacrificing some reverse smoothness might be a good idea. Thanks!
@@TheDigitalMermaid You might have to do some research which make and type has the longest life time (number of turns) and is the most rugged. Usually the turn smooth as butter
You could do it in code but you loose resolution... If you want to do it in code look for a higher resolutoin DAC, I2C, onewire, whtever... reading a 12 bit input gives you 4096 values, ao 2048 descrete values so 1024 forwaed ans reverse. Smooth enough I expect but if not DAC's at 16, 32 an even 64 bits are avilable.
I've not used it yet, but I did look at it. When I start porting over to the STM32, I might switch. I wanted to do the math myself, at least at first, to help me understand the logic.
@@TheDigitalMermaid if else chains can get really confusing. Using a switch statement usually makes it a lot clearer what's going on and how to adjust it. It's not really more efficient in the sense of processing, It's just generally cleaner and easier to read. Also don't be afraid to create functions that you reference as a way to help reduce the amount of code inside a statement. For example if you want to adjust the output voltage you could have a function that says set voltage. You input a voltage into that function and a time and it adjusts the voltage from its current location to the new location over that period of time. You could also have it so instead of a period of time it's at a certain rate. So it adjusts from the current voltage to the new voltage at the rate that you input into that function. That way you don't have to keep writing the voltage changing code over and over.
@@TheDigitalMermaid whatever works for you man. What I'm talking about is mostly a coding guideline. A switch statement only is more performant if you're if else chain is like a hundred conditions long lol also switch statements cannot have conditions in them only values. Just different tools for different needs :) honestly the fact that you're learning to code it all is amazing. It's like learning a new language. It took me years to get the hang of it even then there's always something more you can learn something deeper. However functional code is always better than theoretical code lol Good luck on your endeavors you gained a subscriber :)
Still no apology for your outburst and ridiculing of JK? I actually enjoyed your channel but now I’m a bit pissed when seeing you release a video instead of yey a video from Maddie. I’ve even seen posts where people from here have warned people from using JK and referring to your video on Facebook groups. That make me so pissed that you still have not removed it or made it clear that it is NOT an issue. The problem was on a product Andy has gotten rushed to market. Early adopter issue that was resolved very quickly. Your outburst has made ppl sceptical when they don’t have to be and now might choose inferior products just because you had to yell. Pissed. I’m unsubscribing. Bye Maddie.
I'm not sure what I need to apologise for, I was expressing my opinion. I thought I made it pretty clear in the video (and in the follow up) that my position stems from a series of bad experiences, with the issue Andy had as "the last straw", not "the whole bail". I even mentioned in the follow up that the problem was fixed in 14.17. I'll try to clarify again; I feel like I have a responsibility to be clear about what I, personally, feel to be OK and not OK in marine / electric sailing environments. In *my* opinion, I stand by the fact that I don't think JK are appropriate for the various reasons I stated. I never said others shouldn't use JK, only that _I_ don't recommend JK. I think I even mentioned that, in static installs or even in installs where you can "pull over and get out", I would understand why JK is appealing. In a boat though, the lack of QA testing and the inability to order a part number and be sure of what you'll get is a deal breaker for me. I'm sorry you're angry, but I have to stand on what I believe.
@@TheDigitalMermaid what piss me off is that yes you should have the highest grade of safety in maritime environment. But look at you building that motor controller. Where are your security there? If that was your goal why do you not buy a turnkey system from a reliable brand that you can turn to if something is wrong. Like I said the BMS Andy mentioned was an Alfa product. That was fixed immediately. Your motor controller is a bigger risk than an BMS. Your opinion sharing has made an impact where I see reference to that in comments about people building systems that’s NOT maritime. They get shit for picking JK when JK is a good product for them just because of your issues that stem from your hand built power supply for the monitors that created a phantom load. There is nothing wrong with JK BMS’s itself. Good quality and they have features no other BMS has and now you’ve scared ppl away from an perfectly good product. I’ve unsubscribed so you won’t have to deal with me any further but I will make it clear on any post I see on the diy forums and groups where you are mentioned that it’s not an issue.
@@pederb82 A product for sale to end users, that doesn't require signing a release, is not "alpha". In any case, I explained that I've had multiple issues with JK, including getting stuck with two useless BMSes because they changed the features without changing the model number. If people don't understand my position, despite repeatedly clairfying my position, I don't know how that can be my fault. Again, I'm sorry you're upset, but this is my position. As for the rest of the build; There was no commercially available system I could find that suited my needs and wasn't a black box. I need to be able to repair my system on my own when I'm in remote places. That is my safety. There's no calling for Sea Tow in the North Atlantic.
Also also how does the idea of having your throttle lever in a gate shaped like a runic S (ᛋ) where the center gate has a discrete switch to inhibit the motor? I could probably come up with something like that.
I wanted to keep a more traditional type throttle, is the main answer. That said, I also often "pulse" forward and reverse while docking, and I'd prefer the smoother operation.
@@jimsvideos7201 For the regen slider, yes. For the throttle, nah, I like the circle. I could do it with a linear softpot over a curved surface, but unless I decide on a pretty different design, the rotary is the way to go.
@@TheDigitalMermaid Keep in mind you now know a crafty amateur machinist with a pretty strong background in mechanical things, don't be afraid to think outside the box.