Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does this motor driver work with johnny? #995

Closed
nofear87 opened this issue Dec 17, 2015 · 12 comments
Closed

does this motor driver work with johnny? #995

nofear87 opened this issue Dec 17, 2015 · 12 comments

Comments

@nofear87
Copy link

The driver is the Pololu Dual VNH5019

https://www.pololu.com/product/2507

@dtex
Copy link
Collaborator

dtex commented Dec 17, 2015

Yes, use the 3-pin example:

http://johnny-five.io/examples/motor-3-pin/

The fritzing diagram shows a shield (which is not very helpful TBH) but the code will work.

If this answers your question, feel free to close the issue.

@nofear87
Copy link
Author

thanks, I will give it a try! Is it also possible to read out the encoders?

I have used this motors:

https://www.pololu.com/product/1447

to read the currents of the shield I only have to do an analog read?

@nofear87 nofear87 reopened this Dec 18, 2015
@dtex
Copy link
Collaborator

dtex commented Jan 23, 2016

Hi @nofear87 sorry for the lack of response on this. We are considering adding support for encoders right into the motor class but that probably won't happen too soon. For now, you would have to write your own code to work with the two inputs. It's not something I've looked to deeply into... maybe someone else here knows more or has some examples?

@dtex
Copy link
Collaborator

dtex commented Mar 17, 2016

@nofear87 I'm assuming that the 3-pin example worked for you. Is it okay to close this ticket?

@nofear87
Copy link
Author

I need some time for testing. Then I will give some feedback! Thanks!

@dtex
Copy link
Collaborator

dtex commented May 31, 2016

@nofear87 I'm going to go ahead and close this. If for some reason the 3-pin example didn't work, feel free to re-open.

@dtex dtex closed this as completed May 31, 2016
@chironxie
Copy link

@nofear87 Hello guys, did that 3-pins example worked for you? I got into trouble while working with "Pololu Dual VNH5019"

@rwaldron
Copy link
Owner

@cheerx hope this helps:

Name Pin Name/Number J5 Class & Pin
M1INA 2 Motor/Motors, dir
M1INB 4 Motor/Motors, cdir
M1PWM 9 Motor/Motors, pwm
M2INA 7 Motor/Motors, dir
M2INB 8 Motor/Motors, cdir
M2PWM 10 Motor/Motors, pwm
M1EN/DIAG 6 Sensor/Sensors
M2EN/DIAG 12 Sensor/Sensors
M1CS A0 Sensor/Sensors
M2CS A1 Sensor/Sensors

Using this shield to...

  • Control motors:

    • With object params:

      const a = new five.Motor({
        pins: {
          pwm: 9,
          dir: 2,
          cdir: 4
        }
      });
      
      const b = new five.Motor({
        pins: {
          pwm: 10,
          dir: 7,
          cdir: 8
        }
      });
      
      // Or both in one object: 
      
      const motors = new five.Motors([
        { pins: { pwm: 9, dir: 2, cdir: 4 } },
        { pins: { pwm: 10, dir: 7, cdir: 8 } },
      ]);
    • With Array params:

      // PIN ORDER MATTERS: [pwm, dir, cdir]
      const a = new five.Motor([ 9, 2, 4 ]);
      const b = new five.Motor([ 10, 7, 8 ]);
      
      // Or both in one object: 
      
      const motors = new five.Motors([
        [ 9, 2, 4 ],
        [ 10, 7, 8 ],    
      ]);
  • Check Motor Status:

    var statuses = new five.Sensors([
      // M1EN/DIAG
      { pin: 6, type: "digital", id: "M1EN" },
      // M2EN/DIAG
      { pin: 12, type: "digital", id: "M2EN" },
    ]);
    
    statuses.on("change", target => {
      console.log(`${target.id}, on ${target.pin}, updated: ${target.value}`);
    });  
  • Read Motor Current:
    (According to this: https://github.com/pololu/dual-vnh5019-motor-shield/blob/master/DualVNH5019MotorShield.cpp#L182-L194)

    var currents = new five.Sensors([
      // M1CS
      { pin: "A0", id: "M1CS" },
      // M2CS
      { pin: "A1", id: "M2CS" },
    ]);
    
    currents.on("change", target => {
      // https://github.com/pololu/dual-vnh5019-motor-shield/blob/master/DualVNH5019MotorShield.cpp#L192
      const mA = target.value * 34;
      console.log(`${target.id}, on ${target.pin}: ${mA}mA`);
    });
    
    // or just one...
    
    var current = new five.Sensor("A0");
    
    current.on("change", () => {
      // https://github.com/pololu/dual-vnh5019-motor-shield/blob/master/DualVNH5019MotorShield.cpp#L192
      const mA = current.value * 34;
      console.log(`M1CS, on A0: ${mA}mA`);
    });  

@nofear87
Copy link
Author

@dtex are there any upddates regarding the implementation of the encoders?

@dtex
Copy link
Collaborator

dtex commented Jul 14, 2017

No updates. I have a project the requires encoders (using hall effect sensors), but it's still on my to-do list.

@nofear87
Copy link
Author

nofear87 commented Jun 24, 2018

@dtex any updates? Did you have a nice solution for a soft start of the motors? With low pwm they did not run...I ever have to start with high pwm and then decrease it until I reach the target pwm. Maybe there is a smart algorithm for that?

@dtex
Copy link
Collaborator

dtex commented Jun 24, 2018

No, I haven't worked on encoders.

I don't recall the soft start issue, but we don't have a fix for that. It would be a nice addition to the motor class though. I'll add that to the wish list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants