FT232H Blinka board.I2C() Pulse Length Change

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
EE_ANGEL
 
Posts: 6
Joined: Fri Sep 10, 2021 1:03 pm

FT232H Blinka board.I2C() Pulse Length Change

Post by EE_ANGEL »

I've been trying to get the board.I2C() method to work on the Adafruit FT232H breakout board with an I2C Digipot that I got and I am unsure of why it is not working.

My best guess right now, after looking at the pulses on an oscilloscope and reading through the datasheet for my digipot, is that the pulse length for the HIGH part of the clock is not long enough.

My question is, can I adjust the length of the high pulses using the board.I2C() blinka library? As far as I can tell, with my ~6 months of python experience, my options for the writeto() method are (address, buffer, *, start=0, end=None, stop=True)
None of those look like they are options for adjusting pulse length though. I also have no idea how to use the * part of that, so maybe that is the key. I don't even know what to search to find out what that does though.
Alternatively, is there a different library or method I should use for I2C communication than this? The example for using I2C with the FT232H breakout board on the Adafruit guide doesn't really help me here because the device I am trying to communicate with doesnt have a circuitpython library I can use for it, so I'm trying to figure this out with a different method than the one example I can find.

From the datasheet for the digipot:
Min Low Period of SCL Clock: 4.7µs
Min High Period of SCL Clock: 4.0µs

From observing the clock pulse from the FT232H breakout with my oscilloscope:
Low Period of SCL Clock: ~6.8µs
High Period of SCL Clock: ~3.2-3.4µs

I believe I am getting an ACK from the digipot because I at least am not getting the NACK error, but my digipot is not changing at all when I sent it read/write commands. Monitoring the voltage at the wiper and high end of the potentiometer does not change when I send commands and when I send an empty buffer for a read command, I get the exact same buffer with nothing added to it afterwards. The SDA and SCL lines from the FT232H are definitely sending out square waves that look decent and appropriate, besides the length of the high period on the clock, confirmed with an oscilloscope. The voltages ranges for the pulses are pretty good as well with the high sitting at around 4.96V and low sitting at around 40mV using the 5V provided by the FT232H breakout board.

See viewtopic.php?f=8&t=183096&p=889586#p889586 for significantly more info, but namely my code and my breadboard setup. The only thing that has changed really is I added some zener diodes to the SDA/SCL lines to clean up the square waves a bit.

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: FT232H Blinka board.I2C() Pulse Length Change

Post by adafruit_support_mike »

Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.

User avatar
EE_ANGEL
 
Posts: 6
Joined: Fri Sep 10, 2021 1:03 pm

Re: FT232H Blinka board.I2C() Pulse Length Change

Post by EE_ANGEL »

I posted an image of my setup in the thread I linked at the bottom of my initial post on this thread. I asked a different question there but got no responses and felt that it was a bit easier to just relink that thread for image references. I'll reupload the images here too and adjust my original files to 800x600 while I'm at it.
DS1308-100 + FT232H Breakout 800x600.png
DS1308-100 + FT232H Breakout 800x600.png (144.99 KiB) Viewed 94 times
The pin locations are correct but I couldn't easily find how to change the component images in Fritzing, so ignore the names of the components and the extra pins for the FT232.

I have since switched my setup to a raspberry pi to try the pi's I2C since I was making no progress with the FT232H breakout. I was able to get it to work somewhat using the smbus library with the pi. I do not want to use the pi in the end product though because I then also have to figure out how to send commands from my laptop, to the pi, to control the digipot with a python program on the pi, so I would much rather have the FT232H working properly from my windows laptop.

Here's the DS1308 pinout:
DS1308 Pinout 800x600.png
DS1308 Pinout 800x600.png (24.74 KiB) Viewed 94 times
On the FT232H:
P1: 3.3V, P2: 5V, P3: GND, P4: D0 (SCL), P5: D1 (SDA), P6: D2 (SDA)

On the DS1308:
H is for the high end of the potentiometer, L for the low end, and W for the wiper. A0-A2 are for setting the I2C address for the device, and pins 9 and 10 are SCL and SDA respectively. Pins 8 and 16 are Ground and Vcc (5V or 3V).

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: FT232H Blinka board.I2C() Pulse Length Change

Post by adafruit_support_mike »

Post a photo showing the actual hardware please. Schematics show how things are supposed to be. Hardware shows how things really are.

User avatar
EE_ANGEL
 
Posts: 6
Joined: Fri Sep 10, 2021 1:03 pm

Re: FT232H Blinka board.I2C() Pulse Length Change

Post by EE_ANGEL »

FT232H Breadboard Setup.jpg
FT232H Breadboard Setup.jpg (332.62 KiB) Viewed 83 times
Connections for the DS1308:
  • P1 (H1) - +5V
    P2 - N/C
    P3 (L1) - N/C
    P4 (W1) - Green LED Anode (Cathode to ground)
    P5 (A2) - Ground
    P6 (A1) - Ground
    P7 (A0) - Ground
    P8 (GND) - Ground, Pin 3 GND on the FT232H
    P9 (SCL) - SCK/SCL on FT232H, 4.7kΩ resistor to +5V, 1N5313 Diode Cathode (Anode to +5V)
    P10 (SDA) - MISO/SDA on FT232H, 4.7kΩ resistor to +5V, 1N5313 Diode Cathode (Anode to +5V)
    P11 - N/C
    P12 (W0) - +5V
    P13 (L1) - Red LED Anode (Cathode to ground)
    P14 (H0) - N/C
    P15 - N/C
    P16 (VCC) + 5V, Pin 2 - +5V on the FT232H
The 4.7kΩ resistors are there because the deprecated I2C Adafruit guide said to use them to pull the SDA and SCL lines high. It didn't use them in the newer Adafruit guide for the FT232H, but I'm not sure if thats because the new board deals with the pull ups internally or if its because the board that is connected to in the example deals with it. Either way, the signal on the oscilloscope gets up to 5V with them so I figure it doesn't hurt anything.

Before adding the 1N5313, probing with an oscilloscope showed a square wave with initial sharp rises but then sloped into a U curve up to the +5V marker. I initially grabbed these because I had thought they were Zener diodes, but they appear to be a current regulating diode. It made the square wave look much nicer though so I left it in there.

Without changing anything other than the voltage source and I2C pins, I was able to make this setup alternate turning on and off the LEDs with a Raspberry Pi using the SMBus library and I2C pins, so I know it can work as is now.

In the bottom right of the image I just have an LED in series with a resistor that turns on when power is on so I have a visual indicator of power functioning.

User avatar
EE_ANGEL
 
Posts: 6
Joined: Fri Sep 10, 2021 1:03 pm

Re: FT232H Blinka board.I2C() Pulse Length Change

Post by EE_ANGEL »

My question is moot at this point. I was able to get a change from my digipot so I was wrong about what I thought my problem was.

I had to reorder my commands slightly differently.

Code: Select all

import board
import busio


i2c = board.I2C()
address = 0x28
control_write = 0x50
command_both = 0xAF
data = 0xFF

# What I tried that failed to work
# 1:
i2c.writeto(address, bytes([control_write]))
i2c.writeto(address, bytes([command_both]))
i2c.writeto(address, bytes([data]))
# 2:
i2c.writeto(address, bytes([control_write]), stop=False)
i2c.writeto(address, bytes([command_both]), stop=False)
i2c.writeto(address, bytes([data]), stop=True)
# 3:
i2c.writeto(address, bytes([control_write, command_both, data]))

# What ultimately worked for me:
i2c.writeto(address, bytes([control_write]))
i2c.writeto(address, bytes([command_both, data]))
I'm not really sure why, but for some reason I had to set up my writes in a specific way to make them work for the digipot I was trying to work with. As far as I could tell looking through the datasheet for the device I was using, there was nothing specific that indicated I had to write to the device this way. The examples just showed all the writes in binary one after the other.
I would really love if there were more examples from Adafruit available for using I2C on the FT232H to communicate with a generic device rather than a specific device that has a premade library like the BME280. As a pretty amateur programmer, this was by far the most difficult part to get working. Having two examples there would be a huge help to understanding how to use the FT232H. I wasn't sure what the problem was most of the time. I wound up looking through the busio.py to even found out what functions were available to me, which isn't necessarily a bad thing in and of itself, but it felt like there was a lack of assistance with explaining how to use the FT232H in this regard. With the GPIO I was able to make work it immediately but I just had no idea where to go with I2C on the FT232H unless I had another specific I2C device from Adafruit.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”