mstrens / oXs_on_RP2040

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

Sequencer functions oXs RP2040 #108

Closed Satcomix closed 9 months ago

Satcomix commented 9 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
mstrens commented 9 months ago

SEQ define a "sequencer". This will control ONE GPIO In your example SEQ={3 0 100 15 -100 -100 +90} This sequencer will generate signals on gpio 3. The second parameter (0) says that the signal will be a PWM signal to drive a servo (it mean it will be a pulse in range 1000...2000 us once every 20ms (if pwmHz is 50hz) The third parameter (here 100) means that all delays defined in the second type of parameter (=SEQUENCE) will be in multiple of 100 msec. 15 means that it is the value of RC channel 15 that will be used to retrieve which sequence have to be applied. The next parameter -100 says that at power on, when no sequence is yet selected, the servo must get position -100 (=about 1000us; +100 = 2000us) Next one, also -100, means that even if one sequence request a position e.g.-110, oXs will limit the servo PWM to -100 Last one, +90, is the same but on positive size. So if a sequence request a position 100, oXs will limit the PWM to 90 The 2 last parameters can be compared to the min and max travel limits that you have in the output menu of your TX

I will put more comments about SEQUENCE ans STEP in next post. It will be easier if you have questions about this first part.

Satcomix commented 9 months ago

Hello Mstrens, thank you for your explanation. SEQ={3 0 100 15 -100 -100 +90} is the example from the oXs readme. Servo Port 3 0 for Servo, 1 for digital, 100 delaytime 15 Gpio PWM in? -100 is for power on., normally i use 0 = 1500us at startup. -100 and +90 are the software limits, depends on the hardware limits from the servo. So far I have understood everything. But how is the GPIO 15 =PWM in or digital IO addressed? With a specific PWM value from the receiver(1000us to 2000us) or a digital value? Greeting, Torsten

mstrens commented 9 months ago

So, one sequencer (= one GPIO) can have several SEQUENCE (max 9) and each sequence can have several STEPS. A SEQUENCE has only one RC channel value. Only 9 values are allowed : -100,-75,-50,-25,0,25,50,75 or 100 (where -100= 1000usec, 0=1500us, 100=2000us, ...) Imagine you have E.g. STEP={-100 0 50 3} {-100 10 100 2} {100 0 -100 255} Here the first parameter is or -100 or 100. It mean that there is 2 sequence. When RC value channel 15 will be -100 (=1000us), oXs will "play" steps {-100 0 50 3} {-100 10 100 2} When RC value channel 15 will be 100 (=1000us), oXs will "play" step {100 0 -100 255} When RC value is another value, oXs continues to play the last sequence.

Now look at first sequence with steps {-100 0 50 3} {-100 10 100 2}: The first step is {-100 0 50 3} -100 as said is the RC value that trigger the sequence 0 says that the PWM must immediately take the value define just after 50 is the PWM value to apply. So when RC channel 15 get the value -100, oXs generates a PWM signal of 50 (= 1750us) for some delay 3 defines the delay fthat oXs keeps the PWM on 50. This delay is in multiple of the clock. In our example clock was 100ms; so after 3*100= 300ms, oXs will apply the next steps.

Aboute the next step {-100 10 100 2}
-100 = previous (when value is <> from previous, it means it is another sequence 10 says that oXs may not immediately generate the new PWM value (100) but must make a smooth transition (from current value = 50) and this transition must take 10 100ms (=clock from sequencer) = 1 sec 100 says that after the transition, PWM must become 100 (=2000us). In fact in sequencer we had a limit of max 90; so oXs will not go above 90. 2 says that PWM must stay at 100 for 2100ms= 200ms.

After this delay, first step is repeated (so servo will go to immediately to position 50

Satcomix commented 9 months ago

Hello Mstrens, Now i understand. I will make tomorow a test with the 9 allowed values for one RC channel and write a new LUA script for the RCG members, like Pierre. Why do you use only 9 PWM values? 4 values for negative and 4 values for positive. I make a controller with 12 negative and 12 positive values, that works. Thank you very much. greetings, Torsten

mstrens commented 9 months ago

There is a misunderstanding (I think). First I must say that sequencer works only if oXs is able to get RC channels. It uses directly the RC channels values received from the receiver. If sequencer is based on RC channel 15, there is no need to map this channel to a GPIO pin for the sequencer to work.

SEQ={3 0 100 15 -100 -100 +90} 3 is the gpio where oXs has to generate the PWM signal requested by Servo Port 3 100 delaytime : in fact it is the "unit" for the delay specified in the STEPS 15 is not a Gpio, it is the RC channel that manage the sequencer. It means that when RC channel 15 will take some values (defined in steps) the GPIO 3 will output a PWM signal based on the specifications of steps (and on the value (-100=1000...100=2000us) of Rc channel 15)

Satcomix commented 9 months ago

No missunderstanding. I make a misstake, i mean PWM Ch 15 and not GPIO 15

mstrens commented 9 months ago

Why do you use only 9 PWM values? 4 values for negative and 4 values for positive. I make a controller with 12 negative and 12 positive values, that works.

I think it was enough and I wanted to have some margin. Not all RC systems used the same parameters to map the positions of the stick to RC values transmitted over RF and then map to PWM usec. I found that a gap of 25 between 2 value was easy. In principe I could use a gap of 20 and reduce the margin if really useful.

Satcomix commented 9 months ago

We have 16 GPio(0-15) for PWM, of which I use GPio5 for the FBUS. There would be 15 PWM left, one for PWM_in and 14 as output. That would be 6 or7 negative values, the 0% and 6 or 7 positive values. By 6 you have two GPio for other Circuitry Just thinking like that :-)) When i make tests with Ver. 2.8.16 i noticed some error messages about LOG, ESC and PWMHZ, by default LOG and ESC should be 255. and the PWMHZ should be 50 by default. Greetings, Torsten

mstrens commented 9 months ago

I do not understand why you say that there should be one gpio for PWM_in. oXs does not have a PWM_in

I also do not understand why you say that with 14 outputs there would be 6 or7 negative values, the 0% and 6 or 7 positive values.

In my logic, with X (e.g. 15) values you can control:

So, in most cases, with 15 values you can't control 14 outputs.

Do you remember the error messages about LOG, ESC and PWMHZ. I thought I had already default value. Still there is a difference between using a new device (with a clean flash memory) or upgrading a used device. When using a new device, oXs detect that the flash does not contain a config and apply all default values. When upgrading, it load the current config from flash assuming that all (even the new) parameters are there. When there are new parameters, I always add them after the other so I expect the flash still returns a value 0XFF (for each byte). So I had expected that log and esc pin where 0XFF by default. It is strange if this is not the case.

mstrens commented 9 months ago

Note: I have cross checks between some parameters. E.G. when log pin is not 255, then log baud rate must be in a specific range. For a used device being upgraded, log pin is normally on 255 (default flash value for all bytes). When you flash the upgraded version, oXs should not give an error (because oXs log pin is read as 255 from flash). Still when you manually set a log pin on a value 0..29, oXs performs the control and should give an error about the invalid baudrate (because it is read from flash as 0XFFFFFFFF and so is out of range)

Satcomix commented 9 months ago

Hello Mstrens, As already mentioned, I try to operate the oXs_Sequencer via a LUA interface. In your instructions it says that the value that triggers a function/sequence can have the values ​​-100, -75, -50, -25, 0, +25, +50, +75, +100%. So there are 4 negative PWM values ​​and 4 positive PWM values, and 0% = 1500us as the neutral position. This is how the LUA scripts work. By PWM-in I refer to the only control channel through which the PWM values ​​are sent to trigger a function/sequence. I.e. I send up to 8 different PWM pulses -100% via middle position 0% to 100% via a single channel from the receiver via the radio with LUA touchscreen. Each key press sends a specific RC-PWM value on the same channel (PWM-in). I had installed version 2.6.x and after installing 2.8.10 I got error messages about ESC, Log and PWMHZ. Only when I set ESC, LOG to 255 and PWMHZ to 50 did I no longer see any config errors. Greetings, Torsten

mstrens commented 9 months ago

Before you go to far with Lua and tests, I can change oXs in order to allow 21 values (-100, -90, -80, ...90,100) so with an interval of 10.

mstrens commented 9 months ago

In version 2.8.18 (on github), it should be possible to use 21 rc channel values in sequencer (-100,-90, -80,...100)

Satcomix commented 9 months ago

Hello Mstrens, I have designed several LUAs, up to 72 functions/sequences over up to 3 RC-PWM channels. My PWM-ADC converter can record up to 3 PWM channels and output 3 analog voltages to up to 3 Mini Maestro 24CH. Each RC PWM channel can execute up to 24 functions/sequences.

If you unlock 21 PWM values, that means to me that you get 10 negative PWM values, the middle position 0% = 1500us, and 10 positive PWM values, and could therefore control up to 20 functions/sequences via just a single RC PWM channel. The oXs on RP2040 only has 16 RC-PWM outputs (GPio0-15)

The FrSky Output can be set to the same channel. With 20 values, that would be two touchpad displays with 10 buttons each with the option to label the individual function/sequence. Each press of a button triggers a PWM signal for 300ms. Ethos is polled every 50ms. Greetings, Torsten

Satcomix commented 9 months ago

Hello Mstrens, I will make some Tests with Ver. 2.8.18 and will write a new LUA Script for FrSky ETHOS User with 20 Buttons on 2 Displays. Thanks, Torsten

Satcomix commented 9 months ago

Hello Mstrens, I have completed the first homework, the preliminary version of the lua script for FrSky X20S or Pro is ready. When you press a button, a specific PWM value is output via a single receiver channel. 20 functions via one channel. Touch display1 Button1 = 1550us Button2 = 1600us ....... Button10 = 2012us

Touch display2 Button11 = 1450us Button12 = 1400us ........ Button20 = 988us

The 0% = 1500us are always present before and after a key/button press! Greetings, Torsten Multi 2x10 Buttons.zip

Satcomix commented 9 months ago

Hello Mstrens What do I need now: A script with all sequences and steps to set a servo on PWM-CH13 (GPio8) from 1000us to 2000us when pressing a button, e.g. Button1/Function1 via GPio3 (PWM-in). or press a button on Button2/Function2 via GPio3 (PWM-in) to set a servo on PWM-CH14 (GPio9) from 1000us to 2000us. Can you help me with that? I have still one question: If I press button1 again on my Mini Maestro servo controller, the servo returns to its starting position (1000us). Is this also possible with oXs_Sequencer, or do I need a second button for this? Greetings, Torsten

Satcomix commented 9 months ago

Hello Mstrens, there is something wrong with pitch and roll telemetrie (X20S FBUS Protocol) in the versions: 2.8.17 and 2.8.18 Roll show 90° and jumps to -90° Till ver.2.8.16 everything is ok. Pitch and Roll 0° after MPUCAL greetings, Torsten

mstrens commented 9 months ago

In oXs you need 2 buttons when you want to move e.g. from 1000us to 2000us and then later (when you decide it) to move back from 2000us to 1000us. In this case there will be 2 sequences (one per button). You can use only one button (one sequence) if you want to move from 1000us to 2000us and then goes automatically back to 1000us after a predefined (fixed) time; Then there are 2 steps but only one sequence.

Example :

You can then try : SEQ={9 0 20 3 -100 -100 100} {8 0 20 3 -100 -100 100} STEP= {-80 0 100 255} {-70 0 -100 0 255} {-100 0 100 255} {-90 0 -100 255}

Please note that I had to start with sequencer (and steps) related to gpio9 because oXs has to be able to detect which steps are related to the first sequencer and which are related to the second. To keep the commands quite simple, oXs consider that a step is part of the next sequencer when the RC value of this step is less than previous Rc value. So in my example is manage to have -100 after -70 in the list.

So here you have:

Note: The last parameter of each step is 255 in order to force oXs to continue to generate the PWM value up to when it receives a new valid command ("valid" means a Rc channel value that is defined in the list of all steps of this sequencer.

I hope this is clear. If not just ask for help.

mstrens commented 9 months ago

About mpu6050, I removed a change in 2.8.17. I uploaded now 2.8.19

Satcomix commented 9 months ago

Hello Mstrens, I make tests with Ver.2.8.19, and pitch and roll values ​​are now ok. But the sequencer doesn't want to work. I press button1 = 10% = 1550us to control the servo C13 GPio8 to 100% = 2012us, I press button6 = 60% = 1800us to control the servo1 C13 GPio8 from 100% to -100% = 988us. Nothing happens, no change in the PWM pulses on GPio8, stays at 0%=1500us the whole time. The same thing also happens with Servo2 CH14 GPio9 when I press button2 and button7. I connected PWM measuring devices to all GPio outputs. At GPio3 = C9(PWM-in) I measure all 20 values ​​from the buttons on the touchscreen. When I press a button I can measure all PWM values ​​for 900ms (set in the LUA). greetings, Torsten

processing cmd

Version = 2.8.19 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 . . . . . . . . . = 12 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 13 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 2 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 4 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 14 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 15 (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 = 3 255 255 255 PWM Channels 13,14,15,16 = 8 9 255 255 Voltage 1, 2, 3, 4 = 26 27 28 29 (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 = Hzlu

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 One temperature sensor is connected on V3 RPM multiplier = 1.000000 Baro sensor is detected using MS5611 Sensitivity min = 100 (at 100) , max = 300 (at 1000) Hysteresis = 5 Acc/Gyro is detected using MP6050 Acceleration offsets X, Y, Z = 449 , 85 , -2802 Gyro offsets X, Y, Z = 3 , -163 , -192 Aispeed sensor is detected using MS4525 Vspeed compensation channel = 7 First analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Second analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Foreseen GPS type is Ublox (configured by oXs) :GPS is detected and has a fix Led color is normal (not inverted) Failsafe uses predefined values Chan 1...4 = 1500 1500 1500 1500 Chan 5...8 = 1500 1500 1500 1500 Chan 9...12 = 1500 1500 1500 1500 Chan 13...16= 1500 1500 1500 1500

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

  { Range(-100/-75/-50/-25/0/25/50/75/100) Smooth(clocks) Pwm(-100/100) Keep(clocks) } ...{}

STEP= - {20 0 100 255} {70 0 -100 255}

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

Satcomix commented 9 months ago

one Question: How do I delete the steps or the sequence? Edit: I find the way!!!! STEP= or SEQ=

mstrens commented 9 months ago

I will have to make some more tests. I did it in the and it worked for me (with 9 values instead of 21).

Even if the PWM-in is not correctly identified as one of the 21 values, it is strange that gpio 8 and 9 are not generating a 988usec pulse because this this the default value defined in the sequencer.

I will have to make some tests myself to debug it.

Just 1 point for your Lua: if -100 = 988us and + 100 = 2012us you have to adapt slightly your Lua code. If you have 20 buttons, button 1 should generate a pulse of 988us, button 2 should be 988+(2012-988)/20 = 1039, ... Button 10 should make a pulse of 1500 + (2012-988)/20 , ...

Satcomix commented 9 months ago

Hello Mstrens, I changed my LUA. FrSky 988us - 2012us , 512us = 1024bit First touch display: B1-B10 Button1 = -100% = 988us Button10 = -10% =1450us Second touch display: B11-B20 Button11 = +100% = 2012us Button20 = +10% = 1552us I still have to fine-tune something. Does the sequencer have a span range e.g. +/- 1--2us? or do the values ​​have to be 100% correct?

mstrens commented 9 months ago

Is it not more logic (easier for a user) having Button11 = +10% = 1552us and button 20 = +100% = 2012us? For oXs it does not matter. The sequencer has (in theory - to be checked for bug) a span range of +/- 4

I looked in the code and I saw a note saying that I still had to apply the default PWM value. I will add this code. Please note that no PWM at all should be generated when no frame are yet received from TX. The default PWM should be applied (when code will be added) when oXs receive a first frame of TX and the Rc channel value does not match one value defined in the STEPS (because oXS does not know which action should be taken).

I also noticed in the code that a value of e.g. -100 in a step does not correspond to 988us but to 1000us. (idem +100 is currently 2000 while it should be 2012).

Satcomix commented 9 months ago

I use 2 mixers, one for positive values ​​and one for negative values. If I were to change the order of the buttons now, it would be more work. The calculation in the LUA: for i = 1, 10 do if btstate[1]==1 then t=0.9 pwm= 1024
elseif btstate[2]==1 then t=0.9 pwm= 921.6
elseif btstate[3]==1 then t=0.9 pwm= 819.2
elseif btstate[4]==1 then t=0.9 pwm= 716.8
elseif btstate[5]==1 then t=0.9 pwm= 614.4
elseif btstate[6]==1 then t=0.9 pwm= 512
elseif btstate[7]==1 then t=0.9 pwm= 409.6
elseif btstate[8]==1 then t=0.9 pwm= 307.2 elseif btstate[9]==1 then t=0.9 pwm= 204.8
elseif btstate[10]==1 then t=0.9 pwm= 102.4
end

Satcomix commented 9 months ago

I can also change my settings so that 10% =50us. 2000us to 1000us 2000us ,1950us,..1500us....1050us,1000us.

mstrens commented 9 months ago

For a normal Rc channel, when Ethos is -100 , I expect the PWM is 988 usec. So it should be more logical to use the same convention for sequencer.

I put 2.8.20 that should use the range 988/2012 and should generate pwm pulse with default PWM value when Tx sent frames but the PWM-IN value is not defined in the list of steps.

I did not made tests on it.

Satcomix commented 9 months ago

I just make a test with version 2.8.20. No change. GPio8 and 9 always show 1500us

mstrens commented 9 months ago

I put version 2.8.21 that activates some more debug msg. Perhaps those msg will help.

ps: I will not be available before 18h (brussels time)

Satcomix commented 9 months ago

Hello Mstrens, I have installed ver.2.8.21. I don't see any debug messages or any changes. Brussels time = German time :-)) 18:00 Uhr no problem. In the meantime I'll work a bit with the oXs logger

processing cmd

Version = 2.8.21 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 . . . . . . . . . = 12 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 13 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 2 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 4 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 14 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 15 (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 = 3 255 8 9 PWM Channels 13,14,15,16 = 255 255 255 255 Voltage 1, 2, 3, 4 = 26 27 28 29 (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 = 50 Hz

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 One temperature sensor is connected on V3 RPM multiplier = 1.000000 Baro sensor is detected using MS5611 Sensitivity min = 100 (at 100) , max = 300 (at 1000) Hysteresis = 5 Acc/Gyro is detected using MP6050 Acceleration offsets X, Y, Z = 449 , 85 , -2802 Gyro offsets X, Y, Z = 3 , -163 , -192 Aispeed sensor is detected using MS4525 Vspeed compensation channel = 7 First analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Second analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Foreseen GPS type is Ublox (configured by oXs) :GPS is detected and has a fix Led color is normal (not inverted) Failsafe uses predefined values Chan 1...4 = 1500 1500 1500 1500 Chan 5...8 = 1500 1500 1500 1500 Chan 9...12 = 1500 1500 1500 1500 Chan 13...16= 1500 1500 1500 1500

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

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

STEP= - {-80 0 100 255} {-70 0 -100 255}

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

Satcomix commented 9 months ago

First results in debug messages!!! I change CH8 to GPio8 and CH9 to GPio9 The Input is now CH3 on GPio3 No change on servo output, when i push a button.

processing cmd

Version = 2.8.21 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 . . . . . . . . . = 12 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 13 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 2 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 4 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 14 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 15 (SCL = 3, 7, 11, 15, 19, 23, 27) PWM Channels 1, 2, 3 ,4 = 255 255 3 255 (C1 / C16= 0, 1, 2, ..., 15) PWM Channels 5, 6, 7 ,8 = 255 255 255 8 PWM Channels 9,10,11,12 = 9 255 255 255 PWM Channels 13,14,15,16 = 255 255 255 255 Voltage 1, 2, 3, 4 = 26 27 28 29 (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 = 50 Hz

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 One temperature sensor is connected on V3 RPM multiplier = 1.000000 Baro sensor is not detected Acc/Gyro is not detected Airspeed sensor is not detected Vspeed compensation channel = 7 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 detected and has a fix Led color is normal (not inverted) Failsafe uses predefined values Chan 1...4 = 1500 1500 1500 1500 Chan 5...8 = 1500 1500 1500 1500 Chan 9...12 = 1500 1500 1500 1500 Chan 13...16= 1500 1500 1500 1500

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

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

STEP= - {-80 0 100 255} {-70 0 -100 255}

Config parameters are OK Press ? + Enter to get help about the commands chan changed Start new sequencer 1 at step 2
Start new step for sequencer 1 at step 2 Push Button1 -100% chan changed Start new sequencer 1 at step 3 Start new step for sequencer 1 at step 3 Push Button2 -90% chan changed Start new sequencer 0 at step 0 Start new step for sequencer 0 at step 0 Push Button3 -80% chan changed Start new sequencer 0 at step 1 Start new step for sequencer 0 at step 1 Push Button4 -70%

Satcomix commented 9 months ago

Hello Mstrens, I believe that the problem in the sequencer lies with SEQ and STEP, which does not specify the GPio but rather the PWM channels, or both must even be the same. GPio3 = CH3 GPio8 = CH8 GPio9 = CH9

mstrens commented 9 months ago

You said: I believe that the problem in the sequencer lies with SEQ and STEP, which does not specify the GPio but rather the PWM channels, or both must even be the same. GPio3 = CH3 GPio8 = CH8 GPio9 = CH9

I do not understand what you mean. I do not see any relation between Gpio and CH. In SEQ, 8 and 9 are Rp2040 gpio (from 0/15)(not a Channel) and 3 is the index of a Rc channel (1/16) and not a Gpio.

You report 2 tests with 2.8.21. In the first one you say that you got no debug msg. In the second test the expected msg are present (and seems me ok). What did you change between the 2 tests?

Satcomix commented 9 months ago

Today I had the RC-CH9 on GPio3 the whole time and was able to measure all values ​​on GPio3 with a PWM meter after pressing a button. GPio8 was CH13, GPio9 was CH14, and no debug message was visible after pressing a key.

After switching the GPio and Channels, i got the first debug message. You can see the GPio and PWM in the posts before.

mstrens commented 9 months ago

It should not be possible to use the same gpio to output a PWM based directly on Rc channel and also to output a PWM signal generated by a sequencer. So when a gpio (e.g. 8 and 9) is used as first param of SEQ, it may not be used in a command C1..16=8 or = 9. I though I had a check on it that should make the config not valid. Probably there is a bug in this part. I will check it.

Satcomix commented 9 months ago

But you must set the command for GPio8 and 9 for the PWM Servo output.

mstrens commented 9 months ago

But you must set the command for GPio8 and 9 for the PWM Servo output.

No: when a gpio is used in the sequencer, oXs knows automatically that it has to generate a PWM on it. It may not be a command Cxx=yy for the same gpio.

I uploaded 2.8.22 to have the check that a pin is used only once. The code was present but put as comment. I do not remember why.

Having twice a gpio could explain (perhaps) why you got a PWM of 1500usec.

Can you upload 2.8.22 check that you got an invalid config when a gpio is used twice. change your config to avoid duplicates see if you get now a PWM based on sequencer

Satcomix commented 9 months ago

processing cmd

Version = 2.8.22 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 . . . . . . . . . = 12 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 13 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 2 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 4 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 14 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 15 (SCL = 3, 7, 11, 15, 19, 23, 27) PWM Channels 1, 2, 3 ,4 = 255 255 3 255 (C1 / C16= 0, 1, 2, ..., 15) PWM Channels 5, 6, 7 ,8 = 255 255 255 8 PWM Channels 9,10,11,12 = 9 255 255 255 PWM Channels 13,14,15,16 = 255 255 255 255 Voltage 1, 2, 3, 4 = 26 27 28 29 (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 = 50 Hz

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 One temperature sensor is connected on V3 RPM multiplier = 1.000000 Baro sensor is not detected Acc/Gyro is not detected Airspeed sensor is not detected Vspeed compensation channel = 7 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 uses predefined values Chan 1...4 = 1500 1500 1500 1500 Chan 5...8 = 1500 1500 1500 1500 Chan 9...12 = 1500 1500 1500 1500 Chan 13...16= 1500 1500 1500 1500

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

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

STEP= - {-80 0 100 255} {-70 0 -100 255}

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

mstrens commented 9 months ago

Note: it is allowed to e.g. use channel 3 to control your sequencers and at the same time generate an PWM signal (with channel 3 value) on some gpios (even on gpio3) (but not on the gpio used to output the PWM from a sequencer.

Satcomix commented 9 months ago

processing cmd

Version = 2.8.22 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 . . . . . . . . . = 12 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 13 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 2 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 4 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 14 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 15 (SCL = 3, 7, 11, 15, 19, 23, 27) PWM Channels 1, 2, 3 ,4 = 255 255 3 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 = 26 27 28 29 (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 = 50 Hz

Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 One temperature sensor is connected on V3 RPM multiplier = 1.000000 Baro sensor is detected using MS5611 Sensitivity min = 100 (at 100) , max = 300 (at 1000) Hysteresis = 5 Acc/Gyro is detected using MP6050 Acceleration offsets X, Y, Z = 449 , 85 , -2802 Gyro offsets X, Y, Z = 3 , -163 , -192 Aispeed sensor is detected using MS4525 Vspeed compensation channel = 7 First analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Second analog to digital sensor is detected using ads1115 Measurement setup: 4 , 5 , 6 ,7 Gains: 1 , 1 , 1 ,1 Rates: 5 , 5 , 5 ,5 Offsets: 0.000000 , 0.000000 , 0.000000 ,0.000000 Scales: 1.000000 , 1.000000 , 1.000000 ,1.000000 Averaged on: 10 , 10 , 10 ,10 Foreseen GPS type is Ublox (configured by oXs) :GPS is not (yet) detected Led color is normal (not inverted) Failsafe uses predefined values Chan 1...4 = 1500 1500 1500 1500 Chan 5...8 = 1500 1500 1500 1500 Chan 9...12 = 1500 1500 1500 1500 Chan 13...16= 1500 1500 1500 1500

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

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

STEP= - {-80 0 100 255} {-70 0 -100 255}

Config parameters are OK Press ? + Enter to get help about the commands chan changed Start new sequencer 1 at step 3 Start new step for sequencer 1 at step 3 chan changed Start new sequencer 0 at step 0 Start new step for sequencer 0 at step 0 chan changed Start new sequencer 0 at step 1 Start new step for sequencer 0 at step 1 chan changed Start new sequencer 0 at step 0 Start new step for sequencer 0 at step 0 chan changed Start new sequencer 1 at step 2 Start new step for sequencer 1 at step 2 chan changed Start new sequencer 1 at step 3 Start new step for sequencer 1 at step 3 chan changed Start new sequencer 0 at step 1 Start new step for sequencer 0 at step 1 chan changed Start new sequencer 0 at step 0 Start new step for sequencer 0 at step 0 chan changed Start new sequencer 1 at step 2 Start new step for sequencer 1 at step 2

Satcomix commented 9 months ago

It works!!! But GPio3 is also used for CH3.

mstrens commented 9 months ago

The principle is thaat a gpio can't be used for 2 purposes. A command like Cx=y just means that the value of Rc channel x must be used to output a PWM on gpio y If you want (no sense but allowed) you can output the same Rc channel to several gpio's.

Satcomix commented 9 months ago

Ok,thank you. What would make sense next? The time in the LUA software could still be minimized, from 900ms to 100ms...300ms. A complete script for the 20 functions so that everyone understands............??????? Do you have any ideas, otherwise I would leave it like that. Thank you for your work and effort Greetings, Torsten

mstrens commented 9 months ago

I do not see what should change in Lua script.

About test in oXs about sequencer there are still many things that can be tested, e.g.:

Those tests can be done once for SERVO output and once for ANALOG output

Satcomix commented 9 months ago

Hello Mstrens, I will begin testing tomorow, with all options of the oXs Sequenzer, for servo and for digital output. greetings, Torsten

mstrens commented 9 months ago

Thanks for all the tests you make

mstrens commented 9 months ago

By the way, can you also confirm if latest version still allows (or not) to get a PWM signal with a command Cxx=yy for different values of pwmHz. An issue is opened today about this. This is in principe not related to the sequencer feature.

Satcomix commented 9 months ago

Hello Mstrens, I just tested version 2.8.22 again with different PWMHZ values ​​and could not find any abnormalities with the FBUS protocol. What I've noticed in the last few days is that when I enter a command, the board no longer logs on correctly to the PC's USB. This means: Command C1=1 is entered, the board adopts this setting and boots, does an internal restart, the USB logs off and on briefly, then I have to re-synchronize/open the terminal window every time to check the settings. We have had this phenomenon several times a long time ago. What I also noticed: I used another board with version 2.4.5 for the test, when I installed ver.2.8.22 the error messages regarding sequencer, logger and esc came again. There are further problems in Ver.2.8.22: If I reopen the terminal window after entering a command/boot/restart and call up the terminal window with the ENTER command, the servos adjust from +100% to -100%. I.e. I moved the servos to the position 2012us/+100% via LUA with buttons 1-4, when I pressed the Enter button they set themselves directly to -100%. This happens with every Enter command, regardless of whether I enter a change or simply press the Enter key. Very strange. The debug messages are still helpful in the current test, but could also be turned off. Best regards, Torsten

No sequencers are defined Error in parameters: pin 0 is used 2 times Error in parameters: Logger baudrate must be in range 9600...1000000 Error in parameters: When gpio is defined for ESC, esc type must be HW4 or KON Error in parameters: pwmHz must be in range 50...333 (included)

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

mstrens commented 9 months ago

I think I understand why you get the Error in parameters msg when you upgrade a previously used RP2040. For a new RP2040, the flash memory has 0XFF in all bytes. When I save a config, the RP2040 has to save a full block of 256 bytes even if the config use only part of it. To save the config I define a buffer of 256 bytes and copy the config parameters at the begin. The rest of the buffer remains unchanged. The issue is in the way the buffer was initialized. I though that I filled the whole buffer with 0xFF (just like for a "blank" flash) but in fact I filled only the first byte with 0xFF and all others with 0X00.

The result is that when you upload a version that uses more parameters (and do not clear totally the flash), the new parameters are read as 0x00 instead of 0xFF and so usually are considered by oXs as a well defined value.

I can solve this for the future (for upgrade from 2.8.23 to an upper version) but not when a version lower than 2.8.23 has already been uploaded.