Hi,
I have a Pololu Dual VNH5019 Motor Driver Shield to control a DC motor and want to control it with MyRobotlab. (See layout shield below)
If I program it directly with Arduino code for motor 1 it works fine (piece of code below)
int M1INA = 2;
int M1INB = 4;
int M1PWM = 9;
if (direction1 == 1) {
//Full speed clockwise
digitalWrite(M1INA, LOW);
digitalWrite(M1INB, HIGH);
analogWrite(M1PWM,255);
} else if (direction1 == -1) {
//Full speed anti-clockwise
digitalWrite(M1INA, HIGH);
digitalWrite(M1INB, LOW);
AnalogWrite(M1PWM,255);
} else {
//Stop
digitalWrite(M1INA, LOW);
digitalWrite(M1INB, LOW);
analogWrite(M1PWM,0);
}
But if I try to use the diyServo service as described in http://myrobotlab.org/service/diyservo it won’t work. I have looked for hours at the source of MyRobotlab now, but I have no clue what I am doing wrong. Or is the shield completely different compared to the one used in the samples?
M1INA = 2;
M1INB = 4;
M1PWM = 9;
arduino = Runtime.createAndStart("arduino", "Arduino")
arduino.connect(“COM7”)
motor = Runtime.start("diyServo.motor","MotorDualPwm")
motor.setPwmPins(M1INA, M1INB)
motor.attach(arduino)
servo = Runtime.start("diyServo","DiyServo")
servo.attach(arduino, M1PWM)
servo.pid.setPID("diyServo", 0.020, 0.001, 0.0)
servo.moveTo(90)
Who can help!
Best regards,
Jan
look out for fakes!
It's possibility that You have Fake chips on board i have these same. On about 20 shields only 3 works full. I have buy new chips and resoldered it now it's working.
Or You have other problem, but check first it is working on simple PWM mode and arduino.
P.S. VNH2SP30 are little stronger and cheaper.
Motor service
Hi Jan
If you just want to use it as a motor you should just use the MotorDualPwm service. The DiyServo service is when you want to use the motor as a Servo, i.e when you also connect a potentiometer as a position feedback.
servo.attach(arduino, pin) is there to specify what analog pin you are using for the positional feeback ( the potentiometer ).
I think you can use the script below to test the motor.
M1INA = 2;
M1INB = 4;
M1PWM = 9;
arduino = Runtime.createAndStart("arduino", "Arduino")
arduino.connect(“COM7”)
arduino.pinMode(M1PWM,"OUTPUT")
arduino.digitalWrite(M1PWM,1)
motor = Runtime.start("motor","MotorDualPwm")
motor.setPwmPins(M1INA, M1INB)
motor.attach(arduino)
motor.move(1)
For reference:
http://myrobotlab.org/service/MotorDualPwm
If you are using an Arduno Mega it shoud work without any changes, If you are using an Arduino UNO, you need to change the M1INA and M1INB to be selected from pins 3,5,6,9,10 or 11
If it doesn't work, we will have to create a new service for this type of motordriver.
shield VNH5019
Hi Bart, Mats,
Thanks for you reply!
The shown arduino code works fine so I think the shield is OK.
This shield is propably not compatible with the MotorDualPwm service.
I have tried your code also on a mega, but it still does not work.
As you can see in the arduino code the shield expects a HIGH or LOW on pin M1INA en M1INB for direction while you are describing analog values. and pin M1PWM expects a value between 0 and 255 for speed value.
I think I need a special versie of het motor service.
Do you have a suggestion where and how to start?
Which motor service comes close to inherrit from?
(I am a novice in these kind of programming...)
Best Regards,
Jan
Motor services
Hi Jan
I think the Motor service is the one you want to copy, because it uses both Digital and Analog pins, while MotorDualPwm only uses Analog pins.
If you want to learn how to develop services yourself, we will try our best to help you..
The first step would be to download Eclipse, the development tool that we are using to develop services. Most of the code in MRL is Java. We use Java 8. Download Eclipse for Java developers from here: http://www.eclipse.org/downloads/eclipse-packages/
It contains Eclipse + Java + git ( version control ) + some other goodies.
Next step is to download MRL itself. You can find how to do that here:
http://myrobotlab.org/quick_start
Follow the steps for Developer
When you have MRL installed and runnning in Ecipse, the next step is to find the service to copy.
You will find the Motor service in the same folder as the Runtime service, that you now hopefully can use to start MRL with.
Copy if to the same folder and give it a new name.
Most of the methods are defined in AbstractMotor and inherited to the Motor service. So the code in the Motor service is not that big. You need to change it so that you can use the 3 pins of the motor driver you have.
You also need to make some changes to the Arduino code, since it's aware of the different motortypes, Search for Motor, and you will find the different areas that needs to be updated.
If you want to do it all the way, then a few other things also need to be done, like a swing GUI, a Web GUI, create a service page, an example and in best case also a unit test. But that can wait. Many services are missing all those parts.
/Mats
Motor services
Hi Mats,
Thanks for your info. I will give it a go...
But I have a question:
I already installed Eclipse and have MRL downloaded and installed in Eclipse.
Enerything lookes OK and I also can generate a MyRobotLab.jar with ant jar.
But when I start this jar many services are not installed and when I run system>Install All I get is a No Worky! (See screenprint below)
Do you have any idea how I can solve this?
Regards, Jan
Do you have a good internet
Do you have a good internet connection when you are trying to "Install All" ?
Do you use a proxy server ?
Is there some sort of over-zelous anti-virus software running ?
This is a stage where it should be trying to pull down libraries in order install all the dependencies for all the services. But if there is any kind of network problem, this will not happen...
build jar
Hi Grog,
My internet connection is always good and stable and there is no proxy server.
I did disable my virusscanner and tested it also without any result.
When I "Install All" from the latest build downloaded from MyRobotLab.org everyting goes smoothly.
Perhaps I have to change something in the build.xml file?? or something else?
The build log does not show any errors.
Regards, Jan
MRL local build
Hi Jan
Try copying the myrobotlab.jar that you built to a new empty folder with a simple path like C:\MRLLocal before you execute it.
/Mats
MRL Local build
Hoi Mats,
I am already doing this.
I also tried to copy the complete repo-folder from c:\dev\repo before "Install all" in het new folder. Gives the same problem.
Any other idea's?
Regards, Jan
repo + myrobotlab
Hi
Did you install both the repo and myrobotlab in the same parent folder so that you have
c:\dev\myrobtlab and c:\dev\repo
And c:\dev is your workspace in Eclipse ?
I try to reproduce the error you get, but I don't get the same error as you do.
build Jar
Hi Mats,
I have added mrl to eclipse according the description of quick start - developer
and also
Followed the instructions in readme.md in the myrobotlab folder.
Both with the same result.
Have you seen the noworky I ave send last saturday?
Regards, Jan
Build Jar
Hi Mats,
Perhaps this helps... below is the log of ant dist
Regards, Jan
Build Jar
And this is the NOWorky text if I run runtime>system>install all from the generated myrobotlab.jar
Paths with blanks
Hi Jan
I'm not sure if this is the problem, but spaces and other special characters may cause a problem.
I see that you use a path to the workspace in Eclipse contains a space
C:\Users\Jan Janson\workspace\mrl
Developer
diyServo
Hi Mats,
I did clone the source from GitHub to c:\mrl. But also then it is not possible to generate a jar with all services (actually a jar able to install all services).
I am working direct in eclipse now and for now that will do.
But that leads me to another problem. I would like to use your diyServo-source as a basis for developing a servo-service that supports the VNH5019 dual motor driver with an external encoder. However the source of your diyServo-service is not part of the cloned source. (I see no diyServo.java).
Is your source not published yet? Is it possible to send me this source?
Kind regards,
Jan
I'm not positive, but I
I'm not positive, but I suspect what your looking for is on the "develop" branch.
try the following command in the myrobotlab directory.
git checkout develop
or in eclipse I think its
right click -> Team -> switch branch -> develop
hI GroG, That worked! Not
hI GroG,
That worked!
Not only I see the diyServo source now but also building the jar works.
(when I do a "install all", all service are installed now)
Thanks for you help!
Regards, Jan
Ack not received error
Hi,
Making a version of the diyServo service for the VNH5019 dual motor controller also using a encoder and a endswitch, is going quit well and the DC-motor is acting as a servo, but… when it runs I get a lot of “Ack not received” errors.
After such an error connection with the encoder is gone. So the motor runs for always!
I tried to change the pin-rates, disabled pins, ect, etc, without any success.
Does anyone have an idea how to solve this?
Best regards, Jan
Hello Jan
Hello Jan,
I'm trying to use VNH2SP30, but I do not know how to connect it.
DiyServo service does not have:
Motor1 direction A
Motor1 direction B
Did you have any success creating a new service for VNH5019?
Do you have an example script to understand how it works?
Thank you!
stupid question about DiyServo
Greetings to all. I'm new. Sorry immediately for a contactless or stupid question. And why arduino. It may be easier to connect the "H-bridge" to a cheap or burnt Servo. And inappropriately additional Arduino and program code. And for level matching, optocoupler and Schmitt trigger
Greetings to all. I'm new. Sorry immediately for a contactless or stupid question. And why arduino. It may be easier to connect the "H-bridge" to a cheap or burnt Servo. And inappropriately additional Arduino and program code. And for level matching, optocoupler and Schmitt trigger