I need a code with hysteresis 10 mv.
He needs to work well when reading adc is greater than 1.3 V my exit will be 1 and when the reading is less than 1.29 V my output will be 0. I'm reading a gear tooth with a hall and then I will have only two transition stages ( with tooth or toothless) and therefore need a hysteresis in changing stages .The difference of tension between tooth and tooth is not only 10 mv at the iC hall.
I'm using pic18f2423 with 12-bit ad converter and I'm using mcp1525 2.5 V to VREF +.
I Medelec help in the code that I am attaching .What is happening is that I'm simulating these tensions with a potentiometer and when I have the voltage below 1.29 V the output is okay. But when I raise output above 1.29 V to 1.30 V (my region hysteresis) the output is cycling and stabilizes only when it exceeds 1.33 V which should be 1.3 V. I do not know if I'm correct but my reference voltage is 2.5 V and the Resolution of the ad converter is 4095 then 2.5 / 4095 = 0.0006 which should differentiate the hysteresis 10 mv. It seems that the code is not this getting to understand the adc 12 bit if I'm correct. I am attaching the code for someone to help.
Grateful;
Ricardo
help with adc 12bit
Moderator: Benj
- celebriums
- Posts: 125
- Joined: Sun Sep 25, 2016 3:50 pm
- Has thanked: 71 times
- Been thanked: 33 times
- Contact:
Re: help with adc 12bit
Hello
You have to increase the resolution read.
LEI > 1.3000 and LEI<1.3000 must be
You have to increase the resolution read.
LEI > 1.3000 and LEI<1.3000 must be
- Attachments
-
- Flowcode2HighResulationRead.fcfx
- (9.97 KiB) Downloaded 292 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: help with adc 12bit
Hello,
1.3V / 0.0006 = 2166
Your currently using GetVoltage which uses floating point maths. Probably much more efficient to ReadAsInt and then use integer maths and the values shown above. This would also get around rounding errors.
FRC is not a recommended conversion speed, maybe play around with this and the Aquisition cycles until your ADC readings are more stable.
Maybe Conversion Speeds of /8 or /16 or /32 and Aq Cycles 10 / 20.
1.29V / 0.0006V = 2150I do not know if I'm correct but my reference voltage is 2.5 V and the Resolution of the ad converter is 4095 then 2.5 / 4095 = 0.0006 which should differentiate the hysteresis 10 mv.
1.3V / 0.0006 = 2166
Your currently using GetVoltage which uses floating point maths. Probably much more efficient to ReadAsInt and then use integer maths and the values shown above. This would also get around rounding errors.
FRC is not a recommended conversion speed, maybe play around with this and the Aquisition cycles until your ADC readings are more stable.
Maybe Conversion Speeds of /8 or /16 or /32 and Aq Cycles 10 / 20.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: help with adc 12bit
Hello Benj.
Grateful for your attention.
My lower value is 1.29 = 2150.
My biggest value is 1/30 = 2166.
My hysteresis is 0.01 = 16.
But testing on real circuit the following happens:
The output is on until the voltage 1,325 and not 1,29.
Between 1,325 and 1.345 the output is pulsing. (?)
And above 1,345 the output is off and not worth 1.3.
It seems that the ad converter not solve this with 12 bits.
I have attached the code that you exemplified above is what mean?
I ask your help.
Grateful;
Ricardo.
Grateful for your attention.
My lower value is 1.29 = 2150.
My biggest value is 1/30 = 2166.
My hysteresis is 0.01 = 16.
But testing on real circuit the following happens:
The output is on until the voltage 1,325 and not 1,29.
Between 1,325 and 1.345 the output is pulsing. (?)
And above 1,345 the output is off and not worth 1.3.
It seems that the ad converter not solve this with 12 bits.
I have attached the code that you exemplified above is what mean?
I ask your help.
Grateful;
Ricardo.
- Attachments
-
- TESTE.fcfx
- (7.89 KiB) Downloaded 290 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: help with adc 12bit
Hi Ricardo,
Check the ADC component properties regarding the following.
Check the ADC component properties regarding the following.
12-bit ADC is going to pick up a lot of noise unless everything is very well designed and shielded, 10mV is not a lot of signal, could you use say an op amp to amplify this voltage to give you a better range?FRC is not a recommended conversion speed, maybe play around with the conversion speed and the Aquisition cycles until your ADC readings are more stable.
Maybe Conversion Speeds of /8 or /16 or /32
Aq Cycles 10 or 20.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: help with adc 12bit
Hello Benj.
I'm using a linear output hall IC and this is the maximum gain I could have.
I made the changes that you showed me and still remained the problem.
I put a potentiometer to simulate and increased the range of the hysteresis to 40 mv.
And it worked and 10 mv also did not work.
You have reason 10 mv is a very low level and still have the noise.
But it has to reach a conclusion.
I am very grateful for the help of you and I hope the Flowcode that already is good, keep getting better.
Grateful
I'm using a linear output hall IC and this is the maximum gain I could have.
I made the changes that you showed me and still remained the problem.
I put a potentiometer to simulate and increased the range of the hysteresis to 40 mv.
And it worked and 10 mv also did not work.
You have reason 10 mv is a very low level and still have the noise.
But it has to reach a conclusion.
I am very grateful for the help of you and I hope the Flowcode that already is good, keep getting better.
Grateful
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: help with adc 12bit
Hi Ricardo,
What about tying Instead of ?
That has helped me when there was ADC reading fluctuations and I wanted results to be as steady as possible.
Just start by entering a fairly high value for both E.g.250.
Martin
What about tying
Code: Select all
GetAverageInt
Code: Select all
GetInt
That has helped me when there was ADC reading fluctuations and I wanted results to be as steady as possible.
Just start by entering a fairly high value for both E.g.250.
Martin
Martin