Go Down

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

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.

Go Up