Long time arduino user but little coding experience (mostly editing existing programs for upload). I have been trying to figure out the basic uses of XOD and have watched the Youtube tutorials. I feel extremely humbled by this as I have redone a simple program several times.
I am using a Arduino Nano and would like to have:
Purge switch low D2 turn on Relay D4 for 10 seconds
Then turn on Relay D5 for 30 seconds or until Float Switch goes low
(basic float switch should shut off relay D5 but the delay is a fail safe shut off if the switch fails)
I have 10K pullup resistors on the switches to 5v. The switch to ground. I am still getting weird behavior on my LEDs (stand ins for the relays right now) which makes me think my node linking is incorrect.
Your code looks mostly right, but very fragile. If everything happens at just the right time, it will probably work, but it breaks if something happens out of the ordinary.
The main problem I see is the delay timer for float is linked to TGL, so if relay is turned off by float, it will get turned back on by timer that should be turning it off. Both float and timer should link to RST (so would need joined using âanyâ node).
The purge button should probably be tied to the SET pin rather than toggle (but maybe not⌠It depends what side affects you want, like what happens if purge button is pushed before timer ends)
The other thing that could cause problems is starting another other cycle while the second relay is still active. You could disable the purge button while either timer is active (or maybe that is not how you want it to workâŚ). The details depend on how you want the edge cases handled.
You might also want to add watch nodes to your inputs to make sure they are not reversed. For example, if float switch goes low when relay should be turned off, you need to reverse it, either using a ânotâ or pulse-on-false.
Note that either of these changes (as well as your current code) only turn off the relay when the float switch changes. If it starts out âfullâ, it will not become full and turn off the relay. If you want to âkeep turning off the relay when fullâ (a good safety precaution), you could feed âcontinuousâ to a âgateâ that is turned on/off by float so it keeps pulsing the RST pin as long as float switch indicates full.
All very good points, contrary to code (which processes straight from the top down) Iâm not sure how XOD processes through the nodes (from top down?). Originally I had it flow top down but tried using the delay ACT to hold open the relay while the delay was in progress but it dinât seem to work.
OddâŚI would think the ACT pin should work to activate your relays (and is obviously much cleaner code). The only issue I see with that code is that float will not reset if it already registers âfullâ when delay is SET (it needs to transition to âfullâ to send the pulse to RST).
You could check for wiring issues by replacing your relay nodes with watch nodes & running in debug mode. The watch nodes would display âtrueâ or âfalseâ indicating if relay would be on.
What is the problem you are seeing? LED always on when expecting off (and vise-versa)? That would indicate you wired LED to power instead of ground. LED never comes on? LED just seems to go on/off at random times?
Could you describe the project in terms of what the device should do rather than switches, relays, and timeouts?
One poblem possible is that your float switch might be already engaged after the first 10 seconds stage. In that case, you should use its signal to control the relay directly instead of sending it to RST: it will not reset delay if already True. In other words your device can reset the delay before it is set. Consider this way:
Many thanks. Here is the mechanics of what I am trying to do:
Imagine a single bottle filler:
The bottle is in place, you hit a push button swtich and an air solenoid opens purging the bottle for 10 seconds
Once the 10 seconds elapses, then the liquid fill starts by actuating a different solenoid.
The fill should stop when the float switch engages. The second delay is only to prevent a disaster if the float switch has an electrical problem. Either the float switch or the delay stopping the solenoid should close it until retriggered by the end of the purge cycle (commenced by pushing the first switch again).
Got the idea, thank you! So, I see no reason why your right-hand-side patch or my patch is not working. A dumb question: do you delete the left-hand-side patch before uploading? They affect the same hardware at the same time
If still no, can you explain whatâs going on actually?
P.S. Blocking the air solenoid while performing the second action can be easily acheived if you insert one more and / and not between button and 10-delay with the signal coming from the float switch.
Here is one of many solutions that would probably work. Button & float replace with tweak-boolean and relays replaced with watch nodes so I could test using simulation. It uses your original code with delay-ACT activating relays; it just adds code to disable the button.
The gate at the top disables the switch if either delay timer is running or the float switch indicates âfullâ.
Continuously and gate added to float switch so no matter what else may happen to turn on the fill valve, it will immediately be turned back off if float indicates âfullâ.
Yeah, I just showed bothed for example. Bascially, the relays start on when powered up which is very confusing. I would think relay doesnât default to on as a base state instead waits to be turned on.