Asked — Edited
Resolved Resolved by Rich!

Questionatic L298n Red Connection

Following the instruction video, i was able to set up the Hbridge L298N RED

the problem im facing is, it only controls the read motor, not the turning motor.

the video online shows dj setting up just one motor. am i missing something?


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

United Kingdom
#1  

Not really sure what you mean by the read motor and turning motor to be honest but if you read through the L298n tutorial I wrote it tells you everything you need to know about these H-Bridges.

#2  

sorry, typo. rear motor not read motor.

on ARC when i hit right, left, up, down they all control the back motor (forward /back)

the front motor (right left) stays idle

User-inserted image

User-inserted image

United Kingdom
#3  

First, you are planning to use the H-Bridge differently to how the H-Bridge Movement Panel is designed. I presume one motor is intended to drive the car and the other will turn the steering however if this is the case you will probably be disappointed with the results and possibly even cause damage to the steering. The H-Bridge has no feedback therefore doesn't know where the motor is. It is not suitable for such a steering design. Use a servo.

Both motor channels are used for drive wheels. Both move forwards to move the robot forward. Both reverse for reverse. One forward and one reverse causes turning and the opposite for turning the other direction.

Secondly, and I don't mean any disrespect by this at all but it looks like you have almost ruined that H-Bridge with the soldering. Really no offence is meant here but sloppy soldering (and burning/melting of the insulation and plastic parts) can be dangerous, can cause shorts which can lead to unwanted results or even fire. Use jumper cables and plug in to the pins if your soldering skills are not great.

#4  

haha, didn't know the camera has such good detail. In my defense, I bought a bunch of them from ebay. I Just wanted to test out with one before I rewire everything to fit. prototypes usually start off looking ugly. So if its ruined, it only cost me a dollar.

How would you handle the front wheels in this case. After all, the manufacturers of rc vehicles all use similar motors, and they managed to not 'damage' them somehow.

As you can see in the following examples (and tons of others online) an h bridge is used same way as I'm trying to configure it

#5  

Back to the question though, Why does Right and left on ARC control same as up down(second motor) , instead if controlling the first motor

United Kingdom
#6  

The H-Bridge in ARC is set up for the most common type of drivetrain configuration which is two motors, one on the left and one on the right.

To move forwards both motors spin forwards. To move reverse both motors spin reverse. To turn left one motor spins forwards and the other in reverse. To turn right the motors turn opposite to how I described turn left. This is all in the post I linked to previously.

All 4 directions on the H-Bridge Movement Panel cause a different response from the H-Bridge. Right and Left do not do the same as forward and reverse (or up and down as you put it).

All 4 directions will make both motors move in one direction or another as previously described.

If you want to steer by turning the angle of the front wheels you will need feedback of some kind. You could add in a pot, you could use switches etc. but the easiest, cheapest and quickest method would be to use a servo for this. You would then need to use a custom Movement Panel and script for movements.

#7  

Quote:

most common type of drivetrain configuration which is two motors, one on the left and one on the right.

Sounds like the most common setup is a tank or tricycle

Thanks Rich, It clears some things up.

I still find it funny how a low level audrino can handle the hbridge in the way i want it as depicted in the above videos, while ezb can't.

Also, I'd like to use the onboard RC Battery 9.6v

Do you know if that will break the ezb v3a

#8  

I highly doubt an Arduino can drive a steering motor without pots ir encoders to tell it the motor position. Virtually all RC devices use servos for steering bwcause they have precise position control and end limits so tje motor doesn't spin your steering wheel off.

Using a custom movement panel, your h_bridge to drive the rear motors and a servo for steering, the EZ-B can certainly do what you are trying to do.

The v3 can handle 9.6 volts input, but it regulates down to 5v on all of the outputs, so might get a bit hot, but won't damage it.

Alan

#9  

thanks alan, have you seen the videos i posted? theyre both about modding a generic toys r us type rc car using an Hbridge.

mine looks like the car in the second video. i can probably add a servo but i want to try and do less harm to the chassis, by just keeping the current configuration. Any ideas?

if it is a servo, maybe i just need to treat it like one in ARC?

#10  

on second thought, looking at instructables i found this:

Quote:

The common circuit of RC car consist of : 1-Receiver circuit which is define the frequency that the car will work on( for example 40Mhz or 27 Mhz). 2-Controller chip (De-Multiplexer circuit). 3-Dual H-bridge circuit for driving two DC motor (one for backward ,forward and the other for the steering).
http://www.instructables.com/id/Fastest-way-to-Hack-RC-Car-H-Bridge-1/

United Kingdom
#11  

No microcontroller will be able to receive feedback from a H-Bridge without additional encoders or feedback pots. The H-Bridge does not have any inputs for any encoders or feedback pots, it is not physically possible for the H-Bridge (or any software or microcontroller controlling one) to know the motors position without feedback pots or encoders.

You are ill informed if you believe the Arduino can do this.

Once again I will refer you to the tutorial I wrote for the L298n H-Bridge. If covers everything to do with the H-Bridge and how it works. If you read it and understand how it works or at least how the controller using it works with the H-Bridge then you will see the error in assuming anything can control a motor without any type of feedback.

Unless the steering is spring return to the centre position and has physical switches to cut the power to the motor, setting a H-Bridge to move a motor for steering will both damage the motor and robot/chassis and not know where the centre position is therefore losing any ability to return to it.

The use of a servo or, if a H-Bridge is desired, a feedback pot or encoder is essential for the EZ-B, for the Arduino, for the Raspberry Pi, for anything.

#12  

i understand what you are trying to say.

can you explain how it works in the plethora of videos online

United Kingdom
#14  

No. At least not without repeating what's been said multiple times already.

A method for feedback for the position of the motor is essential for accurate movement of a motor. Without such feedback through encoders, feedback pots or limit switches the motor nor the motor controller will know it's position.

It will also be impossible to return to centre position without some means of position feedback or mechanically returning such as spring return.

With no limit switches and no feedback methods there is an extremely high chance of damage to the motor and to the robot/chassis. The H-Bridge will tell the motor to spin in one direction or the other (regardless of micro controller this is always done the same way which is through the in1 to in4 pins on the H-Bridge), without something to tell it to stop the motor will continue to spin or try to spin when it hits any physical limits therefore causing increased current demand and increased battery usage, increase stresses on the motor and in time will end up with a motor which has burnt out due to this.

To return to centre position is impossible as it doesn't know where it is or where centre position is. One poor method used is timings however these are extremely inaccurate.

The end result, regardless of motor controller, regardless of what videos you may have seen online, is a less than satisfactory result which will cause damage.

Read the tutorial on the H-Bridge, search the internet for H-Bridges and read up on how they work, what they do and their limits and you will see that what has been explained to you multiple times now is in fact correct.

The short answer is, and always has been, use a servo for steering or use the drivetrain method which the H-Bridge Movement Panel in ARC is set up for. A H-Bridge is not the correct device for the job regardless of micro controller.

#15  

Pretty sure they were designed to withstand that kind of damage, otherwise your local rc retailer wouldn't have cars that have motors for steering.

If you don't know, no one will look down on you when you admit it.

#16  

I am not saying there aren't steering motors, I am saying that they either have limit switches and centering springs, or encoders and sensors to give position feedback to stop the motor, or clutches to release the gearing at the limits.

The L298n doesn't have inputs for encoder sensors, so if you want to use a motor for steering you will need one of the other solutions. With one of those, you can use a custom Movement Panel to script the commands to give the h-bridge the proper commands to drive it. If you go the easier route of using a servo for steering, you'll still need a custom movement panel, but you will have significantly more precise steering control since you can precisely tell the servo exactly how far to turn and what its limits are with no risk of the motor tearing your front wheels or steering mechanism off or seeing the magic blue smoke as your motor burns itself up because it can't make the wheels turn any further and nothing told it to stop trying.

Alan

#17  

Normally I fix all my spelling errors when posting from my phone, but just got paged out for a problem at work, so not this time. Sorry.

[edit] work issue resolved quickly, so spelling errors fixed.

Alan

United Kingdom
#18  

I cannot repeat myself any longer. It is not a case of me not knowing, I have provided solutions to you and explained how what you are attempting is not the correct way.

Are you not grasping the concept of feedback? How does the micro controller (EZ-B, Arduino, whatever) know when to stop the motor?

The best case scenario is the motor will burn out. The worst case is it could damage the chassis. This is highly likely. Think about it logically.

Refer to the L298n tutorial I wrote, it explains it's operation and the purpose of the pins on the L298n motor controller board. These are the same pins as on the L298n chip which is on the board.

If you want to know how those who have used Arduino to control a steering motor have done it I suggest you ask them. From the ones I saw they reverse engineer the existing H-Bridge on the car, this is not the same as using a different H-Bridge. The existing motor controller may have a number of different aspects to it, it may have some type of limit switch or feedback pot.

But what I do know is if you connected one channel of a L298n H-Bridge to a steering motor you will damage either the motor or the chassis. It is not the correct method. Use a servo or use a feedback pot and limit switches with a spring return to centre.

Asking the same question and ignoring the answers will not change this.

#19  

@Perses... In the link you posted in your post #14 ..... The first video the steering is being controlled by a standard servo motor.... Most RC cars use a servos to control steering, not an H-bridge... The H-bridge is used to control the drive motors only... In several other of your arduino videos it is clear the arduino is controlling the steering, again via a servo... The EZB can do the same thing...

But what do I know....

#20  

Richard R,

How does this one work

Because thats the setup I was following

#21  

I will try with a servo, since i have a ton of these cars, if i break it i can use another:)

#22  

Also, if that video use s a servo, it still runs through an Hbridge. Is it possible to do that with ezb?

Thanks

#23  

Looking at that video, the wheels definitely have centering springs (just watch the way they pop back to the center when the turn request ends). I am not sure if that is a servo, or a housing for a little hobby motor. If it is a motor, there is also probably some kind of clutch mechanism that allows the motor to keep spinning without damaging the turning mechanism when the wheels reach their furthest extent. It isn't limit switches because the wheel is staying turned until power is released, then popping back to center. Best guess is some kind of simple clutch.

If it is a servo, there would be no need to use an H-bridge because the EZ-B (or an Arduino) can drive them directly. You would still use an H-Bridge for your drive motors and just leave the other channel un-used.

Alan

#24  

The bottom line is...why do it the hard way?....Just use a servo and bob's your uncle...The servo will also provide you with variable steering (like a real full sized vehicle) not just extreme right or left...

#25  

no Richard, keeping the current configuration would be theeasy way. removing it, and finding a servo that fits, modding the chassis, would be the hard way

@Alan, the spring back is present in every rc toy i think. just go to toys r us, rc section, and move the front wheels, they spring back.

@Rich, breaking the chassis with the original motor would be impossible, otherwise they simply wouldn't be in every pre-assembled rc car

United Kingdom
#26  

OK, use the H-Bridge... I have attempted to provide you with explanation and solution on a number of occasions. If you dislike the answers you are given why ask the questions? You seem to have an idea in your head and refuse to accept advice given if it does not match what you want.

Do things the hard way if you think it will be easier. It is your choice at the end of the day but you have at least three people here telling you otherwise.

#27  

Can you take some close up pictures of the steering assembly? Is it some kind of rack and pinion set-up? Maybe the motor gear just goes off the end of the rack and keeps spinning at the extent of the turn.

The whole reason we are trying to push you away from using an H-bridge for controlling a steering wheel is that there must be some way to keep the motor from trying to continue pushing the wheel since there is no way to tell the H-bridge to stop at the end unless it is built into the mechanism. But since you have a working mechanism, then getting a custom Movement Panel to make it work should not be difficult at all.

Alan

#28  

Alan, This was taken earlier, i will get a better picture up a little later.

User-inserted image

#29  

Maybe something from below? Can't really see what the motor is attached to from there.

#30  

@Perses ... When they invented air travel I am sure many people still argued that trains were the better way...

Suit yourself dude... as Rich said, it's your project

#31  

@Alan, i took that with my phone, ill be back at the desk leter tonight for better photos.

@Richard, Bad analogy here, apparently, (once again) if servos were the way to go, Manufacturing plants for rc vehicles would of been using them. I may be wrong, if they are indeed servos, but they appear to be motors.

And this is not just one rc vehicle, this is majority of rc vehicles sold worldwide.

So I think the analogy you have provided might be backwords.

#32  

Quote:

And this is not just one rc vehicle, this is majority of rc vehicles sold worldwide.

Maybe RC toys, which I haven't really looked at in any detail. Real RC cars and planes all use servos.

Alan

United Kingdom
#33  

Using a H-Bridge for the steering motor is considered bad practice and is not the solution that I could ever advise on. Forcing a motor to push against it's limits is bad for the motor and while, in this case at least it may not be enough to break the chassis (who knows if it is or not?) it could on other chassis. It will also increase the current draw of the motor which will decrease the battery life amongst other things.

As Alan said, high end RC cars and planes use servos. Cheap $10 RC cars are built to budget and are often found to be poorly built, this one is no exception to that rule.

Also, the YouTube video posted where this method is used, well the scotch tape holding it all together speaks for itself really. At least it has spring return to centre position (without that, good luck!)

If you want a quality build which wont cause problems and wont fall apart spend the time to retrofit a servo to the steering or at the very least a feedback pot.

The quickest way is not always the easiest way.

#34  

Thanks for the advice, despite the fact that it Advocates for reinventing the wheel.

If no one can answer how to use the front motor with ezb, i will consider this post closed due to lack of experience on the matter. This wasn't a question for speculation. It was a, 'I want to use an rc vehicle, by only implementing an Hbridge like with arduino'.

The answer is inconclusive.

Kudos to Rich for steering conversation to switching to a servo, or installing treads.

United Kingdom
#35  

The answer is "doing so will damage the components and is bad practice therefore I am not willing to provide an answer which leaves you with a sub standard end product".

The answer you seek is in the tutorial I wrote which I have referred to multiple times and linked to in the first reply. The tutorial explains how the L298n works. By reading it and understanding it you will find the answer you are looking for.

What we need to understand is that other people may also use this post for guidance, they may search for the same thing but with a lesser quality motor or chassis or a larger motor, both of which could cause damage as previously mentioned. While it may be fine by you to risk ruining a chassis or motor it's not something I want to advise to anyone.

Read the tutorial I posted, learn about what signals to which pins will cause what to happen to both motor channels. It's all there.

Just to reiterate, the lack of the solution you wish to have is not due to inexperience or lack of knowledge but due to refusal to enable bad practice.

#36  

The answer of how to use a front motor is to use a custom movement panel, rather than an H-bridge movement panel, so you can control which digital pins go high or low based on your desired action.

I think we answered that back on the first page. We then tried to explain why it is a bad idea and the kinds of problems you are likely to experience by using an H-bridge in a manner for which it was not designed, but the question was answered.

Alan

#37  

No RC car worth having uses motors for steering rather than a servo.

#38  

@Perses You don't like my analogy?.... LOL.... How about this then.... You can steer an airplane with the rudder... It's not easy or very efficient but it can be done.... If you're the pilot though, wouldn't it be a no brainer just to use the ailerons?.... As @Zap said, real RC cars use servos to steer. Toys use cheap alternatives in order to reduce manufacturing costs...

Head on over to an RC enthusiast forum and ask them how they steer their RC cars....

#39  

thats fine, damaging it is of no consequence to me. this is just for testing. Will eventually move to a custom rig, but for now am trying to conserve space by using onboard motors.

Basically, if it ain't broke, dont fix it. thanks for the work around advice, but id like to stay with my thickskulled rudder idea.

@zap, i agree but the closest rc shop is far, and have no time for it.

I can always order online, but thats waiting time. i was looking for a quick working fix without much work, so i can focus on programming instead of engineering.

#40  

@Alan, here are some closeups

User-inserted image

User-inserted image

User-inserted image

User-inserted image

#41  

Looks like maybe a rack and pinion like I was describing earlier. When the end of the rack is reached, the gear on the motor keeps spinning off the end of the rack holding the position until the motor stops , then the spring returns it to center.

If you need help figuring out how to set up the custom movement panel, post which digital ports you have the H-bridge plugged into on the EZ-B and I'll step you through setting it up.

Alan

#42  

its set up just like the Hbridge video.

Though im guessing the d8 shouldn't control both motors

#43  

Right, you will need 4 digital ports. Two to trigger forward and back on your drive motor, and one for each direction of your steering motor.

See Rich's excellent tutorial linked at the beginning if this thread for wiring (he also covers the jumper settings for speed control either both motors controlled by the same pwm, ir separately).

However, the H-bridge control won't work in your setup because it will be giving commands to the drive motor for steering. Once wired up let me know the port ids and I'll help with the next part.

(or, I may write it up more generically when I am in front of my computer in an hour or two)

Alan

United Kingdom
#44  

You'll also need to decide if you want the turning to be while moving forwards or while reversing.

Problems aside, you may be better using a few scripts and ControlCommand() to trigger them for forwards, reverse, forwards & left, forwards & right, backwards & left and backwards & right.

The forward/reverse & left/right could just fire off ControlCommand() too (one for each part).

Then your forward command would simply be setting the required ports high or low and PWM (if required).

For example purposes, presuming ports D0 to D3 are on In1 to In4. D4 & D5 for PWM. Motor channel 1 is drive Motor channel 2 is steering

Forwards would be


Set(D0, On)
Set(D1, Off)
PWM(D4, 100)

Reverse would be


Set(D0, Off)
Set(D1, On)
PWM(D4, 100)

Stop would be


Set(D0, Off)
Set(D1, Off)
PWM(D4, 0)

Emergency Brake (if applicable/required) would be


Set(D0, On)
Set(D1, On)
PWM(D4, 100)

Turning of the steering motor would be similar but with D2, D3 and D5. Forward would make it turn one direction and Reverse would make it turn the other. Stop would return to centre. There's a possibility that Emergency Brake would hold it wherever it is. If that's the case, add in two limit switches, one for full lock left and one for full lock right and throw in some monitoring, this will improve safety and remove that bad practice I mentioned yesterday.

Part of the turning code would be; For one direction


Set(D2, On)
Set(D3, Off)
PWM(D5, 100)

The other direction flip the ons and offs.

Use as part of a bigger script with feedback pots or limit switches to protect against damage.

Then add a custom movement panel. For each direction use ControlCommand() to start or stop the required scripts to set the pins on the H-Bridge as necessary.

#45  

Heres my setup, just like DJs video

User-inserted image