XY Routine to control 2 DC Motors with L6204+L6506

Im tryng to create a XY routine to control 2 DC-Motors with L6204+L6506 Ic's.
I have the 2 DC Motors, 2 end stop switches for each axis and 1 switch to set the motors to "home". In that case "home" is a middle position.
So, the chalenge is: Initialize the motors and set than to home position. After that, i want to control this motors separately with another 2 switches. Can you guys hellp me on this project?

What have you tried? there are many, many examples of controlling a motor. Some of those examples are even built into the IDE (File->examples->....)

Give it a shot. If/When you get stuck, post back with your code, the issues and people will help.

1 Like

Only if you can tell us how you know which way to turn the motor to reach the middle position switch!

1 Like

The L6204 is a H-BRIDGE like L293... i already have those Ic's here. They work exacly the same way L293! I just want to read the end stops, count the pwm pulses and set the motor to middle point of axis...

This is the datasheet of L6204 H-BRIDGE

I'll repeat... what have you tried? Have you written some code to read the switches? Does it work? Have you written any code to make the motors run? Does that work?

How is it wired up? And what power supply are you using to power those motors?

1 Like

No code yet. I'm just trying to figure out about what kind of syntax should use in this case. My problem isnt in the hardware approach, it is in the code itˈself!
The motors running in 24v trhough the H-Bridge, wich contain a ENB, IN1 and IN2 pins to control the motor.

That's not generally how DC motors work. Are you thinking each pulse moves the motor one small bit of distance? ( Like a Stepper motor?)

Can you control the position of one of your DC motors with one driver?

1 Like

My idea was to count the pulses sent to the driver (H-Bridge), between the two end stops... Then divide this count by 2 and send it again to the driver so that it places the motor in the middle of the path!

That would work for a stepper motor and a stepper motor driver.

But for a PWM-controlled DC motor, it sends the same number of pulses per unit-of-time, but varies how much energy is in the pulses to vary how fast the motor moves.

1 Like

There is no way to count this pulses between switch0 and switch1? S1 and S2 are the end stop's...

...Yes, you can count PWM pulses, they come out of an Arduino UNO at 490Hz or 980Hz per analogWrite() - Arduino Reference but you'd also need the Widths of the PulseWidthModulation signals to get the energy, and then that still wouldn't be enough to get you to an accurate position.

PWM acts somewhat like a throttle in a car--it would be hard to control position of a car knowing just the RPM history of the engine during a trip.

1 Like

If you are talking about PWM-pulses it will be pretty difficult to count them.
But there is a much bigger problem than that.

The distance how far the motor will move with a single pulse will be varying toooooo muuuuuch!
You might get a precision of 5 mm out of this.
I wouldn't be astonished of the precision is only 10 mm.

This means you do a first "reference"-drive
with lets say exact 10000 PWM-"pulses"
and the motor is at let's say 215 mm which might be the exact middle.

then you do another exact 10000 PWM-"pulses" "reference"-drive and then your DC-motor will be at position 205 mm

then you do another exact 10000 PWM-"pulses" "reference"-drive and then your DC-motor will be at position 225 mm

If DC-motors are used for positioning they always have an encoder which gives exact feedback about the real position

And then these motors are no longer simple DC-motors. Then these motors are servo-drives which require a much more complex driver-electronic than a L293 or L6204

Without such a feedback you are lost.

A stepper-motor works totally different. Stepper-motors rotate a small amount with each step and then stop at a well defined position.

DC-motors stop wherever they want, influenced by things like speed you have reached big load or small load, a lot of friction or small friction etc. etc. etc.

describe the final purpose of your project

You should write about the final purpose of your device.
If the final purpose is known then good suggestions how to reach this purpose can be made

2 Likes

depending on your budget you can realise a XY-movable device pretty cheap if you don't want high perfomance and high precision.

How much performance and precision is needed depends on your final purpose to move XY.

It might be possible for $30 it might require $500 depending on your real project and your requirements about perfomance and precision.

1 Like

I just want to replace an old control board... The board work with the L6204 without a encoder, just with 2 switchs to refference location

I will post some photos latter

Pics? Better description?

If the motors happen to run at consistent speeds, perhaps like a gearmotor driving a leadscrew, you could measure the time between switch activations.

1 Like

LeadScrew!

OK, maybe you can just measure time then. If there is a PWM adjustment on the existing device it likely controls speed, and you'd need to re-measure the times whenever you change the PWM/speed.

1 Like

My bad guys...There is a third switch! Which is located at a midpoint of the route.