0
votes

I have nexus duino 3WD and tried to do serial comm to move the robot. I have to remove shield to upload sketch code. This is my sketch:

#include <fuzzy_table.h>
#include <PID_Beta6.h>

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>

#include <MotorWheel.h>
#include <Omni3WD.h>

#include <EEPROM.h>

#define _NAMIKI_MOTOR    //for Namiki 22CL-103501PG80:1


/*******************************************/

int incoming = 0;

int speed = 100;

// Motors

irqISR(irq1,isr1);
MotorWheel wheel1(9,8,6,7,&irq1);        // Pin9:PWM, Pin8:DIR, Pin6:PhaseA, Pin7:PhaseB

irqISR(irq2,isr2);
MotorWheel wheel2(10,11,14,15,&irq2);    // Pin10:PWM, Pin11:DIR, Pin14:PhaseA, Pin15:PhaseB

irqISR(irq3,isr3);
MotorWheel wheel3(3,2,4,5,&irq3);        // Pin3:PWM, Pin2:DIR, Pin4:PhaseA, Pin5:PhaseB

Omni3WD Omni(&wheel1,&wheel2,&wheel3);

/******************************************/

void setup() {
  Serial.begin(38400);
  Serial.println("setup");

  TCCR1B=TCCR1B&0xf8|0x01;    // Pin9,Pin10 PWM 31250Hz
  TCCR2B=TCCR2B&0xf8|0x01;    // Pin3,Pin11 PWM 31250Hz

  Omni.PIDEnable(0.26,0.02,0,10);
}

/****************************************/
void loop() {
  if(Serial.available() > 0) {
    incoming = Serial.read();
    Serial.print(incoming);
    if(incoming==0) {
      Omni.setCarStop();
    } else if(incoming==1) {
      Omni.setCarAdvance(speed);
    } else if(incoming==2) {
      Omni.setCarRotateLeft(speed);
    } else if(incoming==3) {
      Omni.setCarRotateRight(speed);
    }
  }
  Omni.PIDRegulate();
}

I tried to send data both from Serial Monitor and also PC app with USB cable. When shield is not attached I can send data and receive feedback from arduino. But when shield is attached it seem arduino not receiving data, the RX led flash but not the TX led, got 'setup' text output so arduino can send data to PC. Other thing is I can only use 38400 baud rate, otherwise the output will be garbagish.

I'm not sure if I do wrong in the code? Probably device power issues?

1
hard to say withount analizing the library that you are using AND the eletrical Schema for your arduino/shield (i've done a quick research but found nothing).Lesto
@lesto, I think the lib is doing fine, I have upload the test program, which is random movement with sonar for obstacle avoiding, and it quite good. The problem is when I add serial comm so I can control the movement. Without shield communication just work fine, but with shield it seem the arduino can't receive serial data, it can send data to PC tough. Somehow the shield interfere with serial comm. To be more precise, the product I'm using now is aliexpress.com/item/…, motors are connected to the shield.user3336008
arduino communicate with PC using PIN 0 and 1. So if the shield/code use this pins, it is ruind your serial communication. Shield schematics?Lesto
thanks lesto. PIN 0 and 1 is also RX and TX respectively, right? I'm not sure if I have shield schematics, please find it on dropbox.com/s/z29dc0ysdu8073k/3wd.zip (jpg/pdf). Is there some way to test if the shield also using RX and TX? And if the shield works by using RX and TX, can we make the serial comm also works?user3336008
@user3336008 Just FYI. There is now a stack dedicated to Arduino arduino.stackexchange.comNick Alexeev

1 Answers

0
votes

If you change the jumpers from RS-485 to Bluetooth like what it says here http://www.dfrobot.com/wiki/index.php/Arduino_I/O_Expansion_Shield_(SKU:_DFR0014) then everything will work fine. uploading to the board without removing the shield might still be an issue, and sonars probably will not work, but at least you'll be able to read serial through the board.