Olimex Support Forum

Others => UEXT => Topic started by: OrOoX on April 05, 2013, 08:58:08 PM

Title: [MOD-IO] Need help for Digital Input :)
Post by: OrOoX on April 05, 2013, 08:58:08 PM
Hello,

I come in the forum because i have buy a Duinomite-Emega and Mod-IO cards,

The two cards work, but i don't know read the Digital Input with the BASIC
and the found docs don't help me ... :(

I have found this in the README of Mod-IO, but i don't understand who use it :

Quote************************************
   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 0x20
   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.
   
      2) Get the voltage applied to one of the analogue inputs of the board. The board features four 10bit resolution analogue inputs (input voltages from 0 - 3.3V) and each of them is read with a separate command. Command should have the following common format:

   ************************************
   S aaaaaaaW cccccccc P S aaaaaaaR dddddddd 000000dd P
   ************************************

Thanks in advance !


PS : Sorry for my english, i'm French :D
Title: Re: [MOD-IO] Need help for Digital Input :)
Post by: LubOlimex on April 08, 2013, 08:51:01 AM
Hey OrOoX,

There are some documents that further clarify the protocol (just remember that the address is 0x20 in the latest firmware - you need to change that!!!):

http://www.duinomite.com/files/Hardware/Dontronics/Olimex/UEXT/MOD-IO/MOD-IO%20Additional%20Info%20by%20Ken%20Segler.txt (http://www.duinomite.com/files/Hardware/Dontronics/Olimex/UEXT/MOD-IO/MOD-IO%20Additional%20Info%20by%20Ken%20Segler.txt) and also how to turn on a http://www.duinomite.com/files/Hardware/Dontronics/Olimex/UEXT/MOD-IO/turn-on-relay.bas (http://www.duinomite.com/files/Hardware/Dontronics/Olimex/UEXT/MOD-IO/turn-on-relay.bas).

Overall a good source of information is the dontronics repo about MOD-IO (just the I2C address might be a bit off and would need changing):
http://www.duinomite.com/files/index.php?dir=Hardware%2FDontronics%2FOlimex%2FUEXT%2FMOD-IO%2F (http://www.duinomite.com/files/index.php?dir=Hardware%2FDontronics%2FOlimex%2FUEXT%2FMOD-IO%2F)

Also there is this project (with MOD-MAG) that shows how to interface I2C:
http://olimex.wordpress.com/2012/01/26/duinomite-project-measuring-earths-magnetic-field-with-mag3110/ (http://olimex.wordpress.com/2012/01/26/duinomite-project-measuring-earths-magnetic-field-with-mag3110/)

Best regards,
Lub/OLIMEX
Title: Re: [MOD-IO] Need help for Digital Input :)
Post by: OrOoX on April 08, 2013, 09:18:26 PM
Hi LubOlimex,

Thanks for your response.


I know all links except the last for the magnetic sensor, the link with all .bas files
help me only for enable/disable the relays, not the Digital Input.


Do you have a exemple with the 0x20 adress for enable the Digital Input IN1 ?


Thanks !
Title: Re: [MOD-IO] Need help for Digital Input :)
Post by: OrOoX on April 10, 2013, 08:54:16 PM
Up !  :-\
Title: Re: [MOD-IO] Need help for Digital Input :)
Post by: LubOlimex on April 12, 2013, 04:35:32 PM
Hey OrOoX,

If you write 0x20 as command (no 0 or 1 parameter) and read what MOD-IO returns you will receive the current status of the Digital Inputs. The returned value should be presented in binary format.

Best regards,
Lub/OLIMEX