[3WD Omiwheel Robot] - Wheel control not working properly

Hello all,

I’m new to the forum, so if I’m ignoring some important conventions or posing in the wrong category, sorry for that.

Our faculty just recently bought two 3WD Omniwheel Mobile Robots.

After playing around with the driving functionality using the included library, I noticed that stopping the robot does not work.
More specifically, even changing the speed of a single wheel is not working.

Here is a somewhat minimal example I came up with (derived from the included 3WD example code):

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

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

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

irqISR(irq1,isr1);
MotorWheel wheel1(9,8,6,7,&irq1);

irqISR(irq2,isr2);
MotorWheel wheel2(10,11,12,13,&irq2);

irqISR(irq3,isr3);
MotorWheel wheel3(3,2,4,5,&irq3);

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

void 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() {

int speed1 = 50;
unsigned long now = millis();

if (now % 7000 == 0) {
if (Omni.getCarStat() != Omni3WD::STAT_ADVANCE)
Omni.setCarSlow2Stop(500);
Omni.setCarAdvance(speed1);
} else if (now % 3000 == 0)  {
if (Omni.getCarStat() != Omni3WD::STAT_STOP)
Omni.setCarSlow2Stop(500);
// !!!!
Omni.setCarStop(); // Reverses one wheel instead of stopping all wheels.
// !!!!
}
Omni.PIDRegulate();

}

Looking at the loop function, this should switch between driving forward and stopping every couple of seconds.
However, when the robot is supposed to be stopping, one of the wheels just starts rotating in the other direction and the other one keeps going.

I am guessing this is because, internally, the speed is set to 0 and so the direction is changed from backwards to forwards for this one wheel (which is rotating backwards to mirror the other wheel).
This is of course not the expected behaviour - both wheels ought to stop. Replacing setCarStop() with setting the speed of each wheel individually does not work either, and leaving out the setCarSlow2Stop parts doesn’t change anything.

Another example with one wheel (derived from one of the examples in the documentation):

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


irqISR(irq1,isr1);
MotorWheel wheel1(9,8,6,7,&irq1);


void setup() {
TCCR1B=TCCR1B&0xf8|0x01;
wheel1.PIDEnable(0.26, 0.02, 0, 10);
}
void loop() {
wheel1.setSpeedMMPS(40, DIR_ADVANCE);

for(int i=0;i<1000;++i) {
wheel1.PIDRegulate();
delay(10);
}
delay(1000);

wheel1.setSpeedMMPS(80, DIR_ADVANCE);

for(int i=0;i<1000;++i) {
wheel1.PIDRegulate();
delay(10);
}
delay(1000);

wheel1.setSpeedMMPS(0);

for(int i=0;i<1000;++i) {
wheel1.PIDRegulate();
delay(10);
}
delay(1000);
}

This should rotate one wheel with different speeds for a couple of seconds each, stopping it completely for some time (when the speed is set to 0).
However, it just rotates at a constant speed throughout. Changing the direction to DIR_BACKOFF works (the wheel rotates in the other direction).

I have tested these snippets on both robots we ordered, and the problem is occurring on both, so it’s unlikely to be a hardware- or assembly issue,
which means there’s probably either something wrong with the library or with my code.

Can someone please help me with this? I’ve tried everything I can come up with, and I’m completely clueless as to why it’s not working at this point.
Thank you in advance!

Best Regards
Max

Hi,

Could you verify if the wiring is correct (as shown in page 88 of the Nexus User Manual attached) ?
If the wiring is good, could you test the sample code provided in page 86 ?

Best Regards,
Robot Kits Manual_006.pdf (2.38 MB)

Hi,

thank you for your quick answer!

I looked at the wiring, and it is in fact different.
However, I also noticed that the I/O Expansion Shield is a bit different from the one depicted in the manual.
The one in the manual is called “v1.1 60004”, whereas the one we have has “v1.2 60008” printed on it.

Does this maybe have any effect on the sample code (like what pins to use), or do both the wiring and the sample code from the manual still apply to our version?
For reference, I’ve included images of the wiring as we have it: imgur.com/a/oW9WI6B

(Since the first post, I also noticed that controlling only wheel 3 in the code causes both wheel 1 and 3 to move).

Best Regards and thank you for your time and effort,
Max

The actual wiring of your Nexus I/O Expansion Board is probably what’s causing the issue.
Please verify if your motor encoders wires are connected as follows :

]Motor 1 : PhaseA: Pin6 and PhaseB: Pin7/:m]
]Motor 2 : PhaseA: Pin14(analog 0) and PhaseB: Pin15(analog 1)/:m]
]**Motor 3 : **PhaseA: Pin4 and PhaseB: Pin5/:m]
You can see the attached picture to know which motor is which.

Also, in your code, change :

MotorWheel wheel2(10,11,12,13,&irq2);

To :

MotorWheel wheel2(10,11,14,15,&irq2);

to match the wiring above.
Please let us know how it goes.

Hi again,

thank you for your answer.

I double checked the wiring again thoroughly, and it seems to be correct.

I did get the wheels to stop though, by leaving out the PID part provided by the library,
and controlling the PWM directly:

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

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


void setup() {
  TCCR1B=TCCR1B&0xf8|0x01;    // Pin9,Pin10 PWM 31250Hz
  TCCR2B=TCCR2B&0xf8|0x01;    // Pin3,Pin11 PWM 31250Hz
}

void testWheel(MotorWheel *wheel) {
  int time = 3000; // 3s
  int pwm = 128; // max = 255

  wheel->runPWM(pwm, DIR_ADVANCE);
  delay(time);

  wheel->runPWM(0, DIR_ADVANCE);
  delay(time);
}

void loop() {

  testWheel(&wheel1);

  testWheel(&wheel2);

  testWheel(&wheel3);
}

This works with multiple wheels simultaneously, and with different speeds as well.

So the problem seems to be with the provided PID library, its integration with the MotorWheel part, or my usage of it (though I am pretty sure I used it like the example code).

While looking through the MotorWheel library file, I noticed it includes PID_Beta6. Maybe an old (beta) version of the library was included with the code archive download from the shop?

Thank you again for your time and your support!

Best regards,
Max

We have contacted Nexus to see if they have encountered the same issue before and if they can provide the latest Arduino library/sample codes for the 3WD 48mm Omni Wheel Mobile Robot Kit. We will post their reply as soon as we get it.

Thank you so much!

I will hear from you then,

Best Regards
Max

Nexus replied and provided us the attached Arduino code which should be their latest Arduino libraries and examples (up to date).
They have asked that you try the attached “MotorWheel_test_.ino” example with the 3 wheels of the robot.
MotorWheel_test_.ino (1.23 KB)
10019.zip (2.99 MB)

Sorry for digging out this old thread. But was this ever solved? Having the same problems as maxi and tried the library provided as well as the “MotorWheel_test_.ino”.
When I control the wheels directly or in the test file, it seems to work well. But if I use it as a “car”, it does not stop when it should.

Hi,

We didn’t have more information about this issue. We recommend you to contact the manufacturer’s technical support directly at [email protected]

Hi birdm4n,

I’m the initial poster (maxi-28), but I wasn’t able to reactivate / migrate my account, so I created a new one.

I don’t remember whether I ever figured out what the issue was, but I couldn’t get it to work with the more abstract library features. I dug around in their code a lot and even changed some of it, but it’s rather messy and not very well documented (or was back then).

In the end decided to control the wheels directly, which worked rather well actually.

Here’s my own code for controlling the robot on github: https://github.com/maxi-k/bachelor-code-arduino/blob/master/initial-05-16/actuator.cpp

I hope it helps with your project!!
Cheers

1 Like