I"m stumped, could someone help me?

Hello, my name is Alfonso. I would like to express gratitude in advance for any help or advice. I’m very new to programming but learning. I have recently embarked on a project and i have hit a wall. I am trying to emulate a product for less. Here is the link to the product.

https://www.wakemakers.com/go-surf-assist-aftermarket-surf-system.html

Here is my thought process. I already have bought trim tabs, and have custom fabbed similar devices but more aggressive from the link above. Here is were i come to a halt. The actuators are DC (without feed back) I was thinking of using a dual H-bridge to be able to reverse polarity, and with a potentiometer to control the position of the actuator. All while the 2 momentary switches control which actuator is activated.

Below I have included what i have so far.(keep in mind its very much a work in progress)

Thanks.

int pbutton = 11;         // port botton
int sbbutton = 12;        // Starboard botton 
int sbbuttonled = 2;      // Starboard botton led
int pbuttonled = 3;       // port botton
int pae = 10;             // port actuator enabble (PWM SIGNAL)
int pin1 = 9;             // port actuator fwd rev signal
int pin2 = 8;             // port actuator fwd rev signal
int sbae = 5;             // starboard actuator enabble (PWM SIGNAL)
int in3 = 7;              // starboard actuator fwd rev signal
int in4 = 6;              // starboard actuator fwd rev signal
#include <Servo.h>
Servo myservo;            // create servo object to control a servo
int potpin = 0;           // analog pin used to connect the potentiometer
int val;                  // variable to read the value from the analog pin


void setup() {            // put your setup code here, to run once:
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
 
  pinMode(pae, OUTPUT);
  pinMode(sbae, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
pinMode(pbutton, INPUT);
pinMode(pbuttonled, OUTPUT);
pinMode(sbbutton, INPUT);
pinMode(sbbuttonled, OUTPUT);
// start up 

digitalWrite(pbuttonled, HIGH);
digitalWrite(sbbuttonled, HIGH);
delay(750);
digitalWrite(pbuttonled, LOW);
digitalWrite(sbbuttonled, LOW);
delay(750);
digitalWrite(pbuttonled, HIGH);
digitalWrite(sbbuttonled, HIGH);
delay(750);
digitalWrite(pbuttonled, LOW);
digitalWrite(sbbuttonled, LOW);



  // put your setup code here, to run once:


}

void loop(){
 val = analogRead(potpin);             // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

{if(digitalRead(pbutton) == HIGH){
  
  digitalWrite(pbuttonled, HIGH);
  digitalWrite(sbbuttonled, LOW);
  val = analogRead(potpin);             // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

}

  

if(digitalRead(sbbutton) == HIGH){
 
  digitalWrite(sbbuttonled, HIGH);
  digitalWrite(pbuttonled, LOW);
}
  
  
}
}

start_up.ino (2.11 KB)

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :)

Ajpacheco87: Below I have included what i have so far.(keep in mind its very much a work in progress)

You have not told us what happens when you run the program or what you want it to do that is different.

...R

TomGeorge: Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :)

Done... and thanks!

Robin2: You have not told us what happens when you run the program or what you want it to do that is different.

...R

Its not done yet. i haven't even complied it...lol

Bump*

Ajpacheco87: Bump*

When you have tried your program and run into a problem, perhaps you will find answers here.

I am familiar with Wakemakers. I still have product they bought and paid for setting on the shelf for a year or so.

Paul

Sounds like you don't have a problem, just a prototype you are unsure of. Test it, if it works first time, something can always be made better. What problems are there when tested? What works and what doesn't? What parts are you using? Always double-check your design or code!

Ajpacheco87: Its not done yet. i haven't even complied it...lol

Ajpacheco87: Bump*

That seems a rather pointless succession of posts.

Did it not occur to you that my comment You have not told us what happens when you run the program or what you want it to do that is different. was a hint to get YOU do do something ?

...R

What is this "Bump" you speak of?

KingDubDub:
What is this “Bump” you speak of?

It is someone imagining that if no-one answers their question, asking the exact same question again will cause someone to answer. :roll_eyes:

KingDubDub: What is this "Bump" you speak of?

Its what you are not supposed to do to a pinball machine even if the ball is stuck. :) :) :)

Ajpacheco87: Bump*

It is when someone does not receive instant gratification to a question, so they try and move it back up to the top of the forum, it is considered very rude behavior, keep in mind that most helpers in forums are not paid, I have known many people in forums that will not help a bumped thread and will let it age back down.

Had one time needed help and the only one that could help was the developer that was in the forum once every 24 hours, took a while but I got a very good answer and they improved their app.

Also depending on the help required there might only be a few people that have the background to help on a project, also reading someone else's code without running it is extra difficult.

I would consider a "bump" to be OK if there had been no response to a Thread for 2 or 3 days.

...R

Couple of quick thoughts on your code and idea in general. You might also give us a clue on what exactly you are stumped about.

Think about using a proper Button class to handle your button reading. Google "debounce switch arduino" to find out why.

You are going to need some kind of variable to keep track of where the program thinks the servo position is at. Thus when you push right/left button the variable is incremented/decremented by some value and then with the pot reading, sets the servo. Also don't forget your high/low limits and prevent any values outside the range you want.

The servo class I thought was for running simple relatively low power servos like RC guys use. H bridges circuits aren't quite the same thing. Look around and see if there isn't a library for H bridge motor controls. I would recommend testing your code on a small scale hobby motor and off the shelf H motor controller module/board. So you aren't possibly destroying high powered stuff of the final design.

Speaking of which, what kind of actuators are you planning on using? I can only imagine they will need to be fairly beefy to push a plate into the water at any speed at all. Either go overboard (no pun intended) and get bigger than you need, otherwise, I'd think about current detecting and limiting it so you don't burn them up (too fast). Maybe some H bridge chips might have this feature.

Good luck on the project and I have first dibs on getting to ride/surf with it :)