Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Tachometer and Counter with PIC16F828 - noice !!!

Status
Not open for further replies.

ksor

New Member
I have made such a device on a breadboard and it's working fine - EXCEPT ...

when I make some "noise" =connect/disconnect a power-adaptor in the powercord beside the the one for my device.

I want to find out what is picking up this noise !

I beleave my power supply is "good enough" for powering this device, because NO FAILURE is comming up if I make NO NOISE with the extra power adaptor.

Question 1)
Can I leave my power supply out as causing the troubles ?

What I beleave is that my input (RB0 interrupt counting incomming pulses) is picking up the noise.

The way I see that there is some noise picked up is, that the numbers change in an strange way on the display (4 X 7 segment LED) - the display is showing the content of a variable in my program (multiplexed).
I too beleave the ONLY way the digits can change in this strange way is by changing the content of my variable. Because this variable is changed by interupt on RB0 I HAVE to beleave the noise is triggering the RB0 interrupt.
Another thing that's making me beleave this is that, IF I short the input to ground (or +5V) and make a lot of noise . then NO NOISE is shown in my display.

Question 2)
Am I right when assuming that the ONLY way my display can change is when the content of my variable is changed ?

Question 3)
... and that the noise IS picked up by my input only ?

My software is running into error handling when the incomming "puls-frequence" is 6.5 KHz

Question 4)
What are the method or formula for finding out a the values for some "RC-****" placed in my input ?

(I'm not skilled into electronics - just very interested hobbyist !)

Best regards
KSor, Denmark
 
Last edited:
Hi,

It is quite possible to pick up noise on your pic circuit - without seeing your circuit diagram or a picture of your build its hard to say what exactly is the problem.

Common points are no 100nf caps across the pics Vss and Vdd, long leads on Mclre, long unscreeed leads on any i/o pins.
Using long dc power cables can also cause it, try twisting wires together.
 
Hi,

It is quite possible to pick up noise on your pic circuit - without seeing your circuit diagram or a picture of your build its hard to say what exactly is the problem.

Common points are no 100nf caps across the pics Vss and Vdd, long leads on Mclre, long unscreeed leads on any i/o pins.
Using long dc power cables can also cause it, try twisting wires together.

Hi Wp100 !

Here is my diagram - on the left side is a

1) Togglebutton for changing mode - RPM or COUNTER
2) Pushbutton for FREEZE / RESET the counter

on the right side is ourput to mu LED board - the 7 segments and the multiplexing of digits.

I have tried WITH and WITHOUT the caps - it makes NO DIFFERENCE !

Until now it's only a breadboard but implemented as tide/small as possible - and I think my testings (questions) is pointing to the input as the cause - is my arguments/questions totally wrong ?

Please, teach me !
 

Attachments

  • RPM..JPG
    RPM..JPG
    58.1 KB · Views: 749
Hi,

Am no expert in curing problems like this, just going on practical experience of similar faults.

As you are on short breadboard leads I would try to establish if the problem is airborne or power supply releated.

First try running it on a battery located close to the circuit - if no change, place everything in a metal box or tin or a foil covered box and connect it to Ground.

Do not know the formula for the input capactitors but typically 100nf before the series 1k works for low frequency switching.

One other thing - you do not show a voltage regulator, only some large caps - are you running from a PCs USB +5v or from say a USB programmers power souce - USB power can cause all sorts of weird problems.
 
hi ksor,
Please post your program or at least the CONFIG details for the PIC.
 
hi ksor,
Please post your program or at least the CONFIG details for the PIC.

My program is not worth seeing - it's made automaticly by Flowcode - do you know this software ?

In Flowcode you are working with a bunch of flowcharts - and that's just my way of working - it'd not rocket science :)

I HAVE looked at the C-code (or the ASM-code) comming out of Flowcode - it's not very pretty !

When using Flowcode you are not specific configuring anything - you just make some boxes in the flowchart.

The program IS WORKING PERFECT:

In both RPM and COUNTING mode I use interupt on every incomming puls at RB0 - when COUNTING the interupt service routine just increment a counter variable.
In RPM mode the interupt service routine a timer gives me a counting periode of 1 sec and when the timer interupts, I just show the counting variable in the display - the value IS in fact RPM's !

In RPM mode I have a "gliding" (I don't know the right word in english) mean value of 5 readings - to get a more stable figure in the display - and because I use INTERGERs all over I have to limit my RPM's to 6.500 (5 X 6.500 <= interger max value 32767).

Maybe I can use some software to get rid of the noise - but in the first place I'll try to use "RC-****" in the input - again I don't know the right word for this RC-thing (a resistor in series and a cap to ground) and I don't know the method to find out the R and C values.

You can get the C-code or ASM-code if you want, but it's no pretty coding I think.

Why do you think the code have to do with the noise ?

/KSor
 
Last edited:
--> Wp100
Oh yeah - I could try running on a battery !

My power supply is a 5.3V 140mA power adapter - (like the one I use for making noise)

/KSor
 
Without knowing what the RPM sensor is, it is difficult to advice but the first thing I would try is a 10k resistor from RB0 to ground. Alternatively turn on the weak pullup resistors on port B.

Mike.
Edit, to turn on the WPUs in flowcode you use a C code block and enter the following,

option.7=0;

BTW, I assume "gliding" is averaging.
 
Last edited:
Without knowing what the RPM sensor is, it is difficult to advice but the first thing I would try is a 10k resistor from RB0 to ground. Alternatively turn on the weak pullup resistors on port B.

Mike.
Edit, to turn on the WPUs in flowcode you use a C code block and enter the following,

option.7=0;

BTW, I assume "gliding" is averaging.

-->Pommie
At the moment the sensor is a old generator but in the final solution the sensor is a bridge of light where 60 wholes on the motor axial through a SmidthTrigger is generating the pulses.

A 10K from RB0 to ground - before or after my 1K ?
(What are the purpose - teach me !)

The WPUs on port B - in specific RB0 witch is used for input - for what purpose - teach me, please !

Yes, "averaging" is the right word I think - I'm averaging the last 5 readings to get a more stable display in RPM-mode.

Best regards
KSor, Denmark
 
The 10k would go after the 1k so that it holds the pin at gnd level. The noise that is being induced will not be able to make a high enough voltage across the 10k to trigger the input. The internal WPUs are about 20k and connect the pin to Vdd and should do the same job as the external 10k. You should only do one of these things.

You will probably find that when the schmitt trigger is fitted that the noise problem will disappear.

Mike.
 
Last edited:
First things first: Get the power supply into your microcontroller as smooth as possible. Only then can you start determining if your code is being corrupted by noise coming in elsewhere on the circuit. How close are your 1000uF capacitors to the power supply pin? You might want to reduce these values to 100uF (1000uF just seems a waste), put them right up against BOTH pins of your power supply (Vcc AND ground). put a 100nF in parallel with these caps too. This should remove most of the noise. Keep your power rails short and fat and keep any interface wires to the chip as short as possible to minimise airborne interference.

Then see if your PIC is misbehaving

You might also try adding some low value capacitors (10nF) to the digital input to clobber any noise that might be getting in (without obviously clobbering the signal you are trying to measure)
 
Last edited:
The 10k would go after the 1k so that it holds the pin at gnd level. The noise that is being induced will not be able to make a high enough voltage across the 10k to trigger the input. The internal WPUs are about 20k and connect the pin to Vdd and should do the same job as the external 10k. You should only do one of these things.

You will probably find that when the schmitt trigger is fitted that the noise problem will disappear.

Mike.

The 10K to ground "eats" my signal so what should be 6000 RPM is shown as 5600 and the display is very unstable (=not all "real" pulses is counted I think)

Then I try the WPU-solution but something is wrong with the C-code:

Option.7=0;

C:\Documents and Settings\ksor\Skrivebord\RPM og Counter\00 - RPM og Counter\RPM og Counter.c(1318:2): error: unknown identifier 'Option'
C:\Documents and Settings\ksor\Skrivebord\RPM og Counter\00 - RPM og Counter\RPM og Counter.c(1318:2): error: failed to generate expression
C:\Documents and Settings\ksor\Skrivebord\RPM og Counter\00 - RPM og Counter\RPM og Counter.c(1318:2): error: invalid operand 'Option.7'
C:\Documents and Settings\ksor\Skrivebord\RPM og Counter\00 - RPM og Counter\RPM og Counter.c(1318:10): error: failed to generate expression
RPM og Counter.c success

same if lowercase is used
 
I have tried a combination of SmithTrigger and your 10K to ground but still I can make noise that disstortes the display.

I think I have to make a print with all the caps and R's introduced so far, and then hook up the final setup with shielded cabel (0,75-1 meter) to the light brigde (the input pulses to be counted interupting RB0)

Is this noise problem normal to PICs - I think it's a nightmare !

Can something be done in the software - neglating pulses comming faster than my limit 6.5KHz - have someone tried that ?
 
If your signal is getting "eaten" then increase the resistor value.

And, C is very fussy about case and so,

Option.7=0;

is not the same as

option.7=0;

Mike.
 
Hi Mike

I'll try insert a trim pot instead of the 10R.

Concerning the WPR's I have tried both cases "Option" and "option" as I write in my posting.
 
Woops, it should be option_reg.7=0;

You don't want a 10R resistor, you need 10k. 10R = 10Ω and 10k = 10,000Ω.

Mike.
 
Sorry, the 10R was an error from my side - I normaly know 10R from 10K !

Where did you find out what names you can use in C-code blocks in Flowcode ?

KSor
 
As flowcode produces BoostC code you use the same names as BoostC which can be found in (my case) C:\Program Files\SourceBoost\include in file PIC16F628.h

Just checked and flowcode has a copy of the file at C:\Program Files\Matrix Multimedia\Flowcode V4\boostc\include

Edit, always use the lower case version of the register name.
I'E the ones at the end of the file that start,
Code:
volatile char [COLOR="red"]indf[/COLOR]                   @INDF;
volatile char [COLOR="red"]tmr0[/COLOR]                   @TMR0;
volatile char [COLOR="red"]pcl[/COLOR]                    @PCL;
volatile char [COLOR="red"]status[/COLOR]                 @STATUS;
volatile char [COLOR="red"]fsr[/COLOR]                    @FSR;
Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top