View Single Post
Old Mar 02, 2010, 06:34 PM
Dr Strangelove is offline
Find More Posts by Dr Strangelove
Registered User
Dr Strangelove's Avatar
Joined Feb 2010
43 Posts
Teej,

Thank's again. I set up everything on the bench last night (Australian time) and had a hack, but got nothing out. The sensors are in 3rd party mode, and I put the scope on the SDA and SCA lines and it was all crisp, but nothing sensible came out.

Here's the stamp I2CIN protocol;

I2CIN Pin, SlaveID, { Address { \LowAddress }, } [ InputData ]

Pin is a variable/constant/expression (0 or 8) that specifies which
I/O pins to use. I2C devices require two I/O pins to communicate.
The Pin argument serves a double purpose; specifying the first pin
(for connection to the chip's SDA pin) and, indirectly, the other
required pin (for connection to the chip's SCL pin). See explanation
below. Both I/O pins will be toggled between output and input
mode during the I2CIN command and both will be set to input
mode by the end of the I2CIN command.

SlaveID is a variable/constant/expression (0 255) indicating the
unique ID of the I2C chip.

Address is an optional variable/constant/expression (0 255)
indicating the desired address within the I2C chip to receive data
from. The Address argument may be used with the optional
LowAddress argument to indicate a word-sized address value.

LowAddress is an optional variable/constant/expression (0 255)
indicating the low-byte of the word-sized address within the I2C
chip to receive data from. This argument must be used along with
the Address argument.

InputData is a list of variables and modifiers that tells I2CIN what to
do with incoming data. I2CIN can store data in a variable or array,
interpret numeric text (decimal, binary, or hex) and store the
corresponding value in a variable, wait for a fixed or variable
sequence of bytes, or ignore a specified number of bytes. These
actions can be combined in any order in the InputData list.


In my case;

The pin is 13
I assume the slave ID is 0xEA which is $EA in stamp
I assume the address will just be 0

So my code is;

result VAR Byte(2)
speed VAR word

IC2IN 13, $EA, 0, [result(0)]
IC2IN 13, $EA, 0, [result(1)]

speed = result(0) * 256 + result(1)

Again, thank's heaps for spending thetime to help.

Dr S
Dr Strangelove is offline Find More Posts by Dr Strangelove
Reply With Quote