Arduino - Extend the number of servos supported by a Rx

Electronic projects that are either related to the firmwares for the 9x, or simply great for radio control applications.
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Wow. Thanks! I will try loading it tonight.

Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

The Sketch is loading without problems. It will take some time to figure out if the board is working properly.

Thanks so much!
Erni
Posts: 27
Joined: Wed Jun 04, 2014 3:41 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Erni »

@mstrens

I tried your sketch on a Leonardo, which have the same processor as the micro
As far as I can see the SBUS is interpreted correct, but I can't get any output on the pins.
One good thing about the micro/Leonardo is that it has an additional serial port, so I just replaced your TRACE whit Serial.print

When using DEBUG option I get this:

Code: Select all

UART: 8
SBUS_Error: 0
 ch1: 23880
Servo1: 16120
UART: 8
SBUS_Error: 0
 ch1: 15720
Servo1: 24280
UART: 8
SBUS_Error: 0
 ch1: 32110
Servo1: 7890
The number for servo1 goes from 16120 to 7890 when I move the tx stick from one extreme to the other.

This is the output when using the DEBUGSBUS option

Code: Select all

F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 9E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC D3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DE E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
F DC E3 5E 2C C0 7 3E F0 81 F 7C 0 0 0 0 0 0 0 0 0 0 0 0 0 - 23880 23880 15770 23920 23920 23920 23920 23920 14000 14000 14000 14000 14000 14000 14000 14000  
Again I can see the numbers change as I move the sticks on the tx, but no output on the pins.
I use these settings, and an inverter from rx SBUS to rx on Leonardo

Code: Select all

#define CPPM_SBUS   SBUS 
#define PINS_FOR_OUTPUTS_1_8   A1, A2 , 5 , 6 , A3 , 4 , 3 , 2
#define CHANNELS_TO_DECODE   CHANNELS_1_8 
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

please note that when the option DEBUGSBUS is activated, the main loop does not update some arrays used to generate the pulses to the servo. So it is normal that there is no outputs on the pins.
This option had been foreseen only to check the characters received on the SBUS.

In your case, it seems that arduino read correctly the SBUS because the values that you get change when you move the sticks and the values are in the expected range.

So, please deactivate the option DEBUGSBUS.

I presume that you also tried the sketch without this option and that you did not get pulse output on the pins. If so, there is an issue but I do not see directly the reason.
I have quicly checked the datasheet ot your processor but I do not see a difference that should explain why it does not work.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

looking further at the datasheets and at the arduino pin mapping, it appears that the 2 arduino boards (pro micro and pro mini) use totally different pin mapping and even does not share the same I/O registers (pro micro uses more I/O registers).
This can explain that you do not get signals on the output pins.
If you want, I presume that I could make some more changes to the sketch in order to let the program work on a leonardo/pro micro.
If you want it, I propose that you send me back the version that you tested (replacing TRACE with Serial.print. I would make the changes to this version.

Erni
Posts: 27
Joined: Wed Jun 04, 2014 3:41 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Erni »

That is very generous of you. I have attached the my file
I have commented out line 862 and 863 because I got an error.
Attachments
sbus_leon.zip
(12.67 KiB) Downloaded 328 times
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

@Erni,
I used your file (sbus_leon) to make some changes.
Still I am not sure it is the rigth file because I do not see any serial.print command and I do not see line 862 and 863 commented out.
So, perhaps you will have to change again TRACE command.

In attachment you will find the updated files that hopefully should work with your processor (32U4 instead of 328).
Please note that I did not try to support all arduino pins. I only implemented pins D0 up to D7 and pins A0 up to A5.
If this works and if you really need some other pins, I can try to do it later.
I have tried to let the led named TxLed blink as for an arduino pro mini (this allow to see if there are SBUS errors; please note that SBUS errors are "normal" when DEBUG is activated because the processor can read the SBUS and send TRACE at the same time).

I did not test this version. Let me know if it is OK. Please check on several pins because it could be that due some errors some works and others do not work.
If not, please activate the debug and please send me at least the messages generated by the setup() function.

Just one more comment: in your test from yesterday, I see that servo1 goes from 7890 up to 24280. This seems strange because this should be a pulse of 493 usec and 1517 usec (values being divided by 16 because a 16 mhz processor). Normally the pulses should be between 1000 and 2000 usec. Could it be that your Tx send a non standard signal?
Attachments
CPPM_leon_v2.rar
(12.63 KiB) Downloaded 341 times
Erni
Posts: 27
Joined: Wed Jun 04, 2014 3:41 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Erni »

Success !

Now it works! I have only tested 8 channels so far I will try more.
Just one more comment: in your test from yesterday, I see that servo1 goes from 7890 up to 24280
I tried the debug option again and got the same result:

Code: Select all

0 ch1: 15720 Servo1: 24280
0 ch1: 32110 Servo1: 7890
But when I connect a servo to that pin it works as it should, and I also checked with a logical analyzer that the pulse is correct, so I dont know what it actually means.
My tx is a Taranis, and it is sending as standard as it get, at least I think so. I made a testmodel for this purpose, so no strange mixers in effect.

Again thankyou for your work on this.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

I checked the code again and I saw that the strange values reported by debug for Servo1 are just the result of a bug in the debug option.
Current code is :

Code: Select all

            TRACE ("Servo1: ");
            TRACELN (servoCycle[1]);
It should be :

Code: Select all

            TRACE ("Servo1: ");
            TRACELN (servoCycle[0]);
In fact servoCycle[1] is the delay after the pulse in order to reach 2.5 msec. So if the pulse varies from 1 to 2 msec, it is normal that the remaining time varies from 1.5 to 0.5 msec (= values reported by debug).

So anyway, this bug has no impact on the way servos are controlled.

Please do not forget to deactivate the debug option in your final device (because some SBUS signals are discarded when DEBUG is activated).
Erni
Posts: 27
Joined: Wed Jun 04, 2014 3:41 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Erni »

I made the change in the debug code and now I get:

Code: Select all

0 ch1: 32110 Servo1: 32110
0 ch1: 15720 Servo1: 15720
I checked the pins A1..A5 and 2..7, and they all work both with a servo and looks right on the Logical Analyzer.
I attach the code with TRACE substituted by Serial.print(), and hope it is the right one this time :(
Attachments
sbus_leo_v2.7z
(11.91 KiB) Downloaded 364 times
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

So I have loaded the code on my Pro Micro. And I also found a Pro mini in my drawer (tadaa!) Now I am struggling to get everything connected.
Sorry if this has been posted somewhere, I can't seem to find any documentation.
Could anyone please explain to me the following:
What kind of transistor do I need?
What kind of resistors do I need?
Where do I connect them?

Thanks a bunch!
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

You can look at a schema at this link
http://electronics.stackexchange.com/qu ... tal-signal
I suggest that you use the schema with 1 NPN transistor and 2 resistors (first schema in the link).
The transistor is not critical. any general purpose small signal NPN transistorcan work (like a 2N2222)
VS is the signal to be inverted; so it is the SBUS signal from the receiver.
VO is the inverted signal; so it has to be connected to the Rx pin of the Arduino pro mini
R2 can be between 10k and 33k (not critical)
R1 can be between 2k and 5k (not critical)
+V has to be connected to the arduino pin Vcc (= voltage provided by the arduino voltage regulator ).
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Thanks again!

By:"The transistor is not critical", do you mean it could be omitted? (for testing purposes) or is the type not critical?
And do I understand correctly that I will not be needing 10 resistors (but only 2)?

Thanks again for your help.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

You need a transistor but the type is not critical. Still it should be a type NPN if you use the schema from the link.
You need only 2 resistors as showed in the schema.
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Al is working perfectly. thank you so much for your help!
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Hi,

I have soldered the whole assembly together and all is working great. However, could it be that it is not possible to upload a modified sketch once the inverter is (permanently) connected to the rx pin? I have disconnected the RC receiver and all of the servo's and power, but I am unable to upload a modified sketch.

When I try to upload to a stand alone Pro Mini, the sketch uploads just fine.

This is the message I am getting:

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xf7
avrdude: stk500_recv(): programmer is not responding
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Any help is appreciated.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Arduino - Extend the number of servos supported by a Rx

Post by jhsa »

Did you change the board bact to the pro micro in the arduino IDE?
Hmmm, the transistor connects to the RX line, right? Maybe the transistor is loading that line. I had similar problem when connecting the FTDI to my arduvoice module. As an experiment try to put a diode between the transistor and the rx line. If it doesn't work turn it around and see if it works then.
Or let me get to my computer. I think there might be another option..

João

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Thanks João,

I ended up loading the code on a Pro Mini. (I found some in a drawer), instead of a Pro Micro. And instead of a transistor, I am using a HEX SCHMITT-TRIGGER INVERTER (from the same drawer ;). It is performing flawlessly, except for the part where I can't upload any code anymore.
As everything is already soldered to a pcb, I hope not to have to disconnect any components.
The only reason why I would upload anything at the moment, is to hard code the channel range, rather than using a jumper (I try to eliminate things that can go wrong).

Anyway, I was wondering if any of you guys have had the same problem. If not, perhaps it is the schmitt-trigger inverter (that seems to be the only difference in setup at the moment)

Thanks again!
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Arduino - Extend the number of servos supported by a Rx

Post by Kilrah »

The inverter has an "actively driving" output, so yes it will force the level there to whatever it's outputting and prevent the signal from the programmer from going through (it actually creates a short, not good).
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Arduino - Extend the number of servos supported by a Rx

Post by jhsa »

Ok, here I am with another option as promised.
There is a similar project here:

viewtopic.php?f=91&t=5476

Scroll a bit down on the page.
Here is the schematic of the inverter. You can just modify your PCB. I think this won't load the RX line anymore.
Attachments
Signal Inverter-Transistor.jpg
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by nigelsheffield »

If you are lazy like me you can even do a way with R2 depending on max current requirements of transistor base emitter junction and supply volts which should be 5v.
But probably safest to stick with a divider to make sure of the correct voltage.....
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Hi Guys,
Sorry to bother you again. I'm really excited about this thing and since I live in Hong Kong at the moment, I've decided to try and have the PCB manufactured here in Shenzhen.
This is my first time dealing with Eagle CAD and Gerbers and PCB, but I see great possibilities and I am very excited about it.
I have exported the Eagle file that mstrens has so kindly provided and exported it to Gerber files. However, my pcb manufacturer is unable to locate the drill holes. Is there any setting I should take into account? I am using a rather standard output script: sfe-gerb274x.cam
The result for the holes is a .txt file. When I view it, it looks like the attached image.
SBUS pcb holes.PNG
The fab guy says he can't work with that.
I have tried to replace the holes from the header component with standard holes, but this resulted in the same problem for the PCB house.
SBUS pcb standard holes.PNG
Do you have any suggestions? Or do you perhaps have a set of gerber files that you could send me, so I can compare or just send it directly to the PCB house?

As always, your help is highly appreciated.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

I am not a pro of Eagle and it is already a long time I used it but as far I remember you have to set up a cam processor in order to generate the files to be send to the PCB manufacter.
Some PCB manufacters publish on the web the cam set up to be used (to provide files that they will support).

In attachement you will find:
- a file that contains the cam set up I used. The generated files have been send to the company "smart prototype". I think that this setup is quite standard and sowill be supported by other manufacters too.
- all files related to the PCB. I think that the drill file is the one with txt as extension.

I hope this will help you.
Attachments
Sbus_1e_all.rar
(29.1 KiB) Downloaded 283 times
My_smart_Prototype_EagleCAM.rar
(1.34 KiB) Downloaded 264 times
Ramonster
Posts: 12
Joined: Mon May 18, 2015 12:40 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by Ramonster »

Thank you so much for your reply.

The txt file seems to be exactly what it needs to be. I can use it like that.

Unfortunately, when I use your (or any other) CAM script, the hole file is scaled up by a factor 10. I will investigate further to avoid this from happening in the future. (I'm planning to do much more of this PCB stuff :)

Please let me know if I need to order a few more of these for you. I would be happy to send them to you to say thanks for your help.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Arduino - Extend the number of servos supported by a Rx

Post by MikeB »

I usually generate the drill files separately from the gerber files.
1. Run the ULP file drillcfg.ulp. This creates a drill tool file called xxxxx.drl (xxxxx is your .brd file name).
2. Using the CAM processor, run the job excellon.cam. Enter the xxxxx.drl name for the RACK, and execute the job.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by mstrens »

Sorry but I have no idea why the hole file is scaled up by a factor 10.

Thanks for your proposal sending some PCB but honestly I do not really need them. I already have some PCB from an older version (with only 7 channels).

If you need further help, just ask for on this forum.
addlink
Posts: 1
Joined: Mon May 18, 2015 4:45 am
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by addlink »

Thank so much.
slinger87
Posts: 1
Joined: Sun Mar 27, 2016 12:41 am
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by slinger87 »

Hi,

Did anyone ever try to connect the dji r16 receiver to an arduino? Since DJI Naza can deal with both s-bus and d-bus i made the assumption the two would be exchangeable.

I tried to capture the frame but not much luck, I've added an image of the capture, but i can't make any sense of it. When i debug de serial data i seem to notice a packet of 18 bytes, starting with 0xFE and ending with 0x00.

I googled a lot, but there is almost no information about dji dbus. I found a repository on github by Garfield, but this looks quite the same as s-bus but i can't get this to work. No "packets" are found.

Any advice would be greatly appreciated ;)

Cheers

Rick
Attachments
image.png
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Arduino - Extend the number of servos supported by a Rx

Post by Kilrah »

slinger87 wrote:Since DJI Naza can deal with both s-bus and d-bus
AFAIK these 2 are the same thing bar the name.

Your capture suggests you might be sampling way too slowly and missing transitions.
swampd32618
Posts: 4
Joined: Mon Jun 06, 2016 4:36 am
Country: -

Re: Arduino - Extend the number of servos supported by a Rx

Post by swampd32618 »

I know this thread has been inactive for a couple of months, but I've got a couple of newbie questions:

I'm trying to modify code that simply detects switch positions (Futaba 14SG, FRSKY sBus rcvr) to drive LEDs for navigation lights. I've got it to work with discrete channel inputs (directly from receiver, not sBus) but think it would be much more elegant with a single sBus line in. I've got an Arduino UNO sketch that works great and have successfully transferred to an ATTINY84 for use on a small circuit card. I'd very much like to use mstrens' code to read the sBus channels, then range check the results to drive digital outputs high or low, depending on switch position. My questions are:

1. Do the code and connections need to be modified to work on an Arduino Mega 2650 (using the Mega in place of the UNO in order to monitor the serial bus while the sBus input is read)? If so, does anyone know what those changes need to be?
2. Are the values for the buffers reflective of pulse width? If so, I should be able to use the same code I used for the discrete channels.
3. Does anyone know whether the ATTINY84 can read a serial input? I'd like to keep the ATTINY84 footprint rather than "grow" to an AVR.

I'm somewhat new to Arduino and MCUs in general, but am an electrical engineer by education and a systems engineer by trade, so I believe I can figure this out eventually, but would appreciate any help you can provide to short-circuit my learning curve!

Thanks!

Marsh

Post Reply

Return to “General RC Electronic Projects and Discussion”