This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Motor controller
#1
Hi
I have a generic motor controller with power ground and direction input pins,
What pins on the pi zero with PyPilot go to the motor controller?
Will this solve the motor controller not recognized issue?

Thank you
Reply
#2
the pypilot motor controller uses a microprocessor. This is essentially an arduino nano and was done for several reasons. I recommend studying the schematic for the pypilot motor controller and use a $3 arduino nano clone to drive your controller.

So you cannot easily wire this generic controller to the pi zero pins, however it is possible if you hack pypilot. I don't recommend doing this because the performance is bad, there is no feedback and no protection for the pi.
Reply
#3
Hi djdsails,

(2021-01-18, 03:35 AM)seandepagnier Wrote: the pypilot motor controller uses a microprocessor.   This is essentially an arduino nano and was done for several reasons.   I recommend studying the schematic for the pypilot motor controller and use a $3 arduino nano clone to drive your controller.

So you cannot easily wire this generic controller to the pi zero pins, however it is possible if you hack pypilot.   I don't recommend doing this because the performance is bad, there is no feedback and no protection for the pi.

Can you tell us more about your requirements, what you have, and what you'd like to do?

While I'm here, I'm going to add to what seandepagnier said.  Here's a schematic for an older version, from the PyPilot website:

 https://pypilot.org/schematics/hbridge_controller.pdf

This version uses an H-bridge made of discrete MOSFETs, but other solutions are possible.  

If your motor controller needs an analog voltage, it would be possible (although not easy) to get the Arduino nano to generate the analog voltage you want, by modifying the code which runs on the nano (motor.ino) to emit a square wave of varying on/off time (PWM), and convert this to a varying voltage with a low pass filter:

 https://github.com/pypilot/pypilot/blob/.../motor.ino
 https://www.allaboutcircuits.com/technic...g-voltage/

But perhaps by "motor controller" you mean a motor driver, the thing that switches the high current, as the H-bridge does.  An alternative is to use a chip such as the VNH5019 or BTS7960 which does all the switching.  They are cheap and it's quite easy to hook up the nano to one of these chips.  Example:

 https://forum.openmarine.net/attachment.php?aid=1078

This shows connection to a VNH5019.  Note, as seandepagnier has said, there is no fault detection, no feedback, and no protection for the Pi.  It's just a proof of concept (which works).
Reply
#4
Hi
Thank you for the other dwgs. I do not think I need to change it analog. 
So what is the connection between the Pi and arduino? 
Correct me if wrong 
PI to Aduino 
Pin 8 on pi is tx going to pin 1 on arduino is tx 
Pin 9 on pi is rx going to pin 2 on arduino is rx
5v and ground to arduino from pi

Arduino to motor controller MD10c R3 (it has three pins of input ground, PWM, DIR
Pin D 9 on arduino to pwm on controller
Ground to ground 
Then there is DIR what goes to that?

Thank you

Or should I be getting the pololu vhn5019 like the newer dwg you linked? If so what is the usb link it has?
Reply
#5
(2021-01-20, 01:55 AM)djdsails Wrote: So what is the connection between the Pi and arduino? 
Correct me if wrong 
PI to Aduino 
Pin 8 on pi is tx going to pin 1 on arduino is tx 
Pin 9 on pi is rx going to pin 2 on arduino is rx
5v and ground to arduino from pi

The TX of one should be connected to RX of the other, TX to RX, TX to RX.

The RPi's pin 8 is TX, that is ok.  But RX is pin 10 not pin 9.

The Arduino's TX (aka D1) is pin 1, and RX (aka D0) is pin 2.

Note: Many pinout diagrams for the nano get this wrong (often TX/RX is reversed, or D0/D1 is reversed, or PD0/PD1 is reversed), so it's important to find a diagram from a reliable source.  This is from Arduino:

  https://content.arduino.cc/assets/Pinout...latest.pdf

(2021-01-20, 01:55 AM)djdsails Wrote: 5v and ground to arduino from pi

This is where the fun starts.  

The motor controller nano uses 5V.  

The RPi should be powered by 5V, but that's then regulated to 3.3V.  All GPIO inputs on the RPi are 3.3V not 5V.  That means that if you feed 5V from a nano output into a 3.3V RPi input (TX to RX), it could harm the RPi, and if you're feeding 3.3V from an RPi into the nano (TX to RX), the 3.3V may not be enough for the nano to see it as a "high".

The best solution to this is to put a level converter chip between the nano and the RPi.  I used an Si8621.  seandepagnier used something else.  If you don't want to use a chip, then you could connect the two with USB.  If you want something cheap that might work, you could connect the RPi TX directly to the nano RX, but you'd need to test it and make sure it works reliably.  For the TX to RX signal from the nano to the RPi, you could use a resistor divider, or a resistor and a zener diode to reduce the 5V to 3.3V.

(2021-01-20, 01:55 AM)djdsails Wrote: Arduino to motor controller MD10c R3 (it has three pins of input ground, PWM, DIR
Pin D 9 on arduino to pwm on controller
Ground to ground 
Then there is DIR what goes to that?

The MD10c interface is more like the VNH5019 than a discrete H-bridge (although the MD10c circuit board looks like it has an H-bridge on it).  So, define VNH2SP30 in motor.ino.  In this mode you can connect nano pin D9 to the MD10c PWM pin, and nano pin D2 to DIR.  (Before you try this, you can attach a meter to the nano with PyPilot running and verify the D9 and D2 signals.  You can also try wiring PWM/DIR directly to 5V/GND to see what the motor does.  When you're happy with that, connect the nano and the MD10c together)

(2021-01-20, 01:55 AM)djdsails Wrote: Or should I be getting the pololu vhn5019 like the newer dwg you linked? If so what is the usb link it has?

The VNH5019 is cheap and easy to use, and maybe you could get one as a backup.  It's not USB.  The minimal interface is PWM/INA/INB, so it's similar to the MD10c.  With INA and PWM high, the motor will turn one way.  With INB and PWM high, the motor will go the other way.  There's also a current sense pin that can be connected to the nano with some resistors so PyPilot can monitor the current and detect stalls and faults.

Here's where I got mine.  You just need the single channel version.

  https://www.aliexpress.com/item/4000046778315.html

If you're using VNH2SP30 for a VNH5019 or your MD10c, you may also need to make some other changes to motor.ino:

  https://forum.openmarine.net/showthread....9#pid16359

If all this seems too hard, please consider buying hardware from seandepagnier.  His controllers are very nice, fully tested, and supported.

And finally some pictures of my autopilot experiments:

  https://photos.app.goo.gl/kWuzHooS4Fmwunc19

You're welcome to ask me questions.
Reply
#6
@CapnKernel
not to sound like a winy little bitch but Initially when i started this process there were non in stock in Seans store. so i though this shouldnt be that hard seems to be enough dwgs out there. i probably would have stopped if i had known upfront that 4 devices were needed, there are no easy to read with PN/model #s dwgs saying that, nor did i find anything in my searches about having to modify code till you just showed me.
so the level converter chip is on order should be here sometime next week.
so i am guessing that if i power the nano off the USB with a separate 5v source, hook up its D2 pin to DIR and Pin D9 to PWM and ground on the Analog size to the motor controller. if i hook up through the level converter nano TX to pi RX and nono RX to pi TX and nono ground on the digital side to any ground on pi... THAT its not going to work, ohh and there will be no switch protection or voltage overload protection... so since i think i got the basic wiring down to simply drive the tiller pilot.
how do you pull up the motor.ino?
or @Sean if i send you the motor controller, the leveler, nano, that ive got would you be willing to give me a discount on your controller?
Reply
#7
It's great if you build your own, much more learning this way, and the main reason I used the arduino platform was to make it easier to do this.

It's a great offer, but I don't have much use for these components. I encourage you to hang in and get it working.
Reply
#8
Hi Sean. Have you considered using an esp32 instead of the arduino? They are less expensive, and already run at 3.3v. Most code for arduino complies fine for esp32. Sometimes you need to replace a library.
Reply
#9
esp32 are not less expensive because arduino nano clone is $3. The chip by itself is also the same price but the power consumption is not better. 3v3 is not an advantage because it needs isolation anyway. Also wifi cannot be used for the motor controller to get reliable performance.

So it's possible to use esp32 if you like, and I encourage all possible modifications. I think stm32 would work too, but I am familiar with the atmega series, it is proven and the code much simpler and easier for me to understand. The atmega is sufficient and reliable. I have issues with stm32 that are very difficult to diagnose unfortunately. I would use one of these 32bit processors for a brushless controller, but for brushed I don't see a great advantage.
Reply
#10
@sean or@CapnKernel.... got the motor.ino uploaded to nano everything hooked up along with the bi directional leveler for tx and rx. voltages allong tx and rx are good 3.1v to pi and 5v to nano.
the pi is still saying no motor controller connected, any troubleshooting i can perform? ive checked voltages, ensured the arduino ide uploaded the motor.ino and the crc.h file successfully, did it twice. all connections look good....
Thank you!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)