Out = Out + In

Interested in Robotics? Here's the place to be.
Post Reply
hlreed
Posts: 349
Joined: Wed Jan 09, 2002 1:01 am
Location: Richmond, TX
Contact:

Out = Out + In

Post by hlreed »

I have found a need to update data outside as well as inside. I did that with X = X + k where X is modified inside the node and emitted outside.
Myfood = Myfood + food
hunger = Myfood GT hungerlimit
Since data comes in as a solid stream I am using only data that is different from old data.
Plus
IM = 0
OldI = 0
Loop
Read I
IF I <> OldI then IM = IM + I
Out = IM
OldI = I
Write Out
GOTO Loop
END
I and Out run at about 500 microseconds per datum.<p>Will that work, or is there a better way to select data?
Harold L. Reed
Microbes got brains
Mr. K
Posts: 37
Joined: Sat Sep 06, 2003 1:01 am
Location: Rustbelt, USA
Contact:

Re: Out = Out + In

Post by Mr. K »

The program code looks like it will do what you say you want.<p>Two questions/observations:<p>1.) Is there a way you can "prove" the speed of the code and make sure that the code will execute sufficiently fast to handle the data rate? You said nothing about the capability of your platform.<p>2.) Depending on your environment, and assuming your language allows it, it may be more efficient to code this along the lines of:<p>read
if new<>old then do_all_that_good_stuff
loop<p>This avoids the time losses associated with an assignment statement and output on loops where the input didn't change (unless you need/want a 1:1 correlation with ins and outs).<p>Good luck!
In theory, there's no difference between theory and practice. In practice, there is.
hlreed
Posts: 349
Joined: Wed Jan 09, 2002 1:01 am
Location: Richmond, TX
Contact:

Re: Out = Out + In

Post by hlreed »

Thanks for the comment.
The code for this is a PIC 12F629. It has been simulated. I have not cut a chip yet. The input/ output of these nodes is 8 bit binary bit serial. The reason I cannot use an INode here (O = i(I)) is because of the speed.
And I do not want to use the difference of the inputs, so I chose only if different.
O = O + I iff I<>OldI ;
First thought was to use the difference:
O = O + I - OldI ; but that is not right.
Harold L. Reed
Microbes got brains
bwts
Posts: 229
Joined: Tue Jun 11, 2002 1:01 am
Location: britain
Contact:

Re: Out = Out + In

Post by bwts »

I may B confused here but I dont think ur code will work! Is 'I' just a single bit of info? if so try the following input sequence + C wot U get 0,1,0,1 I think ull find that the output once toggled will stay in that state reguardless of wether the new input is different 2 the last input. Again I stste I may B a little confused 2 day!!<p> :) I take all that back I misread oldI=I as oldI=1 :) <p>B)<p>[ January 29, 2004: Message edited by: Mr Bwtz ]</p>
"Nothing is true, all is permitted" - Hassan i Sabbah
hlreed
Posts: 349
Joined: Wed Jan 09, 2002 1:01 am
Location: Richmond, TX
Contact:

Re: Out = Out + In

Post by hlreed »

Thanks confused B.
Turns out this is a counter.
Count = Count + countbydifference
There is also an uncount which is harder to do.<p>Connect count and uncount in series and you should get countbydifference back.
This is getting very close to integration and differentiation which I alread have.
So these may not make the cut. However, there is no other way to modify outside data other than
X = X + q which puts x on outside and inside.
Uncount is X = q - X
Still don't have uncount right. Something deeper here.
Harold L. Reed
Microbes got brains
hlreed
Posts: 349
Joined: Wed Jan 09, 2002 1:01 am
Location: Richmond, TX
Contact:

Re: Out = Out + In

Post by hlreed »

It turns out that the uncount is a differentiator with memory.
Out = In - OldIn ; is DNode internals
Out = Out - OldIn ; is Minus (uncount)
Since these are cheap TNodes, they will be on the node list.
Harold L. Reed
Microbes got brains
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests