I have been wrecking my head over this the last weeks and cannot find useful information online on how I should do this.
The Goal:
- Drive several servo/RC motors wireless from one
pi
to anotherpi
. - In essence, I want to build a
RC
remote control using api
, with a secondpi
on the receiver end.
What I have done so far:
- I have been able to use the serial library and the Tx and Rx pins on the two Pi to successfully send serial data over a cheap 433MHz receiver/transmitter. However, I need to send over at least six pairs of two-digit numbers simultaneously(ie 12 numbers). This can be done using the serial library on the
pi/arduino
, but it causes the sample rate of the main continuous program loop to slow down to below 200Hz, which is a problem.
Next step and problems:
- Since the serial data transmission is not working adequately I was thinking of embedding PWM signals directly into the RF signal. (As far as I can figure out this is how the hobby RC controllers work anyway).
- The
pi
(as far as I know) is rubbish at sending accurate PWM signals and even worse at picking them up correctly. - Just to clarify I have to do this over a RF module, not over the web.
How can I do this?
Perhaps using two Arduinos to do the transmission and receiving?
Are there "shields" that I could buy?
Are there libraries that could do this for me? (Pi
or adruino
?)
Edited: Roland thank you for your reply
I have added the current serial transmission code. I dont think this is the most efficient way of doing it. If one transmits PWM signals with a pause between another PWM signal one can send far more data instead of just sending bits. I am not entirely sure, but I thought that is how the Remote Control RC aircraft controllers send their signals.
Please note that the code I have inserted is a simple extract from a much larger program with several modules and a couple of hundred lines of code. I do think the few lines below are at the heart of the serial transmitter.
import serial
bProgramLoop = True
while (bProgramLoop == True):
#...lots of code...
iThrustPort = int(fThrustPort)
iThrustStrb = int(fThrustStrb)
iThrustTail = int(fThrustTail)
iPortMotorAngle = int(fPortMotorAngle) + 50
iStrbMotorAngle = int(fStrbMotorAngle) + 50
sPortMotorSignal = '{:02d}'.format(iThrustPort)
sStrbMotorSignal = '{:02d}'.format(iThrustStrb)
sTailMotorSignal = '{:02d}'.format(iThrustTail)
sPortAngleSignal = '{:02d}'.format(iPortMotorAngle)
sStrbAngleSignal = '{:02d}'.format(iStrbMotorAngle)
sSignal = sPortMotorSignal + sStrbMotorSignal + sTailMotorSignal + sPortAngleSignal + sStrbAngleSignal
oSer.write(sSignal) #where sSignal = 1234567890 for example or any combination of numbers from 0 to 9