Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

DELTA value

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Mon Jun 29, 2015 12:42 pm    Post subject: DELTA value Reply with quote

Hi
I need to know if a sensor value has changed more than a specified DELTA value from a previous reading .

One way is to subtract the 2 , get the ABS and compare with a DELTA value .

Is there a faster , less code , way to do this compare ? - for now I only need to know if delta is more than 2 .

A BASCOM function to perform this will be very useful. ( res = DELTA(var1, var 2 , range) )

Cheers

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Mon Jun 29, 2015 4:53 pm    Post subject: Reply with quote

If you use integers, the procedure you describe will be processed very fast. Bascom is a compiler !
If you're using Singles or Doubles, it will take more time .... of course.
If you have an oscilloscope, hook it up to a free pin, set pin @ entry of calculation, clear on exit, and witness the speed of this compiler Smile

I doubt if a specific statement as you describe will be faster. And personally I prefer plain and simple code over smart statements. But that's personal ...

Enjoy!

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Mon Jun 29, 2015 7:28 pm    Post subject: Reply with quote

Hi
Yes , at the end of the day I subtract the 2 , get the abs and do the compare and it is very fast , all on word values .
Thanks for the
reply.

Groetnis .
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Tue Jun 30, 2015 1:42 am    Post subject: Reply with quote

I hope you mean integer, not word. word is not signed, so the result of w1 - w2 may not be what you expect. And taking the ABS of a word may not do much either.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum