Implement control/ electric pump control

I found that and added in your code, but something didn’t go quite right?

Don’t forget the semicolon at the end. May need to turn that 1 into a bit.

I got the semicolon in there now my bad! Still getting the same error. I tried RelayHi[7]=bit; and “byte” in place of the 1? That made for more added errors. What in this code dictates relay 16 or whichever relay i want to control? All I understand is relay 7 being controlled right?

give me a moment

try

if (RelayHi > 0 || RelayLo > 0) bitSet(RelayHi,7);

I have to run for an hour or so.

That finally worked! I’m amazed at what you guys know with this stuff! I’m learning as I go , but wow! So I’m assuming that RelayHi,7 is the relay number that will be controlled for my need? Let me know when ya get back, thank you very much for your time and effort!

RelayHi[7] is section 16

RelayLo is 00000000
RelayHi is 00000000

If anything is 1 such as 10010000
Then it sets the 8th 0 of RelayHi to 1. Such as 00000001. But we count them 01234567. 7 is 8. When it loads it sets everything to 00000000 and 00000000.
If any of that is not 0, set the last one to 1. Later in the program, back were you were wanting to change it, it looks for that relayHi and ok, it is on set that pin to high. If I remember @SK21 has this as pin 0.

So let’s confuse everyone. Bit 7 is really 8, and that is really section 16, on pin 0. And because it is 1, that is high and the pump is running.

I’m still learning also. Keep us posted if it works or not.

Edit/Correction: See discussion below. We should number them 76543210 and setting 7 high is 10000000. Then, sections are 16,15,14,13,12,11,10,9.

only because it could happen, not for argue: what happen if you change the relay logic?

Thanks to @KentStuff for helping to get this code figured out it works great! I just verify like he said which relay i want to control on when any one of my verified sections are on. Such a clean install of this with no extra wires or diodes, just letting the arduino do the work! I did notice and it seems it was doing it before too, when sections are to turn off into a painted path, if it’s not gradual they don’t turn off and then all of a sudden a few of them turn off at once. Same goes for turning on none on, none on and then all of a sudden bunch of them come on. During either of these processes, it’s painting in simulator but the physical relays aren’t matching the sections on the screen?

Open AGdia and see if it is happening real time without the arduino.

Then you got you a mess. And that does happen more than once with AOG.

Glad you and KentStuff got it working. I am not sure why relay 8 doesn’t work. As long as “UseSwitchedPowerPin” = 0 it should work like the other relays. The relay states are stored with two bytes. RelayLo is for 1-8 and RelayHi is for 9-16. Bit 0, the right most bit of the byte is for relay 1 in the case of the byte RelayLo. 0 is off, 1 is on. Bit 1, 2nd from the right is for relay 2 and it continues to bit 7, the left most bit, is for relay 8. As far as not turning off or on at the right time, it can be adjusted in AOG. In settings, implement, timing.

Excellent, it will be Saturday before I get tablet hooked back up to it to test what @KentStuff said and @SK21. @SK21 hit the relay thing on the head and it’s making sense to myself as this kind of computer stuff is all new to me! I may get back to you guys on this topic Saturday, I did play with timing settings some. The shut off got better but it was skipping a fair amount of area in pie pieces before actually turning relays on even though it was painting on the screen. I wondered possible lag time with Microsoft surface pro 8, usb cables, splitter or baud rate anything to do with it? I’ll get back to you guys, thank you very much for all your work and have a great night!

Then it should be:

if (RelayHi > 0 || RelayLo > 0) bitSet(RelayHi,0);

Might check both 0 and 7. It will either be relay 9 or 16.

bitSet(RelayHi,0) is relay 9.

1 Like

So bit 0 is set high is 00000001 or 10000000?

and bit 7 set high is the opposite?

bit 0 set high is 0000 0001, bit 7 set high is 1000 0000. According to wikipedia it can be numbered either way I guess. Bit numbering - Wikipedia

1 Like

Just to clarify
RelayLo sections are:
8,7,6,5,4,3,2,1
RelayHi sections are:
16,15,14,13,12,11,10,9

Yes that’s it.


The rate app has relay definitions now. This allows you to create a slave relay that will turn on when at least one section is on and turns off when all sections are off. There are some other relay types. Section type is a normal relay that turns on when the section is on and off when the section is off. Power type is on all the time. Master type turns on when at least one section is on, turns off when all sections are off and the Section type relays remain unchanged. The Invert_Section type relay turns on when the section is off and off when the section is on. This may be useful for ball-valves that need 12V in each direction to turn on or off.

Where would I find the definitions now? I looked at the @SK21 latest update and it’s 2.1.17 version. That’s what I have, but maybe overlooking a menu part of it for this. All I see is section, width and swtich. The definitions is exactly what I’ve been after this whole time!!