How to connect Servo to multply Nodes?


#1

Hello,

I want to control a Servo from two different nodes but I cant connect them (red arrows on picture), I tried to use gweimers servo library (servo enable) but I cannot get it working. Can somebody help me?

kind regards

AarZeon


#2

You can never feed multiple values directly to a single input pin. The program would have no way to determine which value should be used.

If you want to switch between inputs, then you need logic between the input pin and possible inputs, like a select node or an if-else node. You need to be able to explicitly determine which of the input values should be used; it cannot be implied by tying multiple wires to a single input.

In your example, one solution would be to use if-else nodes to feed each servo so that the lower buffers are used only when the button is pushed (the button being linked to both the buffer-UPD and the if-else-COND), but in that case, the 2nd set of buffers isn’t really needed since you only use the value while you are updating the buffer.

Another solution would be to create a feed-back loop so that when the lower button is pushed, the values are rolled back up through the buffers. This sort of just moves the problem, since now you need a way to select input values for the buffers instead of for the servos.

The “correct” answer depends on what you are really trying to do and what side-affects are acceptable (for example, what happens if a button is pushed before your delay timers expire? If you don’t really want a specific delay & only want to make sure buffer values get shifted correctly, defer-pulse might be a better solution than delay.).


#3

Hi gweimer I tried it with the if-else nodes but it didnt worked correctly. The second option with the feed-back loop reminds me of a “Undo Button” and thats exactly what i need. The helpbar of XOD isnt very helpfull and on the internet isnt anything explained (“https://xod.io/docs/guide/simple-traffic-light/” didnt helped much). Could you make a small example how to roll back information.


Current state.


#4

I’ve added a queue-buffer node to gweimer/utils library. The utils-example-queue is basically an implementation of your program. Replace count with your POT, replace push@5 with your set button, replace pop@11 with your undo button, and replace watch nodes with your servos. If you want a larger undo buffer, you can daisy-chain additional queue-buffer nodes that don’t have servos attached.


#5

I got a problem with your library.

image


#6

Hmmm…I don’t get that error, but there was a problem that I had included a xod_bkp node that would only exist on my system. I have resolved that issue, and it may also fix your problem.

If it does not fix your problem, which version of XOD are you running?


#7

Im running Version 0.20.2

image

But now its worked. Thank You