"Flip" button on Syma X1/WLToys v949

er9x is the best known firmware. It has a superb range of features and is well supported by the community. Well worth trying out.
Post Reply
User avatar
blackmoon
Posts: 40
Joined: Wed Jun 13, 2012 7:49 pm
Country: -
Location: Belgium

Re: "Flip" button on Syma X1/WLToys v949

Post by blackmoon »

Kilrah wrote:Well I only tested r14 supplied by akkuschrauber (that nick will always make me laugh) and my current svn checkout (r17). My spectrum analyzer showed that r17 sent much lower power. Didn't have time to try intermediate revisions as it was my last chance to get it to work before I leave tomorrow, and I had to remove the programming headers to fit the stuff in a JR module case.
So based on this as your chip is low power in the first place I'd recommend r14 as you wouldn't want it to send with even lower power. I'm attaching the hex file I used.

I flashed it to an arduino nano using an usbasp and the following avrdude commands (overwriting the bootloader):

Code: Select all

avrdude -c usbasp -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDA:m -U efuse:w:0x05:m
avrdude -c usbasp -p m328p -U flash:w:ppm2spi.hex:i
What's the advantage of overwriting the bootloader ?

Faster boot up and chances of binding increased ?

Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Code: Select all

avrdude -c usbasp -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDA:m -U efuse:w:0x05:m
avrdude -c usbasp -p m328p -U flash:w:ppm2spi.hex:i
Would I use these same commands to flash a regular (not arduino) Atmega328?
And does the chip have to be connected to the crystal and/or capacitors when flashing?
Thanks.
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

akkuschrauber wrote:In r14 of the code I left the Led's, there's no need of them, but in the new one you will need it.
You just need the Bind Button only one time for first bind process, so it is possible to use some kind of jumper, but you could integrate it easy, watch my first version of Cam's great work on page 3.
Yep seen your module, making mine the same way. I have all the stuff to etch a double sided board but the last time I made a board it was messy and time consuming, so protoboard it is.
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: "Flip" button on Syma X1/WLToys v949

Post by Kilrah »

Yes those commands would be the same for a blank chip, maybe with an additional "-B 100" in the first line in case your programmer is too fast for the internal oscillator.
After the first line is executed the mega328 will be using the crystal, so yes it would have to be connected or the 2nd line will fail. You could swap the 2 and add the -B 100 on both if you wanted to do it with the processor not soldered to the board. But then subsequent reflashings would require the crystal for sure.
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: "Flip" button on Syma X1/WLToys v949

Post by Kilrah »

blackmoon wrote:What's the advantage of overwriting the bootloader ?
Most likely none, but as my module was not working it was one less potential source of problems. If you keep it you could flash the hex using the bootloader instead of an external programmer.

User avatar
blackmoon
Posts: 40
Joined: Wed Jun 13, 2012 7:49 pm
Country: -
Location: Belgium

Re: "Flip" button on Syma X1/WLToys v949

Post by blackmoon »

I just found one module board that I didn't use from the neTX (nine eagle) project.

Image

Image

It also uses hardware SPI, I made the following modification to the code to adapt it to the this board.

I think the current revision (14k on disk) should fit in the 16k of the mega168 on it.

Could someone tell me if the modifications made in common.h and ppm2spi.c are correct ? (I think it is only those two files that need editing)

I need to remap :

BIND_SW to PC4

BIND_LED to PD5

FLYSKY_LED to PD3

HUBSAN_LED to PC1

CS to PB2

In common.h file :

Code: Select all

#define BIND_SW_READ() 	(PINC & (1<<BIND_SW))

#define SPI2 2

#define gpio_set(sfr,bit) (sfr) |=   1<<(bit)
#define gpio_clear(sfr,bit) (sfr) &= ~(1<<(bit))

//Port C
//#define SPI_CS			3
#define	BIND_SW			4
#define LED_G 1  // LED green

//Port B
#define PPM_IN			0
#define DEBUG_1		    1
//#define DEBUG_2     	2
#define SPI_CS			2

#define CS_HI() 		gpio_set(PORTC, SPI_CS)
#define CS_LO() 		gpio_clear(PORTC, SPI_CS) 

//Port D
//#define LED_G 2  // LED green
#define LED_R 3  // LED red
//#define LED_Y 4  // LED yellow
#define LED_O 5  // LED orange
By the way, the #define SPI2 2 is only found here.

What does it do, or is for a future release ?

In ppm2spi.c

Code: Select all

int main (void)
{

Model.fixed_id = 0x00102030;
Model.num_channels = 8;
Model.tx_power = TXPOWER_100mW ;

PORTB=0;
gpio_clear (DDRB, PPM_IN);  // Input  pin0
gpio_set   (DDRB, DEBUG_1); // Output pin1
//gpio_set   (DDRB, DEBUG_2); // Output pin2 (SS output - General purpose output pin)
gpio_set   (DDRB, SPI_CS);
gpio_set   (DDRB,3);        // MOSI output 
gpio_clear (DDRB,4);        // MISO input
gpio_set   (DDRB,5);        // SCK output

PORTC=0;
gpio_clear (DDRC, BIND_SW);  // Input pin4
gpio_set   (PORTC,BIND_SW);  // Pull up resistor on pin4
gpio_set   (DDRC, LED_G);  // LED green
//gpio_set   (DDRC, SPI_CS);   // Output pin3

PORTD=0;
gpio_clear (DDRD, 0);  // Serial Rx input
gpio_set   (DDRD, 1);  // Serial Tx output
//gpio_set   (DDRD, LED_G);  // LED green
gpio_set   (DDRD, LED_R);  // LED red
//gpio_set   (DDRD, LED_Y);  // LED yellow
gpio_set   (DDRD, LED_O);  // LED orange(bind)
In the same file I erased the yellow led reference since I don't use FLYSKY_MOD, but left the if statement, I think it's needed for the rest of the code.

Code: Select all

chtemp = Channels[7];

if ( chtemp <= (CHAN_MIN_VALUE+MARGIN))                        
	{proto_mode=FLYSKY_STD; gpio_set(PORTD,LED_R);}
if ((chtemp <= (NEUTRAL+MARGIN     )) && (chtemp >= (NEUTRAL-MARGIN    ))) 
	{proto_mode=FLYSKY_MOD;}
//	{proto_mode=FLYSKY_MOD; gpio_set(PORTD,LED_Y);}
if ( chtemp >= (CHAN_MAX_VALUE-MARGIN))                        
	{proto_mode=HUBSAN_STD; gpio_set(PORTD,LED_G);}
Thank you.
User avatar
blackmoon
Posts: 40
Joined: Wed Jun 13, 2012 7:49 pm
Country: -
Location: Belgium

Re: "Flip" button on Syma X1/WLToys v949

Post by blackmoon »

Tried to compile with WinAVR and got the following error :

Code: Select all

avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c a7105.c -o a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c flysky_a7105.c -o flysky_a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c hubsan_a7105.c -o hubsan_a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c misc.c -o misc.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c spi.c -o spi.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c ppm2spi.c -o ppm2spi.o
ppm2spi.c:38: error: 'FLYSKY' undeclared here (not in a function)
make: *** [ppm2spi.o] Error 1
The line avr-gcc is complaining about is in global variables :

uint8_t proto_mode = FLYSKY;

it is defined as "extern" in common.h

extern uint8_t proto_mode;

As a trial and error fix, I tried to replace FLYSKY by FLYSKY_STD and got the following errors :

ppm2spi.o: In function `main':
ppm2spi.c:(.text.main+0xb8): undefined reference to `HUBSAN_Cmds'
ppm2spi.c:(.text.main+0xce): undefined reference to `FLYSKY_Cmds'
ppm2spi.c:(.text.main+0xda): undefined reference to `FLYSKY_Cmds'
make: *** [ppm2spi.hex] Error 1

I'm lost, help :D

EDIT:

Think I found it :

- reverted to : uint8_t proto_mode = FLYSKY;

- mapped DEBUG_2 to PORTC 5.

- edited the makefile to read :

Code: Select all

...
CFLAGS  = -Wall -gdwarf-2 -std=gnu99 -DPROTODEF -DPROTO_HAS_A7105 -DFLYSKY -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -DNRF_CHECK_MODULE

LFLAGS  = -Wl,--relax,--gc-sections

OBJECTS = a7105.o flysky_a7105.o hubsan_a7105.o misc.o spi.o $(TARGET).o
...
 
I didn't include spi_bitbang.o in the object files because it generates a bunch of errors.

Since we are using hardware SPI, and the stuff belonging to bitbang in pp2spi.c is commented, I assume it's not necessary.

I'm I right ?

Anyway it compiled without further warnings or errors :

Code: Select all

avr-objcopy -j .text -j .data -O ihex ppm2spi.elf ppm2spi.hex
avr-size -C --mcu=atmega168 ppm2spi.elf
AVR Memory Usage
----------------
Device: atmega168

Program:    4562 bytes (27.8% Full)
(.text + .data + .bootloader)

Data:        429 bytes (41.9% Full)
(.data + .bss + .noinit)
Now to see if it works... :D
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Hmmmm.... Smart phone controlled quad anyone? :D

http://www.hobbyking.com/hobbyking/stor ... droid.html
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Do you guys think that it might be able to be modified or re-flashed to work with the Hubsan X4?
User avatar
JohnEdwa
Posts: 16
Joined: Wed Jul 25, 2012 9:45 pm
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by JohnEdwa »

The output power of the Magic Cube is 10mW, so the range is tiny.
And if that is the Version 1, you don't want it :)
"No fail safe for the magic cube. If it shuts off due the battery runs out or if the connection is broke even for a split second
the helicopter or quad will take off on its own with no response with the controller including throttle hold.
Walkera should address this issue if possible unless they can’t make a fail safe using the TX and magic cube together."
- http://www.rcproreviews.com/walkera-rc- ... be-mtc-01/
And I think the chip inside is not compatible with the Hubsan X4 protocol..?
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: "Flip" button on Syma X1/WLToys v949

Post by Kilrah »

Smartphone control is awful. Nowhere near the feel and precision of sticks. Fun as a toy for a few minutes but it stops there IMO.

Walkera indeed uses a different RF chip than hubsan, so no compatibility.
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

blackmoon wrote:By the way, the #define SPI2 2 is only found here.
It's to fit in with the Devention functions, it originally selects the SPI port on the ARM processor but here it's just stopping complier errors.

2nd vote for awful control by mobile phone here !

New connectors arrived, looks perfect, just need to footprint them.
akkuschrauber
Posts: 57
Joined: Wed Sep 12, 2012 5:06 pm
Country: -
Location: Dortmund
Contact:

Re: "Flip" button on Syma X1/WLToys v949

Post by akkuschrauber »

Mobile phone controlled drone is one step closer to total world controll ...
Ask yourself, why do you got one "extra" cam built in, facing you, while you typing messages etc. ?
One hint: It's not only for "facetime" :D Wake up people, bevore it's getting too late ;-)

Anyone got seen this movie:
http://en.wikipedia.org/wiki/Eagle_Eye

Want to see an relative actual (short) movie about that ?
http://vimeo.com/33555548

Sorry, only in german, but I think you get that, if you only watch the movie.
ACTA (as planed) was yesterday, INDECT (and much more!) is on its way ...
In real, there are much more possibilities to play Stasi 2.0,
more subtile and every one becomes a (unwanted) helper for that !

Am I paranoid ? Not enough I think :D
Know your enemy ...

3rd vote for no iControl at all !
Ironie: read [Wikipedia.de] http://de.wikipedia.org/wiki/Sarkasmus
User avatar
JohnEdwa
Posts: 16
Joined: Wed Jul 25, 2012 9:45 pm
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by JohnEdwa »

akkuschrauber wrote:...drone...
Do not use that word lightly my friend...
Too many people overthink it, and are the reason we might not have fun things in the future.

For most people, a Drone is something that flies autonomously, you are able to set waypoints for it to fly to, and could be used by TERRORISTS (!1one) to KILL EVERYONE (!1one).
For educated and rational people, it is only the first one, but sadly we are a minority.

Seriously, just check wikipedia:

Code: Select all

Drone may refer to:
Vehicles:
    Robot in general
        Unmanned vehicle
            Unmanned aerial vehicle
                Unmanned combat aerial vehicle
            Remotely operated underwater vehicle
            Unmanned ground vehicle
        Target drone
akkuschrauber
Posts: 57
Joined: Wed Sep 12, 2012 5:06 pm
Country: -
Location: Dortmund
Contact:

Re: "Flip" button on Syma X1/WLToys v949

Post by akkuschrauber »

JohnEdwa wrote:
akkuschrauber wrote:...drone...
Do not use that word lightly my friend...
You're right, I totally forgotten that I'm not free in this world ... sadly learned that in the past :D
Ironie: read [Wikipedia.de] http://de.wikipedia.org/wiki/Sarkasmus
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

ok i've got all my components sourced and the A7105 arrived today, breadboarded it all up and flashed the chip. I'm getting a green light from pin 6 indicating Hubsan protocol but it wont bind to the hubsan reciever (lights keep flashing).
I measured: 0.25v, 3.65v, 3.4v on sck, sdio, scs respectively in between the 2k and 1k resistors, on the schematic they should be around 3v?? :S
4.85v from 5v reg (also gets very hot, drawing 180mA with 10.8v input, 400ma with 4.85 output.)
3.2v from 3.3v reg

I've double checked the connections, everything seems ok, what could it be?
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Had the resisters wired wrong, now im getting: SCK 0.36v, SDIO 3v, SCS 2.4v.
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Still doesn't bind.
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

Does the bind LED (orange) come on at all ? It should do so at every switch on while in Hubsan protocol.
180ma seems very high for the current draw from the 5v reg. It's only powering the ATMega and the LEDs. I suspect something amiss with the processor, does it get warm ? Is there any indication code is actually running on the device ? i.e. can you change the modulation mode, does the bind LED come on then go off ?

Have you wired it for the updated firmware that uses hardware SPI ?

I think I would try and get simple blinky program running. If that fails you are looking at hardware or fuse settings.

Measuring the SPI pins for voltage is meaningless as they should all be digital signals, really you need a scope or logic analyser to look at them.

EDIT: You have got the A7105 module on the 3.3v rail ? That would explain the high current draw.

Cam.
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

th9xer wrote:Does the bind LED (orange) come on at all ? It should do so at every switch on while in Hubsan protocol.
180ma seems very high for the current draw from the 5v reg. It's only powering the ATMega and the LEDs. I suspect something amiss with the processor, does it get warm ? Is there any indication code is actually running on the device ? i.e. can you change the modulation mode, does the bind LED come on then go off ?

Have you wired it for the updated firmware that uses hardware SPI ?

I think I would try and get simple blinky program running. If that fails you are looking at hardware or fuse settings.

Measuring the SPI pins for voltage is meaningless as they should all be digital signals, really you need a scope or logic analyser to look at them.

EDIT: You have got the A7105 module on the 3.3v rail ? That would explain the high current draw.

Cam.
Yeh the bind led comes on with the hubsan led, and turns off a few seconds later.
The 3.3v reg is actually connected to the 5v out, thought the 3.3v reg might get too hot powering the module and cutting 10-12.6v down to 3.3v, the 3.3 im using is a smd with legs soldered on.
The 328 doesn't get warm, yes the code seems to work correctly, I can change ch8 on my 9x and change the protocol.

"Have you wired it for the updated firmware that uses hardware SPI ?"
Not sure what you mean, im using the .hex from r24 and following the schematic from r31.
Yes the module is connected to the 3.3v

Off to uni now but when I get back i'll start over.
Thanks for the help!
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Also, you said in a previous post, when ch8 is high on startup hubsan protocol is selected, but I can only get the green led (D4) to light when ch8 is neutral or "midstick".
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Ok, re-flashed the chip (r24) with everything connected, and now it binds to the hubsan (solid lights) only when ch 8 is high, but the green led is off? It only has solid lights though, no response from throttle. :(
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

Powering the 3.3v reg via the 5v reg will explain why the 5v reg is burning up. The actual schematic has the 3.3v reg powered directly from the battery, and it a big reg to.

Your problem of binding but no throttle sounds very similar to Kilrah's. Are you using the Ali Express A7105 500m module, and have you tied the TXEN pin high ? Does it work at really close range ?
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

I bought this exact chip: http://www.aliexpress.com/item/A7105-50 ... 01913.html
Yes TXEN is tied to 3.3v.
My module has writting on the back that isn't in the pictures from the above link. It says XL7105-D03.

edit: still not working even with the receiver right next to the antenna.
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

This has me stumped. It's not one of the new LED X4's ?

Lets start with the green LED..... Hold on spotted mistake in LED ordering on schematic. You should have the red LED lit for Hubsan protocol. Commiting the correction to the schematic now. Sorry !!!
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Its the original hubsan receiver, still works with the original transmitter.
Here a pic of the module.
Attachments
20130528_193519.jpg
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

Yup same module as me. Can you verify you have the RED LED lit ? Or if you have corrected the circuit as per r42 it should now be green.
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

Yep getting high on PD2 for hubsan protocol as it is on r42
Hman545
Posts: 33
Joined: Tue May 07, 2013 10:34 am
Country: -

Re: "Flip" button on Syma X1/WLToys v949

Post by Hman545 »

I'm thinking it might be my atmega chip, I have another one thats soldered into a board but it's not in a chip holder, so i'll have to dremel the pcb and desolder it. It's through hole.
th9xer
9x Developer
Posts: 167
Joined: Fri Jan 20, 2012 11:09 pm
Country: -
Location: Beside the seaside

Re: "Flip" button on Syma X1/WLToys v949

Post by th9xer »

Sounds like the code is running ok. PD2 is right for Hubsan. Trying another processor is worth a shot, don't suppose you have another A7105 module to try ?

It might also be possible your 5v regulator is entering protective shutdown and limiting power, and this is causing problems. I notice you are using a TO220 package reg ? Try a heatsink on it, even if it's not a cure it will still love you for it :)

Cam.
Last edited by th9xer on Tue May 28, 2013 11:01 am, edited 1 time in total.

Post Reply

Return to “er9x”