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


Forum Jump:


Users browsing this thread: 1 Guest(s)