mstrens / oXs_on_RP2040

version of openXsensor to be used on raspberry pi pico RP2040 (more protocols, more functionalities)
84 stars 22 forks source link

Sequencer functions oXs RP2040 #108

Closed Satcomix closed 10 months ago

Satcomix commented 10 months ago

Hello Mstrens, I have read the instructions several times now, but I have some questions about how the sequencer works. e.g. SEQ={3 0 100 15 -100 -100 +90} 1.Which PWM signal 1000us to 2000us triggers the sequence on GPio 15 to control a servo on channel 3.

  1. 100ms clock for what? An analog servo is normally controlled at 50Hz 20ms, digital at 333Hz. 3.PWM = -100 (default), -100 (min) and 90(max) what are these values ​​for? Does the first -100(default) mean that the function is triggered at 1000us? I have already described in the RCG how I would like to trigger the sequences. With my FrSky X20S and the touch display which is controlled by a LUA script. This script creates 24 different PWM values on one RC channel, which are only generated once for 50ms to 150ms(normally, but i can set the time) when a button is pressed. best regards, Torsten
Satcomix commented 10 months ago

Hello Mstrens, I have a problem with STEP={100 0 100 255} The sequencer wants allways the lowest value at first place, but the buttons with the internal values are defined in LUA Is there another way? Otherwise I would have to change the LUA.

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {-100 0 100 255} {-50 0 -100 255}

Attention: error in config parameters Press ? + Enter to get help about the commands

Satcomix commented 10 months ago

I change something, but the sequencer don't want to accept it.

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {-100 0 100 255} {-50 0 -100 255}

Attention: error in config parameters Press ? + Enter to get help about the commands

Satcomix commented 10 months ago

The problem always occurs from the transition of negative values ​​-% to +%.

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {-100 0 100 255} {-50 0 -100 255}

Attention: error in config parameters Press ? + Enter to get help about the commands

Satcomix commented 10 months ago

Another unsuccessful attempt. :-((

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {100 0 -100 255}

Attention: error in config parameters Press ? + Enter to get help about the commands

mstrens commented 10 months ago

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

{ Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{} STEP= - {-100 0 100 255} {-50 0 -100 255}

------------- rs: In the printout you can see that there is a "-" where oXs detect a new sequence in steps. In your case you have

This means that one sequence contains 4 steps. oXs consider that all 4 steps are part of one sequence because the Channel values are in growing order : -60 -10 10 60. In order to get the step 10 and 60 in a separate sequence, you must move them at another place in the list of steps. You must then also move the related sequencer definition to another place in SEQ=

Satcomix commented 10 months ago

Edit: I find my mistake! -20 double Hello Mstrens, In the post before i make a change, but i get the same result.

STEP= - {100 0 -100 255}

Satcomix commented 10 months ago

No way. Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {-100 0 100 255} {-50 0 -100 255}

Attention: error in config parameters Press ? + Enter to get help about the commands

mstrens commented 10 months ago

Each sequence must have at least 2 steps. So you should enter one more step for the last sequence so after {10 0 100 255}

mstrens commented 10 months ago

Sorry. what I said here before is not 100% correct. I said : Each sequence must have at least 2 steps.

I should say : Each sequence must have at least 2 ranges (so 2 steps that have different Rc channel values) .

Satcomix commented 10 months ago

Hello Mstrens, The steps are all 20, please have a look at the change between -10% and +100%

mstrens commented 10 months ago

You have

You can see that oXs consider that those 3 steps are part of the same sequencer

oXs group them in this way because -60 -10 100 is a growing list. oXs put {50 0 100 255} in another sequence because 50 is lower than 100.

You must define STEP in such a way that oXs can detect that the step is part of a new sequencer because the N+1 Rc value is lower than the N Rc values. You can try the following list of steps: STEP= {50 0 100 255}{100 0 -100 255} {40 0 100 255}{90 0 -100 255} {30 0 100 255}{80 0 -100 255} {20 0 100 255}{70 0 -100 255} {10 0 100 255}{60 0 -100 255} {-100 0 100 255}{-50 0 -100 255} {-90 0 100 255}{-40 0 -100 255} {-80 0 100 255}{-30 0 -100 255} {-70 0 100 255}{-20 0 -100 255} {-60 0 100 255}{-10 0 -100 255}

SEQ must be adapted accordingly (to keep the same gpio's: SEQ= {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100} {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100}

Satcomix commented 10 months ago

Hello Mstrens, I have:

-{-60 0 100 255} {-10 0 -100 255} {100 0 -100 255} -{50 0 100 255}

It must be: -{-60 0 100 255} {-10 0 -100 255} -{100 0 -100 255} {50 0 100 255}

There are not three parts ,oXs sequencer doesn`t accept the {100 0 -100 255} as first step from the sixt sequence. normally there must be a - before, like - {100 0 -100 255} to show the beginning of that new step from a sequence.

Satcomix commented 10 months ago

You got it! SEQ= {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100} {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100}

STEP= {50 0 100 255} {100 0 -100 255} {40 0 100 255} {90 0 -100 255} {30 0 100 255}{80 0 -100 255} {20 0 100 255}{70 0 -100 255} {10 0 100 255}{60 0 -100 255} {-100 0 100 255}{-50 0 -100 255} {-90 0 100 255}{-40 0 -100 255} {-80 0 100 255}{-30 0 -100 255} {-70 0 100 255}{-20 0 -100 255} {-60 0 100 255}{-10 0 -100 255}

it works!!! 20 buttons with 10 sequences and 20 steps. Now you can move the servo with button1 and button6 ............it make more sense, because the top button for + and the bottom button for -.

mstrens commented 10 months ago

about : There are not three parts ,oXs sequencer doesn`t accept the {100 0 -100 255} as first step from the sixt sequence. normally there must be a - before, like - {100 0 -100 255} to show the beginning of that new step from a sequence.

Please note (it is explained in the Readme) that the "-" before { is just discarded by oXs when it decodes the command). So it is not used by oXs (currently) to recognize the begin of a new sequencer. The "-" was added when oXs display the config in order to make it easier for the user to see the different sequencers (and so to detect mistakes like you did).

To make life easier, I could change and say that "-" (or better "+") has always to be entered before "{ " to identify the begin of a new sequencer. In this case, oXs does not have to check anymore that RC channel value N+1 is lower than value N. I should then add a check that, inside a same sequencer, the Rc values must be in ascending order (or that 2 consecutive steps may have the same value). I will look at it.

Satcomix commented 10 months ago

Now it is more accurate! I changed the chronological order and make a change in the two mixers for LUA. Now it's like it was at the beginning Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) Channel Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP=

Config parameters are OK Press ? + Enter to get help about the commands

SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

STEP= {50 0 100 255} {100 0 -100 255} {40 0 100 255} {90 0 -100 255} {30 0 100 255}{80 0 -100 255} {20 0 100 255}{70 0 -100 255} {10 0 100 255}{60 0 -100 255} {-100 0 100 255}{-50 0 -100 255} {-90 0 100 255}{-40 0 -100 255} {-80 0 100 255}{-30 0 -100 255} {-70 0 100 255}{-20 0 -100 255} {-60 0 100 255}{-10 0 -100 255}

mstrens commented 10 months ago

I made some changes about the setup of sequencers:

mstrens commented 10 months ago

I forgot to say that new version use a different layout of the stored data in flash for sequencer. So when you upgrade to this new version, you will loose your current sequencer setup.

Satcomix commented 10 months ago

Hello Mstrens, Have you ever thought about the Enter key? It's annoying that the servos move to their starting position with every ENTER input. What does it look like if the PWM input fails with a kind of failsafe, i.e. all values ​​go into a safety position (minPWM). In their current state they remain in the last position if the RC signal is lost.

Satcomix commented 10 months ago

It works. Ver2.8.24 Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) ChannelNr Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP=

Config parameters are OK Press ? + Enter to get help about the commands

mstrens commented 10 months ago

Have you ever thought about the Enter key?

I did not yet look at it. It could be that it takes to much time to print out the configuration and that it blocks the main loop with the result that part of the Sbus signal is lost.

To debug it:

If this is the reason, I do not see an easy way to solve the issue. In practice, this should not be a to big issue because you are not supposed to ask/change the config when you fly.

mstrens commented 10 months ago

About the ENTER issue, perhaps can you make a simple test. If you set failsafe on Hold, the servo should not move when you make ENTER. This should confirm (or not) that the issue is related with the failsafe.

Satcomix commented 10 months ago

Good morning Mstrens, The servos on the sequencer move to their starting position when the RC radio is switched on and the servos were in a switched position when switched off. To test the sequencer, I use my own Pimoroni Servo2040 board with HOLD set. Nevertheless, the servos of the sequencer switch to their starting position when the ENTER button is pressed. processing cmd

Version = 2.8.24 Function GPIO Change entering XXX=yyy (yyy=255 to disable) Primary channels input = 5 (PRI = 5, 9, 21, 25) Secondary channels input = 255 (SEC = 1, 13, 17, 29) Telemetry . . . . . . . . = 255 (TLM = 0, 1, 2, ..., 29) GPS Rx . . . . . . . . . = 255 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 255 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 255 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 255 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 255 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 255 (SCL = 3, 7, 11, 15, 19, 23, 27) PWM Channels 1, 2, 3 ,4 = 255 255 255 255 (C1 / C16= 0, 1, 2, ..., 15) PWM Channels 5, 6, 7 ,8 = 255 255 255 255 PWM Channels 9,10,11,12 = 255 255 255 255 PWM Channels 13,14,15,16 = 255 255 255 255 Voltage 1, 2, 3, 4 = 255 255 255 255 (V1 / V4 = 26, 27, 28, 29) Logger . . . . . . . . . = 255 (LOG = 0, 1, 2, ..., 29) ESC . . . . . . . . . . . = 255 (ESC_PIN= 0, 1, 2, ..., 29)

Esc type is not defined

Protocol is Fbus(Frsky) CRSF baudrate = 420000 Logger baudrate = 115200 PWM is generated at = 333 Hz

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 No temperature sensors are connected on V3 and V4 RPM multiplier = 1.000000 Baro sensor is not detected Acc/Gyro is not detected Airspeed sensor is not detected No Vspeed compensation channel defined; oXs uses default settings First analog to digital sensor is not detected Second analog to digital sensor is not detected Foreseen GPS type is Ublox (configured by oXs) :GPS is not (yet) detected Led color is normal (not inverted) Failsafe type is HOLD

Number of sequencers= 10 Number of steps= 20 { Gpio Type(0=servo,1=analog) Clock(msec) ChannelNr Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} {9 0 20 3 -100 -100 100} {10 0 20 3 -100 -100 100} {11 0 20 3 -100 -100 100} {12 0 20 3 -100 -100 100} {13 0 20 3 -100 -100 100} {14 0 20 3 -100 -100 100} {15 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP=

Config parameters are OK Press ? + Enter to get help about the commands

mstrens commented 10 months ago

Good morning,

I just made a test: I added some code to measure the delay it takes to perform the printout of the config. It takes about 7 msec (with your sequencer setup). The failsafe should be activated only when oXs does not detect a Sbus frame within the 500ms. So there should be another another reason.

Furthermore, when the failsafe is HOLD, oXs must keep the Rc channel values and so the servo should not move.

You said: The servos on the sequencer move to their starting position when the RC radio is switched on and the servos were in a switched position when switched off. To test the sequencer, I use my own Pimoroni Servo2040 board with HOLD set. Nevertheless, the servos of the sequencer switch to their starting position when the ENTER button is pressed.

I presume that with "starting position" you mean what I call the "default position" as defined in the SEQ. So if I understand well the test process is: you power on the rx and oXs: the servos do not move then you power on the TX and then the servos move to their "default" position then you change some channel value (pressing on some buttons) and the related servos move to the expected position. then you use the ENTER command and all servos that where not in their default position move to their default position.

Is it so?

Satcomix commented 10 months ago

You understand it right. TX Radio off = Servos stay in there momentary position. TX Radio on = Servos drive to the "default" position. Servos in momentary position move to " default" position by enter the ENTER command.

mstrens commented 10 months ago

OK I understand why. It is not failsafe related. When you press ENTER, I do not only print the config, I also perform all checks on it. While performing the checks, I reload some internal tables and this is cause the issue. I have to think about the solution.

Satcomix commented 10 months ago

I also thought about FAILSAFE for a long time with my Mini Maestro 24CH board with LUA control. I have assigned a special button twice so that in the event of a problem I can set all 24 connected servos/consumers to a "default" safety setting. Furthermore, in the event of a short circuit or the power being switched on and off, I have a safety function that causes all servos/consumers to move to a "default" safety position.

mstrens commented 10 months ago

I hope I fixed the "ENTER" issue in version 2.8.25 (on github). I did not tested myself.

Satcomix commented 10 months ago

In the meantime I have done some tests with clock delay and duration clock. Everything works as it should, very slowly and sensitively Now i will test the 2.8.25 EDIT: I can`t download the 2.8.25

Satcomix commented 10 months ago

Could you please upload Ver.2.8.25 again.

Satcomix commented 10 months ago

Test Ver.2.8.25 When you press the ENTER button, nothing happens, i.e. the servos remain in their last position. OK After switching the TX radio off and on again, the servos remain in their last position. OK

mstrens commented 10 months ago

Fine. Thanks for testing.

Satcomix commented 10 months ago

Hello Mstrens, You don't need to thank me because your project is for all modelers. Although I am not a model aviator, I am a functional model builder who is very grateful for all the telemetry data and functions. Thank you for your time and effort. Greetings, Torsten Could you please show me how I can move a servo from a default position to a certain position and back to the default position using a specific PWM value.

Number of sequencers= 2 Number of steps= 4 { Gpio Type(0=servo,1=analog) Clock(msec) ChannelNr Default Min Max}...{ } SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP=

mstrens commented 10 months ago

I do not fully understand your question.

Note: you can have more than 2 steps having the same Rc channel value (for the case that you want to have a more complex sequence)

Satcomix commented 10 months ago

Hello Mstrens, i was searching for that: if you had e.g. {80 0 100 10} {80 0 20 30} then servo will move to position 100 when Rc channel is 80, then after 10 clock units , the servo will automatically move to position 20 and stay there for 30 clock units. After that it will automatically go back to position 100, stay there for 10 units, and again go to 20 for 30 units. This will repeat contentiously until the Rc channel value get a value define in another step. So if you e.g want to stop the repeating actions, define e.g. a step {70 0 100 255}.

All other features have I tried. Driving slowly from x to y at a different speed back to x, toggle between Y and Z and back to X

Satcomix commented 10 months ago

Good morning Mstrens, I wanted to get some new boards for testing the oXs logger. Is the iLabs Challenger RP2040 SD/RTC 100% compatible (GPio) with oXs logger?, my Cytron Maker Pi Pico is much too big for me. Greetings, Torsten

mstrens commented 10 months ago

I have no experience with this board. I only use RP2040-Zero. I expect it should work because the sd card is connected to a SPI and oXs logger allows to select the pins for the SPI (within the rp2040 gpio's that supports SPI). Still the LED on this board is a normal led (not a RGB) and is connected to another gpio. Currently the logger does not support a RTC chip (realtime clock) but I could perhaps add this feature to write the date&time of creation of the file on the SD card when there is no GPS installed. I am not sure that the RTC chip is the same (or compatible) with the one that a member put on his own (self made) board or the one I saw on a small module found on aliexpress.

Why don't you use a rp2040 zero and it a SD card module (with or without a RTC). This will be cheaper and smaller. There are only 6 wires (+2 for RTC optionally) to connect between the 2 boards.

Satcomix commented 10 months ago

Hello Mstrens, Thanks for the reply. I like to always have everything on one board, like the development of 52RCGroups in RCG, without additional wiring. I ordered two of the ILabs Challenger Boards, let's see. I'm currently doing some tests with the sequencer again: When I press button1, the servo1 slowly moves from center position to position +100% and slowly back to 0%. When I press button6, Servo1 slowly moves to position -100% and slowly back to 0% Why can't I press each function twice in a row, I have to execute one function first and then the other.

Number of sequencers= 2 Number of steps= 6 { Gpio Type(0=servo,1=analog) Clock(msec) ChannelNr Default Min Max}...{ } SEQ= {6 0 20 3 0 -100 100} {7 0 20 3 -100 -100 100}

  { Range(-100/-90/-80...0/10/20...90/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP=

Config parameters are OK Press? + Enter to get help about the commands

mstrens commented 10 months ago

The logic I implemented is the following (for each sequencer). When Rc channel value changes and match a value that is defined in the steps (with some tolerance), oXs applies immediately the specified sequence starting from the current position. So a sequence being played will not continue and the first step from the new selected sequence starts from current position. If the RC value does not change, oXs just continues to play the sequence. If the RC value changes but there is no step defined for the new value, oXs just continues to play the sequence.

This logic seems me good when you use the sequencer to control e.g 3 or 6 servos for a landing gear with just a switch with 2 positions.

When you use a Lua script that sent normally pulses at e.g. 1500us and change to another value (e.g. 2000) for some pulses (when button 1 is pressed) and then goes back to 1500us, there is some risk. If you press again the button 1 while the first sequence was not totally played, oXs will stop playing the sequence and start again from step 1. This could look strange.

Satcomix commented 10 months ago

Hello Mstrens, I understand. I also had this problem with my Mini Maestro project. In the example I described, the step has reached the end point again and I would like to repeat the last step. So Button1 is pressed, servo moves to a certain position and returns to the origin. Button6 is pressed, servo moves to a certain position and back. I can only approach the positions alternately. i.e. Button 1 then Button6 then Button1 etc. I would like to have Button1=Sequence with step moves and goes back to the starting position, when I reach the starting position I can press Button1 again. But it doesn't work because I first have to move Button6 with Sequence until the starting position is reached. Only then can I press Button1 with Sequence again. I understand your objection about double-pressing while a sequence is running. But in this case the end point has been reached again. Greetings, Torsten

Satcomix commented 10 months ago

Furthermore, I just noticed that when a step is running you can operate another step, and the servo can be moved to the position of Step2 during Step1.

mstrens commented 10 months ago

Now I understand the issue. I have to think about a solution. Perhaps I could say that when oXs get a Rc value (e.g. 1500us) that is not defined in a step, then it continues the sequence (like now). Then I could add a new rule: When oXs reaches the last step and this step has a delay 255 (= keep), oXs looks at the current RC value. If this value is not defined then oXs keeps the PWM position but store the undefined RC value in memory. So, next time that button is pressed, oXs can detect that a sequence has to be payed.

Satcomix commented 10 months ago

That's how I would do it too. Because currently, if a certain position has not yet been completely approached, a second position can already be approached.

mstrens commented 10 months ago

Furthermore, I just noticed that when a step is running you can operate another step, and the servo can be moved to the position of Step2 during Step1.

Yes, this is what I explained. When oXs get a new rc channel value that is defined in a step, it applies immediately the new sequence. This is safe e.g. for a landing gear. This is also logic when the played sequence does not end with 255 because it means it must be played indefinitely. So there must be a way to stop it.

Satcomix commented 10 months ago

Good morning Mstrens, I'm doing further experiments with the sequencer and now want to control an RGB LED on GPIO8 via Button3 and 8. Button3 =80% Button8 =30% RC Channel = 3 RGB-LED = 8 I have the settings for Analog from the Readme. accepted. SEQ= {6 0 20 3 -100 -100 100} {7 0 20 3 -100 -100 100} {8 1 500 3 0 0 100} STEP= +{50 0 -100 255} {100 0 100 255} +{40 0 -100 255} {90 0 100 255} +{30 0 0 255} {80 0 100 255} I'm doing something wrong and the LED doesn't light up when I press Button3. Controlling via GPio8 of a DRV2803 driver with buttons 3(on) and 8(off) works perfectly I want the LED to glow in yellow, red and green. oXs script: void checkLedColors(){ while (1){ blinkRgb(10,0,0, 500 , 10); blinkRgb(0,10,0, 1000 , 5); blinkRgb(0,0, 10, 5000 , 1); } greetings, Torsten

mstrens commented 10 months ago

I will look at your question but first I wanted to explain some changes I could make to solve the issues discovered yesterday: ` I propose following changes:

Then the logic could be the following: Note: to make writing easier I call "valid" a Rc channel value that is defined in a step. The opposite is "unvalid". Each time a RC Channel value is received from the handset, the value is compared to the previous received value (with some tolerance). If there are equal or if the new value is "unvalid", then the running sequence continue to run; if no sequence is currently running, PWM is unchanged If there are not equal and the new value is valid, then depending on state and parameters, or a new sequence starts immediately or the current sequence continue up to the end before new evaluation.

Handlind a valid sequence is as follow:

Note: it is possible to restart the current sequence without waiting his end if it may be interrupted and there are 2 changes of the Rc channel value (e.g. one unvalid and then the valid). In the same way, it is possible to restart a sequence that ended and did not repeat automatically by sending 2 changes of the RC channel value. Those 2 changes are required because, oXs reacts only on changes and not as long the RC channel value remains unchanged.

Note: it is possible to stop a sequence (that may be interrupted) without changing the current position by activating a new sequence having the PWM value equal to 255.

When the last step of a sequence is reached (after the end of the keep delay), oXs look if a valid sequence value has been stored while the sequence was executed:

`

Satcomix commented 10 months ago

Hello Mstrens, That sounds good at first, I'll test everything once you've released a new version with the new features in the sequencer. Greetings, Torsten

mstrens commented 10 months ago

About your RGB led: There are 2 types of RGB LED I think

Satcomix commented 10 months ago

Hello Mstrens, I have the second version, like WS2812, of the RGB LED. I need to by some with four pins (three pins for color) Then it's just not possible, this time to test. I thought of the aircraft modelers. When the landing gear is actuated when the aircraft is flying, the red LED lights up (landing gear retracted, doors closed), yellow LED = sequence for opening the doors and extending the landing gear is running. Green LED = landing gear fully extended, doors closed again, ready for landing. Greetings, Torsten

mstrens commented 10 months ago

It took quite a lot of time to rebuild sequencer for the proposed changes. I put a new version 2.8.28 on github. Please read the readme section. I made some important changes to the syntax to define sequencers. There is now only one command SEQ.

I tested (a little) the SEQ command but not if the sequencer still works. I also have still to implement the dummy PWM value in step in order to stop a sequence and keep the position.

mstrens commented 10 months ago

I put 2.8.29 on github. I added the possibility to have a sequence (step) that request to keep current position. This could be useful to interrupt a running sequence without moving (immediately to another pos). This uses a value "127" in the output PWM of the step (and a smooth parameter = 0).