1 Attachment(s)
Startup power higher than while program running - why?
Hello,
I'm finishing my timer project and I have started to measure power consumption to correctly dimention the power supply on the final PCB.
When I power-up my circuit, the Amp-meter says 50mA. The timer is in some kind of idle mode since it waits for a player to start the timer or to choose the numbers of players.
When a button has been pressed, the current drops down to 19mA (!?) and stays around this value for all the time the game is ongoing.
In the START loop, pressing the RED button will ask the user to choose how many players will play. When it comes back to the initial display (still in the START loop), the current has dropped to 19mA (!?).
I can software reset the game (no power OFF) so the timer can come back to the very starting point of the program = same point as when the circuit is powered-on. The current goes then back to 50mA.
I assume something is wrong in my "START" loop.
Yes but what???
I had to attach the code in a .TXT file since it was to big to be fit in the post.
PS: it's my first "real" program so critics & comments are really welcome
Initialize your variables and ports
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.
Set your Buzzer port to low
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.
Set your Buzzer port to low
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.
Default register settings
Sougata,
I think my SSPCON register is already set but, just to make sure, am I right to say that in the PIC's datasheet, the register settings have default values I can read like here "R/W-0" and it would mean that the bit is set to 0?
Code:
REGISTER 10-2: SSPCON: SYNCHRONOUS SERIAL PORT CONTROL REGISTER (ADDRESS 14h)
R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
WCOL SSPOV SSPEN(1)CKP SSPM3 SSPM2 SSPM1 SSPM0
bit 7 bit 0