element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum DSM2 transmitter attached to Arduino via RS-232
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 15 replies
  • Subscribers 411 subscribers
  • Views 2058 views
  • Users 0 members are here
Related

DSM2 transmitter attached to Arduino via RS-232

roineust
roineust over 12 years ago

Hello!

 

I would like to connect an Arduino Uno via RS-232,  with this transmitter:


http://www.micronradiocontrol.co.uk/docs/dt/dt-tx1-k1-1.pdf


And to have as servo controller, on the receiving side, this receiver:


http://www.hobbyking.com/hobbyking/store/__28554__OrangeRx_R615_Spektrum_JR_DSM2_Compatible_6Ch_2_4Ghz_Receiver.html

 


Can anyone instruct me with such a project?


Thanks a lot!

Roi Neustadt.


  • Sign in to reply
  • Cancel
  • billabott
    0 billabott over 12 years ago

    I seem to recall that the servos hanging off the RX can be substituted with LEDs and series resistors so that the PWM output to the servos will make the LEDs brighten and dim according to the 10 bit control values. 

     

    Makes me wish I had a TX and RX to play with!

     

    Happy Trails.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • roineust
    0 roineust over 12 years ago in reply to billabott

    Hey Bill!

    Good morning/noon !!

    Thanks a lot!!

     

    I might need several more days to get the drift of it. This will demand of me to recall things i did not do for many years. I am sure i will be back to this table, more than once in the very near future, but unfortunately, i can't answer the questions you ask regarding the bytes and bits that easily.

     

    But, before i get to the point of being able to answer these questions - there are a few thing that elude me as well, that seem to me, to be even more basic:

     

    In the code i got (from another good guy who is trying to help me), the first thing that happens, when i try to compile, is that i get an error, because a variable called "datacluster" is said to "Not being recognized in this scope".

     

    Now, the line that the error is indicated at, is this one:

     

    datacluster = B0000000011111111; // data to transmit datasheet contains explanation

    /* the TX requires 16 bytes

     

    But when i went up in the code and checked out the type of variable, i saw this:

     

    int datacluster; // an int array might be handy

     

    So, i thought  that it can not be possible that an int will include the letter B. i changed the B to 0, just to test if the code will compile and it did. Not that anything has been working from that point on...LOL.

     

    I guess, the reason that he put things this way, is so i can fix those variable type and byte structure typos by myself and learn from the process.

     

    He also didn't realize that even to make all these 'simple' conversions between hex, binary and decimal, i will need a fair amount of days.

     

    Or is it a real unintentional typo and i need to change the variable type to another? (i think there is a type called "byte" in IDE, would that be the correct fix?)

     

    Here is the code:

     

    const byte bindPin = 2;  // pin that sends the bind signal to the transmitter

    int datacluster; // an int array might be handy

    void setup()

    {

    1. Serial.begin(15200);

    pinMode(bindPin, OUTPUT);

    }

    void loop()

    {

     

     

    digitalWrite(bindPin, LOW);

    delay(2000);  // bind pin low for 2 sec

    digitalWrite(bindPin, HIGH);

    delay(5000);  // wait 5 for pair.

    // manual pairing may be better since Arduino can not tell if successful or not

     

    datacluster = B0000000011111111; // data to transmit datasheet contains explanation

    /* the TX requires 16 bytes

     

     

    Byte 1 Checksum (sum of bytes 2-16 cast to 1 byte)

    Byte 2 Not used (can be any value)

    Bytes 3-16 2 bytes per channel with following structure 0b000 CCC 9876543210

    - 000 = not used (normally zeros)

    - CCC = channel number (0=Thr, 1=Ail, 2=Ele, 3=Rud, 4=Gear, 5=Aux1, 6=Aux2)

    - 9876543210 = 10bit channel position

     

     

    so send something like:

     

    sum   needs calculated

    0x00  second byte is not used

    B000000PPPPPPPPPP // all chan send same data PPPPPPPPPP is a 10 bit int or 8 would be easier depending on the accuracy you need

    B000001PPPPPPPPPP

    B000010PPPPPPPPPP

    B000011PPPPPPPPPP

    B000100PPPPPPPPPP

    B000101PPPPPPPPPP

    B000111PPPPPPPPPP

     

     

    */

    1. Serial.write(datacluster);

     

    // Serial.write(buf, len) for use with array (16 Bytes is probably to large for single var)

     

    delay(20); // as specified in datasheet

    }

     





    Thanks,

    Roi.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • roineust
    0 roineust over 12 years ago in reply to roineust

    Here is a newer code i got, but still no binding and no servo control:

     

    // ##############  start code  ###########################


    const byte bindPin = 2;  // pin that sends the bind signal to the transmitter

    int datacluster;  // an int array might be handy

    byte pos=0xFF;// position of servo

    byte txdat[16]={0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0};// 16 bytes to send

      //            C   T T   we only need throttle and checksum (maybe)

    void setup()

    {

    Serial.begin(15200);

    pinMode(bindPin, OUTPUT);


    digitalWrite(bindPin, LOW);

    delay(2000);  // bind pin low for 2 sec

    digitalWrite(bindPin, HIGH);

    delay(6000);  // wait >5 sec for pair.

    // manual pairing may be better since Arduino can not tell if successful or not

    // perhaps a photocell could check the led or tap a gpio into it, but thats a little complex

    // as compared to just checking it maybe a reset/retry pair button?


    }

    void loop()

    {


    // txdat[1] = 2 so it is about half way between 0 and 1023 (max min of 10 bit)


    txdat[2]=pos;// only using a byte for right now not sure where position will come from


    byte csum=2+pos;// calculate checksum since all but two are 0 it's easy

    txdat[0]=csum; // byte 0(first sent) is ckecksum (arrays are zero index)


    /*  protocol template


    Byte 1 Checksum (sum of bytes 2-16 cast to 1 byte)

    Byte 2 Not used (can be any value)

    Bytes 3-16 2 bytes per channel with following structure 0b000 CCC 9876543210

    - 000 = not used (normally zeros)

    - CCC = channel number (0=Thr, 1=Ail, 2=Ele, 3=Rud, 4=Gear, 5=Aux1, 6=Aux2)

    - 9876543210 = 10bit channel position


    so send something like:

    sum   needs calculated

    0x00  second byte is not used

    B000000PP PPPPPPPP // all chan send same data PPPPPPPPPP is a 10 bit int or 8 would be easier depending on the accuracy you need

    B000001PP PPPPPPPP

    B000010PP PPPPPPPP

    B000011PP PPPPPPPP

    B000100PP PPPPPPPP

    B000101PP PPPPPPPP

    B000111PP PPPPPPPP


    */ //end protocol template



      Serial.write(txdat, 16)// send 16 bytes from serial


    delay(20); // as specified in datasheet


    } // end loop

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 12 years ago in reply to roineust

    RE: BINDING:

    Select the appropriate model number (1-4) at any time.  Pins 2 & 3

    Hold Pin 1 low for ~2 seconds to enter bind mode (at any time).

    The led will flash for ~5 seconds. Bind is complete as soon as the led comes on solid

    or flickering fast.

     

    So, you probably want the setup(){} to do the bind function at startup.

    I assume that the zener diode & resistor is the proper method to control Pin 1 of the TX with a digital pin in output mode on the UNO.

    Hold it high for 2 seconds, reset to low, wait 5 seconds.

     

    I am curious. Can you share what uC is the brain of the TX?  Use a magnifier to see name on IC.

    All Syntax questions can be researched at http://arduino.cc/en/Reference/HomePage.

     

    -=SyntaxMatters=-

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • roineust
    0 roineust over 12 years ago in reply to billabott

    Hey Bill,

     

    I am not sure to what component you are referring to, on the transmitter (i don't know what is uC or IC) - but if you are referring to the tiny silvery square, then i took my field glasses and flipped them to magnify and it seems that the characters on that component are etched out.

     

    Still, whatever wiring and software configuration i try - what appears is only switching between slow and fast blinking of orange leds, in sync, on both transmitter and receiver - that shows some kind of communication between the components, but not much more than that, i don't think that this even means that they are in bind mode.


    As well, i have added a bind button and a led to the Arduino and code, the led blinks after the attempted binding process and also blinks at changing rates, in sync with changes of the servo 'pos' variable - i wanted the led to blink at one rate when the servo turns left and in another rate, when the servo turns right - but still nothing happens, no binding and no servo predefined movement - the led, though, works perfect, LOL.


    What happens is that 2 or 3 channels (thro, ale, elev) make the servo move in different jerky patterns, as before, but no controlled movement - and i think that since the led changing its frequency, is connected in the code with the 'pos' change of value - if the servo was moving as a result of code commands and not by some other reason, the servo would have moved in sync with the led.



    Here is the code with these additions:



    // ##############  start code  ###########################


    const int bindButtonInputPin = 7;         // input pin for the switch

    const int bindAndServoLed = 8;          // output pin for the LED


    const byte bindPin = 2;  // pin that sends the bind signal to the transmitter

    int datacluster;  // an int array might be handy

    byte pos=0xFF;// position of servo

    byte txdat[16]={0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0};// 16 bytes to send

      //            C   T T   we only need throttle and checksum (maybe)

     

    //int bindButtonInputPinVal;



    int LedBlinkRate; 

     

    void setup()

    {

    Serial.begin(15200);


       pinMode(bindAndServoLed, OUTPUT);


       pinMode(bindButtonInputPin, INPUT);

       digitalWrite(bindButtonInputPin,HIGH);  // turn on internal pull-up on the inputPin



        pinMode(bindPin, OUTPUT);



    }

    void loop()

    {

     

     

        int bindButtonInputPinVal = digitalRead(bindButtonInputPin);  // read bindButtonInputPin value

     

      if (bindButtonInputPinVal == LOW)                  // check if the bindButtonInputPin is HIGH

      {

       

    digitalWrite(bindPin, LOW);

    delay(2000);  // bind pin low for 2 sec

    digitalWrite(bindPin, HIGH);

    delay(6000);  // wait >5 sec for pair.

    // manual pairing may be better since Arduino can not tell if successful or not

    // perhaps a photocell could check the led or tap a gpio into it, but thats a little complex

    // as compared to just checking it maybe a reset/retry pair button?


    digitalWrite(bindAndServoLed, HIGH);


    delay (2000);

     

    digitalWrite(bindAndServoLed, LOW);


    }


    // txdat[1] = 2 so it is about half way between 0 and 1023 (max min of 10 bit)


    txdat[2]=pos;// only using a byte for right now not sure where position will come from


    byte csum=2+pos;// calculate checksum since all but two are 0 it's easy

    txdat[0]=csum; // byte 0(first sent) is ckecksum (arrays are zero index)


    /*  protocol template


    Byte 1 Checksum (sum of bytes 2-16 cast to 1 byte)

    Byte 2 Not used (can be any value)

    Bytes 3-16 2 bytes per channel with following structure 0b000 CCC 9876543210

    - 000 = not used (normally zeros)

    - CCC = channel number (0=Thr, 1=Ail, 2=Ele, 3=Rud, 4=Gear, 5=Aux1, 6=Aux2)

    - 9876543210 = 10bit channel position


    so send something like:

    sum   needs calculated

    0x00  second byte is not used

    B000000PP PPPPPPPP // all chan send same data PPPPPPPPPP is a 10 bit int or 8 would be easier depending on the accuracy you need

    B000001PP PPPPPPPP

    B000010PP PPPPPPPP

    B000011PP PPPPPPPP

    B000100PP PPPPPPPP

    B000101PP PPPPPPPP

    B000111PP PPPPPPPP


    */ //end protocol template



      Serial.write(txdat, 16);// send 16 bytes from serial


    delay(20); // as specified in datasheet


    if (pos>0xDC)

    {

      LedBlinkRate=0;

    }

    else if  (pos<32)

    {

      LedBlinkRate=1;

    }


    if (LedBlinkRate==0)

    {

    pos=pos-0x1E;


    digitalWrite(bindAndServoLed, HIGH);


    delay (300);

     

    digitalWrite(bindAndServoLed, LOW);

     

    delay (300);


    }

    else if (LedBlinkRate==1)

    {

    pos=pos+0x1E;



    digitalWrite(bindAndServoLed, HIGH);


    delay (1000);

     

    digitalWrite(bindAndServoLed, LOW);

     

      delay (1000);


    }



    } // end loop



    // ###################  end code  ###########################

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube