External Links

Creative Science Centre

 

Library SV3 (I2C)

// #include "http://www.byvac.com/mBlib/flb/Library/2016/lib_sv3.bas"

This library is for use with I2C devices that use the SV3 system settings. It is for getting the device ID, version and also for getting / setting EEPROM values. This will normally be included anyway for I2C devices, i.e BV4242, BV4243, BV4601 etc.

This library should be used because when writing to EEPROM a read is made first, this will prevent any unnecessary write to the EEPROM

  • ee.read(i2caddr,eeadr) // reads a single byte from an eeprom address
  • ee.read16(i2caddr,eeadr) // reads two bytes and returns a 16 bit value, high byte first
  • ee.write(i2cadr,eeadr,value) // writes value to eeprom address (8 bit) - if DIFFERENT
  • ee.write16(i2cadr,eeadr,value) // writes value to eeprom address (16 bit) - if DIFFERENT
  • ee.devID(i2caddr) // returns the device ID as a 16 bit value
  • ee.devVAR#(i2caddr) // returns the firmware version as a floating point value
  • ee.reset(i2cassr) // performs soft reset

The last three are not really EEPROM functions but are put here for completeness.

Example

The trigger value of a BV4242 is set as a 16 bit value in EEPROM locations 18 and 19.

print ee.read16(122,18) // will get the current value from EEPROM locations 18 & 19

print ee.write16(122,18,300) // writs a 16 bit value to EEPROM locations 18 and 19