Pages: [1]   Go Down
Author Topic: Optical encoding with Sabertooth 2x25 broken  (Read 1814 times)
0 Members and 1 Guest are viewing this topic.
Midlothian, VA -USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The encoder readings are fine when the wheel is turned manually.

But when the Sabertooth drives the wheels via R/C controller mode, they increase at a random, high rate.

Should I ground the Arduino to the batteries?

Sketch on a mega
Code:

volatile int state = LOW;
int clicks = 0;
void setup()
{
 
  Serial.begin(115200);
  attachInterrupt(5, wheel_tic, RISING);
}

void loop()
{
  //digitalWrite(pin, state);
   Serial.print("CLICKS: ");
  Serial.println(clicks);
  delay(1000);
}

void wheel_tic()
{
  clicks++; 
}



Output:


CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 0
CLICKS: 1 # Manually turning the wheel
CLICKS: 1
CLICKS: 2
CLICKS: 3
CLICKS: 4
CLICKS: 4
CLICKS: 5
CLICKS: 6
CLICKS: 7
CLICKS: 8
CLICKS: 9
CLICKS: 9
CLICKS: 10
CLICKS: 10
CLICKS: 1371 #Using the Sabertooth
CLICKS: 2798
CLICKS: 4397
CLICKS: 6562
CLICKS: 7711
CLICKS: 9414
CLICKS: 11096
CLICKS: 12130
CLICKS: 12130
CLICKS: 12130
CLICKS: 12130
CLICKS: 12130
CLICKS: 12130
CLICKS: 12130
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Should I ground the Arduino to the batteries?

That question in particular makes me go hmm.  Are you using multiple power sources (batteries, power supplies, whatever)?  If so, you have to make sure you have a common ground for everything to work properly together.  On the flip side, you don't want to get carried away with tying all sorts of grounds together or you could create a ground loop that will also be a source of noise.

If you're using two batteries, tie their grounds together, then send this common ground to each device that needs power, and of course tie the positive of the appropriate battery to each device as well. One battery will power the Sabertooth motor controller, and the other will power the Arduino and encoder.  Do not tie grounds together between devices though.
Logged


Midlothian, VA -USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply.

Yes, I have 2 12v batteries wired in series powering the sabertooth. The arduino that listens to the optical encoders are powered by the usb voltage coming from the laptop. I was afraid of wiring the ground on the arduino to the 12v ground. But it sounds like that is the right thing to do?

Thanks again for your help.
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was afraid of wiring the ground on the arduino to the 12v ground. But it sounds like that is the right thing to do?

Nothing to be afraid of there.  It is the right thing to do and it is necessary to do.  So long as you keep the positive lines separate, you will be fine.
Logged


Midlothian, VA -USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I plan on making the common ground connection this weekend. I really appreciate the assistance.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not familiar with the sabertooth, but in general DC motors create a lot of EMI with their brushes.
Probably you're reading the PWM signals-echo?
Therefore they need ceramic capacitors between plus/minus and the housing as well.





Uploaded with ImageShack.us

good luck
olaf


Logged

It's not my fault when my Posts are full of Errors. This stupid autocorrection from my browser is set up for german grammar.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am doing a big bot project with the sabertooth 2X60 but I got the Kangaroo X2 also,  It does all the encoder work for me. leaves the Arduino free for more important tasks like speed, distance, and direction...
Logged


Pages: [1]   Go Up
Jump to: