Author Topic: Interface MCU with PC via USB and SPI protocol  (Read 2446 times)

0 Members and 1 Guest are viewing this topic.

Offline illusiveTopic starter

  • Regular Contributor
  • *
  • Posts: 56
Interface MCU with PC via USB and SPI protocol
« on: May 13, 2018, 02:09:34 pm »
Hi everyone!
I'm building myself a temperature controlled soldering station and i would like to add a communication to a PC to visualize certain variables while the systam is operating. Since i have used all the pins of the mcu (atmega328pb) i don't have the RX and TX pins available but i do have the SPI ones because i am already using them for communication with another IC. Ebay is full of simple modules based ot FTDI chips to establish communication between an MCU and PC but i can't find anything widely used to do SPI to USB. I have found couple of ICs that seems to do that but if i am not missing something obvious they require quite the hassle to implement. Im refering to the FT232H and MCP2210. I'm planning to use one of the available serial port graph plotting software and i have concerns that it might be some interfacing problems.
Can someone with more experience with these stuff recommend me the best approach to the problem?
Thanks!
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Interface MCU with PC via USB and SPI protocol
« Reply #1 on: May 13, 2018, 02:30:46 pm »
Can someone with more experience with these stuff recommend me the best approach to the problem?

I would get an MCU which has enough pins and a built-in USB module. As I recall, FT232H is $4 and requires an oscillator ($1). You can buy a good MCU for this.

Or, if you can't part with your existing design, get PIC16F1454 ($1, no oscillator required) and program it as an USB to SPI bridge.

Of course, if money is not important, FT232H will work.

FT232H also has GPIO pins. It doesn't have programmable brains, but you can manipulate the pins directly from PC. Thus if your design requires PC connected at all times, it might be possible to get by with FT232H alone, without any MCU.
 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: Interface MCU with PC via USB and SPI protocol
« Reply #2 on: May 13, 2018, 03:03:05 pm »
A STM32F103 BluePill board should do the job ...
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Interface MCU with PC via USB and SPI protocol
« Reply #3 on: May 13, 2018, 03:14:21 pm »
FTDI also have the FT220X, which costs a little under two bucks, and doesn't require a crystal.

Offline hans

  • Super Contributor
  • ***
  • Posts: 1638
  • Country: nl
Re: Interface MCU with PC via USB and SPI protocol
« Reply #4 on: May 13, 2018, 03:44:50 pm »
Also consider which chip is SPI master and which is going to be slave. I think most USB chips only work as SPI master. If your ATMEGA328P is also a master (which is typical in a single MCU design), that could create a conflict. An UART is easier, because it's asynchronous and has no master.

It may sound weird, but you could get a chip like a MAX3100 (SPI slave <> UART) and connect that to a normal USB serial cable.
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: gb
Re: Interface MCU with PC via USB and SPI protocol
« Reply #5 on: May 14, 2018, 01:47:48 am »
If it's a temporary solution you're after, hooking an Arduino board up as an SPI slave and writing some simple code to re-transmit each byte received out its serial port will be quite easy.

Oh, by the way: you say you have used all your I/O pins. Don't forget even an SPI solution will need an extra I/O for the chip-select (CS) of the additional slave.
« Last Edit: May 14, 2018, 01:51:05 am by HwAoRrDk »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf