Loading...
Pages: 1 [2]   Go Down
Author Topic: DC Motor and Potentiometer positioning  (Read 626 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino in Visual Studio 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

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6535
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

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino in Visual Studio 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

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19003
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.

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino in Visual Studio MODE
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

still no use the same problem
Logged

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19003
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.

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino in Visual Studio 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

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6535
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

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino in Visual Studio 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

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6535
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

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Pages: 1 [2]   Go Up
Print
 
Jump to: