Hi all,
My name is Adrian and I'm a programmer working on a project with the Pololu Dual G2 High-Power Motor Driver 18v18 Shield driving a DC motor using an Arduino Uno Rev3. Everything has been great so far, with my programming I can send commands to the Arduino using the Arduino IDE's serial monitor. But the next step in the process involves sending the commands over an Ethernet network. For that I am using an Ethernet Shield Rev2. In my code when I call the md.init(); function (using the "dual-g2-high-power-motor-shield" library. I can no longer communicate with the Ethernet shield. When I comment out that function, the Ethernet functionality works, but of course the motor does not since it has not been initialized.
From what I can tell there aren't any pin conflicts. The Ethernet shield requires (or can potentially require) A0, A1, D4, D10, D11, D12, and D13. I'm only using the M1 on the motor shield (not M2), so it seems like I should only need D2, D6, D7, and D9. I have tried bending back the pins required by the shield, as well as cutting the traces between D10 and D12 on the motor shield in case the M2 pin requirements were causing the conflict, all without success.
Has anyone ever encountered this issue before? I can't seem to find this issue in any forum with this particular hardware/shield combination. Any ideas would be very welcome. The code I am using to test is below my signature. Please let me know if there's any other info you require. The tester code I am using is below
Many thanks,
Adrian
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
#include <OSCBoards.h>
#include "DualG2HighPowerMotorShield.h"
//OSC Addresses
const char *MOVE_ROBOT_ADDRESS = "/robot/locvel";
//Networking and OSC
EthernetUDP Udp;
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAF, 0x04, 0xB9 }; //MAC Address of this arduino's ethernet shield
IPAddress ip(192, 168, 10, 6); //IP Address of this arduino (check with AngryIP after plugging in and powering)
const unsigned int OSC_RECV_PORT = 8000; //Which port to listen to for incoming OSC data
// Uncomment the version corresponding with the version of your shield.
DualG2HighPowerMotorShield18v18 md;
float currentVel = 0;
float newVel;
float acc;
int velMin = -400;
int velMax = 400;
int newDir = 0;
int velFactor = 0;
int accFactor;
void stopIfFault() {
if (md.getM1Fault()) {
md.disableDrivers();
delay(1);
Serial.println("M1 fault");
while (1)
;
}
}
void setup() {
Serial.begin(115200);
Serial.println("Dual G2 High Power Motor Shield");
//Ethernet Init
Ethernet.begin(mac, ip);
Udp.begin(OSC_RECV_PORT);
//md.init();
md.calibrateCurrentOffsets();
delay(10);
md.enableDrivers();
delay(1);
delay(10);
}
void loop() {
OSCBundle bundle;
int size;
if ((size = Udp.parsePacket()) > 0) {
while (size--) {
bundle.fill(Udp.read());
}
//bind functions here, skipping packet validation because Isadora is apparently non-compliant
bundle.route(MOVE_ROBOT_ADDRESS, moveRobot);
//bundle.route(MOVE_ROBOT_ADDRESS2, moveRobot2);
}
//md.enableDrivers();
delay(1); // The drivers require a maximum of 1ms to elapse when brought out of sleep mode.
// check if data has been sent from the computer:
while (Serial.available() > 0) {
// look for the next valid integer in the incoming serial stream:
velFactor = Serial.parseInt();
newVel = map(velFactor, -10, 10, -400, 400);
if (newVel > currentVel) {
newDir = 1;
} else if (newVel < currentVel) {
newDir = -1;
} else if (newVel == currentVel) {
newDir = 0;
}
// do it again:
accFactor = Serial.parseInt();
acc = map(accFactor, 1, 5, 100, 10);
// look for the newline. That's the end of your sentence:
if (Serial.read() == '\n') {
if (newVel >= velMin && newVel <= velMax) {
Serial.print("Velocity: ");
Serial.print(velFactor);
Serial.print(" Acceleration: ");
Serial.println(accFactor);
}
if (newDir == 1) {
for (int i = currentVel; i <= newVel; i++) {
md.setM1Speed(i);
stopIfFault();
delay(acc);
}
currentVel = newVel;
}
if (newDir == -1) {
for (int i = currentVel; i >= newVel; i--) {
md.setM1Speed(i);
stopIfFault();
delay(acc);
}
currentVel = newVel;
}
}
}
}
void moveRobot(OSCMessage &msg, int offset) {
Serial.println("Received");
}