This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hydraulic pump - convertible top- replacement for linear actuator
#18
Hi, my controller only has two pins: PWM and DIR. If DIR is HIGH it drives the pump one way and if it is LOW it drives it the other. The PWM input controls the speed. I greatly simplified the Arduino code, the main change being in the position() function:

// this function is called from update_command function (which is called every 20 mS by a timer) to set the motor speed and direction. The parameter (value) is sent from the PyPilot app. 1000 = do nothing. < 1000 = turn to Port (check). >1000 = turn to Starboard
// The amount the value differs from 1000 = how fast to run motor???
// Force stop motor if bypass valve open added 13/01/21
// This function sets a global Var (PWMout) which is used in main() to do an analog.write to the PWM pin.
void position(int value)
{
int cValue = 0;
cValue = abs(1000-value); // calculate amount of movement required from neutral
if (value > 1000) {DIRstate=1;} else {DIRstate=0;} // set direction of pump
PWMout=0; // default is to stop pump
if ((cValue > 20) && (BypSWS == true)) // check cValue > deadband AND bypass is NOT open (FALSE if it is)
{
PWMout = map(cValue,0,1000,125,255); // map from 0 - 1000 to suit PWM out 100 - 255 (125 to give min speed for pump to run)
}
// debug
// lcd.setCursor(0,0);
// lcd.print("v= ");
// lcd.print(value);

// set pump direction and speed
digitalWrite(pumpDIR, DIRstate);
analogWrite(pumpPWM, PWMout); // write PWM value to output

lastpos = value; // keep a copy of the last command value (used in rate of change calculation
} // end of position function

Regards
David
Reply


Messages In This Thread
RE: hydraulic pump - convertible top- replacement for linear actuator - by drbarritt - 2022-04-13, 05:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)