Go Down

Topic: DC Motor and Potentiometer positioning (Read 1 time) previous topic - next topic

THX_RoG

#15
Mar 09, 2013, 06:05 pm Last Edit: Mar 09, 2013, 08:14 pm by THX_RoG Reason: 1
dude ur amazing i just looking for the deadband code
Code: [Select]
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
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

zoomkat

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


What happened when you tried it?
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

THX_RoG

nothing my values wear 0 on both potentiometers
now have issue withe the deadband when i use
Code: [Select]

if (val1 < (targetval1-10) | val1 > (targetval1+10){
if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
                         targetval1=val1
}

my code works one whey
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

AWOL

There's a difference between bit wise OR |  and (no pun intended) logical OR ||
"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.

THX_RoG

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

AWOL

"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.

THX_RoG

here is the code
Code: [Select]

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();
}
}
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

zoomkat

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

Code: [Select]
if ((targetval1=val2)||(val1=minval)||(val1=maxval))
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

THX_RoG

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: [Select]

             if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}

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

zoomkat

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
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up