Page 1 of 1

Software Hysteresis

Posted: Fri Aug 10, 2018 11:29 pm
by anzacinexile
I was wondering if anyone has implemented software hysteresis into their designs?

To explain, I have a project where I read an ADC and send the results to a bar graph and a string on a ViSi display. The ADC is very stable but when the ADC reading is on the cusp of changing the graph and string to another value, the display is a blur of activity between the old and new readings until the value read from the ADC is firmly in the middle of the appropriate range.

I don’t want to slug the response by slowing down the ADC read cycle so I'm thinking that with a bit of hysteresis (similar to a Schmitt input in hardware) this will solve the problem but my problem is I haven’t the software skills to come up with a solution.

Any ideas would be greatly appreciated

Thanks

Chris

Re: Software Hysteresis

Posted: Sat Aug 11, 2018 1:52 am
by medelec35
Hi Chris,
Here is a basic way of software hysteresis.
To open FC5 flowchart.
Select Open project, change dropdown box next to File Name to Flowcode for PIC files (*.fcf)

Edit:
Thinking about it My post a couple below this post maybe more suited for your application

Re: Software Hysteresis

Posted: Sat Aug 11, 2018 8:02 am
by Steve001
Hi Chris,

Another method, i have used in a project

https://www.flowcode.co.uk/wikiv7/index. ... _component

scroll down to the section

"Filtering ADC Inputs"

Hope this helps

Steve

Re: Software Hysteresis

Posted: Sat Aug 11, 2018 10:17 am
by medelec35
I thought of a different way which will give instantaneous results if ADC changes by more then 2.
The 2 can be changed to any suitable amount of course.
Just Select View, Analogue Inputs.
Single step by pressing F8.
Observe the ADC variable within Debug window:
ADC Filter.png
(43.35 KiB) Downloaded 2585 times

Re: Software Hysteresis

Posted: Sat Aug 11, 2018 4:30 pm
by anzacinexile
Thanks guys, much appreciated. Wish I was this skilled in software – I’m a hardware man by profession. :)

Chris

Re: Software Hysteresis

Posted: Sat Aug 11, 2018 10:46 pm
by medelec35
Hi Chris,
Hopefully you will find the solution for your application.
Would you mind letting us know which solution suited you best,
as there will be other Flowcode users looking for a similar answer.

Thanks. :)

Re: Software Hysteresis

Posted: Sun Aug 12, 2018 10:38 am
by anzacinexile
No problem.

I had already applied the low pass filter that Steve highlighted and that resulted in a very stable ADC in a very noisy electrical environment but that alone didn’t stop the digital display constantly updating right on the point of a change in value.

As a result I applied your second suggestion (ADC Filter.fcfx). I modified it a bit because I’m reading the ADC as an INT and a change in computed value needed a jump of 10 from the ADC. After application (I’m still using the low pass filter because of the noise (it’s a motorbike dashboard and the supply is awful with the engine running) the display changes with a flip and doesn’t “hunt” anymore – just what I was looking for.

Many thanks again to you and Steve, I’m learning all the time

Chris

Re: Software Hysteresis

Posted: Sun Aug 12, 2018 3:23 pm
by medelec35
Thanks for the update Chris.
I'm glad the combination is working for you.

Re: Software Hysteresis

Posted: Mon Aug 13, 2018 12:43 pm
by Steve001
Hi Chris,

Glad the combination working. If your interested see this post for an explanation to how it works
Scroll down to Bens Answer

viewtopic.php?f=63&t=20008#p87554

Steve