Low Cost PCB's Low Cost Components

Author Topic: Is there any way I can test out, interface directly with i2c and SPI devices.  (Read 700 times)

0 Members and 1 Guest are viewing this topic.

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
directly from my PC's console without having to use an MCU?

Using some kind of dongle instead. At one point I swear I saw i2c in some kind of device you could buy and just plug in and use..

If not that way, what about internal headers, can we connect i2c devices to our PCs internal i2c bus?

Actually, this sounds like a job for Raspberry Pi. I think perhaps my motherboard has an i2c header somewhere in there.. There are just a few devices I wouldn't mind having handy all the time.


(UPDATE: For testing devices Bus Pirate is useful and it appears a Chinese USB to serial chip variant the CH341A also may have SPI/i2C and some other functionality and is cheap but good luck getting info in English on it)
« Last Edit: September 26, 2017, 06:15:22 AM by cdev »
"What the large print giveth, the small print taketh away."
 

Offline tombi

  • Regular Contributor
  • *
  • Posts: 115
  • Country: au
Checkout buspirate from dangerous prototypes. I think Dave used one in an early video to test and LCD screen.

Tom
 
The following users thanked this post: cdev

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 5334
*WAY* back in the days of DOS, Philips had a simple printer port interface and utility program that bit-banged I2C, but with the removal of legacy ports, and increased security on direct hardware access that's no longer viable on a modern PC

Buspirate is actually a MCU with a USB CDC interface.  However the fact that you simply access it from a terminal rather than needing proprietary software probably puts it ahead of the rest.

Microchip have some USB to SPI and I2C bridge chips, and many of the more recent FTDI USB UARTs can be configured as SPI and/or I2C bridges, but you need a custom PC side application to talk to them.
 
The following users thanked this post: cdev

Offline TK

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: us
  • I am a Systems Analyst who plays with Electronics
I also recommend you use Bus Pirate.  I think there are i2c devices on the PC motherboard, but you will need to access the bus by writing custom device drivers for Windows / Linux or whatever OS you are using, and you don't have control of the existing pull-up resistor values.  SPI is not possible because you will need dedicated SS (Slave Select) pins and I don't think you get them on PC motherboards.

I usually do this type of quick i2c or SPI access tests using my Arduino board.
 
The following users thanked this post: cdev

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
This is good because I have a Bus Pirate 3.6 that I have not used in over three years (since before I had my scope, because the last project was using it as a scope with Python to attempt to visualize 1PPS on a GPS I was fooling around with)  The only cable I had for it was the Seeed mini grabbers cable, however I recently got a pack of 20 10 pin IDC plugs so now can make a nice cable to use it with a breadboard easily. That makes all the difference.

Need to read up on it, make sure the firmware on it is current.
"What the large print giveth, the small print taketh away."
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
Yes, I had been too but both of my Arduinos are kind of old and memory limited.
They make great hardware /computer interfaces generally, though.

It seems as if from what I can tell, I can use STM32 Blue Pill boards somewhat interchangeably with Arduino, with a few exceptions.

And they cost very little. Need to get some accessible book to introduce me to programming with them.


I also recommend you use Bus Pirate.  I think there are i2c devices on the PC motherboard, but you will need to access the bus by writing custom device drivers for Windows / Linux or whatever OS you are using, and you don't have control of the existing pull-up resistor values.  SPI is not possible because you will need dedicated SS (Slave Select) pins and I don't think you get them on PC motherboards.

I usually do this type of quick i2c or SPI access tests using my Arduino board.
« Last Edit: September 24, 2017, 01:06:41 PM by cdev »
"What the large print giveth, the small print taketh away."
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
For years Ive been seeing USB to (fake) parallel port adapters for fairly high prices on the net. maybe $20-30. But the other day I saw one coming from a Chinese vendor for around $3. So, might be possible to use that for all the stuff that needs a parallel port if software could communicate through it. Like flashing old BIOS chips.. (flashrom)  Lots of tools use real parallel ports.


*WAY* back in the days of DOS, Philips had a simple printer port interface and utility program that bit-banged I2C, but with the removal of legacy ports, and increased security on direct hardware access that's no longer viable on a modern PC

Buspirate is actually a MCU with a USB CDC interface.  However the fact that you simply access it from a terminal rather than needing proprietary software probably puts it ahead of the rest.

Microchip have some USB to SPI and I2C bridge chips, and many of the more recent FTDI USB UARTs can be configured as SPI and/or I2C bridges, but you need a custom PC side application to talk to them.
"What the large print giveth, the small print taketh away."
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 5334
It doesn't work that way - Generic USB parallel ports work with *most* printers, but don't provide the register level bit-banged access that was needed to do non-standard stuff with a true PC parallel port.
 
The following users thanked this post: cdev

Online KE5FX

  • Frequent Contributor
  • **
  • Posts: 630
  • Country: us
    • KE5FX.COM
TI's USB2ANY box is very handy, but frustratingly, the company doesn't go out of their way to support it.  You have to scrounge up resources like GUIs, manuals/schematics, and SDK files from various unrelated parts of their site.  It's hard to be sure you have the latest support files since there's no central repository for them.
 
The following users thanked this post: cdev

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 1765
  • Country: it
If it's of any help.. (should work inside realterm)
https://realterm.sourceforge.io/#I2C_Bus
 
The following users thanked this post: cdev

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
Not being a Windows user, I had never looked at Realterm until now.

Looks interesting!



If it's of any help.. (should work inside realterm)
https://realterm.sourceforge.io/#I2C_Bus
"What the large print giveth, the small print taketh away."
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
So, it turns out the Bus Pirate is exactly right for this.
"What the large print giveth, the small print taketh away."
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 1387
  • Country: 00
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2158
  • Country: aq
  • [Personal Text]
Have seen this also and wondered about it...
https://world.taobao.com/item/14541759710.htm

(Update: have found a great deal more about the ch341a chip and the so clled "usb2any" device..   need to clean this article up...

The device is called  "YSUMA01-341A"  - It differs from the Bus Pirate in that the Bus Pirate is a much more versatile swiss army knife of a bus communication tool in a number of ways, and this device appears to be in a number of other ways, and as far as i can tell, there is little overlap..  I eventually found (one) English datasheet for the Ch341A and its quite understandable, so maybe the statement to the effect that the ch340 that I read somewhere saying it was the worst USB-UART driver out there is undeserved or based on incomplete knowlwedge.. I have a medium sized to large collection of USB-UART adapters and my CH340 adapter is better than average in terms of compatibility..

But I had never heard about the ch341A chip until a few days ago when I spotted this dongle on taobao..

So Ive ordered one, looking forward to checking it out. somehow..

Turns out there are a number of projects involving it on github, most are targeting the EEPROM functionality.. This was the first one of several that I found.

https://github.com/karlp/ch341-linux

The manufacturer of the chip does have a site- some datasheets/drivers are on their site.

Some are not.. like as far as I could tell, the English datasheet did not get returned when I searched for "ch341a"

Datasheet in Chinese...

http://www.wch.cn/download/CH341DS1_PDF.html

 their site navigation is also broken in English for me.

It appears this chip is also used in cheap EEPROM programmers

https://onetransistor.blogspot.com/2017/08/ch341a-mini-programmer-schematic.html

From onetransistor.blogspot.com - - this article has a lot more info on the ultra cheap ch341a EEPROM programmer..
.. and promises an update telling more about how to use other CH341A devices.. and its API: sometime in the future...

Link to an English copy of the datasheet that I found eventually. https://hannover.ccc.de/redmine/attachments/download/213/CH341DS1.pdf  Also, on Amazon in the reviews for this product I found a lonk to a 6,5 MB RAR file that appears to have the English versions of some of the below files in it, but they are not coming from the manufacturer and for all I know, could be virus impregnated.. its possible.

So here is a chunk of the one transistor article.. (below)   The ch341a - if I can use it to incorporate arbitrary i2c and SPI devices into my desktop system, semi-flexibly - may be a useful chip, for me.


Quote


"The first two are the ones you need):

    CH341SER.EXE - self installing archive with USB to serial driver.
    CH341PAR.EXE - self installing archive with multiprotocol interface driver (this one is for the programmer mode)
    CH341SER.ZIP - archive containing driver files and serial API and library (you don't need specific API for standard serial port, but it contains some special functions to get IC version etc.)
    CH341PAR.ZIP - archive containing driver files for interface mode and API (header and library to access the device and use any protocol you want).
    CH341PAR_LINUX.ZIP - archive containing Linux driver source code and Linux API
    CH341SER_LINUX.ZIP - Linux driver source code for serial port (don't need this one, it's already included in kernels)
    CH341EVT.ZIP - some source code and tools written to be used with an evaluation board (may be useful for programming software that can access this device)
    CH341DS1.PDF - datasheet, in Chinese 
    CH341DS2.PDF - some additional info and API documentation, in Chinese
    CH341DP.ZIP - contains an ISP programming tool?
    CH341DPS.ZIP - probably similar to the above, but requires login to download

A regular user only needs the first two. Just double click on each of them and when the dialog appears click on Install.

The API becomes interesting due to the versatility of the chip. You can build your own software that will read/write data from/to sensors, real time clocks or any other devices that use serial communication. You can also interface parallel devices to the chip, but this will require modification of the programmer board in order to connect to pins. There is also an universal board featuring CH341A that costs about 10 USD, but gives you easier access to chip pins.

In a future post I will talk a bit more about software (how to use the included API).
« Last Edit: September 26, 2017, 08:37:28 AM by cdev »
"What the large print giveth, the small print taketh away."
 

Offline xani

  • Regular Contributor
  • *
  • Posts: 167
Re: Is there any way I can test out, interface directly with i2c and SPI devices.
« Reply #14 on: September 26, 2017, 11:20:00 PM »
There is also GreatFET https://greatscottgadgets.com/greatfet/ altho it is very much a WiP at this point

 

Offline Back2Volts

  • Supporter
  • ****
  • Posts: 375
  • Country: us
I am sure it is too late for the OP, but just for future reference...   

When looking for a solution for a project, I run into the FT232H.   It does USB to SPI, I2C, UART, JTAG and GPIO (which I find rather unique).   It comes with FTDI drivers and API library.   

FTDI has various dev/breakout boards and even conversion cables.     There is also a breakout board from Adafruit, with support included in their Python GPIO library.

Some links:

https://learn.adafruit.com/adafruit-ft232h-breakout/overview

https://www.digikey.com/product-detail/en/ftdi-future-technology-devices-international-ltd/UM232H/768-1103-ND/2614628

https://www.digikey.com/product-detail/en/ftdi-future-technology-devices-international-ltd/UM232H-B-NC/768-1160-ND/3770837

http://www.ftdichip.com/Products/Cables/USBMPSSE.htm





 
The following users thanked this post: cdev, Ian.M


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf