I am adding a water pump to my blueboat payload which I would like to be able to increase and decrease the power of using a PWM signal to change the flow rate.
I have already established using the navigator to control relays by mapping high/low toggle switching to GPIO pins on the navigator board corresponding to buttons on an XBox controller. What I would ideally like to do next is to be able to increment and decrement a PWM signal on one of these GPIO pins using buttons on the XBox controller.
I imagine I will likely need to set some Autopilot Parameters in BlueOS. Then in Cockpit, I will likely need to create and action. For that I am wondering what the command ID should be. I also assume I might need to create some sort of DataLake variable; any help on the coding front here would be valuable.
Any help that can be provided on this topic would be appreciated. Please be as verbose as you need when explaining.
Hi @willronan -
Before diving into the software side of things, I wanted to clarify your hardware setup! Is the pump you plan to use controlled by a 3.3V PWM signal? Is this a servo-style pwm, or generic PWM? Are you using a FET to receive that PWM and send more or less current?
Without having the right hardware setup, none of the software stuff matters⦠And it is easy to burn out a Navigator output pin if used incorrectly, as they can only source 15mA, across all pins total!
Thank you for the quick reply and for checking. We want a regular PWM signal. The pump needs a 5V signal so we plan to get that from the BlueBoats fusebox, then use a MOSFET as you have suggested controlled by the GPIO pin to encode that 5V source with the PWM signal. The pump will not be drawing any current from the pins
Hi @willronan -
You can provide 5V from the fuse board, but the signal from the Navigator is 3.3V. Are you saying you intend to switch 5V going to the pump, via the FET?
If the pump motor is only 5V, it may be preferrable to use another controller that does use servo-style PWM input? Is the pump brushless or brushed DC?
See this thread for info on how to configure the output to be non-servo style PWM.
Sorry, I misinformed you, the pump is actually 12V. There is a better electrical engineer than I working on the circuit schematic. I will take a look through the thread you shared and let you know if I run into any problems!
In the linked thread, I see that these Cam Tilt and Cam Pan controlls can be forced to be within the desired PWM range, I will give that I try an update. As for the second half of query, do you have an expertise on how I can create and action to control this PWM signal using Cockpit and map the action to buttons? I will not be able to test these updates until next week so it would help a lot if I could attempt both in one sitting when I am able to get around to it
This comment should be a good starting point for the configuration of duty-cycle based PWM, and links to a thorough example of setting up control of an output with a slider. Feel free to follow up if you get stuck on parts of that.
If you really want increment/decrement control via the joystick,
My apologies for the long delays. I am back to working on this project and have read through the support discussions that have been linked. To clarify our approach, we plan to use a driver to control the voltage of the pump based on the PWM signal.
From what I have read, it seams that to use a non-Servo PWM signal, RC_SPEED needs to be manipulated. If I am not mistaken, on the BlueBoat, the Navigator is used to control the thrusters. This thread suggests that by doing so, all PWM signals including those to thrusters will be affected
The instructions you have given me here seem clear enough, however, if I go through with this and change the PWM to be non-servo, will I cause side effects to my thrusters. If that is the case, are there any alternatives or mitigations you could recommend?
That is incorrect, but to interpret pulse durations as a duty-cycle you also need to know the frequency the pulses are being sent at (e.g. a 5ms pulse sent every 10ms (100Hz frequency) is a 50% duty-cycle, but if the pulses are sent every 5ms (i.e. 200Hz) then 5ms pulses would fill up that entire period, which means the duty-cycle is 100%). Reading a parameter value is usually easier than measuring a frequency with an oscilloscope, though note that ArduSub and ArduRover do not share all their parameters - SERVO_RATE should be the relevant one for a BlueBoat.
For context, servo-style PWM only cares about measuring the pulse durations, so the frequency just affects control latency and sets a limit on the maximum pulse length (e.g. pulses sent at a 5ms period cannot be longer durations than 5ms or itās not clear where one pulse ends and the next begins).
Duty-cycle PWM is focused on the ratio between the pulse durations and the transmitting period (which defines the frequency). In that case the frequency still affects latency, but also determines how the signal is interpreted, and affects how smoothly changes are applied. As an extreme example, having a 30 second pulse followed by 30 seconds off is technically a 50% duty-cycle, but thatās likely not how you want to run your pump, and is unlikely to be interpreted meaningfully by your driver. A very high frequency could be a bit smoother, but then requires more precise timing electronics and may cause issues with other functionality.
The servo-style PWM signal sent to the thruster speed controllers (ESCs) can be up to ~490Hz before it becomes harder for them to interpret it. I suspect that would be fine for your pump driverās input control signal (and 50Hz could well be fine too), but youāll need to check its datasheet. Some electronics require higher frequencies to reduce undesirable vibrations or flickering, and if you need a higher frequency than the ESCs can cope with then thereās an incompatibility and youāll need to explore alternative solutions (like a servo-style PWM-controlled driver for your pump).
Great this makes sense. I was able to get what I wanted by setting SERVO_RATE to 400Hz setting SERVOn_MAX/MIN to 1100 and 1900 giving me room to adjust the duty cycle from about 40ish% to 80ish%.
You should be able to āforceā the min/max parameters to cover the full 0-100% duty cycle if thatās desirable. The Navigatorās PWM driver can achieve the full range
Since the limits (unlike the frequency) are set independently per pin that shouldnāt affect the signals getting sent to the motors (or other attached peripherals), so you donāt need to keep them within the servo-style PWM range.
That is great thanks for the advice. I have one more question.
Our setup uses a PMOS to control the motor. We would like the motor to be turned off when we power the system. In its current configuration, the pin starts low, until I toggle a slider that sets the PWM. After which, the pin continuously provides a PWM. I there a way to have the pin at a high voltage on start up while keeping this functionality with the PWM? If not, we will have to rethink our hardware as with the PMOS, a high signal keeps the switch off