Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

555 timer circuit for servo, how to reduce speed?

Status
Not open for further replies.
Please do not post things over at Photobucket who takes all day to wake up. Instead attach your schematics and photos to your replies here like everybody else so we can see them immediately.
 
... "latency problem between a PC key press and the operation of a remote relay, not very spontaneous." ...
Understood, but:
It would take at least 5 second from PC to Arduino to actually switch off the relay
(My emphasis)
I'm having considerable difficulty visualizing the cause(s) for that degree of delay between command and execution. I think it would be most useful to us if you could provide a block diagram (as detailed as possible) of everything (hardware, software and any comm providers) between the PC and the servo.

And if not a block diagram, then perhaps a list of each and every step your system takes between PC click/key press and servo movement.
... anyone willing to modify the code? If so I will provide the current code. ...
Yes, please. In particular, I'm interested in the WiFi portions, i.e., is a new WiFi connection made for each command or is it kept open for a prolonged "session"?

Also, is the camera location such that a more simple RF link won't work?

Anyway, something is chewing up a lot of time (and memory, apparently).

There are several very experienced coders on this forum.
 
Hi cowboybob,
My Arduino Uno Wifi is not working properly, cannot upload sketch...ARRGG
Here is a video using Arduino Mega 2560 with a simple code from Instrucable:
**broken link removed**
servoA.write(position++);

delay(5); //change it to 100

}

if(buttonState2 == HIGH && position > 3){

servoA.write(position--);

delay(5); //change it to 100

}

}
In the video the Delay value 5 is changed to 100, this slows the rotation.
code link:
http://www.instructables.com/id/Servo-Controlled-by-Pushbuttons/

Need the above code implemented to my current code below:
#include <Wire.h>
#include <ArduinoWiFi.h>

#define CH1 4 // Connect Digital Pin 4 on Arduino to CH1 on Relay Module
#define LEDgreen 13 // Connect Digital Pin 13 on Arduino to Green LED

/*
on your borwser, you type http://<IP>/arduino/webserver/ or http://<hostname>.local/arduino/webserver/

http://www.arduino.org/learning/tutorials/webserverblink
*/
void setup() {
pinMode(CH1, OUTPUT); // define realy on
pinMode(13,OUTPUT); // define
Wifi.begin();
Wifi.println("WebServer Server is up");
}
void loop() {

while(Wifi.available()){
process(Wifi);
}
delay(50);
}

void process(WifiData client) {
// read the command
String command = client.readStringUntil('/');

// is "digital" command?
if (command == "webserver") {
WebServer(client);
}

if (command == "digital") {
digitalCommand(client);
}
}

void WebServer(WifiData client) {

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html>");

client.println("<head> </head>");
client.print("<body>");

client.print("Click<input type=button onClick=\"var w=window.open('/arduino/digital/13/1','_parent');w.close();\"value='ON'>pin13 ON<br>");
client.print("Click<input type=button onClick=\"var w=window.open('/arduino/digital/13/0','_parent');w.close();\"value='OFF'>pin13 OFF<br>");

client.print("</body>");
client.println("</html>");
client.print(DELIMITER); // very important to end the communication !!!

}

void digitalCommand(WifiData client) {
int pin, value;

// Read pin number
pin = client.parseInt();

// If the next character is a '/' it means we have an URL
// with a value like: "/digital/13/1"
if (client.read() == '/') {
value = client.parseInt();
digitalWrite(pin, value);
digitalWrite(CH1,HIGH); // Turns ON Led1
delay(3000); // Wait 1 seconds
digitalWrite(CH1,LOW); // Turns OFF Led1
delay(1000); // Wait 1 seconds
}

// Send feedback to client
client.println("Status: 200 OK\n");
client.print(F("Pin D"));
client.print(pin);
client.print(F(" set to "));
client.print(value);
client.print(EOL); //char terminator

}
 
From the above post (#63):
... In the video the Delay value 5 is changed to 100, this slows the rotation. ...
Two weeks ago (Post #40):
... To control the "sweep" speed, adjust the "Delay" value (in mS) to suit your needs, i.e., higher value = slower rotation, etc.. ...
Anyway... Making some progress here.

It would appear, from what you've provided thus far, that some of the WiFi code above is causing at least some of the the delay. For instance, here in "void digitalCommand(WifiData" client):
upload_2017-2-18_13-27-24.png

This, alone, is a 3 second delay causing a "dead stop" in code execution after the Led1 in turned ON.

And, overall, it looks like every single, individual command from the PC is a separate, distinct WiFi comm event, i.e., "Connect - do one thing - Disconnect". This, instead of "Connect - Let me move camera to where I want it (Left, Right, Up, or Down) - Ok, Now Disconnect".

I might suggest, at this point, that this project may need a re-boot. Believe me, I am very sympathetic to your development efforts and the time that represents. I've been there.

But I think your goal can be reached with a considerably less complex and much more responsive system, if your willing to start over. Not an easy decision, of that I am sure.

What do you think? It'll still be your creation: Just a little external guidance here and there...
 
Hi CBB,
I might suggest, at this point, that this project may need a re-boot. Believe me, I am very sympathetic to your development efforts and the time that represents. I've been there.

But I think your goal can be reached with a considerably less complex and much more responsive system, if your willing to start over. Not an easy decision, of that I am sure.

What do you think? It'll still be your creation: Just a little external guidance here and there...
Well at some point I did thought of redoing this project again,
what would you suggest?
 
Hey, HT2K.

If your bench is anything like mine (your videos sort of confirm this), you've got breadboards, components and wires all over the place, so:

1. Disconnect everything and clean/straighten up (this is, actually, therapeutic),
2. Establish basic WiFi comms (with with simple LED ON/OFF commands embedded in the code) between the two Arduinos - test for speed,
3. Add PWM code to remote Arduino and test servo response.

I welcome you thoughts and suggestions.
 
Right now the Uno wifi is experiencing some problem, usually when I type: http://<IP>/arduino/webserver/ will be redirected to this page--->
https://www.arduino.org/learning/getting-started/getting-started-with-arduino-uno-wifi
and configure the SSD so on.. but now I cannot get to this page.....
2. Establish basic WiFi comms (with with simple LED ON/OFF commands embedded in the code) between the two Arduinos - test for speed,
3. Add PWM code to remote Arduino and test servo response.
For number 2, this link might help:
https://arduino.stackexchange.com/questions/17349/connecting-two-arduinos-using-wifi

will have to order it...
 
Right now the Uno wifi is experiencing some problem ...
Let's assume, for the moment, that the WiFi Uno has corrupted code, rather than hardware issues.

I'd suggest you re-perform (step by step, just like the first time you did it) the Uno WiFi initializing routine at the site you listed above, doing all three of the tabbed steps. You will, of course, lose whatever sketch is currently in the Uno.

(For all we know, you may have to re-install the Arduino IDE, but first lets see what happens.)

And, if I may ask, why not use the Uni Wifi for controlling the servo?

<EDIT> My image of your system is:
Command from your PC using WiFi to Uno WiFi to control the servo. What purpose does the Mega 2560 serve (lotta juice to drive just a servo...)?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top