Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 76 to 100 of 111

Thread: Arduino RC library

  1. #76
    @Paul
    I read the values of a poti with the following code
    Code:
    map(analogRead(_pin), 0, 1023, 1000, 2000);
    This works in general. When a servo is connected, it flips all the time. Having a look with the loopback-example, there are values sent of 1492 to 1516. If the poti is centered and not touched, it should return 1500. What is wrong? Rounding is not an option, right?

    EDIT: Well, well, the USB port does not deliver enough power for the XJT TX-Module. When I power this separatly, all works very fine!!!!
    Last edited by nique; 04-03-2014 at 10:46 PM.

  2. #77
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Its funny how when you have a problem you can't solve it until you ask for help, then you find it quick. I seem to have the same problem

  3. #78
    Indeed - but if you are not asking - you will never solve by yourself...

    Actually, I add the Dual Rate and Expo Function to my stuff, after that, I will continue the work with a seperate thread, because it's then no longer about the RC-Lib for Arduino (which I can't use in cause of several HW-specific timing-stuff [not only ppm, but also flight-timer and buzzer and...]).
    Last edited by nique; 04-04-2014 at 11:02 AM.

  4. #79
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    my Teensy's arrived, so I'll be playing on this bandwagon also (can blame whimsical for recruiting me to Teensy). my goals would be hardware expansion via PPM output, some simple PPM combining (have trainer transmitter plug into teensy, and combine that PPM with the hardware expansion for controls, and pass that all to transmitter), and telemetry throughput/transmogrification. mostly wanting the power of Teensy for the telemetry transmogrifying both airborne and on the ground. in the air, it could be a much cheaper and capable alternative to the off the shelf products by the usual RC brands... on the ground, would be great to pull telemetry from modules, translate their format, but also to connect things like bluetooth serial (because some brands have bluetooth serial apps on phones, so adapting a format will enabled more toys for more people).

    ...well... that's my plan. just need time to execute

  5. #80
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    Hopefully PulsePosition will help make this easy.

    The library is still quite new, so if you hit any troubles, please post a detailed report (eg, cod & info to reproduce the problem).

  6. #81
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Quote Originally Posted by PaulStoffregen View Post
    PulsePosition WILL help make this easy.
    Just correcting your comment

  7. #82
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Thought i should show the finished project.
    Thanks again Paul for your library.

    Click image for larger version. 

Name:	DSC_3465.jpg 
Views:	564 
Size:	234.6 KB 
ID:	1964Click image for larger version. 

Name:	DSC_3467.jpg 
Views:	444 
Size:	64.6 KB 
ID:	1965Click image for larger version. 

Name:	DSC_3470.jpg 
Views:	631 
Size:	154.3 KB 
ID:	1966


    #include <PulsePosition.h>

    // this would not be possible, for me, with out the pulseposition library provided by the generous efforts of Paul Stoffregen.
    // Please visit his site and give thanks http://forum.pjrc.com/forums/5-General-Discussion
    // The library takes care of all I/O so all that is needed is to write the time value to the output or read from the input.
    // If a tracker is unpluged it will just continue to output the last valid data. plugging the tracker back in
    // it will resume as if nothing had happened.
    // The library is capable of having up to 6 input or output streams each up to 16 channels long.
    // I only need 8 (now 16) for my project and not many TX's can handle 16 in by the trainer port. The next version of openTX
    // will be able to handle 16.
    // the output pulses are extremely stable.

    // this will only run on a Teensy 3.1 Arm M4 so visit paul and buy 1, they are not expensive, $20 ($17 from OSH Park).
    // The Teensy is slightly smaller than the Nano
    // to compile properly Arduino needs to have the Teensyduino extensions available from the Teensy site
    // https://www.pjrc.com/teensy/index.html
    // library at http://www.pjrc.com/teensy/td_libs_PulsePosition.html


    // this simply reads the 4 axis from the first head tracker and 3 axis from the second head tracker for a passenger.It allows for 4 inputs
    // on input A to use the trainer function without disturbing the other channels.
    // It also has a 6 push button output for Ardupilot so i don't need to remember the 2 switch
    // combinations on the TX, YUCK. The LED's indicate what mode is being sent to the Ardupilot so it
    // is easy to see what mode it is in.
    // i added another 6 push buttons for another feature i want but that is pretty much just a copy of the section for
    // the first 6 but without LED's.
    // I have a gas motor with an electric start so have added an ignition/starter switch, with a spring loaded start position, and a pot for choke control. No more prop flipping.
    // I also have 1 x 3 position switch and an on off switch for the Teensy. These fill the TX case. Bugger
    // line 30


    PulsePositionOutput stream(FALLING); //combined trackers and buttons output
    PulsePositionInput ppmA; // first tracker input
    PulsePositionInput ppmB; // second tracker input
    byte Acount = 0;
    byte Bcount = 0;
    int valA = 0;
    int valB = 0;
    int cnt = 0; // debounce counter
    int volts = 0; // apm control button input voltage
    int starter = 0; // ignition switch
    int choke = 0;
    int switchl = 0;
    int pb2 = 0;
    int cnt1 = 0;

    void setup() {
    stream.begin(9); // start the output stream on pin 9
    ppmA.begin(5); // start the first input on pin 5
    ppmB.begin(6); // start the second input on pin 6
    pinMode(11, OUTPUT); // set up the LED pins for output
    pinMode(12, OUTPUT);
    pinMode(14, OUTPUT);
    pinMode(15, OUTPUT);
    pinMode(16, OUTPUT);
    pinMode(17, OUTPUT);
    digitalWrite(17, HIGH); stream.write(12, 1165); // Set the default LED and APM switch to default value i used the lowest value
    // If you change this make sure you change both the led and the output value
    // The value is the width of the PWM pulse you want in uS

    // Serial.begin(9600); // opens serial port, sets data rate to 9600 bps. Left over from testing not needed


    }

    void loop() {
    Acount = ppmA.available(); // how many incomming channels trackerA
    Bcount = ppmB.available();
    valA = ppmA.read(1); // Take 4 channels from tracker A and 3 from tracker B
    stream.write(1, valA); // I used the diy tracker and shifted the outputs to channel 1, 2 &3
    valA = ppmA.read(2); // They are assmebled into the first 7 output channels
    stream.write(2, valA); // The 4 channels from tracker A is so that it can be used as a trainer input as per the original
    valA = ppmA.read(3); // function for PPM input
    stream.write(3, valA);
    valA = ppmA.read(4);
    stream.write(4, valA);
    valB = ppmB.read(1);
    stream.write(5, valB);
    valB = ppmB.read(2);
    stream.write(6, valB);
    valB = ppmB.read(3);
    stream.write(7, valB);


    // Ignition switch sets ch 8 to 1ms if in the back position. Sets to 2ms if in the middle position or the forward spring position
    // Sets ch9 to 1 ms unless in the spring forward position then it is 2ms to turn on the starter motor.
    // switch is on input 23(A9)
    starter = analogRead(23);
    if (starter < 300) {stream.write(8, 1000); stream.write(9, 1000);}
    if ((starter >= 300) && (starter < 800)){ stream.write(8, 2000); stream.write(9, 1000);}
    if (starter >= 800) {stream.write(8, 2000); stream.write(9, 2000);}

    // Choke (pin A10) Reads the pot and outputs it to chan 10
    choke = analogRead(A10);
    choke = map(choke, 0, 1023, 1000, 2000); // Map the input to be 1mms to 2ms
    stream.write(10, choke);

    // left 3 pos switch 1, 1.5 or 2ms output
    switchl = analogRead(21);
    if (switchl < 300) {stream.write(11, 1000); }
    if ((switchl >= 300) && (switchl < 800)){ stream.write(11, 1500);}
    if (switchl >= 800) {stream.write(11, 2000); }

    // this is the 6 position switch and LEDS for the auto pilot.
    volts = analogRead(19); // read the voltage from the top 6 switches
    if ((volts > 940) && (cnt >0)){ cnt = cnt-1;} // decay the counter if nothing pressed
    if ((volts < 940) && (cnt <1000)){ cnt = cnt+1;} // debounce code
    if ((volts < 940) && (cnt == 1000)){ // less than 940 means a button has been pressed
    cnt = 0; // reset debounce counter
    digitalWrite(11, LOW); // reset the leds to all off
    digitalWrite(12, LOW);
    digitalWrite(14, LOW);
    digitalWrite(15, LOW);
    digitalWrite(16, LOW);
    digitalWrite(17, LOW);
    // test to see which led was pressed, turn on its led and output PPM value to channel 12
    if ((volts >= 785) && (volts < 940)){ digitalWrite(17, HIGH); stream.write(12, 1165);}
    if ((volts >= 630) && (volts < 785)){ digitalWrite(16, HIGH); stream.write(12, 1295);}
    if ((volts >= 470) && (volts < 630)){ digitalWrite(15, HIGH); stream.write(12, 1425);}
    if ((volts >= 300) && (volts < 470)){ digitalWrite(14, HIGH); stream.write(12, 1555);}
    if ((volts >= 102) && (volts < 300)){ digitalWrite(12, HIGH); stream.write(12, 1685);}
    if (volts < 102){ digitalWrite(11, HIGH); stream.write(12, 1815);}
    }

    // this is the 6 position switch without LED's.
    pb2 = analogRead(20); // read the voltage from the bottom 6 switches
    if ((pb2 > 940) && (cnt1 >0)){ cnt1 = cnt1-1;} // decay the counter if nothing pressed
    if ((pb2 < 940) && (cnt1 <1000)){ cnt1 = cnt1+1;} // debounce code
    if ((pb2 < 940) && (cnt1 == 1000)){ // less than 940 means a button has been pressed
    cnt1 = 0; // reset debounce counter
    // test to see which button was pressed, output the PPM value to channel 13
    if ((pb2 >= 785) && (pb2 < 940)){ stream.write(13, 1165);}
    if ((pb2 >= 630) && (pb2 < 785)){ stream.write(13, 1295);}
    if ((pb2 >= 470) && (pb2 < 630)){ stream.write(13, 1425);}
    if ((pb2 >= 300) && (pb2 < 470)){ stream.write(13, 1555);}
    if ((pb2 >= 102) && (pb2 < 300)){ stream.write(13, 1685);}
    if (pb2 < 102){ stream.write(13, 1815);}
    }


    }

  8. #83
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    Just a quick followup on this old thread. PulsePosition was recently updated to fix a bug. The default for undefined output was also changed to 1500 us.

    https://github.com/PaulStoffregen/PulsePosition

  9. #84
    Hy Paul

    Well, build my own RC-Transmitter is a huge job. It has to wait. A smaller is on the way and I think I need a teensy...

    I will build in a RC-Plane two receiver. Each work independet. The signal (S-BUS-Protocol from FrSky) should go to a teensy (each). Both teensy should talk together and decide, wich one sends the signal to the servos attached.

    So, two question:
    - Can you upgrade PulsePosition to support S-BUS-Protocol, and if so, what will it cost to me?
    - Do you have an example to do some "watchdog" between two teensy?

    Thanks for you support
    Nique

  10. #85
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    I do not know anything about S-Bus. But it looks like there's at least one project that's implement it on Teensy.

    http://diydrones.com/forum/topics/am...port-converter

    Maybe you could use the S-Bus portion of that project and PulsePosition to input/output the signals?

    In the file MavLink_FrSkySPort_1.3.zip is Arduino code "FrSkySPort.ino" which appears to read data on Serial1 at 57600 baud and parse it for a number of data types. There's also a FrSkySPort_SendPackage() function which appears to transmit data in some special format.

    Maybe you could make use of that code as a starting point and build your application to do that and the PPM in/out by using PulsePosition?

  11. #86
    Thanks Paul
    But there is a difference between S-BUS (for servo control) ans S.Port (for telemetrie). No way to be engaged? Should I do the research for spec?

    btw: Your PN-Folder is full.

  12. #87
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    Quote Originally Posted by nique View Post
    No way to be engaged? Should I do the research for spec?
    I can't possibly take on any new consulting-basis projects for at least 18 months (and quite likely much, much longer). PJRC has far too much planned for Teensy....

    But there is a difference between S-BUS (for servo control) ans S.Port (for telemetrie).
    That just goes to show how little I know about these specific RC protocols. You really should find someone who's familiar first with these protocols, and secondly who knows how to use Arduino. Libraries like PulsePosition make doing things like PPM extremely easy, so you don't need deep hardware skills to achieve excellent results, only moderate skill with Arduino programming (which *many* people have).

    btw: Your PN-Folder is full.
    Yes, indeed. I do not accept private messages here. It's perfectly fine for other people to use the private messages, but I answer tech questions on public pages, so the answers are permanently available for anyone who might later have a similar question.

  13. #88
    I understand.

    There is a library for arduino and it should almost work. There is maybe only a small problem. the used uart works inverted. With an Arduino, they use RX1 for input and have an 7414 in that path to invert the signal. As I understand, a big advantage of teensy is, that I can invert it by software? So I don't need the inverter? And Arduino RX1 is also your RX1 - right?

    In a german forum is a solution that seams to work. My big hope is, that it works also on the teensy.

  14. #89
    Some additional infos I found (here):
    The Futaba S-BUS protocol is a serial protocol to control servos. Up to 16 proportional and two digital channels are available. The protocol is derived from the very known RS232 protocol used everywhere. The signal must be first inverted. The frame is 8E2.

    The protocol is 25 Byte long and is send every 14ms (analog mode) or 7ms (highspeed mode).
    One Byte = 1 startbit + 8 databit + 1 paritybit + 2 stopbit (8E2), baudrate = 100'000 bit/s
    The highest bit is send first. The logic is inverted (Level High = 1)
    Is the baudrate of 100'000 a problem?

  15. #90
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    100000 baud is perfectly fine. Teensy 3.1 can create that baud rate perfectly.

    All 3 serial ports on Teensy 3.1 have a high-res baud rate feature that allows very accurate baud rates. In fact, when running at 48 MHz, any arbitrary baud rates below 1.2 Mbit/sec can be created will less than half the allowed 2.5% error for 8 bit formats, and Serial1 & Serial2 have double resolution when running at 96 MHz.

    Baud rates in the normally used ranges are created very accurately on Teensy 3.1 when running at the normal 48 or 96 MHz speeds.

  16. #91
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    Quote Originally Posted by nique View Post
    There is a library for arduino and it should almost work. There is maybe only a small problem. the used uart works inverted. With an Arduino, they use RX1 for input and have an 7414 in that path to invert the signal. As I understand, a big advantage of teensy is, that I can invert it by software? So I don't need the inverter?
    That's correct. Teensy 3.1 has serial formats with "_RXINV" and "_TXINV", to invert the RX and TX signals.

    For example, you can use:

    Code:
      Serial1.begin(100000, SERIAL_8N2_RXINV_TXINV);
    Documentation is available here:

    http://www.pjrc.com/teensy/td_uart.html

  17. #92
    Thanks Paul, that sounds great. Will try to rewrite the Lib to teensy...

    3 uart is finally perfect to my project. Is teensy fast enough to handle 2 uart with 100000 baud and one at lower rate to "watchdog" another teensy? My teensy runs at 96MHz.

    Is it ok, to continue the discussion here? At least, it will be also a RC-Library.

  18. #93

    Question

    Ahm

    It seams to be very easy to adabt to teensy...

    SBUS.cpp:
    Code:
    #include "SBUS.h"
    #include <Arduino.h>
    
    void SBUS::begin() {
    	SBUS::begin(true);
    }
    
    void SBUS::begin(bool useTimer) {
    	if (useTimer) {
    		noInterrupts();
    		TCCR2A  = 0;
    		TCCR2B  = 0;
    		TCNT2   = 0;
    		OCR2A   = 249;
    		TCCR2A |= (1 << WGM21);
    		TCCR2B |= (1 << CS22);
    		TIMSK2 |= (1 << OCIE2A);
    		interrupts();
    	}
    
    	for (byte i = 0; i<18; i++) {
    		_channels[i]      = 0;
    	}
    
    	_goodFrames         = 0;
    	_lostFrames         = 0;
    	_decoderErrorFrames = 0;
    	_failsafe           = SBUS_FAILSAFE_INACTIVE;
    
    	_serial.begin(100000, SERIAL_8N2_RXINV_TXINV);
    }
    
    void SBUS::process() {
    	static byte buffer[25];
    	static byte buffer_index = 0;
    	
    	while (_serial.available()) {
    		byte rx = _serial.read();
    		if (buffer_index == 0 && rx != SBUS_STARTBYTE) {
    			//incorrect start byte, out of sync
    			_decoderErrorFrames++;
    			continue;
    		}
    		
    		buffer[buffer_index++] = rx;
    
    		if (buffer_index == 25) {
    			buffer_index = 0;
    			if (buffer[24] != SBUS_ENDBYTE) {
    				//incorrect end byte, out of sync
    				_decoderErrorFrames++;
    				continue;
    			}
    			_goodFrames++;
    			
    			_channels[0]  = ((buffer[1]    |buffer[2]<<8)                 & 0x07FF);
    			_channels[1]  = ((buffer[2]>>3 |buffer[3]<<5)                 & 0x07FF);
    			_channels[2]  = ((buffer[3]>>6 |buffer[4]<<2 |buffer[5]<<10)  & 0x07FF);
    			_channels[3]  = ((buffer[5]>>1 |buffer[6]<<7)                 & 0x07FF);
    			_channels[4]  = ((buffer[6]>>4 |buffer[7]<<4)                 & 0x07FF);
    			_channels[5]  = ((buffer[7]>>7 |buffer[8]<<1 |buffer[9]<<9)   & 0x07FF);
    			_channels[6]  = ((buffer[9]>>2 |buffer[10]<<6)                & 0x07FF);
    			_channels[7]  = ((buffer[10]>>5|buffer[11]<<3)                & 0x07FF);
    			_channels[8]  = ((buffer[12]   |buffer[13]<<8)                & 0x07FF);
    			_channels[9]  = ((buffer[13]>>3|buffer[14]<<5)                & 0x07FF);
    			_channels[10] = ((buffer[14]>>6|buffer[15]<<2|buffer[16]<<10) & 0x07FF);
    			_channels[11] = ((buffer[16]>>1|buffer[17]<<7)                & 0x07FF);
    			_channels[12] = ((buffer[17]>>4|buffer[18]<<4)                & 0x07FF);
    			_channels[13] = ((buffer[18]>>7|buffer[19]<<1|buffer[20]<<9)  & 0x07FF);
    			_channels[14] = ((buffer[20]>>2|buffer[21]<<6)                & 0x07FF);
    			_channels[15] = ((buffer[21]>>5|buffer[22]<<3)                & 0x07FF);
    
    			((buffer[23])      & 0x0001) ? _channels[16] = 2047: _channels[16] = 0;
    			((buffer[23] >> 1) & 0x0001) ? _channels[17] = 2047: _channels[17] = 0;
    
    			if ((buffer[23] >> 3) & 0x0001) {
    				_failsafe = SBUS_FAILSAFE_ACTIVE;
    			} else {
    				_failsafe = SBUS_FAILSAFE_INACTIVE;
    			}
    
    			if ((buffer[23] >> 2) & 0x0001) {
    				_lostFrames++;
    			}
    		}
    	}
    }
    
    int SBUS::getChannel(int channel) {
    	if (channel < 1 or channel > 18) {
    		return 0;
    	} else {
    		return _channels[channel - 1];
    	}
    }
    
    int SBUS::getNormalizedChannel(int channel) {
    	if (channel < 1 or channel > 18) {
    		return 0;
    	} else {
    		return (int) lround(_channels[channel - 1] / 9.92) - 100; //9.92 or 10.24?
    	}
    }
    
    int SBUS::getFailsafeStatus() {
    	return _failsafe;
    }
    
    int SBUS::getFrameLoss() {
    	return (int) ((_lostFrames + _decoderErrorFrames) * 100 / (_goodFrames + _lostFrames + _decoderErrorFrames));
    }
    
    long SBUS::getGoodFrames() {
    	return _goodFrames;
    }
    
    long SBUS::getLostFrames() {
    	return _lostFrames;
    }
    
    long SBUS::getDecoderErrorFrames() {
    	return _decoderErrorFrames;
    }
    Changed row 30 to what Paul recommends for Serial1.begin...
    In the Origin-Library:
    Code:
    _serial.begin(100000, SERIAL_8E2);
    SBUS.h:
    Code:
    #ifndef SBUS_h
    #define SBUS_h
    
    #include "Arduino.h"
    
    #define SBUS_FAILSAFE_INACTIVE 0
    #define SBUS_FAILSAFE_ACTIVE   1
    #define SBUS_STARTBYTE         0x0f
    #define SBUS_ENDBYTE           0x00
    
    
    class SBUS {
    	public:
    		SBUS(HardwareSerial & serial) : _serial (serial) {}
    		void begin();
    		void begin(bool useTimer);
    		void process();
    		int getChannel(int channel);
    		int getNormalizedChannel(int channel);
    		int getFailsafeStatus();
    		int getFrameLoss();
    		long getGoodFrames();
    		long getLostFrames();
    		long getDecoderErrorFrames();
    	private:
    		HardwareSerial & _serial;
    		int _channels[18];
    		int _failsafe;
    		long _goodFrames;
    		long _lostFrames;
    		long _decoderErrorFrames;
    };
    
    #endif
    (unchanged)

    And here an example:
    Code:
    #include <SBUS.h>
    SBUS sbus(Serial3);
    
    void setup()
    {
      sbus.begin();
      Serial.begin(115200);
      Serial.println("SBUS Status");
    }
    
    // this is timer2, which triggers ever 1ms and processes the incoming SBUS datastream
    ISR(TIMER2_COMPA_vect)
    {
      sbus.process();
    }
    
    void loop()
    {
      delay(1000);
      printSBUSStatus();
    }
    
    void printSBUSStatus()
    {
      Serial.print("Ch1  ");
      Serial.println(sbus.getNormalizedChannel(1));
      Serial.print("Ch2  ");
      Serial.println(sbus.getNormalizedChannel(2));
      Serial.print("Ch3  ");
      Serial.println(sbus.getNormalizedChannel(3));
      Serial.print("Ch4  ");
      Serial.println(sbus.getNormalizedChannel(4));
      Serial.print("Ch5  ");
      Serial.println(sbus.getNormalizedChannel(5));
      Serial.print("Ch6  ");
      Serial.println(sbus.getNormalizedChannel(6));
      Serial.print("Ch7  ");
      Serial.println(sbus.getNormalizedChannel(7));
      Serial.print("Ch8  ");
      Serial.println(sbus.getNormalizedChannel(8));
      Serial.print("Ch9  ");
      Serial.println(sbus.getNormalizedChannel(9));
      Serial.print("Ch10 ");
      Serial.println(sbus.getNormalizedChannel(10));
      Serial.print("Ch11 ");
      Serial.println(sbus.getNormalizedChannel(11));
      Serial.print("Ch12 ");
      Serial.println(sbus.getNormalizedChannel(12));
      Serial.print("Ch13 ");
      Serial.println(sbus.getNormalizedChannel(13));
      Serial.print("Ch14 ");
      Serial.println(sbus.getNormalizedChannel(14));
      Serial.print("Ch15 ");
      Serial.println(sbus.getNormalizedChannel(15));
      Serial.print("Ch16 ");
      Serial.println(sbus.getNormalizedChannel(16));
      Serial.println();
      Serial.print("Failsafe: ");
      if (sbus.getFailsafeStatus() == SBUS_FAILSAFE_ACTIVE) {
        Serial.println("Active");
      }
      if (sbus.getFailsafeStatus() == SBUS_FAILSAFE_INACTIVE) {
        Serial.println("Not Active");
      }
      
      Serial.print("Data loss on connection: ");
      Serial.print(sbus.getFrameLoss());
      Serial.println("%");
    }
    (also unchanged)

    If this works, all Thanks go to here: https://github.com/zendes/SBUS

    Well, there are only a few use of serial: begin, available and read...

    I have not jet tested, becaus:
    - Teensy is waiting at home...
    - It uses a Timer, that kind of code I do not understand. Does it need some changes? It looks hw-specific to me

    Does one see some other problems with that code? I will give a try probably tonight.

    Thanks

  19. #94
    Oops, is this a problem:
    The origin code talk about 8E2 and Pauls recommondation is 8N2. Or ist this done by inverting the signal?

    In the UART-Format table 8E2 is impossible...

  20. #95
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    There is no option for 8E2 on the Teensy 3.1 hardware.

    You could try 8E1 and hope it works. Or you could use 8E1 and transmit the data 1 byte at a time with extra delays.

  21. #96
    Oh dear!

    Another lib starts serial by this:
    Code:
    Serial1.begin(BAUDRATE);
    Where BAUDRATE is 100000

    So there is no definition of any parity/stopbit. Does this help? What will be default?

  22. #97
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,974
    Quote Originally Posted by nique View Post
    Another lib starts serial by this:
    ....
    So there is no definition of any parity/stopbit. Does this help?
    Well, you didn't even mention the name of this other library, not to mention a link to its source code or technical info. What kind of help or answers do you expect anyone could give?

    You can keep posting question after question here, but really, what is the point? Unless you find exactly the code you need that's already been tested on the hardware you want, you're going to need to either dig into the technical specs and/or simply try stuff and discover what works and what fails.

    What will be default?
    8N1

  23. #98
    Thanks again

    The other Lib is here https://github.com/mikeshub/FUTABA_SBUS

  24. #99

    Talking

    Very interesting - both lib do what they have to do!

    Interesting in the aspect, that I can run with several modes.

    with this:
    Code:
    _serial.begin(100000, SERIAL_8N2_RXINV_TXINV);
    and that:
    Code:
    _serial.begin(100000, SERIAL_8E1_RXINV_TXINV);
    What is not working: Timer in the SBUS-Lib (pasted above). I simply commented out and did the sbus.process() Call in the loop. I'm happy with it - real happy.

  25. #100
    Did you ever figure out how to implement the timer in the SBUS-Lib to work in the teensy 3.1 ? Can you post the library ? I have the whole thing running on a MEGA but I need to port to the teensy 3.1 for more memory.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •