I am using a Pic 18f2423 with reference voltage on the adc converter of 1.25 volts.
I'm trying to read a gear with a linear output hall sensor model a1301k.
When this gear is spinning I have at the output of the hall sensor a sine wave of approximately 16 millivolts.
When the sensor is on top of the gear tooth I have the minimum voltage (sinusoidal valley). And when the sensor is in the hollow space I have the maximum voltage (sinusoidal crest). But not all the teeth have the same minimum tensions (but approximate), and not all spaces maximum tensions (not teeth) have equal (but approximate) .
I need to do a logic that finds the minimum voltage of the sinusoid and presents result 0 and then find the maximum voltage and present result 1 and is doing so in succession. It can only present 1 after a 0 and 0 after a 1.
I did a logic that is attached where I find the minimum value and then add a minimum value that would be the space of the gear. It works but when I change the size of the gear is my logic does not work anymore.
Grateful;
Ricardo
help with programming logic
Moderator: Benj
-
- Posts: 170
- Joined: Fri Jul 15, 2016 9:51 pm
- Has thanked: 69 times
- Been thanked: 61 times
- Contact:
Re: help with programming logic
Hi Ricardo,
I think you should use more samples for the decision and have to find local minimum and maximum.
It should be considered whether the actual sample value is smaller or larger than the previous samples.
For example, if the value of samples was growing for a time, but value of three samples successive are getting smaller than the previous one in the order, then was a positiv peak with four sample had been before and have to set up the output in "0".
Due to the noises, measured values may need to add a small hysteresis.
This method causes a small delay in detection.
In my opinion, the hall-sensor signal should be amplified, if it possibile.
The maximum frequency of the signal can also be interesting.
Best Regards,
Lagoda
I think you should use more samples for the decision and have to find local minimum and maximum.
It should be considered whether the actual sample value is smaller or larger than the previous samples.
For example, if the value of samples was growing for a time, but value of three samples successive are getting smaller than the previous one in the order, then was a positiv peak with four sample had been before and have to set up the output in "0".
Due to the noises, measured values may need to add a small hysteresis.
This method causes a small delay in detection.
In my opinion, the hall-sensor signal should be amplified, if it possibile.
The maximum frequency of the signal can also be interesting.
Best Regards,
Lagoda
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: help with programming logic
Unfortunately what you are doing is very odd in my opinion,The Standard procedure will be to translate the Sine signal into a TTL(square wave) signal that can easily be captured with HW modules such as the CCP module of your PIC which results in you having Time / number of pulses and duty cycle .RLOPES780 wrote: I did a logic that is attached where I find the minimum value and then add a minimum value that would be the space of the gear. It works but when I change the size of the gear is my logic does not work anymore.
depending howe you setup and use the CCP module .The problem with your logic is that if you change gear size or speed changes happen your SW will not work as the Amplitude of your sine varies accordingly.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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 programming logic
I'm with QMESAR on this - 16mV is not a lot to play with and so I would use a simple opamp circuit to amplify this signal to something more usable. By amplifying the signal it should be a lot easier to track the variation across a wider range of gears, assuming your sensor is up to the job, can accuratley monitor the variation and has no excess capacitance.
http://www.electronics-tutorials.ws/opamp/opamp_8.html
http://www.electronics-tutorials.ws/opamp/opamp_8.html
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
-
- Posts: 58
- Joined: Sat Aug 22, 2009 5:45 pm
- Has thanked: 17 times
- Been thanked: 7 times
- Contact:
Re: help with programming logic
You could use a suitable IC for the job such as: LM1815. it translates the sine to a nice clean TTL signal that can be captured by your PIC, I have used this IC in automotive aplications and it works like a charm.
-
- 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: help with programming logic
Hi Ricardo,
Will the attached flowchart work for you?
Flowchart assumes no noise of course.
If there is, then a few samples will be required as Lagoda stated.
Martin
Will the attached flowchart work for you?
Flowchart assumes no noise of course.
If there is, then a few samples will be required as Lagoda stated.
Martin
- Attachments
-
- SR CARLOS V2.fcfx
- (10.66 KiB) Downloaded 216 times
Martin
- Steve001
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
- Contact:
Re: help with programming logic
Good morning friends;
Thank you for your help.
Continuing. I amplified the exit of the hall and made the program that is attached.
I can read the pulses of the gear teeth.
However I can read up to a range of 1000 hz. Even with a low reading sample in the adc converter. I am working with active PLL with the clock of 32 mhz.
I need to read a frequency higher than that around 2000 hz.
Is this a compiler problem that is free?
Is it possible to use another compiler that runs my programs without limitations to 8-bit pic?
Grateful;
Ricardo.
Thank you for your help.
Continuing. I amplified the exit of the hall and made the program that is attached.
I can read the pulses of the gear teeth.
However I can read up to a range of 1000 hz. Even with a low reading sample in the adc converter. I am working with active PLL with the clock of 32 mhz.
I need to read a frequency higher than that around 2000 hz.
Is this a compiler problem that is free?
Is it possible to use another compiler that runs my programs without limitations to 8-bit pic?
Grateful;
Ricardo.
- Attachments
-
- SR CARLOS.fcfx
- (10.56 KiB) Downloaded 193 times
- Steve001
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
- Contact:
Re: help with programming logic
Hi Ricardo
I am not sure if this is what you are after,
this ic converts frequency to voltage (used to use it in a past life with digital tacho's) - you will have to clean the sine wave up though to a square wave
http://www.ti.com/lit/ds/sbvs015/sbvs015.pdf
Steve
I am not sure if this is what you are after,
this ic converts frequency to voltage (used to use it in a past life with digital tacho's) - you will have to clean the sine wave up though to a square wave
http://www.ti.com/lit/ds/sbvs015/sbvs015.pdf
Steve
Success always occurs in private and failure in full view.