Go Down

Topic: Robot arm arduino+adafruit motorshield + firmata + VB,run dc motor in reverse? (Read 1 time) previous topic - next topic

Nookster

Hi guys,

I have a toy usb robot arm which I have added potentiometers to and ran the 4 dc motors into the adafruit motor shield in points M1- M4. My potentiometers are reporting back to my VB.NET application just fine using FirmataVB and StandardFirmata on the arduino, I can control my robot arm in one direction with the test application on the output with digital pins but only in one direction.

Where do I start looking for the code to edit in order to make this able to run the DC motor in both forward and reverse given the variable, or is there something obvious I am missing? Has someone done this already? I can't find anything on it!

Thanks a lot for your time guys.

Steve

PaulS

Quote
Where do I start looking for the code to edit in order to make this able to run the DC motor in both forward and reverse given the variable, or is there something obvious I am missing?

"I have some code. I'm not going to show it to you. It doesn't work, though, and I need help. What am I not doing right?" Did I paraphrase your post correctly?

Nookster

Well, I am using StandardFirmata.. so the same code that comes default with Arduino.. there is no code, only the test app which moves them only in one direction, which is why I have my question, How do I go about making them run in reverse? I've read on another forum I need to edit *something* in either the default Arduino StandardFirmata sketch or FirmataVB order to make it run both forward and backwards, this is where I don't know where to start

Sorry if it's confusing, it's hard to explain

UKHeliBob

Let's make this simple.

Please post the code that you have running on the Arduino
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Nookster

Hi there, it's the StandardFirmata sketch included with Arduino as follows:

(exceeds post length) : http://pastebin.com/x55xK3Uy

Thanks

Nookster

I guess my question boils down to these points:

I am using 4 DC motors connected to the adafruit motor shield which use the digital ports

The potentiometers are from analog pins 0-3, they report to my VB.net application which uses FirmataVB to interface with the arduino, FirmataVB also includes access to the digital pins, although this currently only lets me move it in one direction when I set OUTPUT to HIGH.

I want to be able to control the 4 DC motors in both directions, and read the potentiometers which shows the position of each arm.

- Which of the default sketch examples included with Arduino is most appropriate as a base to start editing given what I need to do and the fact I need to use FirmataVB (?)

- How do I edit the sketch to include a variable which lets me control the direction of each motor, rather than setting the OUTPUT to HIGH or LOW (one direction, or stop)

- Will I need to include other items to achieve this? I've read some stuff about needing to import AFMotor.h or can I just make a few changes to the firmata sketch and FirmataVB?

I would be really grateful if you guys could point me in the right direction, the more I seem to read the more I am confusing myself.

Thanks for your time


PaulS

The standard firmata sketch removes, effectively, the brains from the Arduino. Some other code is actually in control. You want help with the code, you show it.

Quote
- Which of the default sketch examples included with Arduino is most appropriate as a base to start editing given what I need to do and the fact I need to use FirmataVB (?)

StandardFirmata is fine.

Quote
- How do I edit the sketch to include a variable which lets me control the direction of each motor, rather than setting the OUTPUT to HIGH or LOW (one direction, or stop)

You don't. By loading the StandardFirmata sketch, you've essentially told the Arduino that you are not interested in it's ability to do anything more than read inputs and write outputs.

It is up to the other program that is going to be the smart one to be the smart one.

Quote
- Will I need to include other items to achieve this? I've read some stuff about needing to import AFMotor.h or can I just make a few changes to the firmata sketch and FirmataVB?

No, no, and yes.

PeterH


The potentiometers are from analog pins 0-3, they report to my VB.net application which uses FirmataVB to interface with the arduino, FirmataVB also includes access to the digital pins, although this currently only lets me move it in one direction when I set OUTPUT to HIGH.


Seems to me that Firmata and your VB sketch between them contain the logic to drive the Arduino pins to send the required commands to the motor shield, and at the moment that logic is wrong. I suggest you read up on the pins used by the motor shield and what signals are needed on those pins to get the forward and reverse movements you require, and then correct the logic in Firmata/VB to provide those signals.
I only provide help via the forum - please do not contact me for private consultancy.

Nookster


Thanks for your replies, I have come to that same conclusion Peter, I am looking on the adafruit website, but all I could find was http://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/arduino-code However, I'm not sure how to apply this to the adafruit motor shield (incase it is different) and what the equivalent of in1pin and in2pin would be on the motor shield , any ideas guys?

PeterH

The set of pins used to control the shield are pretty straight forward and you should be able find them described in the documentation for your shield. You need to find the piece of code that coverts the abstract idea of 'turn motor on' to a set of signals written to output pins. This will presumably be in your VB or Firmata code. The documentation will tell you what signals you need to give the shield to make it do what you want. The VB/Firmata code will show you what it's actually doing. You need to see what the difference is, and fix the code so that it does the right thing.

Code samples showing how to control the motors directly from a sketch running on the Arduino may help you to confirm you understand what pins do what, but the code you need to fix is NOT Arduino code; it is your VB/Firmata code.
I only provide help via the forum - please do not contact me for private consultancy.

Nookster

Thanks Peter that is helpful, I will take a further look at it tomorrow.

Go Up