RP2040 MultiCore Communications Recomendations

Hi folks,

I am somewhat new to the Arduino IDE and need some advice about communicating data between cores on an RP2040.

I have a project in which I will drive 16 servos using DMX data and an RS485 interface. I want core1 to receive RS485 DMX data and process that with a motility algorithm that "Smooths" and limits servo action. Once position data is "Smoothed," I use the state machines to drive the servos via PWM on the GPIO pins. This runs on Core1

I also have built a Serial UI that runs on Core0; this interface will take commands via the USB serial port and apply changes to the servo motility profiles as well as return servo performance data.

I have all of the above workings well. Just one last step.

I need to move servo profile data and system status data between the cores in a safe way. so the UI can talk to core1 servo handlers

I have looked at the RP2040 Fifo queues as well as using queues.

Any recommendations on the best efficient and safe way to exchange data between cores?

Thanks in advance from someone new to the Arduino IDE environment.

Have you looked at a framework like GitHub - arduino/ArduinoCore-mbed

i was worked with the RP2040 with multicore process. Maybe if you explain (more specific) what kind of safe interaction do you want?. I have one project same as you but with data analysis and only i need to stablish the global variables and work well with functions called in the 2 cores

1 Like

Thanks Here is a little more detail.

In core1, I have three arrays

  1. Servo profile data (16) that is mainly statics and updated occasionally via the UI on Core 1
  2. Servo position data (16) that shows the real-time position and target position for each servo. Run Data for all 16 servos is getting updated every 150 microseconds.
  3. Run Status that keeps information like debug levels and what mode the system is operating in.

Core 0, needs to load the profile data at boot from flash and occasionally (during config) updated it once it is running.

Core 0 also needs to monitor position data in real-time or at least every 50ms for output to UI and monitoring of performance.

In config mode, Core 0 needs to send real-time position data to Core 1 to move servos.

Core 0 needs to monitor status information and update Status (debug level, for example) occasionally.

I have spent a lot of time optimizing performance on Core 1, and using the State Machines has really sped things up. Here is a quick block diagram that shows how things are moving around from a data and control perspective.

Thanks for taking a look at this, I really appreciate the second set of eyes on this.

Cheers

Example of simple queuing:

RP2040 example sketch for dual core queuing - Arduino Stack Exchange

If you feel the need for more control, you may wish to test the current state of Earl's freeRTOS implementation.

1 Like

Quick update on my journey with this. I found a great presentation that walks through multi-core comms. I thought I would Share.
MODULE16-MULTIPROCESSING.pdf (1.1 MB)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.