Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Microcontroller Practical tips

Status
Not open for further replies.

MahmoudHassan

Full Member level 6
Full Member level 6
Joined
Oct 4, 2010
Messages
349
Helped
44
Reputation
90
Reaction score
40
Trophy points
1,328
Activity points
3,918
While working with PC16 and other microcontroller series . i found there are a lot of practical tips that could be forgot during programming like noise considerations .When implement pic in a circuit board it's performance is different from environment with high noise than other such as controlling high power motors that generate spikes in control signals from push buttons and sensors and produce erratic performance in relays that control motors ,so we have to program PIC such that it check the conditions twice with delay between them

if(RB0_bit == 1)// check button pressing
{
delay_ms(3000)
if(RB0_bit ==1) // make sure that this press is not noise spikes
{
....Instruction list...

while(RB0_bit ==1)
{
/*done to ensure that when pressing button the condition is executed only one time*/
}
}
}

I am not expert in this field and i need help for other tips .....
PLZ if you have other tips write them
Thanks in advance
 

what you have demonstrated is called debouncing.. and 3000 ms is too much..
when u push a button. it bounces high to low and vice versa several times and same thing happens during releasing too..

see figures
 

Attachments

  • c027e.gif
    c027e.gif
    6.1 KB · Views: 71
  • hardwareDebounceWaveforms.GIF
    hardwareDebounceWaveforms.GIF
    3.2 KB · Views: 68
1>a capacitor could be connected close to the microcontroller Vdd and Vss pins to avoid some type of feed backs.
2>similarly,in case of small dc motor running on drivers like ULN,relays etc, connect a .1mF capacitor in parallel with motor and ULN supply.
3>connect the resonator or crystal oscillator more close to the PIC pins .
4>if u r using TSOP or such sensors, then always connect a capacitor (abt 10 or 100 mF) near the TSOP power supply legs(decoupling capacitor).A 100 ohm resistor could be used to connect Vcc to TSOP . Then it will be more isolated from disturbances from external noise.
5>As Nickhilele replied, that 3000 ms delay to avoid switch de-bounsing detection is very high and that much delay is not needed to avoid the debouncing effect.
 
I am not expert in this field and i need help for other tips .....
PLZ if you have other tips write them

It would be better if you can use simulators like "Proteus" Labcenter Electronics - Downloads before hardware implementations

Other thing is proper comments of your code with module wise break down then other may understand it also later it may help to understand yourself as well

good luck
 
1>a capacitor could be connected close to the microcontroller Vdd and Vss pins to avoid some type of feed backs.
2>similarly,in case of small dc motor running on drivers like ULN,relays etc, connect a .1mF capacitor in parallel with motor and ULN supply.
3>connect the resonator or crystal oscillator more close to the PIC pins .
4>if u r using TSOP or such sensors, then always connect a capacitor (abt 10 or 100 mF) near the TSOP power supply legs(decoupling capacitor).A 100 ohm resistor could be used to connect Vcc to TSOP . Then it will be more isolated from disturbances from external noise.
5>As Nickhilele replied, that 3000 ms delay to avoid switch de-bounsing detection is very high and that much delay is not needed to avoid the debouncing effect.


Thanks a lot very helpful

---------- Post added at 16:05 ---------- Previous post was at 16:01 ----------

It would be better if you can use simulators like "Proteus" Labcenter Electronics - Downloads before hardware implementations

Other thing is proper comments of your code with module wise break down then other may understand it also later it may help to understand yourself as well

good luck

Thanks for your advise
iam using Protues ,it is good in simulation but Noise handling needs more practical experience

---------- Post added at 16:06 ---------- Previous post was at 16:05 ----------

I need book names that have interest for these practical considerations if there any

Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top