HiSky HCP60 3G/6G mode switching

More
16 Jan 2016 06:51 - 17 Jan 2016 17:13 #41816 by cyuryo
HiSky HCP60 3G/6G mode switching was created by cyuryo
Recently I got HiSky HCP60 and flew it with my Devo8S+deviation.
It flies well, but it is always in 6G mode, and can't switch to 3G mode.

I tried with various values on ch5 or ch7, but they make no difference.

I read the source code "hisky_nrf240l1.c" and have noticed packet takes only
restricted value. In the HiSKy protocol, packet values are between 0 and 1000.
When you set fixed channel data via the mixer screen, the value is from -100 to 100.
So, as log as you set the fixed value via the mixer,
packet values are non-contiguous, 0, 1, 5, 9, 13, .. and so on.

After some experiments, I found 3G mode is activated when ch7 packet value is 2 or 3.
But unfortunately, as described above, without code modification, you can't set
ch7 packet value either 2 or 3.

The simplest way to make it possible to set these values is just adding 2 to
the packet value in the source code "hisky_nrf24l01.c".
   static void build_ch_data() {
     ...
     ch_data[i] = (unsigned int)temp + 2; // just add 2
     ...
   }
This modification changes packet value to 2, 3, 7, 11,.. instead of original 0, 1, 5, 9 ..
then the packet value of ch7 can be set to 2 by setting fixed mixer value
small enough, e.g., -120.

And you need to increase a number of channels so that you can set ch7 in a mixer.
   const void *HiSky_Cmds(enum ProtoCmds cmd) {
        ...
        case PROTOCMD_NUMCHAN: return (void *)8L;        // change 6L->8L
        ..
   }

That's enough, but instead of simply adding 2 to the packet,
I modified the code so that you can offset the packet value by changing a ch8 value.
This may not be necessary. It is just for adding more flexibility.
static void build_ch_data() {
      ....
        temp = (s32)Channels[7] * 450/CHAN_MAX_VALUE + 500;
        temp = (temp%16)/4;
        ch_data[i] += temp;
      ....
   }
For example, if you set fixed value 1 to ch8 in the mixer, temp value is 501,
then offset is calculated by the formula (501%16)/4, results 2,
accordingly every packet value offsets by 2.

note1: code is based on version 4.0.1, not the latest nightly build. 
If you try attached devo8.dfu, be careful about tx.ini and hardware.ini.

note2: these are the modified functions and modified parts are marked by "//!ST"
  • build_ch_data()
    shift all packet values, depending on ch8 value.
  • HiSky_Cmds()
    set maximum channel to 8, so that you can set ch7 and ch8.

note3:
ch7 packet value and result gyro mode.
channel7channel8
mixerpacketmixerpacketmode
-1200-14996G
-120105006G
-120215013G
-120325023G
-120035036G

note4
Attached files are
  • hisky_nrf24l01.c modified source
  • model7.ini sample model file. fmod1,2 3G mode, else 6G mode
  • .doc mixer setting screen .doc file.
  • devo8.dfu dfu file for devo8S , version shows as "devo8-v4.0.1+"

Sorry for my poor English, but I hope that someone will merge this modification
to the deviation source tree.

P.S.
That is irregular to use ch8 for the specific purpose,
if the deviation can set arbitrary packet value, e.g. 2, on the mixer screen,
that is more desirable.
Attachments:
Last edit: 17 Jan 2016 17:13 by cyuryo.

Please Log in or Create an account to join the conversation.

More
19 Jan 2016 02:36 - 23 Jan 2016 14:58 #41928 by cyuryo
Replied by cyuryo on topic HiSky HCP60 3G/6G mode switching
Wasp09 SAN pointed out that the nightly-build hisky_nrf24l01.c already has the code that can set  value 3 to channel 7 packet.

Sorry, I missed out on checking the nightly-build source.

P.S.
In the nightly-build mixer , values less or equal to zero results packet value 0, otherwise packet value is 3 for channel 7.
Last edit: 23 Jan 2016 14:58 by cyuryo. Reason: Typo

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum