""You have compiled in FREE mode.
Using Omniscient Code Generation that is available in PRO mode,
you could have produced up to 60% smaller and 400% faster code.
See http://www.microchip.com/MPLABXCcompilers for more information.""
About the above description.
I'm using the pic 18f2423 with the internal clock of 8 mhz, reading through the ad converter 12 bits and fosc/2 of a linear hall ic a1301k. I'm reading teeth of a gear that reaches maximum frequency of 1500 hz. The distance between the Hall and the gear is of 2 mm. The amplitude of the signal is low. At low rotation until about 300 hz I can make the perfect reading. Above this frequency I start to lose pulses and I do not have a correct reading.
I do not know if the problem is with the amplitude of the signal or with the reading speed of the input ad.
With code compiled in FREE mode is my processing speed lower or does it have no interference?
Ricardo
Compiler Doubt
Moderator: Benj
Compiler Doubt
- Attachments
-
- FISICO.fcfx
- For testing I made a simple comparison with a signal level a little below the maximum without hysteresis. But neither does it work at higher frequencies.
- (8.51 KiB) Downloaded 252 times
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Compiler Doubt
Hi Ricardo,
I would not put it down to compiler.
You are polling an ADC input with an internal osc set to 1MHz.
That is the default start up frequency if not using a C code block with
Since you have set clock frequency 8MHz there will be a mismatch!
Anyone starting a new project is always wise to start with a 1 second flasher test.
My advice is enable PLL so you can use internal oscillator at 32MHz.
Looking at the datasheet you will need to use which selects 8MHz internal oscillator.
Then you need to enable PLL (this will multiply osc speed by 4 = 32MHz) by setting
This is done by
Set your clock speed to 32MHz.
Finally use interrupt pin e.g INT0 on pin RB0 so it can detect the pulse rather than polling.
Take a look at this Wiki page
There is a link with examples for different types of interrupts.
Also for comparing polling with interrupts you could have a look here
Martin
I would not put it down to compiler.
You are polling an ADC input with an internal osc set to 1MHz.
That is the default start up frequency if not using a C code block with
Code: Select all
OSCCON = 0x70;Anyone starting a new project is always wise to start with a 1 second flasher test.
My advice is enable PLL so you can use internal oscillator at 32MHz.
Looking at the datasheet you will need to use
Code: Select all
OSCCON = 0x70;Then you need to enable PLL (this will multiply osc speed by 4 = 32MHz) by setting
Code: Select all
OSCTUNE PLLENCode: Select all
set_bit(OSCTUNE,PLLEN);Finally use interrupt pin e.g INT0 on pin RB0 so it can detect the pulse rather than polling.
Take a look at this Wiki page
There is a link with examples for different types of interrupts.
Also for comparing polling with interrupts you could have a look here
Martin
Martin
Re: Compiler Doubt
Hello Martin;
Thanks for listening;
The IC hall I am using is not logical but rather linear (following datasheet attached). Its output varies the voltage according to the magnetic field having as output a sine wave. That is why I am using the input adc. For this IC to work This way I put a magnet on its coast and the gear teeth rotate in front of the IC changing the magnetic field.
What happens is that at low frequencies I can read, but I can not read.
Can I send the photo of the gear and the sensor?
When the recommendations passed I added the code in c but gave compilation error. Can you help me?
Ricardo.
Thanks for listening;
The IC hall I am using is not logical but rather linear (following datasheet attached). Its output varies the voltage according to the magnetic field having as output a sine wave. That is why I am using the input adc. For this IC to work This way I put a magnet on its coast and the gear teeth rotate in front of the IC changing the magnetic field.
What happens is that at low frequencies I can read, but I can not read.
Can I send the photo of the gear and the sensor?
When the recommendations passed I added the code in c but gave compilation error. Can you help me?
Ricardo.
- Attachments
-
- A1301-Datasheet.pdf
- (461.19 KiB) Downloaded 244 times
Re: Compiler Doubt
Hello Martin;
How would the setup to work with the pic18f2423 with osc 32mhz internal?
I made a change in the code and attached it.
Would be like this?
How would the setup to work with the pic18f2423 with osc 32mhz internal?
I made a change in the code and attached it.
Would be like this?
- Attachments
-
- FISICO.fcfx
- (8.72 KiB) Downloaded 246 times