Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Communication between Arduino and FPGA

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
I have a lot of Adafruit Sensors like Temperature Sensor, IMU, Pressure Sensors, etc. which are configured to Arduino. Now I want to connect Arduino to FPGA and the FPGA must read the sensor data and detect for abnormalities for control system. In my case the MCU is acting as slave and FPGA as master. We can use serial interface like SPI or UART. Can someone walk me through how can I make this possible
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
21,809
Helped
4,580
Reputation
9,174
Reaction score
4,765
Trophy points
1,393
Activity points
143,900
Hi,

Each sensor has an interface, maybe all use the same interface, maybe not, we don´t know.

"..which are configured to Arduino" does not mean much to me. Usually a sensor is a sensor and is not fixed to any IDE or hardware. It has an interface and the description for the interface is in it´s datasheet.
So between FPGA and sensors you have to keep on the datasheets.

"... MCU is acting as slave and FPGA as master ...."
I´d do it the other way round. Usually the MCU is the master. But for sure it´s possible to use the FPGA as master.

..While between FPGA and sensors, then FPGA should be the master.

****

There is no general answer.
Between MCU and FPGA I already used: SPI, I2C, parallel, UART...
Each application has it´s own requirements..

****
If I had to do it: I need to read all the datasheets...

Klaus
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,595
Helped
1,148
Reputation
2,308
Reaction score
1,201
Trophy points
1,393
Location
California, USA
Activity points
30,524
That’s a pretty broad question. Yes, you can use a serial interface.

What in particular are you asking? There’s plenty of information about implementing SPI, I2C, etc.
 

danadakk

Advanced Member level 5
Joined
Mar 26, 2018
Messages
1,667
Helped
279
Reputation
572
Reaction score
356
Trophy points
83
Activity points
7,585
The interface depends on the data rate you want aggregated for all sensors. So
that predicates choice between One Wire, I2C, SPI, UART...

So you build a simple protocol for the FPGA to interpret the data coming to it.
Generally a frame encapsulates a sensors data, like its address or name, its specific
piece of data and that data's name, ID, ands so on. Wrap that in a frame for start/end,
even CRC if this application has safety issues attached to it. You could even give data a priority
such that when a frame of data comes into FPGA you decide what to process first. Put
the data on a stack and high priority gets serviced first. Or data into memory so that it
can be monitored and serviced based on priority.

It would be nice if all the sensors have same buss type, for the Arduino to handle,
buts thats not a project show stopper to handle.

For sensors that have high sampling rates use interrupts to speed up the response handling.
You could run a RTOS on the Arduino to manage differing sample rate sensor servicing.

Many possibilities.


Regards, Dana.
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
That’s a pretty broad question. Yes, you can use a serial interface.

What in particular are you asking? There’s plenty of information about implementing SPI, I2C, etc.
I just want to read the sensor data from the micro-controller and the data should be a priority. So what do you suggest
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
Hi,

Each sensor has an interface, maybe all use the same interface, maybe not, we don´t know.

"..which are configured to Arduino" does not mean much to me. Usually a sensor is a sensor and is not fixed to any IDE or hardware. It has an interface and the description for the interface is in it´s datasheet.
So between FPGA and sensors you have to keep on the datasheets.

"... MCU is acting as slave and FPGA as master ...."
I´d do it the other way round. Usually the MCU is the master. But for sure it´s possible to use the FPGA as master.

..While between FPGA and sensors, then FPGA should be the master.

****

There is no general answer.
Between MCU and FPGA I already used: SPI, I2C, parallel, UART...
Each application has it´s own requirements..

****
If I had to do it: I need to read all the datasheets...

Klaus
The sensors are sending their data to the Arduino and they are working just fine. I want to connect my FPGA board to the Arduino and read that data. Please note: There are many Arduinos used for this.
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
The interface depends on the data rate you want aggregated for all sensors. So
that predicates choice between One Wire, I2C, SPI, UART...

So you build a simple protocol for the FPGA to interpret the data coming to it.
Generally a frame encapsulates a sensors data, like its address or name, its specific
piece of data and that data's name, ID, ands so on. Wrap that in a frame for start/end,
even CRC if this application has safety issues attached to it. You could even give data a priority
such that when a frame of data comes into FPGA you decide what to process first. Put
the data on a stack and high priority gets serviced first. Or data into memory so that it
can be monitored and serviced based on priority.

It would be nice if all the sensors have same buss type, for the Arduino to handle,
buts thats not a project show stopper to handle.

For sensors that have high sampling rates use interrupts to speed up the response handling.
You could run a RTOS on the Arduino to manage differing sample rate sensor servicing.

Many possibilities.


Regards, Dana.
Okay, so I want the sensor data to be the top priority. So what should I exactly be doing to achieve seamless communication
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,595
Helped
1,148
Reputation
2,308
Reaction score
1,201
Trophy points
1,393
Location
California, USA
Activity points
30,524
That's still way too broad a question. How do you define "seamless communication"?

What's your data rate? How much data? Saying you have "a lot" of sensors is meaningless. Are you transmitting continuously? Once an hour? What else does the Arduino have to do besides "seamless communication"? Is there handshaking? Do you want/need error correction, e.g. checksums? How do you handle bad data?
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
That's still way too broad a question. How do you define "seamless communication"?

What's your data rate? How much data? Saying you have "a lot" of sensors is meaningless. Are you transmitting continuously? Once an hour? What else does the Arduino have to do besides "seamless communication"? Is there handshaking? Do you want/need error correction, e.g. ? How do you handle bad data?
Yes i am transmitting data continuously every 0.5 a second for 30 seconds. Apart from communication it makes sure that the data that we want in output is in proper format. Not yet thought anything about error correction
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,595
Helped
1,148
Reputation
2,308
Reaction score
1,201
Trophy points
1,393
Location
California, USA
Activity points
30,524
So, you're transmitting one byte every 0.5 seconds, at a data rate of 2 bytes/second, and you're repeating it for 30 seconds?

Or, maybe you're transmitting 1 million bytes, at a data rate of 100 terabytes/second, every 0.5 seconds?

I think you need define WHAT you need to do before you ask HOW to do it.
 

FlyingDutch

Advanced Member level 1
Joined
Dec 16, 2017
Messages
412
Helped
44
Reputation
88
Reaction score
50
Trophy points
28
Location
Bydgoszcz - Poland
Activity points
4,210
I have a lot of Adafruit Sensors like Temperature Sensor, IMU, Pressure Sensors, etc. which are configured to Arduino. Now I want to connect Arduino to FPGA and the FPGA must read the sensor data and detect for abnormalities for control system. In my case the MCU is acting as slave and FPGA as master. We can use serial interface like SPI or UART. Can someone walk me through how can I make this possible
Hello,

more experienced colleagues have right that your question is too broad, but as long as my own experience is saying that UART and SPI are the easiest way for comunication between Arduino and FPGA. I2C is slow and I had some issues implementing it on FPGA. There are many projects with free code on: opencores.org website. for example:
https://opencores.org/projects?expanded=Communication controller

https://opencores.org/projects/uart

https://opencores.org/projects/miniuart2

https://opencores.org/projects/spi

https://opencores.org/projects/simple_spi


Few years ago I described project using UART and RS485 for comunication from" Arduino UNO" (one direction) to Spartan3 FPGA over long distance. It is easy to make this comunication two directions (just use also UART_RX).

Here is translation of page on Polish forum (Forbot.pl) translated by "Google Translate" (English) describing that topic:
https://forbot-pl.translate.goog/fo..._tr_tl=en&_x_tr_hl=pl&_x_tr_pto=wapp#comments

You should also tidy up your assumptions related to such transmission between Arduino nad an FPGA board.

Best Regards
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,894
Helped
14,483
Reputation
29,236
Reaction score
13,391
Trophy points
1,393
Location
Bochum, Germany
Activity points
286,515
I agree with Warpspeed that SPI is preferred if you have 4 pins available at each peer, due to highest possible speed and lowest resource utilization on the FPGA side.

SPI speed is effectively limited by Arduino interrupt response time as slave. SPI is unbuffered and no DMA available for the simple processor, each byte must be processed before the next arrives.
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,595
Helped
1,148
Reputation
2,308
Reaction score
1,201
Trophy points
1,393
Location
California, USA
Activity points
30,524
I agree that SPI is probably the best approach, but, again, without knowing the details of the system this is all a purely theoretical discussion.
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
I agree that SPI is probably the best approach, but, again, without knowing the details of the system this is all a purely theoretical discussion.
There are multiple sensors that are communicating with multiple Arduinos and all their data are sent to a single FPGA board.
 

neospice

Newbie level 4
Joined
Jan 21, 2022
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
64
Hello,

more experienced colleagues have right that your question is too broad, but as long as my own experience is saying that UART and SPI are the easiest way for comunication between Arduino and FPGA. I2C is slow and I had some issues implementing it on FPGA. There are many projects with free code on: opencores.org website. for example:
https://opencores.org/projects?expanded=Communication controller

https://opencores.org/projects/uart

https://opencores.org/projects/miniuart2

https://opencores.org/projects/spi

https://opencores.org/projects/simple_spi


Few years ago I described project using UART and RS485 for comunication from" Arduino UNO" (one direction) to Spartan3 FPGA over long distance. It is easy to make this comunication two directions (just use also UART_RX).

Here is translation of page on Polish forum (Forbot.pl) translated by "Google Translate" (English) describing that topic:
https://forbot-pl.translate.goog/fo..._tr_tl=en&_x_tr_hl=pl&_x_tr_pto=wapp#comments

You should also tidy up your assumptions related to such transmission between Arduino nad an FPGA board.

Best Regards
Since the data rate is very high and continuous UART would not really be a good option.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
21,809
Helped
4,580
Reputation
9,174
Reaction score
4,765
Trophy points
1,393
Activity points
143,900
Hi,

It's till unclear
* whether the MCU communcates with the sensors or the FPGA
* how many sensors
* how many MCUs
* how many different interfaces
* what data rate
(Some consider 19200 baud as high soeed, some consider 5MBaud as low speed. We don't know, as long as you don't say)

You don't do yourself a favour in giving vague informations.
Please do a simple sketch where we see what is connected with what.
Also give clear informations about part count (sensor, mcu, fpga...)
Also give clear values about average data rate (data to process and store in a guven time) and burst data rate (interface speed)

Klaus
 

FlyingDutch

Advanced Member level 1
Joined
Dec 16, 2017
Messages
412
Helped
44
Reputation
88
Reaction score
50
Trophy points
28
Location
Bydgoszcz - Poland
Activity points
4,210
Since the data rate is very high and continuous UART would not really be a good option.
I don't understand why you need high data rate for temperature and pressure sensor (they are slowly shifting signals). IMU can require a bit of faster signal, but also without exaggeration ;) Can you explain why you claim that you need very high transmission speed?

Best Regards
 

barry

Advanced Member level 5
Joined
Mar 31, 2005
Messages
5,595
Helped
1,148
Reputation
2,308
Reaction score
1,201
Trophy points
1,393
Location
California, USA
Activity points
30,524
There are multiple sensors that are communicating with multiple Arduinos and all their data are sent to a single FPGA board.
Multiple sensors, like 10000000000000? You INSIST upon not giving us any useful information. I’m done trying to help you.
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top