-
-
Notifications
You must be signed in to change notification settings - Fork 109
How to use a VNH2SP30 DC motor shield with MobiFlight
The board has since been discontinued by Sparkfun, but as it was originally open source hardware design, there are clones around, and I got one from Aliexpress to play with some ideas. You can find plenty ones (also with information about low quality clones that do not work or fail, as usual with these kinds of modules). Search for "VNH2SP30 motor shield for arduino". It mounts as a shield on top of an Arduino Leonardo here without wires, which works with Mobiflight as a Pro Micro, they are essentially the same with just a different board form factor.
The board has the ability to run DC motors with pretty high currents, and you can control it with PWM and some data pins to set desired operation (clockwise, counterclockwise, brake, and speed). There are arduino sketches around with test code, but I wanted to just hook the pins into Mobiflight, and possibly control it with data coming from the simulator, because it works with two control pins and PWM for speed control, and one pin to enable/disable the motor altogether.
So I flashed the Leonardo with Mobiflight and configured the pins that the shield uses. There are two "direction" pins, one speed control pin, and one enable/disable pin for each motor. You can also read the current sense pin as an analog input to get a reading of the relative current being used by the motor.
Configure these as "Led Output" in Mobiflight:
- Clockwise signal: 7
- Counter-clockwise signal: 8
- PWM speed control: 5
- Enable: A0
Optionally you can configure this as Analog input:
- Current sense: A2
Configure these as "Led Output" in Mobiflight:
- Clockwise input: 4
- Counter-clockwise input: 9
- PWM speed control: 6
- Enable: A1
Optionally you can configure this as Analog input:
- Current sense: A3
This was easy, I just added each pin into Mobiflight as "Led Output" (except the current sense pin that is analog input, if you want to use that) - and uploaded the configuration.
As I was just playing with this, and figured I'd write a wiki page to share the findings until I forget, I didn't do anything fancy with the simulator yet, I simply just used the Mobiflight Transform field to hardcode values to the pins to make the motor run, and used a potentiometer in my existing sim panel to control the motor speed in the 0-255 range.
To make a motor run in clockwise direction, set "enable" pin to 1, clockwise pin to 1, counter-clockwise pin to 0, and adjust speed with PWM. To run the motor counter-clockwise, set the CW and CCW pins the other way around.
For some reason my shield only lets me run the motor counter-clockwise, which might be a fault in the shield, but in any case, hopefully this information is useful for someone. I will need to test the other motor output and see what the problem is. In any case, have fun.
Naturally DC motors turn quite fast, but if you have some geared motors, or some belt wheel reduction for speed, you could think of some way to do a limit switch that sets the enable pin to 0 if tripped, and then connect a potentiometer to the movement, and see if you can build an autothrottle, or even control centering with braking and careful adjustment of direction and force, though it might require a bit faster control loop than what Mobiflight is designed for. Maybe worth a shot anyway.
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
- MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards