Go Down

Topic: Arduino software programmer needed (Read 923 times) previous topic - next topic

cga

I am needing a programmer/consultant who can write a sketch for me.
I have an Uno. 8 channel Relay. and a Analog 4 axis Joystick.
I need a sketch that will use the joystick to operate X and Y axis,
1. 12v DC motor (left/Right) X
2. 12v Dc Motor/Actuator (up/Down) Y
3. Use the moentary button on the joystick to activate a relay channel off/on for a 12v pump
4. 12v Dc motor Forward/Backward using the 4th axis of the joystick
i would need to be able to set speed and limit rotational movement.
Contact me if interested.

wvmarle

You have to provide a lot more information before a job like this can even be considered

- how to set the direction of the DC motors? Which pins, what signals?
- how to set the actuator? Which pins, what signals?
- you mention you need to "set speed and limit rotational movement" - what hardware do you have in place to provide this feedback? What signals to expect?
- you mention an 8-channel relay board, is that for switching the motors? If so, what options are there to actually set the speed of the motors beyond a simple on/off?
- what signals come from the joystick, what range of analog inputs?

The above must be provided in minute detail. Without those details there is just no chance to even start writing a sketch.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

cga

I can wire as diagramed/needed. But i have been using....
  A0 for the X axis and A1 for the Y, utilizing the  potintometers on the joystick.
Pins Out on the Adruino 3&4 for the X, 8&9 for the Y. (PWM)
On the Relay i have used 1&2 for inputs from 3&4. Relay pin in's 3&4 are recieving from 8&9.
I was assuming using the 8 channel relay as the switch for all of it.
Was assuming the code/sketch would be able to set the limits in it for speed and also set for the rotation?

cedarlakeinstruments

Shouldn't be a difficult task. Do you have a motor driver chosen yet, or are you controlling the motors directly from the relays right now?

Very often I suggest a completely different hardware configuration since starting with what the project builder already has is suboptimal. In this case, hardware choices would depend very much on how powerful the motors are, the speed and loads required and the application. e.g., does it need Emergency Stop capability? What motion limits are needed, etc.

I've spent most of my career doing various forms of motion control and it's amazing how complex even the simplest-looking applications really are.

Send me a PM and we'll talk.
Electronics and firmware/software design and assistance. No project too small

wvmarle

I can wire as diagramed/needed. But i have been using....
  A0 for the X axis and A1 for the Y, utilizing the  potintometers on the joystick.
Pins Out on the Adruino 3&4 for the X, 8&9 for the Y. (PWM)
On the Relay i have used 1&2 for inputs from 3&4. Relay pin in's 3&4 are recieving from 8&9.
I was assuming using the 8 channel relay as the switch for all of it.
Was assuming the code/sketch would be able to set the limits in it for speed and also set for the rotation? \
PWM and relays don't work together. You may get very noisy relays (if the frequency is low enough for the relay to follow it), more likely it will just switch on or off the relays completely. You need motor drivers, H-bridge configuration if you want directional control. H-bridges normally have four inputs.

Code can not set limits to speed/rotation without feedback. Code can change PWM rates to get to a certain speed, but it has to have some form of feedback to know what speed the motor is actually at. Same for limits to rotation. You need some form of feedback that a limit has been reached - e.g. a microswitch, or a break beam sensor, or a magnet + reed switch or hall effect sensor - something like that.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Anshu_Raj

PWM and relays don't work together. You may get very noisy relays (if the frequency is low enough for the relay to follow it), more likely it will just switch on or off the relays completely. You need motor drivers, H-bridge configuration if you want directional control. H-bridges normally have four inputs.

Code can not set limits to speed/rotation without feedback. Code can change PWM rates to get to a certain speed, but it has to have some form of feedback to know what speed the motor is actually at. Same for limits to rotation. You need some form of feedback that a limit has been reached - e.g. a microswitch, or a break beam sensor, or a magnet + reed switch or hall effect sensor - something like that.
Yes exactly!
You can control the direction of the motors by creating a H-Bridge using Relays (4 relays just for 1 motor).
But, controlling speed of motors using Relays?? I don't think so. As relays are only for closing a particular circuit. Relays don't have anything to do with the amount of current going to your motors. So you can't control your motor speed I guess.

cga

I will look at the H bridge set ups. Right now i am using a 8 modue realy analog read function of the Arduino (PWM), 5K pot, I am not needing speed in the motors, and have considered servos instead. However... I am using a 12v dc motor connected to a gear to move my spray nozzel LEFT/RIGHT. And the actuator to move the same nozzel UP/DOWN. I thought making a Joystick configuration would be best then the switches i have been using. And the Arduino seemed to be a good platform to build/control with. This is the code i am working with right now.
 /* 
  Joystick Model OM400B-M2 www.omter.com
  Joystick control with Arduino Uno and 8 channel relay Module Controller
  Motor A 12v DC controlong LEFT/RIGHT relay channels 1&2 (need to be able to set 90degree rotation limit both ways and speed),
  Motor B 12v dc Actuator OPEN/ClOSE relay channels 3&4,
  Motor C 12v DC pump ON/OFF via switch realy channel 5,
  Motor D 12v DC controling Valve OPEN/ClOSE realy channels 6&7 (set limits of motor rotation and speed to control valve/ i.e. how long motor runs and how fast)
 
*/
 
// Motor A LEFT/RIGHT
 
int in1 = 9;
int in2 = 8;
 
// Motor B actuator OPEN/CLOSE

int in3 = 3;
int in4 = 4;

// Motor C momentary button

int in5 = 2;

// Motor D valve motor

int in6 = 6;
int in7 = 7;

// Joystick Input
 
int joyVert = A0; // Vertical 
int joyHorz = A1; // Horizontal
int pot1 = A3; // Motor D

// Motor Speed Values - Start at zero
 
int MotorSpeed1 = 0;
int MotorSpeed2 = 0;
int MotorSpeed3 = 100;
int MotorSpeed4 = 0
int MotorSpeed5 = 0

// Joystick Values - Start at 512 (middle position)
 
int joyposVert = 512;
int joyposHorz = 512; 
 
 
void setup()
 
{
 
  // Set all the motor control pins to outputs
 
 
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(in5, OUTPUT);
  pinMode(in6, OUTPUT);
  pinMode(in7, OUTPUT);
 
  // Start with motors disabled and direction forward
 
  // Motor A
 
   
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
 
  // Motor B
 
 
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);

  // Motor C

  digitalWrite(in5, HIGH);

  //Motor D
 
  digitalWrite(in6, HIGH);
  digitalWrite(in7, LOW);
}
 
void loop() {
 
 // Read the Joystick X and Y positions
 
 joyposVert = analogRead(joyVert);
 joyposHorz = analogRead(joyHorz);
 
 // Determine if this is a forward or backward motion
 // Do this by reading the Verticle Value
 // Apply results to MotorSpeed and to Direction
 
 if (joyposVert < 460)
 {
 // This is Backward
 
 // Set Motor A backward
 
 digitalWrite(in1, LOW);
 digitalWrite(in2, HIGH);
 
 // Set Motor B backward
 
 digitalWrite(in3, LOW);
 digitalWrite(in4, HIGH);
 
 // Set Motor D backwards
 
 digitalWrite(in6, LOW);
 digitalWrite(in7, HIGH);
 
 //Determine Motor Speeds
 
 // As we are going backwards we need to reverse readings
 
 joyposVert = joyposVert - 460; // This produces a negative number
 joyposVert = joyposVert * -1;  // Make the number positive
 
 MotorSpeed1 = map(joyposVert, 0, 460, 0, 255);
 MotorSpeed2 = map(joyposVert, 0, 460, 0, 255);
 
 }
 else if (joyposVert > 564)
 {
 // This is Forward
 
 // Set Motor A forward
 
 digitalWrite(in1, HIGH);
 digitalWrite(in2, LOW);
 
 // Set Motor B forward
 
 digitalWrite(in3, HIGH);
 digitalWrite(in4, LOW);
 
  // Set Motor D forward
 
 digitalWrite(in6, LOW);
 digitalWrite(in7, HIGH);
 
 //Determine Motor Speeds
 
 MotorSpeed1 = map(joyposVert, 564, 1023, 0, 255);
 MotorSpeed2 = map(joyposVert, 564, 1023, 0, 255);
 
 }
 else
 {
 // This is Stopped
 
 MotorSpeed1 = 0;
 MotorSpeed2 = 0;
 
 }
 
 
 // The Horizontal position will "weigh" the motor speed
 // Values for each motor
 
 if (joyposHorz < 460)
 {
 // Move Left
 
 // As we are going left we need to reverse readings
 
 joyposHorz = joyposHorz - 460; // This produces a negative number
 joyposHorz = joyposHorz * -1;  // Make the number positive
 
 // Map the number to a value of 255 maximum
 
 joyposHorz = map(joyposHorz, 0, 460, 0, 255);
   
 
 MotorSpeed1 = MotorSpeed1 - joyposHorz;
 MotorSpeed2 = MotorSpeed2 + joyposHorz;
 
 // Don't exceed range of 0-255 for motor speeds
 
 if (MotorSpeed1 < 0)MotorSpeed1 = 0;
 if (MotorSpeed2 > 255)MotorSpeed2 = 255;
 
 }
 else if (joyposHorz > 564)
 {
 // Move Right
 
 // Map the number to a value of 255 maximum
 
 joyposHorz = map(joyposHorz, 564, 1023, 0, 255);
   
 
 MotorSpeed1 = MotorSpeed1 + joyposHorz;
 MotorSpeed2 = MotorSpeed2 - joyposHorz;
 
 // Don't exceed range of 0-255 for motor speeds
 
 if (MotorSpeed1 > 255)MotorSpeed1 = 255;
 if (MotorSpeed2 < 0)MotorSpeed2 = 0;   
 
 }
 
 
 // Adjust to prevent "buzzing" at very low speed
 
 if (MotorSpeed1 < 10)MotorSpeed1 = 0;
 if (MotorSpeed2 < 10)MotorSpeed2 = 0;
 
 // Set the motor speeds
 
 analogWrite(in1, MotorSpeed1);
 analogWrite(in3, MotorSpeed2);
 analogWrite(in5, MotorSpeed3);
 analogWrite(in6, MotorSpeed4);
 analogWrite(in7, MotorSpeed5);
}

wvmarle

Did you actually try to run this code?
If so, what happens?

It sounds like you're building some kind of remote controlled fire hose.

Motor A: that very much sounds like a job for a servo, so you can simply tell the device which direction it has to point at. With a motor you have to build all that directional feedback and control yourself.

Motor B, which apparently is not a motor but an actuator: in your description you say it's moving the nozzle up/down, in your code you say it opens and closes something. What is it?
If it's the first, again a servo may be more appropriate. Or at least you need an actuator that tells you where it is along its path.
If it's the second, it sounds like a job for a solenoid valve. Open/close, that's it.

Motor C: no issues. Just a pump, switch it on and off.

Motor D: another valve? One that can open/close partially to regulate flow I take it? That'd be more of a job of a valve with linear actuator. Again you need positional feedback from the valve to have any chance of regulating closing speed and so.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

cga

right now in testing phase. I have a l298N motor driver coming in this week to test with it.

Motor A moves the sprayer left right with a gear system.
Motor B moves an actuator Up/down to move the nozzle. Actuator has a built in limit switch to stop it at full extension and visversa.
Moor C No problems.
Motor D i have not began the sketch writing process any farther yet.

Problem right now when running sketch is motor A and B run at the same time (not independently via pot/analog input) move joystick left and both motors run.

If i can locate a valve/solenoid that can be run open/close via power on/off and can handle at least 1000psi then i can re write Motor D to replicate Motor C . The pump i am running has an automatic bypass when main is closed.

Yes, this is to be able to operate a mounted spray gun on the front of my skid steer, so i wont have to walk as much.lol

I am a newbie when it comes to coding. Well all of it. i have a problem (spray gun remote mount) and i thought the arduino control offered teh solutions to it. I just dont have enough time between family and work to learn it and work out the issiues.

Go Up