T2ThTrig not working on companion9x

A fork of eePe. It's aim is to provide one tool that works with ALL firmwares!
Post Reply
wallaguest1
Posts: 121
Joined: Mon Jan 02, 2012 9:56 am
Country: -

T2ThTrig not working on companion9x

Post by wallaguest1 »

hi,
in the "simulator" of companion9x, i activate T2ThTrig and the timer 2 is always running, no matter if i have thr at 0 value,
so i guess its a bug

Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: T2ThTrig not working on companion9x

Post by Romolo »

Which firmware ?
wallaguest1
Posts: 121
Joined: Mon Jan 02, 2012 9:56 am
Country: -

Re: T2ThTrig not working on companion9x

Post by wallaguest1 »

last one, 760 and early versions
bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: T2ThTrig not working on companion9x

Post by bertrand35 »

You simulate the er9x firmware. I just did a quick try, the parameter is well shared beween companion9x and the simulator.
Could you explain what is the T2ThTrig parameter? I see that the Timer2 is started and stopped with the [MENU] button.

Bertrand.
wallaguest1
Posts: 121
Joined: Mon Jan 02, 2012 9:56 am
Country: -

Re: T2ThTrig not working on companion9x

Post by wallaguest1 »

in the radio the timer 2 start itself when the throttle value is above 0
but at the simulator it start even if its 0, its like always "on"

Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: T2ThTrig not working on companion9x

Post by Romolo »

I'm trying to understand what is wrong.... the release embedded now is 760 so should be the same as your one..
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

FYI, this is enableded in the software by g_model.t2throttle, and actioned a few lines into trace() in menus.cpp

Code: Select all

    uint16_t val = calibratedStick[CONVERT_MODE(3)-1]; //Get throttle channel value
    val = (val+RESX) / (RESX/16); //calibrate it
    if ( g_model.t2throttle )
    {
        if ( val >= 5 )
        {
            if ( Timer2_running == 0 )
            {
                Timer2_running = 3 ;  // Running (bit 0) and Started by throttle (bit 1)
            }
        }
    }
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: T2ThTrig not working on companion9x

Post by Romolo »

Yes I see that val in companion ranges from 32 and 1024...
g_model.t2throttle is properly setup by companion, what seems wrong is "val"
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

val is set on the lines above (edited in my previos post). val should go from 0 to 32.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: T2ThTrig not working on companion9x

Post by Romolo »

The problem is here:

val before "calibration" ranges from 64512 to 1024
64512 + 1024 is too much for uint16_t;
writing the code in this way it works:

uint16_t val = (uint16_t)(RESX + calibratedStick[CONVERT_MODE(3)-1]);
val /= (RESX/16); //calibrate it

we can either change it in companion (by patching the code) or even better you may change it in er9x.
btw Mike, it will be nice to have companion patches included in er9x, it will make development of companion much more easy.
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

Yes, calibratedStick is an int16_t, which is why the RESX is added to it. The compiler for companion probably does some extra conversions.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: T2ThTrig not working on companion9x

Post by bertrand35 »

The compiler for companion works on 32bits

1) -1024 converted to an uint16_t means 64512.
2) This line: val = (val+RESX) / (RESX/16); //calibrate <= there is no cast here, so on a 32bits arch it will not give 0!

That's why companion will not simulate correctly what is done on the stock board. Then I think it would be better to write:

Code: Select all

uint16_t val = (uint16_t)(RESX + calibratedStick[CONVERT_MODE(3)-1]);
val /= (RESX/16); //calibrate it
It should not take more flash. On the Arm, I think you will have the same problem, am I right?

Bertrand.
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

I'll change er9x, the code stays the same size, the ARM doesn't have the same problem as I changed it to have two, fully triggerable timers, with two trigger sources each.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: T2ThTrig not working on companion9x

Post by bertrand35 »

Thanks Mike! Did you have time to continue working on the patch I sent you? No need to integrate everything before commiting, we will adjust our patch and send you first feedback ... And if no time, no problem either !

Bertrand.
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

I have some of the patch in, but I'm also working on another update as well, so they will get committed at the same time.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
G550Ted
Posts: 389
Joined: Tue Dec 27, 2011 6:15 pm
Country: -
Location: Savannah, GA, USA

Related Issue?

Post by G550Ted »

After flashing er9x r760 to both of my radios the Turnigy second timer can no longer be stopped/restarted with the menu button. Works fine on my FlySky radio. All other functions also work OK. No hardware mods to either radio. Strange this, makes no sense!

Ted
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: T2ThTrig not working on companion9x

Post by MikeB »

You are right, it makes no sense, I can't think of a reason.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

Post Reply

Return to “companion9x”