Tchao Luciano,
The 1µF cap looks good! A 10µF one makes it even worse...
Still making some more tests...
Thanks a lot.
Tchao Luciano,
The 1µF cap looks good! A 10µF one makes it even worse...
Still making some more tests...
Thanks a lot.
Roger
Hi,
Disconnect the piezo from the microcontroller.
Connect the piezo to +5V via the 1µF DC blocking
capacitor and measure the current.
* * *
Connect the piezo to the microcontroller.
With an oscilloscope measure what you have
on the pin used to drive the piezo speaker.
(Measure when you don't hear the piezo speaker).
Best regards,
Luciano
Hi,
You mentioned that the current drops when you start the program and fall into the main loop. PBP does not inititialize a variable and it can have arbitary values. When you use the SOUND command for the first time it sets the data direction registers. (Actually it does it every time). So either initialize your variables,Data Direction Registers and PORT Latches or just use a short sound before you fall into the start loop. Do this without the cap and with it post the results.
Regards
Sougata
OKay now,
After y few different tries, I connected: PIC - 1µF - Piezo - R33 - Vss.
Sound is very good; current drawn by piezo is about 8mA.
I have attached both signals results (signal directly from PIC and signal after the 1µF cap).
Sougata,
I've tried to do as you said. But without the cap, it just does the same as before (current stays 50mA until I press a button).
I don't understand your comment about the variables initialisation. Is my "INIT" piece of code not correct?
Roger
Hi,
As you mentioned that after you press a button then the current goes down. You have also found out that it is the buzzer that is drawing the current. So when you are starting up your PIC if the port is set to an output you expect a low. If that was true then with the other end connected to VSS rules out any possibilities of drawing current. So the port is not low as expected. This is what I meant. You should always setup the initial states of the port yourself. The capacitor is acting as a DC blocking only and thus even if your port is high at startup it prevent current draw from the PIC. An interesting phenomena could be excessive switching noise at the PIC port (which starts as a input by default ), your buzzer can actually create signal if it is vibrated. Connect your scope to its ends and tap it to see for yourself. But that will not cause so much of current drain due to the internal CMOS structure switching with noise. So I still doubt what is the state of the pin when first start it up. 16F88 has got onboard peripherals which are connected to the same pin. Hope I have made myself clear this time.
Regards
Sougata
Hi,
As you mentioned that after you press a button then the current goes down. You have also found out that it is the buzzer that is drawing the current. So when you are starting up your PIC if the port is set to an output you expect a low. If that was true then with the other end connected to VSS rules out any possibilities of drawing current. So the port is not low as expected. This is what I meant. You should always setup the initial states of the port yourself. The capacitor is acting as a DC blocking only and thus even if your port is high at startup it prevent current draw from the PIC. An interesting phenomena could be excessive switching noise at the PIC port (which starts as a input by default ), your buzzer can actually create signal if it is vibrated. Connect your scope to its ends and tap it to see for yourself. But that will not cause so much of current drain due to the internal CMOS structure switching with noise. So I still doubt what is the state of the pin when first start it up. 16F88 has got onboard peripherals which are connected to the same pin. Hope I have made myself clear this time.
Regards
Sougata
Okay, I'll init it LOW.
It was now clear to me.
Checking this out now...
You're right - now it works fine.
Actually, I noticed that all PORTBs are driven HIGH for one second when I power-up the circuit. I initilize them to LOW but this happens after the register setting.
I don't think it would make sense to set the PORTBs LOW before the registers are set, does it?
Roger
Hi,
Could you please insert the following lines in your register settings:
Portb.5 is shared with the onboard Synchronous Serial Port. Turning off bit 5 of the SSPCON registers turns off this peripheral and configures it as general I/O.Code:SSPCON.5 = 0 ' DISABLE THE SYNC.SERIAL.PORT AND USE AS I/O TRISB = %11000000 PORTB = 0 ' Init PORTB to low
Regards
Sougata
Bookmarks