Speed stabilise through input

Hi , i’m working on a project of controlling a 12v dc motor that it will open and close a valve according to the input and the speed.

I have the speed
I have the how much meters per hour it goes
But i cant understand how i have to think to get
Lets say, i insert a value 25 m/h, and speed is showing 40 m/h, how im gonna write the code so it will check the speed and if its bigger than my input it will turn motor left if it’s lower right so somehow it will stabilise to my input

Do you have a sketch that simply runs the motor in one direction or the other ?

If so then assuming that you can read the speed

if (speed < targetSpeed)
{
  //code here to speed up
}
else if (speed > targetSpeed)
{
  //code here to slow down
}

So target speed will be my input? And this will be inside a void loop right? Thank you very much

It is a little more complicated that that but in essence, yes, that is how you do it

I know its more complicated thats for sure still thank you, one more fast question, lets say i made it through relays but when it gets close to my input speed 40 it goes up 41 and then goes down 39, what i can do for that? Should i make the relay work for less time if the difference is less than 3 ? Or should i not use relay in general an check for another way

Hi.

The speed of what?
How are you measuring the speed?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Im measuring the speed/meters/mph through a rotary encoder. And there is a valve that i mount a 12 volt dc motor on top of it that will turn left and right to open and close it, when i open it the speed increase when i close it the speed decrease. So the question was what way should i use to control the motor so it will stabilise to my input, my input is 40 m/h , the screen shows 30 m/h so it have to open to get to 40 and stop

Hi

Of the fluid with an encoder mounted to a flowmeter?
Litres per minute?

Specs of the valve motor?
Power? Current? Stall Current?

Thnaks... Tom.. :smiley: :+1: :coffee: :australia:

It is mounted on a wheel and the wheel goes on top of a hose the hose is moving and the rotary is gathering the speed.
The valve is a simple 3 inch brass gate valve, when i open the valve the hose reel faster, when i close it the hose reel slower.
Motor is 12 volt Bosch window regulator motor, 13 Nm torque, 2 pin connector

Do you have any position feedback on the valve? How do you know when it is fully open or fully closed or in an intermediate position?

I dont have any position feedback, but what i think is i don't have to even know, cause even if its fully closed it will have to open it to match my input speed

Please explain more about these relays. What you are using to control the on/off of the motor, possibly the speed it runs, and the the direction it turns.

image
This are the relays i am gonna use 2 channel 12 volt module

Thats the motor im gonna use it have 2 pins which it will get connected one to each relay i think im still not sure if it is the best way to do it . And the through Arduino i will program it to turn left or right to open or close the valve, maybe use a command like/ open relay for 1 sec ,check the speed, if the difference is more than 10 m/h open again for 1 sec etc. dont know how else to think. With my low experience and research i come up with this idea. If you think there is a better way please you are welcome

The relay will be connected to a battery 12 v 6 ah

Hi,

You need to know when fully open and fully closed so you do not try and drive the motor against the valve stops and damage something, possibly the motor.

Have you measured the current that the motor draws at 12V?
You need to know this to make sure the relay contacts can handle the current.

Do you have a DMM?

Tom... :smiley: :+1: :coffee: :australia:

You are right , what you suggest

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.