Software Hysteresis

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
anzacinexile
Posts: 55
Joined: Tue Apr 01, 2014 9:10 am
Has thanked: 16 times
Been thanked: 18 times
Contact:

Software Hysteresis

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Software Hysteresis

Post 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
Last edited by medelec35 on Sat Aug 11, 2018 10:21 am, edited 1 time in total.
Reason: Added reference to another post.
Martin

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Software Hysteresis

Post by Steve001 »

Hi Chris,

Another method, i have used in a project

https://www.matrixtsl.com/wikiv7/index. ... _component

scroll down to the section

"Filtering ADC Inputs"

Hope this helps

Steve
Success always occurs in private and failure in full view.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Software Hysteresis

Post 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
Attachments
ADC Filter.fcfx
(8.71 KiB) Downloaded 252 times
Martin

anzacinexile
Posts: 55
Joined: Tue Apr 01, 2014 9:10 am
Has thanked: 16 times
Been thanked: 18 times
Contact:

Re: Software Hysteresis

Post by anzacinexile »

Thanks guys, much appreciated. Wish I was this skilled in software – I’m a hardware man by profession. :)

Chris

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Software Hysteresis

Post 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. :)
Martin

anzacinexile
Posts: 55
Joined: Tue Apr 01, 2014 9:10 am
Has thanked: 16 times
Been thanked: 18 times
Contact:

Re: Software Hysteresis

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Software Hysteresis

Post by medelec35 »

Thanks for the update Chris.
I'm glad the combination is working for you.
Martin

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Software Hysteresis

Post 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
Success always occurs in private and failure in full view.

Post Reply