Raptor and MotorControllerL298

Seems like my MotorControllerL298 can only drive motors backwards with 100% speed.

Here is what works and what is not:

speed -100 - works
speed -20 - motor will tune at 100% speed
speed 0 - motor will stop
speed 30 - motor does not move,
speed 100 - motor does not move

if speed is set to a any negative number - motor moves, any positive - it stops.

Same behavior o Raptor socket #18 and on any P socket of the Hub AP5 (hub connected to socket 6).

While test runs I can see led 1 set to green, led 4 is set to red, while other lest #2 and #3 are always off.

Is it defective module?

By the way.
The power to the MotorControllerL298 comes of UC_Battery_4xAA module.
Motors are tiny 6v motors from a hobby store.

Maybe the motor is not happy to run in reverse? You can swap the wires on the motor and see what happens.

1 Like

Have swapped wires on both motors, and now they run in reverse direction only,
Behavior is the same - motors only respond to a negative speed, any positive number simply turns them Off.

Motors are reversible, connecting them directly to the battery and swapping wired does have expected behavior.

There were some older discussion about the driver not covering the reversing scenarios well, like https://www.ghielectronics.com/community/forum/topic?id=9171 but they aren’t totally the same as you’re seeing. Perhaps I would ask you to download the driver and put some break points in the speed change routine and look at what is going on?

1 Like

Got source code for L298 driver (MotorControllerL298_42.cs) .

Additional observations:

  • changing frequency to 1000 does not turn wheels instead controller hums but wheels don’t turn, at 25000 there is no difference as at 50000 (default) so I am using default.
  • speed acts weird: at -1% or at -5%, or at -20% or at -100% wheels turn at the same (unknown) speed but it is not -100% because they definitely run faster if connected directly to the battery.
  • I can hear a little click sound when setting up positive speed (for that observation I send all my family for a walk :slight_smile: ) but nothing moves…

Looking in to the code, motor2 for instance start turning at the step when it writes “True” in to the DigitalOutput m_Direction2, the actual speed settings have little or no effect.

Hi Brett,
I have seen that post as well as other posts that come up when one searches for motorControllerL298 on the forum.

The code I got seems fine… it addresses old issues with division by 0, and the duty cycle fix. I have tried to set motor speed to 100% (and -100%) as the first step as it was suggested in one of the posts, no luck.

I have noticed a few times that when system runs of of batteries, Raptor will only be able to turn one motor connected to the J5, but when it is powered from USB, then both motors turn (again only when negative sped and direction has been applied).

Another thing, which is probably a subject for a different topic, is the socket 7 on Raptor, if anything is connected to it then Raptor becomes unrecognizable by my PC, it enters the “stealth mode” :slight_smile: all routines run fine on Raptor, but PC does not see it at all…

Any way, I will dust of old rechargeable battery and will try to use it as a power source instead of UC_Battery_4xAA maybe L298 just need more juice…

motors are notorious for drawing lots of power, but I would have expected if this was your problem you’d be seeing a different behavior. I can’t predict where the investigation will go from here sorry !

1 Like

We can try it on our end.

1 Like

Charging old Tamia 7.2V 2000mA battery, will try it tonight.
Base on L298P datasheet it can handle way more.

Gus, if battery will not work, do you want just motor controller only or the whole set up to try?

I was able to get a motor to move in both directions over the full range of speed. The motor I used was the same one we use on the FEZ Cerbot. Do you have any other motors you can try?

1 Like

Tried a couple of small motors from different toys: 3V (had a few on hand) and 1.5V (from little Tomas train) - same behavior as before(constant negative speed at close to 100%).

What is really strange is that I just noticed that you are seeing the same thing with the hub! Maybe the motor control module is defective.

1 Like

With the bigger battery I can turn motor #2 (and only this one ) that sits on the J5 in both directions by manually setting (or hardcoding) following values directly in the driver code:

            //First quickly power motors for a short time then, Stop motors. freq=50000
            m_Pwm1.Set(freq, 1.00);
            m_Pwm2.Set(freq, 1.00);
            //Stop motors
            m_Pwm1.Set(freq, 0);
            m_Pwm2.Set(freq, 0);

Interestingly, any other positive value (between 0 and 0.99) supplied for motor #2, besides 1, have no effect, including 0.99 used for Duty Cycle fix.

While motor #1 does not move, it does turn on the led after calling a line listed above.

All this suggests that hardware can do staff (I hope), and maybe software source code or driver code is outdated, but I have NETMF SDK 4.3 (RTM), and the latest firmware on the Raptor.

It does seem like the motor module itself might not be working properly. Do you have any other P type modules you can test with to verify that PWM is working?

1 Like

@ John, I have brand new Tunes Module (haven’t open it yet), will play a melody or something.
Would that works? Is there any other that I might use?

Tunes would work, you could also use an oscilloscope if you have one.

1 Like

Just for a clarity of the experiment all modules were disconnected from Raptor and then following three tests were performed.

Case 1 – direct connect
[em]Setup: Raptor, UC_Battery_4xAA (socket #8), Tunes (socket #18), and Button (socket #10) [/em]

Tunes sample from website unchanged, as is, compiled and deployed - runs fine, plays melody(up, back down, arpeggio). On the cons side however, in the debug mode, code does not run fine, instead it sporadically play a note or two, or might not play at all…

Case 2 – through the hub – S2 – H4
[em]Setup: Raptor, UC_Battery_4xAA (socket #8), HubAP5 ( socket #2), Tunes (socket H4), and Button (socket #10)[/em]

In debug mode – inconsistently plays a note or two, it is definitely not a melody.
Standalone – inconsistently plays a note, or does not play anything. Reset produces different result, but mostly – no sound at all…

Case 3 – through the hub S2 – H8
[em]Setup: Raptor, UC_Battery_4xAA (socket #8), HubAP5 ( socket #2), Tunes (socket H8), and Button (socket #10)[/em]

In debug mode – plays one scream sound, it is definitely not a melody, or if it is melody then it is very compressed in time.
Standalone – on power on always plays something, but definitely not a melody. After resets usually there is no sound ( I was tired after clicking reset 15 times)

Testing Motor Controller now.