I want to transmit multiple signals to control multiple servos

My goal now is to have two joysticks, one for pan and the other for tilt, that can control two servos for their respective uses.

For context I am using the arduino nano and uno r3. The way I initially wanted to do it is with the r3 transmitting signal from two joysticks to the nano which would be receiving the separate signals to control their respective servos.

I am trying this with the NRF24L01 boards and the nrf24 library by TMRh20, but from what I understand each board can only open one writing pipe at a time. Which would be fine but I want to be able to send signal from both joysticks at the same time so that they can be working in unison. So I thought, ok I’ll use two of these nrf boards, one for pan and one for tilt.

From what I understand about the boards is they use the SPI pins to communicate with the arduino and that there are only one of each respective SPI pin within the arduinos. So I thought ok I’ll just use another nano to transmit signal from the other joystick. The uno for pan and another nano for tilt. Both being transmitted to the receiving nano with the servos.

Now the issue arrives with the nrf boards only being able to receive one signal at a time. Which again I want to be able to move both servos in unison, which would require reading both signals at the same time. So now I’m thinking I use another nrf board for the other servo, but since it needs the SPI pins I would need another arduino.

So from what I understand I would need 4 separate arduinos. 2 for separate transmission of the joysticks and two to receive and operate the two servos simultaneously.

I’m fairly new to all of this so it’s very possible I’m missing something simple or am going about this the entire wrong way. I would like to know if my thought process is sound and I wouldn’t be hooking up 4 arduinos and 4 nrf boards when there’s a simpler way of doing this.

I had an idea where I would only need two for transmission and one for receiving. Could I have the receiving arduino put a very short delay in the loop where it reads information from one pipe to read one joystick and control one servo, then after that delay it reads the other pipe with the other joystick controlling the other servo. If I have the delay be very small could I mimic it working in unison? This idea would reduce the number of arduinos and nrf boards needed to 3 of each, but if that works would I also be able to do that with just 2 of each like how I originally wanted it? Just have the r3 quickly swap between writing information from one joystick to the other and have the nano swap to controlling the respective servo from the respective joystick. I would have it swap at the same time as the r3 so it would know which joystick to talk too. This would only need 2 arduinos and 2 nrf boards like I originally wanted it, but would only work if I could swap fast enough to mimic simultaneous control.

Forgive me if any of my terminology is wrong I’m still very new to this. Is any of this feasible or is there a simpler way of going about this?

Hello lieutenantwumbo

Welcome to the world's best Arduino forum ever.

I have been following the topic of using this type of wireless module and the associated software functions for some time now.

For wireless projects, I recommend using the HC12 module.

What are the advantages:

  1. no external functions from a library are needed.
  2. the development of a communication protocol is in your hands
  3. the necessary development steps can be programmed and tested without using the wireless module
  4. the radio module can be easily configured for the project requirements
  5. both transmitter and receiver are contained in one radio module.

hth

Have a nice day and enjoy coding in C++.

One sender and one receiver would be simpler :wink:

You did not explain what those joysticks are; but it should be possible to connect two joysticks to one Arduino and let that Arduino send to the Arduino that controls the servos.

1 Like

The writing pipe can carry whatever data you need. One servo, 200 servos. Completely unnecessary to use 2 nrf boards.

SPI is a bus system. This means you can connect many devices to the same Arduino pins. The MISO, MOSI and CLK pins will be shared by all devices. But there must be a separate SS pin for each device. To connect a second nrf, you would need 1 additional Arduino pin. But as mentioned above, you don't need to add a second nrf.

1 Like

Right, but can I send two separate values at the same time and have the receiving end control either servo with their respective value at the same time?

I want to be able to send two different int values at once. One for the tilt position and one for the panning position. One servo is horizontal and the other is vertical so I can go left-right, up down/tilt, pan. I’ll be sending two different int values for x and y rotation, x to the horizontal servo and y to the vertical servo. Can I transmit both int values separately from either joystick at the same time, while the receiver receives both values to control the respective servos?

Actually I may have just solved my own issue. Couldn’t I just read both x and y positions from the joysticks, put them in an array, then send that to the other arduino? That way it’s only sending the one value and I can differentiate the values from the array to control both servos separately and simultaneously.

Should work.

1 Like

Exactly. Or maybe a "struct" which is simply a record or packet of data that can contain several values of the same or a mix of types as needed.

Not really. What you want is that your servos to appear to react pretty much instantly to the movement of your joysticks. Behind the scenes, the data will be transmitted one bit at a time, so maybe 64 bits for your 4x 16-bit values. But they will, or can, be transmitted so fast and so frequently, it will appear to be instant and simultaneous.

1 Like

@PaulRB @sterretje

I got it to work great now, thank you both for your reply’s :slight_smile:

In order to minimize errors in your communication between the devices, send the values quite often, even if the values are identical to the previous transmission. Since you have no feedback from the receiving devices as to whether the servo has moved or not, you may need to continue to tell the device to move and if it is already positioned correctly, nothing will move.

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