Pulse-on-true/false

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.

1 Like

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.