I have a clock node looping the code but It seems like those two nodes only output pulse on detecting a change, but not if the value stays the same over subsequent cycles.
What would you suggest to change their behaviour to continuously pulse while their respective value is matching?
I donāt have my computer handy, but Iām pretty sure there is a pulse-continuous node. If it doesnāt have an input to enable/disable, you can use a gate node to block the pulses you donāt want, or use branch node to route them correctly.
It is not always possible, but you might be able to change your code to work with true/false instead of using pulses.
I have deleted ā&& state == falseā out of the node code and now it seems to work the way I want
If you want continuous readings when a boolean is true, just use an if-else node.
That was my original idea but it didnāt work.
I have a ālessā node that outputs boolean and I need to drive a servo motor on ātrueā.
āIf-elseā will pulse on either false or true, so, useless
Can you post a screen shot of your project?
Your statement regarding if-else generating a pulse on āeither false or true, so, uselessā doesnāt quite make sense.
If you only want to do something when you have a true boolean, āif-elseā is literally the exact thing you requireā¦
Connect your nodes for servo control to the ātrueā input of the if-else and then connect the if-else output to the servo device.
You can also have your boolean connect directly to the āactā pin of the servo device.
Somehow āif-elseā didnāt work for me.
Removing condition check ā&& state == falseā out of āpulse-on-trueā did the trick however.
Donāt mind the cropped part, itās a serial output.
The only thing I havenāt figured out yet is how to detach the servo once itās back to 0
Are you using āpulse-on-trueā or āpulse-on-changeā?
And what do you mean ādetachā the servo? As in, power down/stop the jitter?
Also, the way you have your āless-thanā setup will give you a true result if your reading is above 0.34.
If you need the servo to operate when the reading is below 0.34, youāll need to move the 0.34 to āIN2ā
Iām not sure what youāe doing there after the ārotate_backā command. The whole setup could be simplified to this
It also might be worth having the readings pause for a while to allow moisture levels to equalise (Iām guessing youāre using a servo to tip water into soil?
Dear mci-ryan, thanks for all your suggestions. As I already mentioned my sketch works perfectly well. All the nodes, including less, do exactly what I want them to do and there are delays where required.
Following ārotate-backā I have a counter, there is also a remapper and a long string of concats that feeds UART>print setup some values I am interested in. I cropped that part out because itās irrelevant.
As I already mentioned the āif-elseā way does not work. If you read this nodeās description carefully you will see that it Outputs either input value depending on condition.I think it means it will pulse on either true or false, hence, useless. This is exactly the behaviour I observed and thatās why I decided to modify āpulse-on-trueā to suit my needs.
By ādetachā I mean power servo off. I believe this what the Arduino command is called but I may be wrong.
No need to be condescending.
āIf you read the nodeās description carefullyāā¦ If-else does not pulse on true or false. it is a logic gate. if the condition is true, it allows whatever is linked to ātrueā to pass through. if the condition is false, it allows whatever is linked to āfalseā to pass through. if-else does not produce any pulses, it can only open to door for whatever is linked to the T/F inputs.
to turn the servo off, you would need to wire the voltage feed through a pin (or a relay if high current) that is controlled by a digital pin.
I am only trying to explain to you that your suggested patch does not work the way you describe.
Please, wire this up yourself and check if you wish.
And below is the code, by gweimer, that detaches the servo, but this function is absent in the node I am using.
{{#global}}
#include <Servo.h>
{{/global}}
struct State {
Servo servo;
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
State* state = getState(ctx);
auto port = (int)getValue<input_PORT>(ctx);
auto En = getValue<input_En>(ctx);
if (En) {
state->servo.attach(port);
state->servo.write(getValue<input_VAL>(ctx) * 180);
} else {
state->servo.detach();
}
}
It does work. that was the point of me showing it to youā¦
Note: the code excerpt that youāve posted from the Gweimer/Servo library uses an if-else. Hopefully you can understand the logic of if-else when it isnāt coming from me. You can also use a gate, a pass-if and many other nodes that will accomplish what youāre trying to do. Using a method like this will mean that you donāt need to modify the C++ implementation and therefore it wonāt affect the way the node works for other projects.
If you want to use gweimers library, then just use the node youāve taken the excerpt fromā¦ Itāll accomplish the same thing that the xod-dev/servo does, with the detach that youāre after.
Worth noting is that if you detach (stop pwm pulses), the servo will be free to rotate, i.e. no position āholdā.
I have assembled the patch with āif-elseā again, exactly the way you proposed and the servo was just going back and forth every clock tick, regardless of the ālessā node output.
As I said before this was my original patch design and the reason I started this thread.
I have only modified a cloned node within my project so this wonāt affect anything else.
The problem is now solved so we can end this discussion.
Thanks.
Thatās probably because of the āless-thanā that you have set, which is basically running the pulse whenever 0.34 is less than the moisture reading value.
Basically if the moisture reading is 0.35 to max, youāre activating the servo.
If you want to activate when the sensor reading is LESS THAN 0.34 (MIN to 0.34), you need to move the input to the left side and make the right side 0.34. That way when the input is less than 0.34 it will activate the servo.
I mentioned this earlier.
Dear mci-ryan, I am struggling to understand what are you trying to achieve here.
Are you genuinely mistaken but trying to help or are you just having fun?
If itās the latter then I will just carefully ignore any messages from you.
If itās the former then hear me out:
You proposed āsimplificationā wouldnāt even compile. There is a loop which wonāt work without a ādeferā node. Seems like you havenāt tested your code before posting.
My ālessā node behaves exactly as intended, outputting True for values >0.34. Perhaps it would be more appropriate to call it āmoreā but I just left the default name. So yes, when itās 0.35 to max servo is being activated.
However, it doesnāt matter what is being compared there if you place the āif-elseā downstream. It will be firing on both true and false, triggering the servo.
Please be more mindful when you post your advice. This could have damaged someoneās servo motor and would certainly upset anyone new to Arduino/XOD.
Your condescending attitude is pointless and your points are incorrect.
If-Else doesnāt āfireā anything on true or false. Itās simply a logic gate that allows the input to pass through.
Youāre right about the deferā¦ but that isnāt releventā¦ its only needed in the second screen clipping I showed you (which was YET ANOTHER thing that was posted to HELP you)
Your ridiculous comment at the end about damaging a servo motor is also ridiculous.
I gave you several options that would allow you to include a logic gate without having to adjust the C++ implementation to get the code work (via using the wrong node); pass-if, a standard gate, etcā¦ You can do with that, what you wish.
Note: you also said that you ARE in fact, after āgreaterā than 0.34 and that you should have have renamed it āmoreā. This is another indication of your ongoing inability to look in to using a node other than the one that you are currently usingā¦ why? because there is literally a node for āgreaterā.
In future, think about the fact that people are helping you and donāt be an arrogant clown.
Your code does not work. not a single version you posted. I have tested it and reported the results to you every time.
I have never been rude to you but pointed out again and again the above.
Your anger and frustration, calling me names eventually, did not help at all
All I can do is report this thread to moderators.
The person who made the patch you referenced, liked my commentā¦ anyone can see who has the condescending and arrogant tone hereā¦ do as you wish.