I've got an arduino uno and a relay board. Each digital output pin on the arduino connects to a relay on the board, and then each relay is connected to a solenoid. In this application, it is common for the solenoids to be added/removed frequently.
So, what I'm trying to achieve is some way of knowing whether a solenoid is connected to the relay or not. If it is, then I will be able to display some sort of an icon on the software side, representing "solenoid #4 is connected" ... If there's no easy way to just detect that, I wouldn't be opposed to having a little toggle switch next to each solenoid, when you connect one flip it on, when you disconnect flip it off. But even then I still need some way of detecting if each switch is open or closed, and then relating the switch to which solenoid it represents....
Sure, a sensor. What kind of sensor? And even then, how do I connect it to the arduino and relate it to the solenoid which it represent? (input pins? every arduino I've ever seen has more output than input, and I'm currently using ALL my output pins... when this is complete I'll be utilizing about 50 on an arduino mega)
I don't think a voltage sensor would work. Like I said, I want to be able to detect when its CONNECTED (ie, a solenoid is presently hooked up to the relay or not). This is different than saying the solenoid is open or closed. Just by giving the relay board power, ALL relays are already getting voltage if you measure across the NC/COM pins, regardless of if there's anything connected to them or not. Maybe you'd measure resistance or something? Otherwise, the toggle switch idea also is an option (though I'd prefer to automatically detect)
Also, as I said, the analog input pin route doesn't work so well either (I was hoping for a different magical solution I guess?)... But, if that's the only way.... Then is there any arduino board that has 30+ analog inputs AND 30+ digital outputs? (because obviously I would need a 1-1 mapping of analog in to digital out)
More output than input? Each pin is capable of both, so that does't really make sense.
Anyway, sounds like you need some IO expansion. One way is with simple shift registers. So for example instead of connecting 8 IO pins to 8 relay control pins, you use 3 pins to control a shift (out) register, and have the shift register control the 8 relay pins.
Similarly for switches that the solenoid closes when its put into place, or a toggle/rocker switch flipped. Connect the switch to a shift (in) register (74HC165, 74HC166 from mouser.com), read the switch states before commanding any relay action, report an error if the switch indicates the solenoid is not installed. Or read them all periodically, and maintain a status of what's there or not.
Hmm.. I'm pretty new to this, have never heard of shift registers. I will have to look into how those work...thanks
Basically, I want to be able to control (turning them on or off, just 1 at a time) up to 50 solenoid valves through software. Since not all 50 valves will always be present, I'd like to also be able to know which valves are connected (ie, valves 1-20 exist, 21-40 are missing, and 41-50 exist). This way, when I present options to the user for which valves they'd like to turn on/off, I can grey out/exclude the ones which are not even present.
I currently have the on/off control working with an arduino uno for 8 valves. I'd like to expand this to 50 valves, and add the ability to know which valves are present or not.
So, through the use of shift registers, I could independently control 50 solenoid valves without having to use 50 digital output pins?
If your relay is connect to act as a ground side switch of the solenoid then when a solenoid is connected, there will be a positive voltage present. If there is no solenoid, there will be nothing. As soon as the relay closes (with a solenoid attached) the voltage would of course be 0.