PDA

View Full Version : [Question(s)] Basic Atom Pro / PulsinRead issues / How to invert some inputs.

LikWidChz
03-31-2009, 11:41 AM
Hi everyone.

So Basically here is what I'm trying to do, take a pulsin value off 1 channel of a receiver and invert the number's here is what I'm working with.. feel free to tell me I'm wrong or hey there is a better much more simple way of doing this, maybe I'm missing a command in the Atom Pro syntax that would help me do what I'm doing.

Connecting my receiver to an input pin and turning it on gets me these values
1088 left
1500 centered
1912 right

so.

Subtracting 1500 from it get's me these values

-412 left
0 centered
412 right

so all and all I need to invert these results, what I want is

0 left
412 centered
0 right

This is the code I came up with

If RcInput(0) > 1500 then
InputTimeDelay = (Abs(RcInput(0) - 1500 ) + 412)
Else
InputTimeDelay = (Abs(Abs(RcInput(0) - 1500 ) - 412))
Endif

This works fine on paper, works fine in my ti-89 calc when I plop values in although on the atom pro... this is broken!

I end up with a couple instances of the sticks not being all the way left and all the way right and the value of InputTimeDelay is zero when it should be a value less then 412 but higher then 0

Its driving me coo coo.. since I know the answer is just this simple, or is there an eaysier way to do this? ... you guys are the experts.

--Aaron

Connor
03-31-2009, 12:01 PM
First, I would give yourself some dead band space.. it's not always going to be 1500.. It may change a little.. Try something like this..

If RcInput(0) >= 1510 then
InputTimeDelay = (Abs(RcInput(0) - 1510 ) + 412)
ElseIf RcInput(0) <= 1490 then
InputTimeDelay = (Abs(Abs(RcInput(0) - 1490 ) - 412))
Else
InputTimeDelay = 1500
Endif

Note: I've not programmed in Atom Pro, so the ElseIf syntax may not be correct. but.. you get the idea.

Thanks, Connor

LikWidChz
03-31-2009, 01:47 PM
Hi Connor,

I'm not concerned with dead space which is why I didn't add any syntax for that :)

I'm not so worried about it not being exactly 412 as that number is a high delay value so it being anywhere between 412 and 400 would be perfectly OK in my situation.

I want a high number when the sticks are centered and a low number when the sticks are at the maximum's which is the issue I'm having.

the code above works for me on paper.. but on the atom pro it gives me not correct numbers I encounter zero in 4 spots 2 spots left and 2 spots right when there should be a gradual decline from 412 to 0 while moving the sticks far left and far right but stay 412 while centered.

--Aaron

LikWidChz
03-31-2009, 05:35 PM
Hah Oh crap, I feel like a tool..

InputTimeDelay was a byte, so max value was 255 no wonder I was seeing crazy values :\

anyway, does anyone have a easier way of doing this?