Unsure how to approach
Jack3
Posts: 55
Well I have searched and searched and cannot find out how to proceed. With Spin, I have no idea at all, with C, I wonder if pulse_in(pin, state) might be my answer. It returns a long that is the duration of the "pulse in" but I need it to look for 3 states, not just 2
My quest is a light controller for RC aircraft. One function that is desirable is to be able to turn on/off the landing lights from the transmitter and also have them do a flash pattern in one mode. This is usually accomplished on the RC transmitter with a 3 position switch. I can write the code after I know how to ingest the state/change in state, of that signal that comes off of the RC receiver. (Spectrum or XPS 2.4ghz systems). I plan on having a cog run a loop looking for change of state and acting upon it
I guess I don't know what to expect incoming or how to have values for the 3 states so I can do my truth's to get the state/change of state. The receiver system runs either analog or digital servos.
My quest is a light controller for RC aircraft. One function that is desirable is to be able to turn on/off the landing lights from the transmitter and also have them do a flash pattern in one mode. This is usually accomplished on the RC transmitter with a 3 position switch. I can write the code after I know how to ingest the state/change in state, of that signal that comes off of the RC receiver. (Spectrum or XPS 2.4ghz systems). I plan on having a cog run a loop looking for change of state and acting upon it
I guess I don't know what to expect incoming or how to have values for the 3 states so I can do my truth's to get the state/change of state. The receiver system runs either analog or digital servos.
Comments
I modified an object which reads 6 RC channels to make it easier to use on any of the Propeller's pins. You don't have to use all six channels. It includes a demo program.
Let say the you store the channel of interest in variable "x". You could do some thing like this.
I'm just guessing on the pulse values and what you would want to do (turn on or off lights).
I've done stuff like this myself in many of my projects.
You need declare an array of longs to serve as the stack for this cog; 16 is plenty. In your mainline code, start the cog like this:
where PIN is the IO pin receiving the pulse (use a resistor if this is coming from a 5v system), and pulsewidth is a global variable that will hold the pulse. This lets you keep the logic of dealing with the pulse width in the main code (my preference as other factors could affect behavior).
I appreciate the rapid responses. I did download the RCreceiver121116c.spin and have given that enough of a look to know I need to digest it....but it seems simpler than the one you modified from, as I had already looked and that and could not follow it on first attempts.
I saved JphnnyhMac's too.
I think that is more what I am looking for, but I need to keep on with the educational stuff until I get that far along. Need to finish chapter 7 in the BOE first and hope that answers my need to clearly understand what the H is going on. Part of my problem was I had no idea what would come from the RC system until I spoke with a friend this morning and got that cleared up. Therefore, I think what you have offered is more to what I am trying to do.
Duane, cool stuff, but way further than I want to go with a simple light controller.
So to clarify:
I finally learned that I need to read a square wave and check for changes in state to 3 possible ranges and act accordingly
Using the code I posted above, you could do something like this in your main loop:
I find case a little cleaner than if-else in when checking for a value in multiple ranges. Systems will vary, so giving your code a little bit of latitude around the expected values is helpful.
Hello Jack,
Please edit your post here to point back to this thread or delete it. It can be confusing to have 2 threads on the same topic. Moderators will remove it if you like.
I looked for more info on the XPS 2.4ghz receiver, and found these pages:
http://www.xtremepowersystems.net/data/RFU_v1.0.pdf
http://www.xtremepowersystems.net/data/X10+1.3.pdf
Assuming for now that is within the ball park, I'll try to offer a solution. A servo is usually controlled by a PWM signal ... which is basically a rectangular wave.
If I'm not mistaken, your PWM control signal may look something like below. I can't find anything in the docs that prove it though, and this post could be a waste of time.
So, assuming your 3 states are actually referring to a PWM, it may mean the first state is the start (low-high) transition on the left side of the active control time pulse rather than the level of the pulse. The second state would be the (high-low) transition on the active control time pulse. The third state would be the next start state (low-high) transition.
So it seems what you really want to measure are the 2 periods : the active control time and the passive wait time. This can be easily handled by pulse_in(pin, state).
If the servo connector (like the X10+1.3 doc) is connected to say P12 on an ActivityBoard, then one can say:
Sorry about not linking the two posts. I did ask about pulse_in in the first post here and because I got no response to a "C question" I assumed I needed to post over in the C part.
Anyhow, I learned that I needed to look for a pulsewidth and also that it had to be a range and was hoping the ... notation would do the trick for that. The links to the documentation are awesome, thanks. Still trying to learn how to get to those places. So much to learn, please be patient.
Using the picture and labeling what each is helps me visualize too.
To find those pages in SimpleIDE, look at the Help Menu, and click on Simple Library Reference. The online version of Simple Libraries can be found here.
We have considered adding an alphabetical index, but just making it a priority has been a little rough. Maybe we can start that back up in mid February.
We all had to swear an oath of patience here especially for all our new friends Old friends sometimes fight like cats and dogs or crabbyistas though.
I think I will probably follow your suggestions, but need to finish chapter 7 so I learn about the cog registers, which has been started.