the signal is dc, I dont think a analog to dc converter will help. I only want the circuit on when there is a low of 1.3 and off at 1.5. I have tried to use an opamp to a comparator to a FET switch; It still wont turn off at the 1.5V.
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.
You need some way to detect when the control voltage is around the thresholds (1.3V and 1.5V). You can do this with an analog to digital converter. You can also do this with a pair of comparators, one with a threshold of 1.3V and one with a threshold of 1.5V.
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.
I need to run a servo with an external low of 1.3V and shut it down at 1.5V; any ideas?
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.
Thans for responding mike, attached is my program to turn my servo. I only want the servo to turn at the low freq, how can I program the BOE to do that?
PS thankyou so much! I stayed up all night trying to figure this out.
I have an lm339, could you show me a circuit design that would work? Also I need to either use a transistor or programing to kill power to pin 14 as long as there is a high signal. I'm not really sure what transistor to use or how to make a program to do that.
First of all, you need to learn Stamp Basic. The "What's a Microcontroller?" tutorial is a good starting point. You should find it in PDF form in the Stamp Editor's help files.
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?
Here is a diagram of a basic window comparator. The outputs could go to the input pins of a micro or to additional circuitry. The output level (high/low) can be reversed by reversing the signals on the +/- pins.
I really don't understand what you're trying to do. First of all, what do you mean by "pin 14"? Assuming you're using a BS2, there's I/O pin 14 which is physically pin #19 of the module. Physical pin #14 is I/O pin 9. Neither one is a power connection. If you mean for this to be an I/O pin, it could be connected directly to the LM339's output(s). You don't need a transistor between them. You need to read the sections of the "What's a Microcontroller?" tutorial on testing I/O pin states and on program decision making (IF / THEN statement). You might also read the parts of the "Basic Stamp Syntax and Reference Manual" on "BASIC Stamp Architecture - Memory Organization" since the I/O pins are mapped into memory locations.
I really don't understand what you're trying to do. First of all, what do you mean by "pin 14"? Assuming you're using a BS2, there's I/O pin 14 which is physically pin #19 of the module. Physical pin #14 is I/O pin 9. Neither one is a power connection. If you mean for this to be an I/O pin, it could be connected directly to the LM339's output(s). You don't need a transistor between them. You need to read the sections of the "What's a Microcontroller?" tutorial on testing I/O pin states and on program decision making (IF / THEN statement). You might also read the parts of the "Basic Stamp Syntax and Reference Manual" on "BASIC Stamp Architecture - Memory Organization" since the I/O pins are mapped into memory locations.
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.
the signal is dc, I dont think a analog to dc converter will help. I only want the circuit on when there is a low of 1.3 and off at 1.5. I have tried to use an opamp to a comparator to a FET switch; It still wont turn off at the 1.5V.
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.
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.
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.
I'm going to simplify things for the purpose of discussion. Your program looks sort of like this:
' Stuff that moves the servo around
DO
' Stuff that moves the servo around
LOOP
There are all sorts of ways to make the loop quit when something happens. It depends on when you want things to stop. One way would be to
' stuff
DO UNTIL <condition>
'Stuff
LOOP
The <condition> is some kind of test that becomes true when the program should stop. It could be something as simple as "IN9 = 1".
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.
]
The <condition> is some kind of test that becomes true when the program should stop. It could be something as simple as "IN9 = 1".
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. .
Hmm how do you make it start the loop again once the <condition> goes back to the previous state?
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.
Hmm how do you make it start the loop again once the <condition> goes back to the previous state?
Well, you create a separate method (SUB) who's whole job is to move a servo given some parameters. Then you put values in the parameters and call the method. You should have run across an example in the suggested reading materials.
What you want is a subroutine that tests for a condition (like input = 0). This subroutine returns if the condition is true. If false, it waits until the condition becomes true again, then returns. You call this subroutine just before doing the PULSOUT in each of the FOR / NEXT loops in your DO / LOOP. Something like this:
DO
'FOR ...
GOSUB testRoutine
'PULSOUT ...
'PAUSE ...
'NEXT
LOOP
testRoutine:
'Wait here if input is not zero
IF input = 1 THEN GOTO testRoutine
'Go back to main loop
RETURN
Okay, thank you all for your help. I was able to get this circuit to work. I used a opamp and programming to get there. 1/2 of the opamp I used for a closed loop gain of about 3 and the other 1/2 as a comparator. I used pots to change the gain and ref voltage. when I get the high signal it shuts off the servo as planned.
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?