Comments (2)
Hi,
if (channel_flags & (1 << i)) {
output_raw_channels(result);
channel_flags = (1 << i);
}
channel_flags |= (1 << i);
The important part of this code is that channel_flags is declared static,
i.e. it persists between interrupts.
The code checks if a particular servo channel has been seen a second time,
and if it has it calls output_raw_channels().
This code allows automatic detection of how many servo channels are
connected to the light controller, and it also ensures that the order in
which servo pulses are sent by the receiver does not matter.
Example:
- At startup channel_flags is 0. result[ST, TH, CH3] are all set to 0 to
indicate "no servo pulse". - Only two servo channels are connected to the light controller; Steering
(ST, setup for timer capture CTIN_1) and Throttle (TH, setup for timer
capture CTIN_2). CH3/AUX (setup for timer capture CTIN_3) is not connected. - The receiver outputs TH first, then followed by ST (most transmitters
output ST first, but some like FrSky GT3B output TH first) - The interrupt triggers Timer Capture CTIN_2 at the rising edge of TH.
start[TH] is set with the timer value. channel_flags is 0, so
output_raw_channels is not called. channel_flag bit TH is set at the end
of the function. - The interrupt triggers Timer Capture CTIN_2 at the falling edge of TH.
The pulse duration for TH is calculated and saved in result[TH] - The interrupt triggers Timer Capture CTIN_1 at the rising edge of ST.
start[ST] is set with the timer value. channel_flags has only the TH bit
set, but not the ST bit, so output_raw_channels is not called.
channel_flag bit ST is set at the end of the function. - The interrupt triggers Timer Capture CTIN_1 at the falling edge of ST.
The pulse duration for ST is calculated and saved in result[ST] - [around 4..20 ms go by until the receiver repeats the servo channels]
- The interrupt triggers Timer Capture CTIN_2 at the rising edge of TH.
start[TH] is set with the timer value. channel_flags has the TH bit now set
from the pulse pulse before, which makes the if statement you quoted
true, therefore output_raw_channel is being called, with result[ST] and
result[TH] holding the measured pulse durations, and result[CH3] being 0
because this channel is not connected so it was not measured. After
output_raw_channel returns the TH bit in channel_flags is set because we
are just processing a new rising edge for TH, all other bits are cleared.
kind regards, Werner
On Mon, Jan 11, 2016 at 11:07 PM, Locke Huang [email protected]
wrote:
Please check void SCT_irq_handler(void) in
rc-light-controller-master\mk4-tlc5940-lpc812\firmware\servo_readercif (channel_flags & (1 << i)) { output_raw_channels(result); channel_flags = (1 << i); } channel_flags |= (1 << i);
whatever channel_flags and i change, output_raw_channels() is impossible
to run I picked up related code and verified in VS2015 Obviously,
output_raw_channels(result) has no chance to runLocke
—
Reply to this email directly or view it on GitHub
#2.
from rc-light-controller.
Hello, Werner:
Thanks for the so detailed explanation. You are exact right. output_raw_channels(result); will be invoked in THE SECOND rising edge of TH. I verified this with my VS. It is well designed and very intelligent.
I should noticed the PWM for receiver is contentious. Thanks for the clarify. And this is an awesome project. Please kindly close this "issue".
BR
Locke
from rc-light-controller.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rc-light-controller.