Notifications
Clear all

Uno Glitches

2 Posts
1 Users
0 Likes
1,200 Views
(@darkar)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

Hello. Looking for advice. One year ago I started building a control for solar trackers. I finally got it working about October last fall without any glitches. It has worked perfectly for 6 months. When it decided to go completely around Clockwise 3 times and rip all the AC wiring etc. apart. There are limit switches in the unit that is supposed to prevent this so that is another issue. Got it straightened out and it worked fine for a week and it went around 8 times Counter Clockwise. With my code it should never get close to the limit switches in the unit because it has a compass to tell it where it is. I made a remote that I can plug in to move the unit around manually. So logic wise the only thing that makes sense is that it thinks it is getting a remote move signal. I have 4 buttons that when pushed can move the unit in different directions (pins 10-13). If more than 1 button is pushed it stops all movement. No buttons pushed it is in Auto and does its thing. 

So here is the problem. I am suspicious of the manual inputs. I can push buttons in any order and every thing works fine. But I can push 2 buttons and if they are pushed for 5 to 10 minutes you need to release all buttons and start auto then you can get manual to work again.  I do not own a real arduino. Just cheap clones but they have seemed to work just fine. Is it possible that the processor could think it is getting voltage from a pin even though there is none. Would a real Arduino work any better.

The whole code is lengthy but this is the manual button portion.

Any advice would be appreciated. Thank you for your help.

 

//////////// Evaluate Manual Operation Buttons. More than One Button Pushed all motors stopped. ////////////

rightbutton = digitalRead(rbuttonPin);
if (rightbutton == HIGH)
{
rightbutval = 1;
}
else
{
rightbutval = 0;
}

leftbutton = digitalRead(lbuttonPin);
if (leftbutton == HIGH)
{
leftbutval = 1;
}
else
{
leftbutval = 0;
}

topbutton = digitalRead(tbuttonPin);
if (topbutton == HIGH)
{
topbutval = 1;
}
else
{
topbutval = 0;
}

botbutton = digitalRead(bbuttonPin);
if (botbutton == HIGH)
{
botbutval = 1;
}
else
{
botbutval = 0;
}

manbutval = (rightbutval + leftbutval + topbutval + botbutval);

/////////////////// Manual Operation Control. ////////////////////

if (manbutval > 1)
{
MotorOff(TurnMtrLeftIn1, TurnEn);
MotorOff(TurnMtrRgtIn2, TurnEn);
MotorOff(TiltMtrDwnIn3, TiltEn);
MotorOff(TiltMtrUpIn4, TiltEn);
Serial.println(" MAN Stop ");
goto END;
}

if (manbutval <= 1)
{
{ rbutLastState = rbutState;
rbutState = digitalRead(rbuttonPin);
if (rbutState != rbutLastState)
{
if (rightbutton == HIGH)
{
MotorOff(TurnMtrLeftIn1, TurnEn);
MotorOff(TiltMtrDwnIn3, TiltEn);
MotorOff(TiltMtrUpIn4, TiltEn);
MotorOn(TurnMtrRgtIn2, TurnEn);
Serial.println(" MAN RT ");
goto END;
}
if (rightbutton == LOW)
{
MotorOff(TurnMtrRgtIn2, TurnEn);
}
}
}

{ lbutLastState = lbutState;
lbutState = digitalRead(lbuttonPin);
if (lbutState != lbutLastState)
{
if (leftbutton == HIGH)
{
MotorOff(TurnMtrRgtIn2, TurnEn);
MotorOff(TiltMtrDwnIn3, TiltEn);
MotorOff(TiltMtrUpIn4, TiltEn);
MotorOn(TurnMtrLeftIn1, TurnEn);
Serial.println(" MAN LT ");
goto END;
}
if (leftbutton == LOW)
{
MotorOff(TurnMtrLeftIn1, TurnEn);
}
}
}

{ tbutLastState = tbutState;
tbutState = digitalRead(tbuttonPin);
if (tbutState != tbutLastState)
{
if (topbutton == HIGH)
{
MotorOff(TurnMtrLeftIn1, TurnEn);
MotorOff(TurnMtrRgtIn2, TurnEn);
MotorOff(TiltMtrDwnIn3, TiltEn);
MotorOn(TiltMtrUpIn4, TiltEn);
Serial.println(" MAN UP ");
goto END;
}
if (topbutton == LOW)
{
MotorOff(TiltMtrUpIn4, TiltEn);
}
}
}

{ bbutLastState = bbutState;
bbutState = digitalRead(bbuttonPin);
if (bbutState != bbutLastState)
{
if (botbutton == HIGH)
{
MotorOff(TurnMtrLeftIn1, TurnEn);
MotorOff(TurnMtrRgtIn2, TurnEn);
MotorOff(TiltMtrUpIn4, TiltEn);
MotorOn(TiltMtrDwnIn3, TiltEn);
Serial.println(" MAN DN ");
goto END;
}
if (botbutton == LOW)
{
MotorOff(TiltMtrDwnIn3, TiltEn);
}
}
}
}


   
Quote
(@darkar)
Member
Joined: 3 years ago
Posts: 7
Topic starter  

My mistake (again). I need to always assume I am the problem and not the equipment. I had changed some values in the sketch while trouble shooting another problem and forgot to change it back. These things seem to do exact what you tell them to do. 🙄 


   
ReplyQuote