Pages: [1]   Go Down
Author Topic: Continuous Servo/Relay issue  (Read 602 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys!

Been watching these forums a long time. But now I've got a problem myself that I cannot solve..
I have been trying to make my own automated curtain system for a while now, so I have 1 continuous rotation servo that I let rotate for a while until my curtains are closed. Now this al works, but I wanted to make my servo stop for real, not just by writing angle 90 to the servo. So first I tried to make a switch with use of a transistor, result, I lost a lot of power on the servo.

But I had an relay laying around, so I put that in between. Now I can turn on and off my servo by this relay. Only problem is that once the servo is powered, then turned off by the relay, I't won't turn on again. Only after I disconnect the battery pack from the relay/servo and connect it again it works. But just for one time.

So once I toggled the servo by the relay, It wont toggle on again.

I tried to use a LED instead of the servo to test whether there is something wrong with my batterypack and/or relay, but this works just fine. So I'm really stuck right now, and would really appreciate some help!

Code see below, Fritzing see attachment.

Code:
#include <Servo.h>
int servoPin = 9;
int incomingByte;
Servo servo;
void setup()
{
Serial.begin(9600);
pinMode(8,OUTPUT);
}
void loop()
{
if(Serial.available()){
incomingByte = Serial.read();
}
digitalWrite(8, HIGH);
if (incomingByte == 49){
digitalWrite(8, LOW);
}
if (incomingByte == 50){
digitalWrite(8,HIGH);
}
servo.attach(servoPin); //Start the servo library on the servoPin
servo.write(95); //left
}


* Schermafbeelding 2013-05-16 om 18.06.53.png (69.43 KB, 655x501 - viewed 27 times.)
Logged

BCC AZ USA
Offline Offline
God Member
*****
Karma: 21
Posts: 930
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Shouldn't servo.attach be in setup()?
Logged

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10446
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You mustn't turn off power to the servo while it is still being sent PWM signals, you risk damaging it or the Arduino.

First detach() the servo from that pin, then digitalWrite (servoPin, LOW), then turn off the power to the servo.
Logged

[ I won't respond to messages, use the forum please ]

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1023
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is an application for a motor and a couple switches. The when it gets to the end you just turn off the motor.
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Setups that might work for curtains.



Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for you replies and sorry for the late answer, have been away this weekend.
So I tried what you said, I alterd the code to this:

Code:
#include <Servo.h>
int servoPin = 9;
int incomingByte;
Servo servo;
void setup()
{
  Serial.begin(9600);
  pinMode(8,OUTPUT);
  servo.attach(servoPin); //Start the servo library on the servoPin
}
void loop()
{
  if(Serial.available()){
    incomingByte = Serial.read();
  }
  digitalWrite(8, HIGH);
  if (incomingByte == 49){
    servo.detach();
    digitalWrite(servoPin, LOW);
    digitalWrite(8, LOW);
  }
  if (incomingByte == 50){
    servo.attach(servoPin);
    digitalWrite(servoPin, HIGH);
    digitalWrite(8,HIGH);
  }
  servo.write(95); //left
}


Unfortunately this doesn't change a thing, besides that it would be less harmfull. I tried to understand the schematics above, but I wonder why something that should be so simpel, has to be so difficult. Why can't I just cut the power to the servo, and put it back on?
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why can't I just cut the power to the servo, and put it back on?

You can, I don't think anybody here is going to stop you.
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I get that. But why do I have to manually reset my servo, by pulling off the batteries, before it can run again?
Logged

Australia Mate!
Offline Offline
Sr. Member
****
Karma: 2
Posts: 269
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Zoomkat's Schematics nailed it.
Logged

Pages: [1]   Go Up
Jump to: