Ir al contenido

Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Esta pregunta ha sido marcada
1 Responder
2273 Vistas

My requirement is to use a LTC6820 device to control & collect battery information and then use the built-in Ethernet on my "M-Duino 21+ Ethernet" PLC to send them to a remote server. I've noticed because the LTC6820 communicates with the PLC via SPI, it conflicts with the Ethernet module (which also uses SPI). This means that I can't use the two modules at the same time.


I learned that SPI implements this Master-Slave architecture, with the master only able to talk to one slave at a given time. And it is possible to have the master "switch" communication to a different slave device programmatically. The problem is, I am not sure how to do that.


Ideally, I would like to achieve the following:

LTC6820 --> switches to Ethernet --> switches to LTC6820 --> switches to Ethernet...rinse and repeat.


Thanks in advance for providing detailed instructions preferably with actual coding/examples/tutorials since I am fairly new to this.

Avatar
Descartar
Mejor respuesta

In Arduino, the SPI library provides functions for communicating with devices using the SPI protocol. When you call the SPI.beginTransaction() function, it "establishes a connection" with a specific SPI device and sets the appropriate settings for communication (puts the chip select low).

The SPI.beginTransaction() function will block other SPI transactions from happening until it completes. This means that if the Ethernet module is using SPI for communication, any attempt to initiate an SPI transaction with the LTC6820 will be blocked until the Ethernet module finishes its transaction. Conversely, if the Ethernet library tries to initiate an SPI transaction while you are communicating with the LTC6820, it will have to wait until you have completed the transaction.

You don't need to consciously switch between SPI slaves, the library will handle it for you. For an example, you can check this blog.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 20
3365
1
jun 20
3267
1
jul 23
8362
1
dic 20
3231
2
ago 21
3321