New Hubsan Upgraded Version on the way

More
30 Dec 2013 20:46 - 30 Dec 2013 20:50 #17499 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
That "for" function is not good there are more than 120 instances..plus the rx timing is variable ..
And the tx timing is variable too sometimes is 2.64ms other time is 2.68ms.
and the diference is on rx ......10 ms between frames is fixed so the rx is
10-2.64/2.68
Idk if working I'm not so much into PB code..I see something like that:
case DATA_5:
        hubsan_build_packet();
		ms=CLOCK_getms();
		CLOCK_ResetWatchdog();
		A7105_Strobe(A7105_STANDBY);
        A7105_WriteData(packet, 16, state == DATA_5 ? channel + 0x23 : channel);	
			while(1){
			if(!(A7105_ReadReg(A7105_00_MODE) & 0x01))//get 0x1A
			break;
			}
			A7105_Strobe(A7105_RX);//strobe rx
			while(CLOCK_getms()-ms <10)//till 10ms
		    {
            if(!(A7105_ReadReg(A7105_00_MODE) & 0x01)) // get 0x18data received ?
            {
                A7105_ReadData(packet, 16); // A7105_RST_RDPTR + 16x A7105_05_FIFO_DATA
                Telemetry.p.hubsan4.volt = packet[13];
                A7105_Strobe(A7105_RX);
            }
			}
			if (state == DATA_5)
            state = DATA_1;
		else
            state++;
        return 10000;

This the way I see it.
Last edit: 30 Dec 2013 20:50 by midelic.

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

More
30 Dec 2013 20:54 #17500 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way
The for( i=0; i<20; i++) is called every ms (7 times), 3ms after the packet is sent.
But that doesn't explain why this stop com with the quad.

Well ... maybe I should wait that I have a H107D before continuing but BNF is out of stock everywhere I've looked at.

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

More
30 Dec 2013 20:57 - 30 Dec 2013 20:59 #17501 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
yes i understand but i<20 doesn't seem right to me there are over 120 >20..or may be i misunderstood.
Last edit: 30 Dec 2013 20:59 by midelic.

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

More
30 Dec 2013 21:03 #17502 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
So the only problem is that you loose connection?

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

More
30 Dec 2013 21:03 #17503 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way
Yes

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

More
30 Dec 2013 21:04 #17504 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
when I got home I'll try my arduino code to see if working.

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

More
30 Dec 2013 21:06 #17505 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way
Thanks,

in fact issuing A7105_ReadReg(A7105_00_MODE) commands is enough to lose com, after a random amount of time...

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

More
30 Dec 2013 21:09 - 30 Dec 2013 21:20 #17506 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
That command should be part of a loop it should be also on tx side after strobe command 0xD0 , when all packets are sent......received 0x1A

You should have 2 loops one on tx and one on rx ...reading mode register and compare the value you get every loop.
One loop on tx(can be while(1)) ....when you get 0x1A, break.

The other loop is timed loop on difference till 10ms on Rx poled ....again mode register till get 0x18 .....if not timeout on more than 10ms.

and all sent packets resumed again.
That 10ms is carved in stone like Moses tablets..the rest varied a little.
Last edit: 30 Dec 2013 21:20 by midelic.

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

More
30 Dec 2013 21:39 - 30 Dec 2013 21:41 #17509 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
goebish
I see here in your code.

else{
delay=1000;
}
return delay
//
I thing should be return 10000//10000us
not return delay=1000//1000us
I see in PB code return 10000
Last edit: 30 Dec 2013 21:41 by midelic.

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

More
30 Dec 2013 21:41 - 30 Dec 2013 21:44 #17510 by PhracturedBlue
Replied by PhracturedBlue on topic New Hubsan Upgraded Version on the way
you cannot spend significant abmounts of time in the interrupt handler. You need to create new states to handle this.
after transmission, go into Rx mode, then return something like 8000 to return 8msec later.
Now check if you got any packets. If so, read them in. Then return 2000 and setthe state to be ready for the next iteration.

I haven't been following this thread closely enough to know what the proper timing is, but you should never busy-wait in an interrupt handler, and all protocol code is done in interrupt context.

The Devo code is a better example of how to do telemetry, even if the commands themselves don't apply to the A7105.

Note that the return value is the time from the last interrupt that you want to return. So regardless of what you do in the callback, the total sum of the return values should be 10000 so that you poll at a regular cadence. And make sure you never spend more time in the interrupt handler than the value you return (though generally it should be much, much less)
Last edit: 30 Dec 2013 21:44 by PhracturedBlue.

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

More
30 Dec 2013 21:43 #17511 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way

PhracturedBlue wrote: The Devo code is a better example of how to do telemetry, even if the commands themselves don't apply to the A7105.


My code is more like the Devo one, well... I'll find what's wrong :)

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

More
30 Dec 2013 21:46 #17512 by PhracturedBlue
Replied by PhracturedBlue on topic New Hubsan Upgraded Version on the way
If you need a hand, let me know, and I'll spend some time actually going over it, but probably not today.

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

More
30 Dec 2013 21:48 #17513 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way

PhracturedBlue wrote: If you need a hand, let me know, and I'll spend some time actually going over it, but probably not today.


Thank you, if you don't see anything obvious in the code I posted I'll scratch my head a little more, that's nothing urgent anyway, my priority was the vTX channel selection, who needs voltage telemetry when we have timers ? :whistle:

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

More
30 Dec 2013 22:00 - 30 Dec 2013 22:03 #17516 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
I remembered now why I didn't copy PB code...I didn't get it at that time(even now is difficult ) how his timer interrupt function works.Of course in a timer interrupt routine you have to stay the smallest amount of time possible.
Last edit: 30 Dec 2013 22:03 by midelic.

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

More
30 Dec 2013 22:00 #17517 by SeByDocKy
Replied by SeByDocKy on topic New Hubsan Upgraded Version on the way

goebish wrote:

PhracturedBlue wrote: If you need a hand, let me know, and I'll spend some time actually going over it, but probably not today.


Thank you, if you don't see anything obvious in the code I posted I'll scratch my head a little more, that's nothing urgent anyway, my priority was the vTX channel selection, who needs voltage telemetry when we have timers ? :whistle:


Me :) ... and you never know the real state of your LiPo ;)... So a double security is better than a unique one ;)

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

More
30 Dec 2013 22:03 #17518 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way

SeByDocKy wrote: Me :) ... and you never know the real state of your LiPo ;)... So a double security is better than a unique one ;)

That was a lazy dev joke only ;)

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

More
30 Dec 2013 22:04 #17519 by PhracturedBlue
Replied by PhracturedBlue on topic New Hubsan Upgraded Version on the way
Sorry, I got confused and was looking at midelic's code. I don't see anything wrong with your code. But my guess is that somehow you are going more/less than 10000us and are eventually getting out of sync. Looking at the timimg on a logic analyzer would likely be informative.

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

More
30 Dec 2013 22:07 #17520 by goebish
Replied by goebish on topic New Hubsan Upgraded Version on the way

midelic wrote: I remembered now why I didn't copy PB code...I didn't get it at that time(even now is difficult ) how his timer interrupt function works.Of course in a timer interrupt routine you have to stay the smallest amount of time possible.

Thta's why I use a for( i=0; i<20; i++) loop only (every ms) to check A7105_MODE register, we can't afford spending 10ms in the callback !

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

More
30 Dec 2013 22:12 #17521 by midelic
Replied by midelic on topic New Hubsan Upgraded Version on the way
Yes I get it now..I was thinking my way following exactly the spi dump
Sorry if I confused you ...better stick with my code it is easier for me.

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

More
30 Dec 2013 22:15 #17522 by PhracturedBlue
Replied by PhracturedBlue on topic New Hubsan Upgraded Version on the way
The only thing I see is that you don't check for write completion before switcing to Rx mode. After 3msec that really shouldn't be an issue, but it would be safer to verify that transmission has completed before strobing the A7105.

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

Time to create page: 0.098 seconds
Powered by Kunena Forum