Comments (12)
It's not the code, it's INA. I removed both usi_i2c_master and tinusaur-ssd1306xle code, disabled all interrupts and wrote my own I2C bitbanging code including autodetecting INA's slave address. There is aboslutely no response from INA at any slave address, it's not sending ACK at all. Thought it was working earlier but I was mistaking SDA going up for an ACK (technically, it's a NAK and it was going up because of the pullup, INA had nothing to do with it).
There is a lot of garbage on I2C bus immediately after power-up. Could be it's messing up INA's I2C but I added procedure for resetting INA's I2C bus before trying to talk to INA, same problem. INA's bus is reset when SDA or SCL are pulled low for at least 28ms.
Replaced R4 with 0 ohm resistor, same problem.
Checked optoisolator, signals seem to pass to both ends. There is about 4.2V on one end and 5V on the other but that shouldn't matter.
Removed optoisolator and tried accessing INA directly, same problem.
Either INA you sent me is dead or it's I2C doesn't work without a load. There is only 2.45 mV on the shunt resistor while the red LED is on, if it matters.
Ordered 2x INA219 from an EU seller, it will be faster than ordering from China.
Some screenshots...
Autodetection of INA's slave address, no ACK was ever received:
Same as above but zoomed in and after improved ACK/NAK timing in the code. INA is not sending ACK. Pullup resistor is doing NAK, INA must pull it low for ACK.
Further I2C timing improvements with releasing SDA earlier and proper termination of INA's reset sequence. Every xfer start has a green dot and every xfer stop has a red dot. 5 us minimum per high/low and still no sign of life from INA.
from c64-saver-bwack.
SDA and SCL are mixed up.
from c64-saver-bwack.
I think it got stuck here in the usi_i2c_master library
while (!(PIN_USI & (1<<PIN_USI_SCL))); //Wait for SCL to go high
#ifdef I2C_FAST_MODE
USI_I2C_WAIT_HIGH();
#else
USI_I2C_WAIT_LOW();
sorry too long ago I don't remember.. I suspect the ssd1306 library, or the way we use it. maybe it needs to be freed or something. At least the i2c_master expects a state that it never gets. Could be a state set in the TWI register. Not sure.
Back when I tested this I had my scope up and I could see the I/Os got stuck.
from c64-saver-bwack.
It could be both the ina and the issue I descibed above. Just beware of that.
from c64-saver-bwack.
maybe the voltage on the ina's VDD is too low because of the drop-out voltage in the 5V regulator driven at V_IN=5V. Edit: just checked. recommended is 3.3V, and absolute max is 6V. No problem there then.
from c64-saver-bwack.
Great work btw. Tell you what. I will hook up the addon-board to my c64 DIY PSU with ina219 voltage meter. I can easily unscrew the cables going to the ina and connect the addonboard and see if I get read-out on the PSU display (if you know, I have a C64 DIY PSU with ina219 and arduino pro micro)
from c64-saver-bwack.
Here are the I2C data recorded from my C64 DIY PSU with only INA219 on the I2C bus. The data rate is 100kHz. I have used the adafruits ina219 library. You can see how it at very first writes calibration bits, and it does that several times too. Second transfer is the configuration h00. No reset command (that would be most significant bit set to h00.
recorded from power on:
Start, h80 [ h40 | WR ], h05, h10, h00, Stop set calibration register
Start, h80 [ h40 | WR ], h00, h3C, h1F, Stop set config register
Start, h80 [ h40 | WR ], h02, Stop request bus voltage register
Start, h81 [ h40 | RD ], h27, hD2 NAK, Stop
Start, h80 [ h40 | WR ], h05, h10, h00, Stop another set config register
Start, h80 [ h40 | WR ], h04, Stop request current register
Start, h81 [ h40 | RD ], h02, h9C NAK, Stop
Start, h80 [ h40 | WR ], h02, Stop
Start, h81 [ h40 | RD ], h27, hCA NAK, Stop
Start, h80 [ h40 | WR ], h05, h10, h00, Stop
Start, h80 [ h40 | WR ], h04, Stop
Start, h81 [ h40 | RD ], h02, h5D NAK, Stop
Start, h80 [ h40 | WR ], h02, Stop
from c64-saver-bwack.
This is from with your code. I have replaced the pullups on my board now. oled disconnected.
Start, h80 [ h40 | WR ] NAK, h05 NAK, h10 NAK, h00 NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h00 NAK, h3C NAK, h1F NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h01 NAK, Stop
Error
Error
Start, h81 [ h40 | RD ] NAK, hFF, hFF NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h02 NAK, Stop
Error
Error
Start, h81 [ h40 | RD ] NAK, hFF, hFF NAK, Stop
Error
from c64-saver-bwack.
I tried with TinyWireM for Arduino, same problem. It's highly unlikely that both codes are faulty. The problem is most likely on the addon board itself. I've replaced 3 INAs so far and none of them sent any ACKs ever no matter what code I use. Please fix the board.
from c64-saver-bwack.
let me try this first.
from c64-saver-bwack.
Regarding the title. The two libraries ssd1306 and discoHR's ina219 go well together. Example shown in the hans-doodle branch.
https://github.com/bwack/C64-Saver-bwack/tree/hans-doodle/addon%20board/src
from c64-saver-bwack.
I'm closing this issue. Open a new one if you encounter a new problem.
from c64-saver-bwack.
Related Issues (20)
- 3D model of C1 shown the wrong way
- SDA and SCL are mixed up
- The 5V section draws power through the shunt resistor
- SENSE_VAC feeds in on non ADC input
- No cut-off for 9VAC power line HOT 1
- BOM does not match current version HOT 1
- U4,U5 EL1012 Discontinued HOT 4
- Removed capacistor HOT 4
- Gerber for addon board not latest version HOT 2
- Optimizing gate voltage for Q1 HOT 18
- 2.4 Throughhole C2 HOT 5
- Images not showing HOT 1
- PCB dimensions HOT 1
- U7 wrong pin configuration addon board 1.3
- High voltage drop over the power MOSFET HOT 36
- BOM? HOT 9
- R10 in C64 Saver SMD 2.5 HOT 7
- Through hole Zener Diode Sizing HOT 10
- Soldered board (2.6 throughhole) with new mosfet not working =/ HOT 28
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c64-saver-bwack.