PIC-Based Battery Monitor
-
My friends, as usual, drove me to craziness again and led me to design,
fabricate and test a smart battery monitor... The usual blinking lights and
so on.....
13 years ago
13 comments:
tak aci!!!!!! pakai cacing...
Got cacing and panah oso...
Cacing and panah was going to me my next lesson.. :)
Good try dexter. The idea is to make the code small. Thats why we have loops. It reduces repetitive task and expands on it. But at least i know, we have an audiance now. I will try to post more info, when i get the time. If it was MikroBasic it would be easier. :) bcos you can use variable to access individual bit on portX.
in basic you could do portb.bit where bit is a variable from 0 to 7.
Unfortunately in MikroC this does not work.
Maybe i should not have posted the programming lesson until i explained bit access..
Hey how you guys capture screen? what software you use?
This is the code for blinking one way with out using >> and ~.
main() {
unsigned char mbit, count,x;
trisb=0;
while (1) {
for (count=1; count<=8; count++) {
mbit=1;
if(count!=1) {
for (x=1; x<=count; x++) {
mbit=mbit*2;
}
}
portb=mbit;
delay_ms(100);
}
}
}
Basir you too advance...Where is uncle Chow and Yau?
Hamid,
Let it be advance... can use to introduce some more C operators... and push them to learn and explore more...
I used screen capture from here...
http://www.mirekw.com/winfreeware/mwsnap.html
Freeware... but very good...
I know...I havn't explained the cacing and panah. :) i tot they could write the code with what they learned so far. It is easy for, if we dont know how to do something, we know what term to look for in the help file, but they dont.
On the other hand, they get exposed to new commands and functions. And since it is a hands on approach, they should understand faster.
I am still working on the conditional, bitwise, if(, baseN and boolean operators. All on paper not to pc yet. too busy...
Actually, I am confused because I don't have any reference and explanation for C syntax and usage..
Although Hamid did some explanation earlier, it's confusing cos it is not separated by making the syntax as "Bold" and the explanation in normal.
Actually, I am confused because I don't have any reference and explanation for C syntax and usage..
Although Hamid did some explanation earlier, it's confusing cos it is not separated by making the syntax as "Bold" and the explanation in normal.
Actually, I am confused because I don't have any reference and explanation for C syntax and usage..
Although Hamid did some explanation earlier, it's confusing cos it is not separated by making the syntax as "Bold" and the explanation in normal.
Hamid... are you writing the post in Open Office? Doing it using blogger interface sometimes doesn't give the expected results once you do heavy editing...
On the cacing and panah, I just wanted to throw some spanners into dexter's head... just for fun... hi hi...
ADC lesson being written-up... need to test it on the DevBoard before putting it up...
My code makes me look quite silly but I am a newbie at this.
int a = 1;
void main ()
{
TRISB = 0;
PORTB = 0;
while (1);
{
do
{
PORTB = a;
Delay_ms(100);
a <<= 1; //shift bit to the left
}
while(a<255);
a >>= 2; //stops bit 7 double flashing between do loops
do
{
PORTB = a;
Delay_ms(100);
a >>= 1;
}
while(a>1);
}
}
Sorry there was a small mistake in my last post.
Should be:
int a = 1;
void main ()
{
TRISB = 0;
PORTB = 0;
while (1)
{
do
{
PORTB = a;
Delay_ms(50);
a <<= 1; //shift bit to the left
}
while(a<255);
a >>= 2; //stops bit 7 double flashing between do loops
do
{
PORTB = a;
Delay_ms(50);
a >>= 1;
}
while(a>1);
};
}
Hi there Sparky,
Everyone's a newbie at sometime so no need to feel silly... :-)
What's important is you can do it... get a working code and you're learning in the process....
We're no expert... just a bunch of guys who like to tinker around... Good to know someone else is benefiting from this blog...
Post a Comment