Git Product home page Git Product logo

i2c's People

Contributors

andec avatar gaetronik avatar larsin avatar ppaques avatar xasin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i2c's Issues

Hello

Sorry, there is no message facility in github and you didn't leave a mail. So just close this when read.

I have created a site to share experience with ruby on the pi. And this library makes you an "expert"

I was wondering if you would like to write a little article on ruby and serial communication.

http://rubinio.org/

BTW: how is that motor coming along ?

Torsten

warning: already initialized constant ...

Hello,

I hava a small problem. When i use your gem (thanks for it), i get theses warnings.

/home/sebastien/.rvm/gems/ruby-1.9.3-p392/gems/i2c-0.2.0/lib/i2c/drivers/mcp23017.rb:16: warning: already initialized constant INPUT
/home/sebastien/.rvm/gems/ruby-1.9.3-p392/gems/i2c-0.2.0/lib/i2c/drivers/mcp23017.rb:17: warning: already initialized constant OUTPUT
/home/sebastien/.rvm/gems/ruby-1.9.3-p392/gems/i2c-0.2.0/lib/i2c/drivers/mcp23017.rb:20: warning: already initialized constant HIGH
/home/sebastien/.rvm/gems/ruby-1.9.3-p392/gems/i2c-0.2.0/lib/i2c/drivers/mcp23017.rb:21: warning: already initialized constant LOW

I think it's because there constant are initialized twice (in both drivers) but i'm not sure.

Good afternoon

TypeError: no implicit conversion of Array into String

What I'm trying:

require 'i2c'
i2c = I2C.create('/dev/i2c-1')
mcp = I2C::Drivers::MCP23017.new(i2c,0x20)

and I get:

TypeError: no implicit conversion of Array into String at file lib/i2c/backends/i2c-dev.rb:31:in block in write with Ruby 2.1.10.

I found on that file that there is a data << value assignation, when data is defined as string in line # 28 :/

Update Gemspec and push gem

I just checked, and the current version of the i2c gem found on rubygems.org is a little outdated, as it is from 2015.
I recommend testing the gem, updating the gemspec's version and then publishing a fresh version ^^

Some more docs

Hi,
this is nice and small, and works, great. Also google and rubygems lead here.

So i thought it may be nice to have a little more explanation in the readme, eg:

  • on newer pi's it's /dev/i2c-1
  • maybe mention i2c-tools
  • some read write examples
  • small section on master/slave working of the protocol

I could make a pull request if you want, if the topics are ok

initialisation of MCP23017 corrupts data

We have a MCP23017 attached to a Raspberry Pi compute module.

The device is setup to use address 0x23. We have the reset pin also wired to the Pi.

As a reference we use the two methods to read input values of the device. Python and direct shell

We read after the device is reset. As per datasheet it is therefore initialised to input

i2cget -y 1 0x23 0x12
i2cget -y 1 0x23 0x13

and we get the values as expected.

Also with python:

#!/usr/bin/python

import smbus
import time
import sys

bus = smbus.SMBus(1) # Rev 2 Pi uses 1

DEVICE = 0x23 # Device address (A0-A2)

GPIOA  = 0x12 # Register for inputs
GPIOB  = 0x13 # Register for inputs

stateBankA = bus.read_byte_data(DEVICE,GPIOA)
stateBankB = bus.read_byte_data(DEVICE,GPIOB)

print "state of the GPIO " + bin(stateBankA) + bin(stateBankB)

When a signal is attached to pin 16 we read:

0x00
0x80

same with the python script:

state of the GPIO 0b00b10000000

And it reacts accordingly when I provide a signal to another pin.

We wrote a little ruby script to also read the input values. Our business logic is also written in Ruby so this is the prototype of the final implementation:

#!/usr/bin/env ruby

require 'i2c'

mcp = I2C::Drivers::MCP23017.new("/dev/i2c-1", 0x23)
#(0..15).each do |pin|
#   mcp.mode(pin, INPUT)
#end
(0..15).each do |pin|
   print "#{mcp[pin]}"
end
print "/n"

First issue: The default state when reading via ruby is not 0000000000000000 but it is 0000000011111111. There is no input signal. When providing an input to pin 16 the output is 0000000011111110.
The issue is present both when setting the mode or not.

Why is the second bank inverted?

Second issue: After running the ruby script once, also the output in python and shell is "corrupted".

0x00
0x7f

is now the output of the shell script
state of the GPIO 0b00b1111111 is the output of the Python script.

state of the GPIO 0b00b11111111 is the output with input signal.

I looked in the initialisation and saw there is some writing when doing the initialisation:
https://github.com/andec/i2c/blob/master/lib/i2c/drivers/mcp230xx.rb#L54

I'm trying to make some sense of the reading in the irb. I don't understand how to do a simple i2cget -y 1 0x23 0x12would translate to the ruby code:

irb(main):025:0> device.read(0x23,2,0x12).unpack('CC')
=> [0, 128]
irb(main):026:0> device.read(0x23,1,0x12).unpack('CC')
=> [0, nil]

output of i2cgetremains to be

0x00
0x80

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.