PWM and ADIN

Hello everybody,

I started writing code for my project and I have 2 problems.

First I’ll go over my parts:

Basic Atom + 24 pin chip

Sabertooth 2x10 (PID - everything is down)

Accelometre 2g

2 motors

Problem 1:

I’m trying to operate the 2 motors using PWM command,

The problem is that when I put any duty cycle less then 255 it doesn’t work at all

When I use 255 it sends pulses but very weird:

PWM 15, 255, 2500

And instead the motor spins for 0.5 sec and goes off and 0.5 again and off again and so on…

When I put duty cycle higher then 255 (strangely) it works but very weird too,

All I’m trying to do for now is to control the motors, and make them work in a desired speed, and it seems like they do whatever they want…

Problem 2:

I’m trying to read signal from Accelometre, I’m using this code:

Dur var word
Adin ax0, 1, AD_RON, dur ; read signal duration
Debug [dec dur,13] ; print signal duration

The problem is that the accelometre responds only to very drastic movement, is it just because it’s very unaccurate?

Thank you very much for your help, I hope I gave all the information and none is missing, if it’s necessary I will post pictures or code.

What sabertooth mode are you useing, what are the jumper settings? :smiley:

plus some other stuff that I forgot:

Accelomertre: Buffered ±2g Accelerometer
Motors: Planetary Gear Motor - 9.6vdc 51:1 271rpm (LS-550S) (6mm shaft)

PWM 15, 255, 2500

Correct me if I am wrong - doesnt the PWM command with the Basic Atom take 4 parameters

PWM pin, period, duty, cycles (page 110 of manual)

where
pin is the pin to use
period is the period of the pulse width in microseconds
duty is the duty of pulse width signal in microseconds
cycles is the number of pulses to output

Take a look at this as possible source of troubles

Additionally - are you using lithium batteries - otherwise pin 3 should be up and not down. the repurcussions of this are not known by I but could explain anomolies.

Try these first

What you wrote works for the Pro ABB, mine is normal

Are you using an RC filter? You didn’t mention it. I thought that was necessary when using PWM to control motors with the Sabertooth. If not, read the Sabertooth manual for more information.

Have you tried the HPWM command. I will try to get Nathan from BM to chime in here…

The PWM command only runs for as long as you specify in the command and nothign else can run while it’s running.

I’d definitely suggest HPWM instead. You’ll get continuous pwm signals in the background without messing with your main program.

Also PWM(on the BasicAtom and MBasic, not AtomPro) is not a on off PWM(on x% off y%). it is a time sliced average on x% and off y%. It’s fine for voltage generation(using a filter) but not good for devices that need a true pwm signal. HPWM generates a true pwm signal.