- Posts: 174
New Hubsan Upgraded Version on the way
- midelic
- Offline
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.
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
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.
- midelic
- Offline
- Posts: 174
Please Log in or Create an account to join the conversation.
- midelic
- Offline
- Posts: 174
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
Please Log in or Create an account to join the conversation.
- midelic
- Offline
- Posts: 174
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
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.
- midelic
- Offline
- Posts: 174
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.
Please Log in or Create an account to join the conversation.
- midelic
- Offline
- Posts: 174
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
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
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)
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
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.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
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 ?
Please Log in or Create an account to join the conversation.
- midelic
- Offline
- Posts: 174
Please Log in or Create an account to join the conversation.
- SeByDocKy
- Offline
- Posts: 1016
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 ?
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.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
That was a lazy dev joke onlySeByDocKy wrote: 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.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- goebish
- Offline
- I Void Warranties
- Posts: 2631
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 !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.
Please Log in or Create an account to join the conversation.
- midelic
- Offline
- Posts: 174
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.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Protocol Development
- New Hubsan Upgraded Version on the way