Oh no, not the PCF8591 again...
Moderators: grovkillen, Stuntteam, TD-er
Oh no, not the PCF8591 again...
How can I use a PCF8591 as a comparator with ESP Easy?
I understand that I would need to set the control byte to the appropriate value, but I don't know how to do that.
I understand that I would need to set the control byte to the appropriate value, but I don't know how to do that.
Last edited by Hairyloon on 17 Jul 2019, 17:44, edited 1 time in total.
Re: PCF8591 as comparator.
The plugin only provides simple analog reads of the four inputs. No other functions are supported.
-Thomas
-Thomas
Re: PCF8591 as comparator.
That may be true, but in order to read the simple analogue input, the plugin must send a control byte to the chip: I just need to send a different control byte.
I may have to hack the plugin to do that, and being new to this game, I'm not sure how big a deal that will be.
Re: PCF8591 as comparator.
Getting familiar with the PlatformIO IDE will probably be the hardest part.I'm not sure how big a deal that will be.
You mentioned that you want to use the PCF8591 as a comparator. This can be done in ESPEasy's rules. Read the ADC channel, then have a rule compare it to the "reference" voltage (another ADC channel, system variable, or hard coded value).
- Thomas
Re: PCF8591 as comparator.
Yeah, I tried that once and gave up on it. I may look for another way...
I can see how that would sort of work, but I want to measure a small voltage between two points, and comparing the two voltages in software would not have the resolution.You mentioned that you want to use the PCF8591 as a comparator. This can be done in ESPEasy's rules. Read the ADC channel, then have a rule compare it to the "reference" voltage (another ADC channel, system variable, or hard coded value)
Much better to set it up as a comparator:
Re: PCF8591 as comparator.
The PCF8591 does not provide user access to its internal comparator (it's assigned to the successive approximation logic). But using the differential input feature with a low reference voltage is a trick worth playing with if the rule based concept does not work. Keep in mind that this is not the same as comparator solution, just differentially driven ADC operation.
If microvolt threshold accuracy is needed then a dedicated comparator chip might be the easiest solution. Especially since you don't have to make a custom plugin. Plenty of chips to choose from, so nothing to worry about. DIP package, five wires, done. Sometimes solder is the best software.
- Thomas
If microvolt threshold accuracy is needed then a dedicated comparator chip might be the easiest solution. Especially since you don't have to make a custom plugin. Plenty of chips to choose from, so nothing to worry about. DIP package, five wires, done. Sometimes solder is the best software.
- Thomas
Re: PCF8591 as comparator.
Ah, am I using the wrong terminology? OK, so what's the difference?
And how do I get ESPEasy to use the differential input?
The easiest solution (at least on one level) is to use what I've got available... I've got an ADS1115 in the box, if that would be any better?If microvolt threshold accuracy is needed then a dedicated comparator chip might be the easiest solution.
Re: PCF8591 as comparator.
A comparator changes logic state when the threshold voltage is exceeded.Ah, am I using the wrong terminology? OK, so what's the difference?
A differential ADC's two inputs are subtracted from the other. This is intended to reduce common mode noise on input signals.
It has greatly increased ADC resolution. I would encourage you to try that chip (using single ended mode) with the rule based comparison method mentioned earlier.I've got an ADS1115 in the box, if that would be any better?
- Thomas
Re: PCF8591 as comparator.
Why single ended?
I'm not seeing the sense to that when the differential measurement seems to be exactly the tool for the job. Perhaps I've not understood what you mean...
Re: PCF8591 as comparator.
Because I have high confidence single ended ADC operation will work without much fuss. I'm not convinced the differential input will work as you intended (it's there for applications that need noise immunity, not analog compare). But give it a try since experimentation is fun. And it would be an interesting trick to do.Why single ended?
I'll flip that comment back to you; I'm not seeing the sense in using an ADC when the info about your project points to using a common comparator chip. For example, I would grab an LM393 (or any other single supply comparator) and configure ESPEasy with the Switch Input plugin to read the state.I'm not seeing the sense to that when the differential measurement seems to be exactly the tool for the job.
But this is your project. And there are many solutions to choose from. So just do it the way that excites you the most.
- Thomas
Re: PCF8591 as comparator.
But I want to read the value, not the state...
Re: PCF8591 as comparator.
OK, a comparator won't work. Wire up a ADC and put it to work.But I want to read the value, not the state...
- Thomas
Re: PCF8591 as comparator.
Which brings us back to the original question of how to tell the chip to measure the comparative voltage...
Is there the means to send a specific command to a given I2C device?
Re: PCF8591 as comparator.
If you mean you want to enable ADS1115's differential mode, then configure its plugin for Differential operation. It's in the "Input Multiplexer" drop down list. Reading ADC values will use differential operation after you do that.
If the ADC's differential mode trickery does not work as you expected, then use Single-Ended operation and rules, as mentioned earlier.
Not much more to say. Your turn to just try it out and experiment.
- Thomas
If the ADC's differential mode trickery does not work as you expected, then use Single-Ended operation and rules, as mentioned earlier.
Not much more to say. Your turn to just try it out and experiment.
- Thomas
Re: PCF8591 as comparator.
Ah yes.
I've not found the box with the module yet, so not looked at the interface for it. Sorry, I'll let you know in due course. It may be a while: it's dropped off my priority list.
Thank you for the help.
I've not found the box with the module yet, so not looked at the interface for it. Sorry, I'll let you know in due course. It may be a while: it's dropped off my priority list.
Thank you for the help.
Re: Oh no, not the PCF8591 again...
I hope this isn't a breach of forum etiquette, but since I'm still on with the PCF8591, I thought it better to change the title and carry on here rather than start a new thread, even though it is a completely different issue.
I've got a PCF8591 set up measuring some voltages from sensors, which I would expect to vary over time, but generally quite slowly, whereas these ones are bouncing up and down like nobody's business: one bouncing erratically from 130 to 230, another from 0 to 80.
My first thought is that I've wired it up wrong, but I cannot see how so. Interference is a possibility, but there is nothing else on the circuit or plugged in near to it, so I think not.
I've got a PCF8591 set up measuring some voltages from sensors, which I would expect to vary over time, but generally quite slowly, whereas these ones are bouncing up and down like nobody's business: one bouncing erratically from 130 to 230, another from 0 to 80.
My first thought is that I've wired it up wrong, but I cannot see how so. Interference is a possibility, but there is nothing else on the circuit or plugged in near to it, so I think not.
Re: Oh no, not the PCF8591 again...
I am having similar issue - all works ok when only one input is defined in devices, but more give odd results. I was having similar issue when testing PCF8591 with RPi, solution was to introduce slight delay (5ms) between setting which input we want, and reading its value. Might be why we are seeing seemingly random values.
Who is online
Users browsing this forum: Amazon [Bot] and 7 guests