rewolff / bw_library

Python library to talk to the BitWizard expansion boards on raspberry pi.
1 stars 2 forks source link

menu.py example program having trouble on i2c RPI-UI #6

Open mrumpler opened 11 years ago

mrumpler commented 11 years ago

Hi,

I just found this great piece of software when searching for usable libraries to use in my PI-project. I own two RPi-UI boards both with i2c as interface.

I changed the code in menu.py to reflect my i2c board like that:

bus = I2C( 1 ) lcd = RPi_Ui_20x4(bus) lcd.SetPinConfig(1,MCP9700) lcd.ExtTemp=lcd.Pins[1] lcd.Contrast(128) lcd.Backlight(128) lcd.Cls()

the rest is original. When i start the demo program the UI screen gets blanked, the differently set contrast and backlight as well as the Cls() works, but when the program tries to show the main menu this happens:

pi@raspbmc:~/bw_library-master/examples$ sudo ./menu.py Traceback (most recent call last): File "./menu.py", line 168, in menu.Show() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 99, in Show self.MenuLoop() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 135, in MenuLoop self.Buttons.ReportPressed() #flush register File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 725, in ReportPressed v =self.Bus.Read_uInt8(self.Address,0x30) File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 162, in Read_uInt8 return struct.unpack('B',self.Transaction(chr(Address+1)+chr(Register),3)[1][2])[0] IndexError: string index out of range

Any ideas what happens? The screen shows Characters that in pieces look like the wanted menu but there are also unwanted characters on the screen.

Any ideas? Thanks for your help Mike

ghost commented 11 years ago

Mike,

The library changed at some points, an I was really ill when I did those. Some functions are untested, as is read_uint8, there might be indeed something wrong with the indexes.

I focused on documenting it all first, but I am in the progress of building a project with ui.py (menu class) and will soon hit this. Can you wait for one or two days?

Verstuurd vanaf mijn iPad

Op Nov 10, 2013 om 17:04 heeft mrumpler notifications@github.com het volgende geschreven:

Hi,

I just found this great piece of software when searching for usable libraries to use in my PI-project. I own two RPi-UI boards both with i2c as interface.

I changed the code in menu.py to reflect my i2c board like that:

bus = I2C( 1 ) lcd = RPi_Ui_20x4(bus) lcd.SetPinConfig(1,MCP9700) lcd.ExtTemp=lcd.Pins[1] lcd.Contrast(128) lcd.Backlight(128) lcd.Cls()

the rest is original. When i start the demo program the UI screen gets blanked, the differently set contrast and backlight as well as the Cls() works, but when the program tries to show the main menu this happens:

pi@raspbmc:~/bw_library-master/examples$ sudo ./menu.py Traceback (most recent call last): File "./menu.py", line 168, in menu.Show() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 99, in Show self.MenuLoop() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 135, in MenuLoop self.Buttons.ReportPressed() #flush register File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 725, in ReportPressed v =self.Bus.Read_uInt8(self.Address,0x30) File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 162, in Read_uInt8 return struct.unpack('B',self.Transaction(chr(Address+1)+chr(Register),3)[1][2])[0] IndexError: string index out of range

Any ideas what happens? The screen shows Characters that in pieces look like the wanted menu but there are also unwanted characters on the screen.

Any ideas? Thanks for your help Mike

— Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

Mike,

Sorry for the delay.

I have just tested the code on my SPI version of the UI and that works like a charm. Since I do not have an I2C UI at the moment it is a bit hard to see what is wrong in your situation.

What worries me though is the wrong characters on your display.

On I2C bus read in Transaction I do catch an IOError and return 0,” " (two spaces)

I guess an IOerror is happening…

you can eliminate the catch by editing bw.py. on line 356, you find def Transaction

in that function remove the Try:, except IOError: and return 0, " „ lines and fix indentation so it will look like:

def Transaction(self, OutBuffer,read=0):
    if read!=0:
       #try:
       return 0,'  '+''.join([chr(m) for m in self.I2cBus.read_i2c_block_data((ord(OutBuffer[0])>>1),ord(OutBuffer[1]))])
        #except IOError:
        #   return 0,"  "
    else:
        self.I2cBus.write_i2c_block_data(ord(OutBuffer[0])>>1  ,ord(OutBuffer[1]), [ord(m) for m in OutBuffer[2:]])           
        return 0,None

go back to the place where you can python setup.py install to reinstall and see what happens… I guess you will get an IOError

A few things are possible, I already mentioned the cabling with that I mean long wires. Do you have the UI directly on the Pi?

Can you confirm the firmware version which is shown when you power on the UI.

I’m sort of puzzled by this…

Martijn

On 10 Nov 2013, at 17:04 , mrumpler notifications@github.com wrote:

Hi,

I just found this great piece of software when searching for usable libraries to use in my PI-project. I own two RPi-UI boards both with i2c as interface.

I changed the code in menu.py to reflect my i2c board like that:

bus = I2C( 1 ) lcd = RPi_Ui_20x4(bus) lcd.SetPinConfig(1,MCP9700) lcd.ExtTemp=lcd.Pins[1] lcd.Contrast(128) lcd.Backlight(128) lcd.Cls()

the rest is original. When i start the demo program the UI screen gets blanked, the differently set contrast and backlight as well as the Cls() works, but when the program tries to show the main menu this happens:

pi@raspbmc:~/bw_library-master/examples$ sudo ./menu.py Traceback (most recent call last): File "./menu.py", line 168, in menu.Show() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 99, in Show self.MenuLoop() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 135, in MenuLoop self.Buttons.ReportPressed() #flush register File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 725, in ReportPressed v =self.Bus.Read_uInt8(self.Address,0x30) File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 162, in Read_uInt8 return struct.unpack('B',self.Transaction(chr(Address+1)+chr(Register),3)[1][2])[0] IndexError: string index out of range

Any ideas what happens? The screen shows Characters that in pieces look like the wanted menu but there are also unwanted characters on the screen.

Any ideas? Thanks for your help Mike

— Reply to this email directly or view it on GitHub.

mrumpler commented 10 years ago

Retried and also on a fresh raspbian installation. Also tried the second UI I have. Still the same problems.... How can we get a grip on that?

thanx Mike

allebone commented 10 years ago

I've got the 1.3v RPI UI, i2c, as well. I haven't gotten a good use out of it yet, so I am very excited to see if this can get worked out. If I can provide any more information, I can as well.

rewolff commented 10 years ago

Guys, to separate software problems from hardware problems: are you able to use bw_tool to get something on the display?

allebone commented 10 years ago

Ok, I can now get some progress using the bw_tool. It may have been part anomaly and part user incompetence. It was spitting out crazy characters and tacking on my messages instead of displaying them properly. However, I totally powered off, and removed the board, replaced, and now it will at least let me run the CPU load script you had somewhere on the Wiki. I guess my problem now is, RTC gives me permission denied when I try the steps. Also, I have NO clue how to properly output to the screen using the bw_tool. I think I have no good reference for what should be hex or what should be decimal (or text). I can only get both lines populated with text by clearing the screen and inputting them one at a time. Or is that right? I'm certainly not saying everything isn't working as prescribed, but I just don't know how to go about it. I'm working on a basic status for now, something like "Loading..." during boot or Rc.d, then change to Application name once its booted, then IP on second line, maybe rotating between IP, load, and clock.

Since I have 1.3UI is it correct to assume that I cannot change the booting message and scroll text across the screen when bigger than 16 characters?

rewolff commented 10 years ago

If you need a newer firmware mail me. We'll see if we can get your board field-upgraded.

I might have written the RTC install steps when logged in as root. Try "sudo -s" before starting the steps on the wiki.

In shell scripts I always start out with the command-used-to-contact-my-device (this saves me typing it over and over again, but also makes it easy to adapt to a typo in this part). ui='bw_tool -I -D/dev/i2c-1 -a 94' Then I can easily... clear the screen: $ui -w 10:0 or move to line 2.. $ui -w 11:20 or display a text: $ui -t "hello there" ....

allebone commented 10 years ago

amazing, that worked for the RTC and the lines. This should help me get started on the scripting I needed.

Any chance on a field upgrade for the firmware, however?

Thanks,

Bryan

On Dec 29, 2013, at 3:24 PM, rewolff notifications@github.com wrote:

If you need a newer firmware mail me. We'll see if we can get your board field-upgraded.

I might have written the RTC install steps when logged in as root. Try "sudo -s" before starting the steps on the wiki.

In shell scripts I always start out with the command-used-to-contact-my-device. ui='bw_tool -I -D/dev/i2c-1 -a 94' Then I can easily... clear the screen: $ui -w 10:0 or move to line 2.. $ui -w 11:20 or display a text: $ui -t "hello there" ....

— Reply to this email directly or view it on GitHub.

Bryan Allebone bryan.allebone@yahoo.com

ghost commented 10 years ago

There might be a small quirck in the I2c code, not sure. Soon I will have a I2C ui and I will test.

Menu.py is something written with specific hardware in mind on SPI.

have you tried to communicate with the UI like:

from BitWizard.bw import *

i = I2c(1) ui=RPi_Ui_20x4(i) ui.Cls() ui.Print(’Test’)

?

On 30 Dec 2013, at 00:21 , Bryan Allebone notifications@github.com wrote:

amazing, that worked for the RTC and the lines. This should help me get started on the scripting I needed.

Any chance on a field upgrade for the firmware, however?

Thanks,

Bryan

On Dec 29, 2013, at 3:24 PM, rewolff notifications@github.com wrote:

If you need a newer firmware mail me. We'll see if we can get your board field-upgraded.

I might have written the RTC install steps when logged in as root. Try "sudo -s" before starting the steps on the wiki.

In shell scripts I always start out with the command-used-to-contact-my-device. ui='bw_tool -I -D/dev/i2c-1 -a 94' Then I can easily... clear the screen: $ui -w 10:0 or move to line 2.. $ui -w 11:20 or display a text: $ui -t "hello there" ....

— Reply to this email directly or view it on GitHub.

Bryan Allebone bryan.allebone@yahoo.com — Reply to this email directly or view it on GitHub.

XXL-Wing commented 10 years ago

For more information:

it is the same with two displays (i have two of them) and on two different PI's... bw_tool can be used to bring meaningful stuff onto the screen :-)

mrpopoff commented 10 years ago

Hello, everybody! Looks like i2c readings via python's module smbus.SMBus.read_i2c_block_data are very unstable, generating IOError exceptions. Writing to RPi UI is stable.

rewolff commented 10 years ago

mrpopoff if you can provide me with a "howto" to see the ioerrors, I'll put the logic analyser to work and see if I can diagnose the problem. Hopefully that will help mmoeling fix the problem.

ghost commented 10 years ago

I see Some weird behaviour too. This started after The last firmware/kernel update as iT seems. I have to start my programs twice before they work... I am investigating.

Verstuurd vanaf mijn iPad

Op Feb 11, 2014 om 10:13 heeft rewolff notifications@github.com het volgende geschreven:

mrpopoff if you can provide me with a "howto" to see the ioerrors, I'll put the logic analyser to work and see if I can diagnose the problem. Hopefully that will help mmoeling fix the problem.

— Reply to this email directly or view it on GitHub.

mrpopoff commented 10 years ago

Here is my SMBus test script (https://dl.dropboxusercontent.com/u/104580372/RaspberryPi/BitWizard/smb_test.py), idea is taken from btw_library, reading buttons pushed:

Hello! creating bus... [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, True] [False, False, False, False, True, False] [False, False, False, False, True, False] [False, False, False, True, False, False] [False, False, True, False, False, False] False, True, True, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, True, False, False, False, False] [True, False, False, False, False, False] True, False, False, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, False, False, False, True, True] [False, False, False, False, True, True] [False, False, False, False, True, True] [False, False, False, True, True, False] [False, False, False, True, True, False] [False, False, False, True, True, False] [False, False, False, False, False, False] [True, True, False, False, False, False] True, True, False, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, False, False, False, False, False] closing bus... Bye bye!

ghost commented 10 years ago

I have not seen this behaviour before. It seems to me that this is below the python code. The smbus seems stable to me.

Could this be rpi, i2c bus wiring or board firmware? What happens if you add a sleep in The Main loop?

On The top, add: From time import sleep

And in The Main loop (while True) At the end: sleep(.1) for a 100ms sleep.

Verstuurd vanaf mijn iPad

Op Feb 11, 2014 om 12:29 heeft mrpopoff notifications@github.com het volgende geschreven:

Here is my SMBus test scrit, idea is taken from btw_library:

!/usr/bin/python

import struct from time import sleep from smbus import SMBus

print "Hello!"

print "creating bus..."

open Linux device /dev/ic2-1

i2c = SMBus(1) address = 0x4a

Read i2c bus with retries

def DoTransaction(read=0): for attempt in range(0,5): try: if read!=0: return 0,' '+''.join([chr(m) for m in i2c.read_i2c_block_data(address,0x30)]) else: return 0,None except IOError as err: print "({0}) read_i2c_block_data I/O error({1}): {2}".format(attempt, err.errno, err.strerror) continue return 0,None try:

Register = i2c.read_i2c_block_data(address,0x10)

print Register

while True: Transaction = DoTransaction(3)

print Transaction

v = struct.unpack('B', Transaction[1][2])[0]
#print v
Buttons = []  
for i in range (0, 6):
    Buttons.append(v & 2**i == 2**i)
print Buttons
sleep(1)

finally: print "closing bus..." i2c.close() print "Bye bye!"

Output: Hello! creating bus... [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, False] [False, False, False, False, False, True] [False, False, False, False, True, False] [False, False, False, False, True, False] [False, False, False, True, False, False] [False, False, True, False, False, False] False, True, True, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, True, False, False, False, False] [True, False, False, False, False, False] True, False, False, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, False, False, False, True, True] [False, False, False, False, True, True] [False, False, False, False, True, True] [False, False, False, True, True, False] [False, False, False, True, True, False] [False, False, False, True, True, False] [False, False, False, False, False, False] [True, True, False, False, False, False] True, True, False, False, False, False read_i2c_block_data I/O error(5): Input/output error [False, False, False, False, False, False] closing bus... Bye bye!

— Reply to this email directly or view it on GitHub.

mrpopoff commented 10 years ago

Definetely it is a problem somewere near python, shell scripts with bw_tool works like a charm.

ghost commented 10 years ago

Hmm very weird,

Over The weekend I tested a I2C ui without any problems at all. I Will run your test script this afternoon and see what I come up with... I'll let you know what I come up with.

Martijn

Op Feb 11, 2014 om 13:30 heeft mrpopoff notifications@github.com het volgende geschreven:

Definetely it is a problem somewere near python, shell scripts with bw_tool works like a charm.

— Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

Ok,

it seems there is a ‘problem’ with the python-smbus module in combination with the Pi…

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=34734

Confirms what I’ve found out here. I could not reproduce your problem since I configured my I2C clock to be @ 32KHz a long time ago for something else…

Can you create a file in /etc/modprobe.d called i2c.conf (name does not really matter) and enter the line:

options i2c_bcm2708 baudrate=32000

and reboot the Pi…

next, make sure you have the latest version of bw_library on you system (last update ~2 months old) and I did change bits in the I2C Transaction function Error handling, If I’m right you seem to have a slightly older version.

next run your test script again…. Here It works fine..

Martijn

On 11 Feb 2014, at 13:30, mrpopoff notifications@github.com wrote:

Definetely it is a problem somewere near python, shell scripts with bw_tool works like a charm.

— Reply to this email directly or view it on GitHub.

mrpopoff commented 10 years ago

Thanks, changing bus baudrate to 32KHz helps me to read buttons with no errors

ghost commented 10 years ago

We found the problem and are preparing a fix which should be tested before release. BW_Library will be updated since that is the best place to do so. A little bit more error handling will be added to retry once after a NACK is received to let the firmware in the board do its work after a ‘packet received interrupt’. With lower bus speeds, this does not happen...

On 11 Feb 2014, at 13:39, Martijn Moeling martijn@moeling.net wrote:

Hmm very weird,

Over The weekend I tested a I2C ui without any problems at all. I Will run your test script this afternoon and see what I come up with... I'll let you know what I come up with.

Martijn

Op Feb 11, 2014 om 13:30 heeft mrpopoff notifications@github.com het volgende geschreven:

Definetely it is a problem somewere near python, shell scripts with bw_tool works like a charm.

— Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

ok mrpopoff,

I just pushed an update to Git with an update which has been tested on 100KHz and it solved the problem…

Pull the library from Git, reinstall with sudo python setup.py install, remove the file in /etc/modprobe.d you created, reboot and you are good to go!

Martijn

On 14 Feb 2014, at 13:40, mrpopoff notifications@github.com wrote:

Thanks, changing bus baudrate to 32KHz helps me to read buttons with no errors

— Reply to this email directly or view it on GitHub.

mrpopoff commented 10 years ago

2014-02-14 17 30 30 Hi, Martijn!

Launched menu.py from bw_library examples, selected ScanBus, example crashes and my RPi UI board is now stoned. Unplugging power doesn't help at all. i2cdetect doesn't display 0x4a address anymore :-( Only RTC clock is available now. Could ypu please help me to solve this problem?

root@raspberrypi:/home/pi# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU 70: -- -- -- -- -- -- -- --

rewolff commented 10 years ago

sometimes the board seems to adopt a new address without the user wanting that. It looks as if your rpi_ui is now living on address 0x36 (= 0x6c in bitwizard-talk). We have not been able to reproduce this yet, so we don't know how to fix it. Sorry :-(

(Since we've first heard about this, we've added checks for accidental change-of-address requests as well as more validation for the eeprom data. )

Can you try: bw_tool -a 6c -I -d /dev/i2c-1 -w f1:aa f2:55 f0:94

mrpopoff commented 10 years ago

Thanks, rewrite address data with sequence -w f1:55 f2:aa f0:94, but LCD startup messages are damaged too. Could you tell me please, how to write string values to registers with bw_tool, '-w' an '-W' are for numbers.

ghost commented 10 years ago

menu.py was basically a test program which evolved. In the header it states what hardware you should connect. Scanbus scanned the SPI bus as far as I remember… I will pull menu.py from the examples soon meny.py was never tested or intended for I2C

I am working on multiple small examples, please look at http://pb0ner.nl/BitWizardDoc/ , something I’m working on, look at examples: menu.py it said Requires 20x4 SPI!!!!!! ui The Docs directory in the bw_library contains a version of the documentation too… a bit outdated though.

Rogier already commented on your address change...

Martijn

On 14 Feb 2014, at 14:49, mrpopoff notifications@github.com wrote:

Hi, Martijn!

Launched menu.py from bw_library examples, selected ScanBus, example crashes and my RPi UI board is now stoned. Unplugging power doesn't help at all. i2cdetect doesn't display 0x4a address anymore :-( Only RTC clock is available now. Could ypu please help me to solve this problem?

root@raspberrypi:/home/pi# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU 70: -- -- -- -- -- -- -- --

— Reply to this email directly or view it on GitHub.

mrpopoff commented 10 years ago

Hello! I thank you all! All my problems with I2C_rpi_ui were solved with your help. Here is my repair shell script (bitwizard i2c address = i2cdetect address * 2):

#!/bin/sh
#
# bw_tool config
BWT='/usr/bin/bw_tool --i2c --device /dev/i2c-1 -a <your dev address> -s 100000 -d 1000'

# set initial i2c address 0x94
$BWT -w f1:55
$BWT -w f2:aa
$BWT -w f0:94

# clean (reset) startup messages
$BWT -w 08:ff
$BWT -w 09:ff
$BWT -w 0a:ff
$BWT -w 0b:ff
ghost commented 10 years ago

You are welcome,

Thank you for your patience and help. The bw library supports address changes too. I think that setting the startup texts is still on the todo list. That was a feature added in later ui firmware.

Martijn

Verstuurd vanaf mijn iPad

Op Feb 18, 2014 om 11:36 heeft mrpopoff notifications@github.com het volgende geschreven:

Hello! I thank you all! All my problems with I2C_rpi_ui were solved with your help. Here is my repair shell script:

!/bin/sh

#

bw_tool config

BWT='/usr/bin/bw_tool --i2c --device /dev/i2c-1 -a 20 -s 100000 -d 1000'

set initial i2c address 0x94

$BWT -w f1:55 $BWT -w f2:aa $BWT -w f0:94

clean (reset) startup messages

$BWT -w 08:ff $BWT -w 09:ff $BWT -w 0a:ff $BWT -w 0b:ff — Reply to this email directly or view it on GitHub.

XXL-Wing commented 10 years ago

Hello guys,

sorry for reporting back so late, but I was busy with other things in the last months and did not have time to further work with the RPI_UI.

I tested the latest additions but for me the problem is still not solved :-( I still get errors when trying to use the menu.py sample....

pi@raspbmc:~/bw_library-master/examples$ sudo python menu.py Traceback (most recent call last): File "menu.py", line 166, in menu.Show() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 100, in Show self.MenuLoop() File "/usr/local/lib/python2.7/dist-packages/BitWizard/ui.py", line 136, in MenuLoop self.Buttons.ReportPressed() #flush register File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 1098, in ReportPressed Buttons = BitWizardPushButtons.ReportPressed(self) File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 759, in ReportPressed v =self.Bus.Read_uInt8(self.Address,0x30) File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 163, in Read_uInt8 return struct.unpack('B',self.Transaction(chr(Address+1)+chr(Register),3)[1][2])[0] File "/usr/local/lib/python2.7/dist-packages/BitWizard/bw.py", line 362, in Transaction return 0,' '+''.join([chr(m) for m in self.I2cBus.read_i2c_block_data((ord(OutBuffer[0])>>1),ord(OutBuffer[1]))]) IOError: [Errno 5] Input/output error

any ideas?

cheers Mike

XXL-Wing commented 10 years ago

Something in addition to that.... It still looks like some timing issues....

When the RPI is not overclocked it sometimes works and something is displayed on the screen (you can guess what it should be but it is not correct). Reading Temperature is producing only -50°C readings all the time.

Navigating works somewhat but one press often issues 3 or more presses.

It is worse when the RPI is overclocked. at 900MHz clock speed the error occurs each time the sample is started....

cheers Mike

ghost commented 10 years ago

Hi Mike,

Overclocking your Pi changes The i2c speed since the i2c clock is derived from the core_freq. If you overclock, to get i2c working properly with Bitwizard boards you should lower the i2c bus speed number so the actual frequency on the bus does not exceed 100KHz. There is more info on this when you google for 'raspberry pi overclock i2c'

Be sure you have the latest updates on the pi, including the bw_library. And if you do overclock set the i2c bus speed to as low as 32KHz, test to see if that works and go up from there.

If you want to calculate the i2c bus speed: 100khz with core_freq=300 becomes 120khz: (300/250)*100khz

The 250khz is set in the kernel and so 450/250*55= 99 so the 'bus' speed setting must be set to 55 to end up with a 99khz i2c bus clock.....

The Menu.py example does not clear the key buffers correctly, so it has 'sticky' keys.

It should be updated to handle that but it is going to be replaced by smaller and more individual examples.

Martijn

Verstuurd vanaf mijn iPad

Op Apr 5, 2014 om 12:03 heeft XXL-Wing notifications@github.com het volgende geschreven:

Something in addition to that.... It still looks like some timing issues....

When the RPI is not overclocked it sometimes works and something is displayed on the screen (you can guess what it should be but it is not correct). Reading Temperature is producing only -50°C readings all the time.

Navigating works somewhat but one press often issues 3 or more presses.

It is worse when the RPI is overclocked. at 900MHz clock speed the error occurs each time the sample is started....

cheers Mike

— Reply to this email directly or view it on GitHub.

rewolff commented 10 years ago

On Tue, Apr 08, 2014 at 06:00:47AM -0700, mmoeling wrote:

Overclocking your Pi changes The i2c speed since the i2c clock is derived from the core_freq.

If you overclock, to get i2c working properly with Bitwizard boards you should lower the i2c bus speed number so the actual frequency on the bus does not exceed 100KHz. There is more info on this when you google for 'raspberry pi overclock i2c'

Let me add that the bitwizard boards would hapily work at well over 100kHz or below 100kHz for that matter, if there wasn't a hardware bug in the I2C on the broadcom processor.

If clock stretching happens, the broadcom processor will sometimes issue I2C CLOCK pulses that are way too short to capture for the bitwizard board. I've seen pulses as short 80ns, the bitwizard board requires 250ns, the spec says 2500ns (or 10000ns at 100kHz).

To prevent the troubles that come from this bug, a workaround on the bitwizard board will make it work, as long as the I2C clock is 100kHz.

Roger. 

* R.E.Wolff@BitWizard.nl * http://www.BitWizard.nl/ \ +31-15-2600998 \ Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 -- BitWizard writes Linux device drivers for any device you may have! -- The plan was simple, like my brother-in-law Phil. But unlike Phil, this plan just might work.

Theuno commented 10 years ago

Can you create a file in /etc/modprobe.d called i2c.conf (name does not really matter) and enter the line: options i2c_bcm2708 baudrate=32000

This seems to solve the following problem for me:

root@raspberrypi:/home/pi/bw_library/Theuno# ./test.py
Traceback (most recent call last):
  File "./test.py", line 26, in <module>
    menu.Show()
  File "/home/pi/bw_library/Theuno/BitWizard/ui.py", line 100, in Show
    self.MenuLoop()
  File "/home/pi/bw_library/Theuno/BitWizard/ui.py", line 156, in MenuLoop
    Buttons = self.Buttons.ReportPressed()
  File "/home/pi/bw_library/Theuno/BitWizard/bw.py", line 1098, in ReportPressed
    Buttons = BitWizardPushButtons.ReportPressed(self)
  File "/home/pi/bw_library/Theuno/BitWizard/bw.py", line 759, in ReportPressed
    v =self.Bus.Read_uInt8(self.Address,0x30)
  File "/home/pi/bw_library/Theuno/BitWizard/bw.py", line 163, in Read_uInt8
    return struct.unpack('B',self.Transaction(chr(Address+1)+chr(Register),3)[1][2])[0]
  File "/home/pi/bw_library/Theuno/BitWizard/bw.py", line 362, in Transaction
    return 0,'  '+''.join([chr(m) for m in self.I2cBus.read_i2c_block_data((ord(OutBuffer[0])>>1),ord(OutBuffer[1]))])
IOError: [Errno 5] Input/output error

However, as this feels like some timing issue it might come back. I will keep this running on my I2C UI version.