This may seem like a basic question, so let me expand:
I am working with an EC sensor and a PH sensor. Apparently there is an issue with these sensors sharing a power supply. When both sensors used at the same time the pH increases.
I am trying to find a software way around this. I am trying the following:
setup
pinMode(EC_PIN, OUTPUT)
pinMode(PH_PIN, OUTPUT)
void loop
digitalWrite(EC_PIN, LOW)
digitalWrite(PH_PIN, HIGH)
read_ph()
digitalWrite(EC_PIN, HIGH)
digitalWrite(PH_PIN, LOW)
read_ec()
Read_ph and read_ec are just functions that calculate EC and PH. Basically I am trying to alternate when the reading are taken to avoid the aforementioned issue. I have snooped around online, but I haven't found something that works.
Should this work? So far i am having no luck, but maybe I am missing something. Is there a software method for solving the issue I mentioned above?
Thank you for your help. Let me know if you need to know anything else
Sounds like a bad plan. Sagging voltage supplies are too unpredictable to compensate properly in software.
Please explain exactly what supply you are using, the power requirements of each module, and whether "apparently" means it's something you read, or something you see on your workbench.
That's less than what is usually asked of you, a complete diagram. It would at least give people here something to get started with...
On another note and something else to look for. If both sensors are analog devices they share a A:D converter on the MCU. The A:D converter has a sample and hold cap that needs to be bleed off between A:D reads. Somewhere there is a spec on how fast the A:D takes a reading has it ready for a read and, after a read is ready to go again.
Perhaps, if all is going well with the power, the A:D converter needs to be cleared between reads.
Say one device is on A0 and the other is on A1 and A2 is grounded. A sequence could go like this read A2, read A0, read A2, read A1 repeat.
As a matter of interest, it sounds like you are able to power up/down the sensors. Two issues come to mind. One, can the sensors handle that without errors (e.g. is there any start up or warm up time etc.). Two, can your digital interface handle an interface between powered and non-powered devices correctly?
conductivity and pH sensors both make a circuit with the solution they are dipped in - you cannot use both at the same time in the same solution without them interfering with each other, unless they have completely isolated power supplies and electronics each, and are far apart in the container.
pH sensors in particular are incredibly high impedance and need isolation to a high standard (requiring teflon hardware for instance).