Pages: 1 [2]   Go Down
Author Topic: DC Motor and Potentiometer positioning  (Read 1739 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino in VS MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dude ur amazing i just looking for the deadband code
Code:
void Motor()
{
val1=analogRead(Poti1);
val2=analogRead(Poti2);
if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}
if ((val1=val2)||(val1=minval)||(val1=maxval))
{
Motor_OFF();
}
}
one question can i put val = analogread to a different void or this wouldn't work
« Last Edit: March 09, 2013, 02:14:33 pm by THX_RoG » Logged

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
one question can i put val = analogread to a different void or this wouldn't work

What happened when you tried it?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino in VS MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

nothing my values wear 0 on both potentiometers
now have issue withe the deadband when i use
Code:
if (val1 < (targetval1-10) | val1 > (targetval1+10){
if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
                         targetval1=val1
}
my code works one whey
Logged

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26471
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a difference between bit wise OR |  and (no pun intended) logical OR ||
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino in VS MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

still no use the same problem
Logged

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26471
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Still no code
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino in VS MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here is the code
Code:
void Motor()
{
val1=analogRead(Poti1);
val2=analogRead(Poti2);
targetval1=(val1<(val1-10)||val1>(val1+10));
if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}
if ((targetval1=val2)||(val1=minval)||(val1=maxval))
{
Motor_OFF();
}
}
Logged

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The below might need some attention, depending on just what you are trying to accomplish.

Code:
if ((targetval1=val2)||(val1=minval)||(val1=maxval))
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino in VS MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

my minval is 10 and my maxval 1000 thats because i don't want damage the potentiometer so im using this as a stop point
it seems to me as hes in loop with this part
Code:
             if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}
Logged

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something that may/may not make a difference depending on what you are trying to do.

http://arduino.cc/en/Reference/Assignment

http://arduino.cc/en/Reference/If
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: 1 [2]   Go Up
Jump to: