I2C 16bit ADC expansion for WC8

sure, of course it is behind my firewall.  and since it is, I'm not really needing any additional unnecessary embedded security measures, like making it impossible to change things remotely, from within my secure lan  :mellow:
 
but, I'll live with it and won't make a feature request.  I have my own php interface for interacting with the data, and I can send some stuff back to the wc8 with buttons, like the  uroms or ttls.  but what would be extremely nice is to be able to change some of the timings I use in the plc, for controlling valves and whatever, or any of the other triggers, from the convenience of my own php interface.  even if I have to reload the entire code for any change, which it seems would be the case.

I might be able to code for a set of different timings and select which one I want by sending bits to the ttl inputs, but that is a little limited.  reaching into the heart of the beast and editing its code from my own control panel widgets would be much preferred to having to use the onboard web interface.  particularly if I wanted to develop an interface for a client to use.  seems like an api for this wouldn't be too difficult, you could do it, if you wanted to  :)


In slightly related news, I have the MCP23017 working, it was easy, took about half an hour.  opens up potentially 128 additional ttls.  I'm adding an additional 16 outputs for relays, and as many as I can for inputs, from our security system, primarily a lot of motion IR sensors, a few capacitive proximity, and some light beams.  for these things I don't really need to capture the data, but I have that working too, buffering the bytes out thru the VARs.  the sixteen 16 bit analog values from the four ADS1115s can also fit out thru the eight 32 bit VARs, two in each, MSB and LSB, then rehexed and split by my script and saved in sqlite.  all working, stuff I did while waiting

having sixteen 32 bit VARs in the wc32 will allow moving out twice the data per cycle.  I notice there is a serial port on that board, but I do not see any plc syntax in the guide for using it.  Is it hiding somewhere in the examples?
 
I see the wc32 serial port thread, but it rather promptly changes into a wifi discussion, without enough info about using the port.  I see there are actually two, but I'm not clear on what can be done with them.  After I install the emulator and bridge, and can connect to the port, then what?
 
I think if you are developing a PLC program for your customers, you can use UROM for tunable parameters.  From outside PHP or anything like that, you can easily set UROM value through HTTP protocol, that can change the behavior for your designed functions.  Another way is to use WEBSET, by sending back a return 32 bit value, that can be used for communicate with the board.  Anyway, we probably want to keep that separate from this ADC discussion in a different topic.
 
ok.  I already do use the uroms thru urls for that, but as I said, it is limited.  and the plc code becomes more complex

I'll necro the serial port thread to hear about that
 
This is final version of example PLC code based on your 6.144V full scale and 128 sample/s rate.  Reading from A0 and stored in AIP5
 
Code:
START    
	I2CWRITE 1 0 144     # I2c start, write address for chip with addr connected to ground
	I2CWRITE 0 0 1       # configuration register address is 1
	I2CWRITE 0 0 193     # single end AINp = A0, full scale 6.144V, one shot conversion page 18-19
	I2CWRITE 0 1 131      # 128 sample/s, disable comparator, 
	DELAY 10            # wait for conversion done, WC8 stop write to chip
	I2CWRITE 1 0 144     # I2c starts, write to chip on this I2c address
	I2CWRITE 0 1 0       # tell ADS1115 we address register 0, send STOP
	I2CWRITE 1 0 145     # I2c starts, tell chip we will read
	I2CREAD 0 0 RAM11    # reads MSB byte, notice ADS1115 require ACK, which is zero in ACK bit
	I2CREAD 0 1 RAM10    # reads lower byte, send stop to tell ADS1115 no more read
	MUL RAM1L 1872 VAR1   # 1872 is the scale factor for 6.144 full scale reading
	DIV VAR1 10000 AIP5   # divide by 10000 to set value to 0.001V scale, store in AIP5  
END
 
CAI_Support said:
This little ADC board is based on TI ADS1115, it has an I2C interface talking to Webcontrol I2C interface and four 16 bit analog channels. We will provide detailed programming help in this thread. 
 

http://www.ebay.com/itm/361338787943

datasheet from TI is here:

http://www.ti.com/lit/ds/symlink/ads1115.pdf
Hmm, for battery cell monitoring may be we would need galvanic separation of the channels, for battery level and PV panel monitoring a range up to 21 V 
 
Efried said:
Hmm, for battery cell monitoring may be we would need galvanic separation of the channels, for battery level and PV panel monitoring a range up to 21 V 
 
Depends how you do it. Earlier today I posted a link to one of my cell monitors, limiting volts to 21V means only the lowest powered systems (12V) could be managed, which makes it somewhat limited appeal.
I run a 48V nominal battery bank (as do most of the serious installations), and my PV is around 100V(mp).
 
Sure, you could add dividers, but then you lose resolution.
Or, you could add level-shifting, but that's more complexity, and introduces the high probability of drive and zero offset problems.
 
If you're wanting to monitor for cell imbalance, 16-bits with a common ground and doing mathmatical deltas is only just going to make it (once you take jitter etc into account and cumulative errors quickly compound. (Plus, with only 4 channels, a typical lead-acid, 48V bank will need 6 boards just to measure each cell)
 
Because chip limited max analog input at VDC+0.3V, for 5V supply, it might make more sense to use 4.096V full scale, it will have better linear result.  As Ross pointed out, one can always use divider resistor network to divide input voltage fit in scale.
 
From what our tests, this chip does provide much higher resolution than 10 bit ADC measurement.
 
I haven't fielded the actual sensors yet, still waiting on the spool of cable.  so I still don't know what the real typical voltages will be.  and it does already have a divider & trimpot on the sensor board.   after all that is in place and adjusted, I'll report back what the best scale seems to be for these particular sensors. I just need a number that represents 'too dry'.  the actual numerical value at that point isn't really going to matter, as long as it's relatively consistent between the sensors.  I think I will really only need a few in analog mode, then once I have a good sense of where to set the trimpots, the 1 bit digital mode will probably be sufficient.  that's principally why I bought the MCP23017s, and it will allow a lot more sensors, presuming that doesn't bring the wc8 to its knees

will also report eventually for the wc32, where I'll be using these with the current sensors.   accuracy will have more of a focus there
 
klaatu said:
I just need a number that represents 'too dry'.  the actual numerical value at that point isn't really going to matter, as long as it's relatively consistent between the sensors.  I think I will really only need a few in analog mode, then once I have a good sense of where to set the trimpots, the 1 bit digital mode will probably be sufficient.
 
Sounds to me like you might be better off with comparators and digital inputs....
 
the MCP23017s are i2c digital inputs, 16 on a chip, bidirectional, and addressing support for 8 of them on the bus.  I have three of them so far.   but when this started, I didn't know about them, or that it would be so easy to extend the number of digital inputs for the webcontrol.  I already bought a slew of the sensors some time ago, a buck a piece, and saw the optional digital output on the boards, but didn't think I would be using them, as my native wc8 ttl inputs are all already occupied

if I had known that adding inputs was nearly trivial, I might have bought another wc8 instead of the wc32.  but heck, your i/o board for the wc32 is just so purdie. I had to have one
 
A new firmware for hw rev 2.2.2 board just released today. Download link is here:

The latest firmware for hw rev 2.2.2 has a new version:
http://www.cainetworks.com/support/download/wc8plc030223-update.zip

 
The change is I2CWRITE PLC command now set ZBIT value to I2C slave ack value.  In most I2C devices, during write slave device will ACK by pulling down the bus SDA line. So that if after I2CWRITE, ZBIT is 1, that is an indicator the slave device does not exist.  This is the only change for this release from previous.
 
The reason we made above mentioned change is that when ADS1115 chip not on I2C bus, example program before will read in 65535.  With the 3.02.23 firmware and following example PLC code, it will read zero.
 
Code:
START    
	CALLSUB ADS1115   
END    

ADS1115:
	I2CWRITE 1 0 144	# I2c start, write address for chip with addr connected to ground
	I2CWRITE 0 0 1 		# configuration register address is 1
	I2CWRITE 0 0 193 	# single end AINp = A0, full scale 6.144V, one shot conversion, see page 18-19
	I2CWRITE 0 1 131 	# 128 sample/s, disable comparator,
	DELAY 10   		# wait for conversion done, WC8 stop write to chip
	I2CWRITE 1 0 144 	# I2c starts, write to chip on this I2c address
	I2CWRITE 0 1 0 		# tell ADS1115 we address register 0, send STOP
	I2CWRITE 1 0 145 	# I2c starts, tell chip we will read
	BNZ  NO_DEV  		# if device exist? not, then do not read <<---- change
	I2CREAD 0 0 RAM11 	# reads MSB byte, notice ADS1115 require ACK, which is zero in ACK bit
	I2CREAD 0 1 RAM10 	# reads lower byte, send stop to tell ADS1115 no more read
	MUL RAM1L 1872 VAR1 	# 1872 is the scale factor for 6.144 full scale reading
	DIV VAR1 10000 AIP5 	# divide by 10000 to set value to 0.001V scale, store in AIP5
	RET
NO_DEV:
	I2CWRITE 1 1 144	# release I2C bus by insert STOP bit to bus  <<---- must
	SET AIP5 0		# ADS1115 not on I2C bus, so set AIP5 to zero
RET
 
This same change is also made on newer hw rev 2.3.x board firmware

The latest firmware for hw rev 2.3.x has a new version:
http://www.cainetworks.com/support/download/wc8plc030320-update.zip

 
Please note 3.03.xy firmware is only for hw rev 2.3.x boards.  For hw rev 2.2.2 board, please use firmware version 3.02.xy firmware.
 
Back
Top