servo/programing problem
dylants
Posts: 13
I need to run a servo with an external low of 1.3V and shut it down at 1.5V; any ideas?
Comments
http://www.datasheetcatalog.org/datasheet/maxim/MAX1112-MAX1113.pdf
Now I am trying to program the input shut off at a high; the program turning the servo just starts over instead of stopping when it reads the high signal.
A single comparator won't work for this since it responds to a single voltage threshold and you want a lower and upper threshold to define a voltage window.
If you want help with your program, you'll have to provide it ... as an attachment to a reply. Use the "Go Advanced" button and you'll find an attachment manager that can upload your source file.
What you want is called a window comparator. It consists of 2 comparators, one for each voltage, and an R/S flip flop that the comparator outputs turn on and off. A 555 timer might also be able to do this. Look at the LM339 and 7474 dual D flip flop.
PS thankyou so much! I stayed up all night trying to figure this out.
Your program starts with a GOSUB, followed by the subroutine itself. You never get in trouble with that because the subroutine never exits, so the lack of a matching RETURN doesn't affect anything.
I see where your program puts the servo through a pattern of movements, one after another, then moves the servo through its range, first in one direction, then the other. Nowhere is there any test of an input. Your program does exactly what it's written to do. How did you plan to control the movement with the voltage input? We've made some suggestions. What do you want to do?
Do a web search on "window comparator". One hit I found was this.
I'm reading it right now. What I am trying to do is stop the loop from pulsing out while say for example pin 3 input is high. and return to pulsing when pin 3 input is low. I have been experimenting with "if then" statement to no avail.
As Mike G mentioned, an analog to digital converter ( A/D ) will work just fine and get rid of all the related window comparator components. An A/D converter inputs a voltage, 0-5V for example, and outputs a digital number corresponding to the voltage.... so FOR EXAMPLE, 0V might be a digital zero, while 5V might be a digital 65535.... your 1.3 and 1.5V would be somewhere in the middle.... maybe digital 500 and 600 respectively.... So you read the output of the A/D with your stamp, and toggle the servo as you see fit based on the A/D's output.
You might be able to get satisfactory results with the RCTIME command and related circuit as well. Look in the Stamp manual for RCTIME. It's essentially a crude A/D.... sort of.
If you need finer control, you'd need to put IF / THEN statements all through your code, something like "IF <condition> THEN STOP". This would cause the program to stop. If you want something different to happen, you might want to do "IF <condition> THEN GOTO someLabel" where "someLabel" is defined elsewhere in your program.
I dunno which you were referring to, but keep in mind, for RCTIME you may need an opamp, or use a different voltage level (If that's possible)... Refernce the manual regarding the 1.4V threshold.
Basically what I want the circuit to do is run the first part of the program once.
then if input = 0 run the loop and if input = 1, stop loop until input = 0 again and then resume loop from where it left off until input reaches 1..... repeating forever.
Do you need the hysteresis between 1.3V and 1.5V or would a single above or below a threshold of say 1.4V work?