DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

AVR-ICSP View Datasheet(PDF) - Unspecified

Part Name
Description
Manufacturer
AVR-ICSP Datasheet PDF : 30 Pages
First Prev 11 12 13 14 15 16 17 18 19 20 Next Last
OLIMEX© 2015
MOD-IO user's manual
2.6.2 Getting the state of optocoupler
The board features four optoisolated inputs named IN1, IN2, IN3 and IN4 and their statuses can be
read together with one command. The command should have the following format:
************************************
S aaaaaaaW cccccccc P S aaaaaaaR 0000dddd P
************************************
,where
S – start condition
aaaaaaa – slave address of the board
W – write mode, should be 0
cccccccc – command code, should be 0×20
P – Stop condition
R – read mode, should be 1
dddd – bitmap of the input states received from the MOD-IO board, i.e. bit0 corresponds to
IN1, bit1 to IN2 and so on. '1' means that power is applied to the optocoupler, '0' means the
opposite.
Note: Successive readings from the board without reissuing the command code will not get an
updated value of the ports (i.e. the user will read the same value) until another command is issued.
Example:
Reading optocoupled inputs in pseudo code
i2cStart()
i2cSend(0xb0);
i2csend(0x20);
i2cClose();
i2cStart();
i2cSend(0xb1);
byte = i2cRead();
i2cClose();
//Send start condition;
//This is 0×58 shifted to left one time and added 0 as W
//Read inputs commands
//Send stop condition
//Send start condition. You can use i2cRestart() instead
//This is 0×58 shifted to left one time and added 1 as W
//Read one byte of data;
/* “byte” now holds the state of the inputs. To “decode” bitmask the data. */
in1 = byte & 0x01; //To get state of IN1
in2 = byte & 0x02; //To get state of IN2
in3 = byte & 0x04; //To get state of IN3
in4 = byte & 0x08; //To get state of IN4
Page 11 of 30

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]