HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Jan 10, 2013, 02:57 AM
wjs
William
United States, MI, Brighton
Joined Oct 2012
1,966 Posts
Here is an interesting method to bypass the gyro all together for turn off mode. Giving rx direct control.
https://sites.google.com/site/2007ar...erface-dxi-dxo
wjs is offline Find More Posts by wjs
Reply With Quote
Sign up now
to remove ads between posts
Old Jan 10, 2013, 08:24 AM
Registered User
Joined Dec 2006
1,443 Posts
there are probably lighterweight implementations of the i2c access libraries that i can use (multiwii is one case) and hopefully do not disable interrupts. this would be higher priority.

will be using timer1 eventually (next). 16bit makes it ALOT more convenient to implement the servo out code. 16bit at 1us/cycle == 32.768ms before overflow, which is >> 2-ish ms for rc pulses. currently, i work with 8 bit at 4us/cyc = 1.024ms, which is < 2ms, so some footwork is needed to handle the overflow.


Quote:
Originally Posted by Odysis View Post
Some read/write operations (i.e. 16bit ones) need to disable ISRs as they take two clock cycles to complete. that might be one reason you're seeing small ISR disable periods.

Why they're doing that in the I2C I don't know.

Edit: Just had a look at your code. Using micros() will give you a 4us best case resolution. Why not use TCNT1 like you have with Timer0?
noobee is offline Find More Posts by noobee
Last edited by noobee; Jan 10, 2013 at 08:30 AM.
Reply With Quote
Old Jan 10, 2013, 08:54 AM
Registered User
Joined Dec 2006
1,443 Posts
Quote:
Originally Posted by wjs View Post
Here is an interesting method to bypass the gyro all together for turn off mode. Giving rx direct control.
https://sites.google.com/site/2007ar...erface-dxi-dxo
interesting, it looks like only 2 of the 3 modes are supported if you connected both rx and servo?
- servo out
- pass through

is it possible to read the rx without affecting the servo? (if both are connected).

another interesting idea is to use the s/w isr to just shadow the rx in signals directly to servo out on aux_in gain ~= 0, this would result in lower and less varying latency. i'll look into the lock-free stuff first though..
noobee is offline Find More Posts by noobee
Reply With Quote
Old Jan 10, 2013, 11:30 AM
Registered User
Joined Dec 2007
569 Posts
Multiwii has a interrupt block free I2C and i think also the itg3200 library.

The way to get rid of all jitter caused by concurrent irq's is to proper serialize the actions. Read, calculate, write. I assume calculate is 2ms max, write is 4*2ms = 8ms max, read is 8ms if the channels are consecutive. Fits into a 20ms frame.

From my time with KK board i had a parallel servo out routine for i think 4 channels with decent resolution, using no timer at all and doing the job in 2ms (all 4 channels). There was a asm file and C header for that. Any intrest i dig that out of my old winxp.

Read is the problem, since the order of the channels is brand specific. But this system should be doable with some brand defines. In a 20ms frame only the output frame generation is taboo, means input can use 12ms (or 18ms for parallel out).

Edit:
Attached the asm file for 3 channels and the C header for it. No idea if it works with arduino, but it does with avrstudio. The code is for 3 channels 8 mhz, 512 resolution (520 to 1040 input). On a 16mhz 4 channels should be easy doable.
Cesco is offline Find More Posts by Cesco
Last edited by Cesco; Jan 10, 2013 at 11:52 AM.
Reply With Quote
Old Jan 10, 2013, 12:39 PM
wjs
William
United States, MI, Brighton
Joined Oct 2012
1,966 Posts
Quote:
Originally Posted by Cesco View Post
Multiwii has a interrupt block free I2C and i think also the itg3200 library.

The way to get rid of all jitter caused by concurrent irq's is to proper serialize the actions. Read, calculate, write. I assume calculate is 2ms max, write is 4*2ms = 8ms max, read is 8ms if the channels are consecutive. Fits into a 20ms frame.

From my time with KK board i had a parallel servo out routine for i think 4 channels with decent resolution, using no timer at all and doing the job in 2ms (all 4 channels). There was a asm file and C header for that. Any intrest i dig that out of my old winxp.

Read is the problem, since the order of the channels is brand specific. But this system should be doable with some brand defines. In a 20ms frame only the output frame generation is taboo, means input can use 12ms (or 18ms for parallel out).

Edit:
Attached the asm file for 3 channels and the C header for it. No idea if it works with arduino, but it does with avrstudio. The code is for 3 channels 8 mhz, 512 resolution (520 to 1040 input). On a 16mhz 4 channels should be easy doable.
Funny, I was just thinking the same thing. Blocking on reads is a real cpu waste, but in the end may better for the whole system then varience of interrupts, locks, etc. A single threaded system is tons easier (and faster in many cases) if you can wiggle the pattern to fit.
wjs is offline Find More Posts by wjs
Reply With Quote
Old Jan 12, 2013, 11:49 AM
Registered User
Joined Dec 2006
1,443 Posts
an update:

i've merged back some of the latency/jitter improvement code back to the master branch.

key changes so far:
- used 16bit timer1 for rx in and servo out. this reduced the background jitter from +/- 5us to about +/- 1 us. thanks for the heads up on the overflow math pointer.
- implemented a polling based I2C_LIGHT i2c and imu functions (referenced from multiiwii). this reduced the occasional "significant" jitter.

next changes:
- synchronize rx in and servo out to reduce latency. the goal is to reduce it to << 1 servo frame (and even < 1 channel pulse width) in the common case. once any rx channel arrives (trailing edge), apply the most recent pid correction and immediately emit the corresponding servo channel out. done on a per-channel basis. will work well if the rx in channels arrive serially (most cases). will also give the opportunity to schedule pid compute and i2c accesses when the system is "idle". finally, it will also follow the rx behaviour for failsafe (hold last position or remove pulses altogether).
noobee is offline Find More Posts by noobee
Reply With Quote
Old Jan 12, 2013, 11:59 AM
Registered User
Joined Dec 2006
1,443 Posts
cool, thanks for the file and pointers.

emitting all channels out in parallel and using the cpu to poll would work well, particularly if we have to serialize these actions with the input, i2c read and pid.

i think, so far, most implementations work at the servo frame level: they read all the inputs (assume they arrive sequentially), compute all the results, then output to all the servos (either sequentially or in parallel). thus, they will introduce a lag of roughly at least one servo frame interval (unless they can detect which is the last arriving rx channel in the frame).

i'll try to reduce that by treating the channels individually (described in the previous post) and also try to sequence the activities slightly better..

think that would work?

thanks


Quote:
Originally Posted by Cesco View Post
Multiwii has a interrupt block free I2C and i think also the itg3200 library.

The way to get rid of all jitter caused by concurrent irq's is to proper serialize the actions. Read, calculate, write. I assume calculate is 2ms max, write is 4*2ms = 8ms max, read is 8ms if the channels are consecutive. Fits into a 20ms frame.

From my time with KK board i had a parallel servo out routine for i think 4 channels with decent resolution, using no timer at all and doing the job in 2ms (all 4 channels). There was a asm file and C header for that. Any intrest i dig that out of my old winxp.

Read is the problem, since the order of the channels is brand specific. But this system should be doable with some brand defines. In a 20ms frame only the output frame generation is taboo, means input can use 12ms (or 18ms for parallel out).

Edit:
Attached the asm file for 3 channels and the C header for it. No idea if it works with arduino, but it does with avrstudio. The code is for 3 channels 8 mhz, 512 resolution (520 to 1040 input). On a 16mhz 4 channels should be easy doable.
noobee is offline Find More Posts by noobee
Reply With Quote
Old Jan 12, 2013, 01:45 PM
Registered User
florida
Joined Nov 2002
187 Posts
I originally erased my V1 with the Hobbyking programmer.I jumped the gun and fed the 5 volts into it and figured I had destroyed the gyros. Once I had the first Hex file I figured why not try it so I wrote it to the chip.It Works !!!. I guess I was lucky not to damage the gyro's but maybe its OK to apply 5 volts.Next I'll try the new updated hex and let you know.
flightdeck is offline Find More Posts by flightdeck
Reply With Quote
Old Jan 12, 2013, 02:20 PM
Registered User
Joined Dec 2006
1,443 Posts
i don't think the itg3205 will like 5v vcc very much. try disconnecting the vcc line from the programmer and power the rx3s v1 via an rx or bec instead. this will use the onboard regulator to provide the 3.3v to both processor and itg3205.

thanks.


Quote:
Originally Posted by flightdeck View Post
I originally erased my V1 with the Hobbyking programmer.I jumped the gun and fed the 5 volts into it and figured I had destroyed the gyros. Once I had the first Hex file I figured why not try it so I wrote it to the chip.It Works !!!. I guess I was lucky not to damage the gyro's but maybe its OK to apply 5 volts.Next I'll try the new updated hex and let you know.
noobee is offline Find More Posts by noobee
Reply With Quote
Old Jan 12, 2013, 02:40 PM
Registered User
idonasch's Avatar
Germany, Berlin
Joined Jun 2004
72 Posts
Bricked my V1...

I tried to upgrade to 20130112 while the unit was installed in the system, now the unit is "bricked". bummer, worked fine this morning, but now the programmer complained "Power on failed - can't communicate". (yes, I had the unit powered on from an external battery and I'm sure not to program the fuses!). used a USBASP, anybody any idea how to un-brick?
idonasch is offline Find More Posts by idonasch
Reply With Quote
Old Jan 12, 2013, 02:54 PM
Registered User
florida
Joined Nov 2002
187 Posts
extreme burner says" RX3S_v1_20130112 " corrupt hex file .Rechecked link is not to raw Hex file.
flightdeck is offline Find More Posts by flightdeck
Last edited by flightdeck; Jan 12, 2013 at 03:16 PM.
Reply With Quote
Old Jan 12, 2013, 03:04 PM
Registered User
United States, NC, Raleigh
Joined Oct 2011
855 Posts
Quote:
Originally Posted by idonasch View Post
I tried to upgrade to 20130112 while the unit was installed in the system, now the unit is "bricked". bummer, worked fine this morning, but now the programmer complained "Power on failed - can't communicate". (yes, I had the unit powered on from an external battery and I'm sure not to program the fuses!). used a USBASP, anybody any idea how to un-brick?
I wiped out a V2 while programming. I am using the HK programmer that has a jumper to be able to program without supply voltage from the programmer. I started an update and noted that my ESC was not connected to the battery and I immediately connected it without stopping the programmer. Never worked again "can't communicate". I verified that the MISO pin on the processor no longer works, I suspect bond out wire from the chip to the package pin acted like a one time fuse. Waiting for replacement 168PA module to arrive. SMD rework tools required.

Probably time to just order another if you do not have the skills/tools. Shipping back and forth to someone that can repair it equals or exceeds the cost of the RX3S.
JohnRB is online now Find More Posts by JohnRB
Reply With Quote
Old Jan 12, 2013, 03:18 PM
Registered User
United States, NC, Raleigh
Joined Oct 2011
855 Posts
Quote:
Originally Posted by flightdeck View Post
extreme burner says" RX3S_v1_20130112 " corrupt hex file
Open the file with a text editor and see if it is full of HTML as well as the Intel Hex data. If it is you need to download again in a different manner. I had the same problem.

When you open the link and the hex file is displayed in a window on the page look for the button above the window that says RAW. Click that button and a new page should open with only the Intel Hex data. Now do a File->Save As on that page. If you open that file with a text editor it should now contain only Intel Hex data and no HTML.

The firmware is still a work in progress, so you might want to wait until more issues have been corrected.
JohnRB is online now Find More Posts by JohnRB
Reply With Quote
Old Jan 12, 2013, 03:23 PM
Better to burn out, than fade
SlimTom's Avatar
Slovenia, Ljubljana
Joined Sep 2012
29 Posts
Quote:
Originally Posted by lvale View Post
following
me too
SlimTom is offline Find More Posts by SlimTom
Reply With Quote
Old Jan 12, 2013, 03:32 PM
Registered User
florida
Joined Nov 2002
187 Posts
No problem I'll wait. After erasing the chip and finding the file corrupt(probably my fault).I rewrote the first version of the program to the chip again and it worked .This is on a V1.First shipment from Hobbyking and the Hobbyking programmer with the jumper on.
flightdeck is offline Find More Posts by flightdeck
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Sold Flight Stabilization System with Programing Card Woody_99 Aircraft - Electric - Helis (FS/W) 1 Mar 23, 2012 01:50 PM
Sold Flymentor Flight Stabilization with Field Programmer Woody_99 Aircraft - General - Radio Equipment (FS/W) 0 Mar 17, 2012 08:43 AM
Sold Totally Tricked out 400 size with flight stabilization installed, BNF Woody_99 Aircraft - Electric - Helis (FS/W) 2 Mar 12, 2012 07:56 AM
Wanted FY-30A Flight Stabilization System Casey_S FPV Equipment (FS/W) 0 Mar 05, 2012 03:40 PM