1. Attachments are working again! Check out this thread for more details and to report any other bugs.

Duinomite CAnview i2c LCD screen mod.

Discussion in 'Prius PHEV Plug-In Modifications' started by Flying White Dutchman, Oct 18, 2012.

  1. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    well because i have the duinomite thanks to lopez and jdh

    its also possible to use a small lcd screen instead of a large touchscreen.


    this way it can be hidden.

    i want to place it in the litle bin under the radio and just pup it open when going to drive.
    so i can watch voltages and amps.
    a few buttons beside it for pHEV and DTC clear and its al i would need for basic operation..

    only now its time to figure out how to get working

    i am using a i2c lcd screen because this way i only need 2 data wire and a plus en minus for power to the screen.

    so i free up pins that can be used for relays etc and i dont have a large paralel cable running from the duinomite and lcd.


    but i expected it to be like print "text to screen" in mmbasic .. but it seems a little bit more to it then that.


    below some mmbasic i2c info
    -------
    I2C Implementation

    The I2C implementation fully supports master and slave operation, 10 bit addressing, address masking and general call, as well as bus arbitration (ie bus collisions in a multi master environment).

    In the master mode, there is a choice of 2 modes - interrupt and normal. In normal mode, the I2C send and receive commands will not return until the command completes or a timeout occurs (if the timout option has been specified). In interrupt mode, the send and receive commands return immediately allowing other MMBasic commands to be executed while the send and receive are in progress. When the send/receive have completed, a MMBasic interrupt will be executed. This allows you to set a flag or perform some other processing when this occurs.

    To connect the Maximite to an I2C bus, use MCU pins 43 (SDA) and 44 (SCL). These are available on the 26 pin I/O connector as logical pins 12 and 13 respectively. The actual connector pin number depends on which version of the schematic you are using as Geoff has recently revised it and changed the connector numbering. On the revised schematic it is pins 6 and 8 respectively (on the original it was pins 21 and 19 respectively).

    Pullup resistors will be required on the SDA and SCL lines - I use 2.2K but depending on cable length and number of devices connected it may be up to 4.7K . I connected my pullups to the 5V line on the I/O connector - pin 23 (on the original schematic it was pin 4).

    A common ground is also required - this is available from any one of the following I/O connector pins - 1, 2, 25 & 26.


    The implementation has 4 commands for master mode: I2CEN I2CDIS I2CSEND I2CRCV
    and 4 commands for slave mode: I2CSEN I2CSDIS I2CSSEND I2CSRCV

    I2CEN speed, timeout [, int_line]
    I2CEN initialises the I2C master module and disables the setpin and pin commands/functions for pins 12 and 13
    speed is a value between 10 and 400 (for 10kHz to 400kHz)
    timeout is a value in milliseconds after which the I2CSEND and I2CRCV commands will be interrupted if they have not completed
    (a value of zero for timeout will disable the timeout - however this is not recommended)
    int_line is an optional argument that supplies the line number of an interrupt routine to be invoked when the I2CSEND or I2CRCV commands complete
    if this is not supplied, the I2CSEND and I2CRCV commands will return when they have completed (or timed out)
    if it is supplied then the I2CSEND and I2CRCV commands will complete immediately and the command will execute in the background


    I2CDIS
    I2CDIS disables the i2c master module and reenables the standard pin 12 and 13 functionality (and will send a stop if the bus is still held)


    I2CSEND addr, option, sendlen, senddata [,sendata ...]
    I2CSEND sends data to a slave device
    addr is the slave i2c address
    if addr is 0 and option is 0 or 1, then this will be a general call
    option is a number between 0 and 3
    if 1, will keep control of the bus after the command (a stop condition will not be sent at the command completion)
    if 2, will treat the address as a 10 bit address
    if 3, will perform as if option 1 and option 2 had been set
    sendlen is the number of bytes to send
    senddata is the data to be sent - this can be specified in various ways (all values sent will be between 0 and 255):
    the data can be supplied on the command as individual arguments
    the data can be in a one dimensional array (the subscript does not have to be zero and will be honoured) bounds checking is performed
    the data can be string variable (not a constant)

    After the completion of the I2CSEND command the MM.I2C function will return one of:
    0 - all completed OK
    1 - we received a NACK response
    2 - command timed out

    Examples:
    I2CSEND &h6f,1,3,&h23,&h43,&h25
    I2CSEND &h6f,1,3,array(0)
    I2CSEND &h6f,1,3,string$


    I2CRCV addr, option, rcvlen, rcvbuf [,sendlen, senddata [,sendata ...]]
    I2CRCV receives data from the slave device, and optionally will send a command first
    addr is the slave i2c address
    option is a number between 0 and 3
    if 1, will keep control of the bus after the command (a stop condition will not be sent at the command completion)
    if 2, will treat the address as a 10 bit address
    if 3, will perform as if option 1 and option 2 had been set
    rcvlen is the number of bytes to receive
    rcvdata is the variable to receive the data - this is a one dimensional array or if rcvlen is 1 then this may be a normal variable
    the array subscript does not have to be zero and will be honoured - bounds checking is performed
    sendlen is the number of bytes to send first - this is optional
    senddata is the data to be sent - this can be specified the same as in I2CSEND

    After the completion of the I2CRCV command the MM.I2C function will return one of:
    0 - all completed OK
    1 - we received a NACK response
    2 - command timed out

    Examples:
    I2CRCV &h6f,1,1,avar
    I2CRCV &h6f,1,5,anarray(0)
    I2CRCV &h6f,1,4,anarray(2),3,&h12,&h34,&h89
    I2CRCV &h6f,1,3,anarray(0),4,anotherarray(0)


    I2CSEN addr, mask, option, send_int_line, rcv_int_line
    I2CSEN initialises the I2C slave module and disables the setpin and pin commands/functions for pins 12 and 13
    addr is the slave i2c address
    mask is the address mask (bits set as 1 will always match)
    option is a number between 0 and 3
    if 1, will enable reponding to the general call address
    if 2, will treat the address as a 10 bit address
    if 3, will perform as if option 1 and option 2 had been set
    send_int_line is the line number of a send interrupt routine to be invoked when the module has detected that the master is expecting data
    rcv_int_line is the line number of a receive interrupt routine to be invoked when the module has received data from the master


    I2CSDIS
    I2CSDIS disables the i2c slave module and reenables the standard pin 12 and 13 functionality (and will send a stop if the bus is still held)


    I2CSSEND sendlen, senddata [,senddata ...]
    I2CSSEND will send data to the master - this command should be invoked after the send interrupt routine has been invoked
    sendlen is the number of bytes to send
    senddata is the data to be sent - this can be specified in various ways (all values sent will be between 0 and 255):
    the data can be supplied on the command as individual arguments
    the data can be in a one dimensional array (the subscript does not have to be zero and will be honoured) bounds checking is performed
    the data can be string variable (not a constant)

    Examples:
    I2CSSEND 3,&h23,&h43,&h25
    I2CSSEND 3,array(0)
    I2CSSEND 3,string$


    I2CSRCV rcvlen, rcvbuf, rcvd
    I2CSRCV will receive data from the master - this command should be invoked after the receive interrupt routine has been invoked
    rcvlen is the maximum number of bytes to receive
    rcvbuf is the array that will receive the returned bytes - if rcvlen is 1 then this can be a standard variable
    rcvd will contain actual number of bytes received by the command

    Examples:
    I2CSRCV 1,avar,rcvd
    I2CSRCV 5,anarray(0),rcvd


    There are also 2 utility commands/functions that allow numbers to be sent as consecutive bytes: NUM2BYTE BYTE2NUM

    NUM2BYTE number, array(x)
    NUM2BYTE number, variable1, variable2, variable3, variable4

    This command will convert 'number' to 4 numbers containing the 4 separate bytes of 'number' (MMBasic numbers are stored as the C float type and are 4 bytes in length). The bytes can be returned as 4 separate variables, or as 4 elements of 'array' starting at index 'x'. (See the function byte2num() for the reverse of this command)

    BYTE2NUM(array(x))
    BYTE2NUM(arg1, arg2, arg3, arg4)

    This function will return the number created by storing the 4 arguments as consecutive bytes (MMBasic numbers are stored as the C float type and are 4 bytes in length). The bytes can be supplied as 4 separate numbers (arg1 - arg4) or as 4 elements of 'array' starting at index 'x'. (See the command num2byte for the reverse of this function)
     
  2. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    i need to use pin 5 and 6 on the Uext connector for (6) SDA and (5)SCL data.

    pin 1 provides 3,3 volt power and pin 2 ground.


    the adress of the screen is 0x20 if i am correct.
     
  3. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    this one would be easyer i think

    a serial lcd

     
  4. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    When i get my second Duinomite setup as bms without relays to control the charger i can use the current relay board for the Duinomite canview and get to try the lcd screen.

    -Tapatalk
     
  5. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    uploadfromtaptalk1351018893315.jpg uploadfromtaptalk1351018931219.jpg

    Duinomite and i2c is a pain and i got a cursor running when using arduino
    Funny it uses a simple print command to write text to the screen.



    -Tapatalk
     
  6. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    Anyone out there have an Orginal HybridInterfaces CANVIEW for sale ??
     
  7. mrbigh

    mrbigh Prius Absolutum Dominium

    Joined:
    Sep 6, 2005
    3,686
    699
    2
    Location:
    Long Island, NY
    Vehicle:
    Other Electric Vehicle
    How much are you willing to spend? these are unique electronic pieces...:rolleyes: