caramoan tour package

caramoan tour package

Author Topic: Q&A sa CCS C  (Read 7218 times)

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Q&A sa CCS C
« on: February 25, 2009, 01:27:57 PM »
sa lahat ng may question sa CCS C, you may post your questions here para masagot ng ating mga masters?


here's my question po:

gusto ko po sanang gumawa ng up/down counter using pic16f84a kasi to lang ang available kong MCU.

tpos ganito po ang ginagawa nya:

may dalawang switch, isa para sa increment isa naman para sa decrement at ididisplay po ang count sa 3 multiplexed na 7 segment display.

at pagkatapos po ng approx. 10 minutes isisave nya to sa eeprom ng mcu. para pagnawalan man ng power yung circuit ang last count pa rin ang ididisplay nya sa 7 segment kasi kukunin nya na muna yung count sa eeprom.

hope you can help me with this mga masters...
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Q&A sa CCS C
« on: February 25, 2009, 01:27:57 PM »

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #1 on: February 25, 2009, 02:29:37 PM »
hehe parang walang gustong sumagot dito ah,

sige ito na lang po.

papano po bang ang routine para sa 10 min delay using tmr0 ng pic16f84a using CCSC? assuming that im using a 32.768Khz LP oscillator. ;D

please, sagot naman kayo dito. ;D
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Re: Q&A sa CCS C
« Reply #1 on: February 25, 2009, 02:29:37 PM »

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #2 on: February 27, 2009, 11:47:03 AM »
hehe parang walang gustong sumagot dito ah, ;D

sige ito na lang po.

papano po bang ang routine para sa 10 min delay using tmr0 ng pic16f84a using CCSC? assuming that im using a 32.768Khz LP oscillator.

please, sagot naman kayo dito.  ;D
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Re: Q&A sa CCS C
« Reply #2 on: February 27, 2009, 11:47:03 AM »

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #3 on: February 27, 2009, 12:46:07 PM »
tagal ko na din kinukulit ang CCS C nyan....
at since di ko talga masove kahit dinifine ko na yung mga registers manually, pagkatapos ko lang ng project ko, lipat an ako dyan...

kasi sa hitech, ang definition ng registers ay direkta. tulad ng PSA, PS0, etc...
kahit pinilit ko na sa CCS, di nagwork.
#bit psa        = 0x81.3
#bit ps2        = 0x81.2
#bit ps1        = 0x81.1
#bit ps0        = 0x81.0

baka may mali lang ako, balitaan kita maya kung may magawa ako. :)
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Philippine Electronics Forum

Re: Q&A sa CCS C
« Reply #3 on: February 27, 2009, 12:46:07 PM »

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #4 on: February 27, 2009, 02:16:44 PM »
^hay salamat may nagpost na rin sa thread na to. hindi lang pala ako ang namomroblema bout sa topic na to e.

sa assembly kasi sir parang kaya kong gawin ang 10 min delay na yan using timer0, pero since baguhan ako sa C tlgang nahihirapan ako. kaso gagamit pako ng eeprom e, masyadong madugo kung assembly ang gagamitin ko. lalo na sa pagwrite sa eeprom every 10 mins. maganda sana sa CCSC kasi andaming built-in functions, sa hitech c naman halos wala. need ko kasi before 2nd week of march yung ginagawa ko e.

balitaan moko sir. ;D
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Re: Q&A sa CCS C
« Reply #4 on: February 27, 2009, 02:16:44 PM »

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #5 on: February 27, 2009, 03:22:47 PM »
eto... very simple code using RTCC interrupt.

after 10 mins, this shall show a very common knowledge! hehehe ;D

Code: [Select]
#include <16F84A.h>

#FUSES NOWDT,XT,NOPUT,NOPROTECT

#use delay(clock=32768)       // this could be remove, however flex_lcd420.h
                              // requires to use delay_us();

#include "delay_TMRO_flex_LCD420.h"

short RTCC_flag;

#int_RTCC
void  RTCC_isr(void)
{
   RTCC_flag = TRUE;          //fires when RTCC interrupt occurs
}

void main()
{
   int sec, min;
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);    //overflow every 1.0s
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
   
   lcd_init();
   lcd_gotoxy(1,1);
   printf(lcd_putc,"TIME: ");
   
   while(TRUE)
   {
      if(RTCC_flag)
      {
         RTCC_flag = FALSE;
         sec++;
         if(sec>=60)
         {
            sec = 0;
            min++;
            if(min>=10)
            {
               min = 0;
               lcd_gotoxy(1,4);
               printf(lcd_putc,"marcelino pogi mo!");
               
            }
         }
      }
      lcd_gotoxy(7,1);
      printf(lcd_putc,"%02u:",min);
      lcd_gotoxy(10,1);
      printf(lcd_putc,"%02u",sec);
   }
}
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #6 on: February 27, 2009, 03:34:17 PM »
Code: [Select]
while(TRUE)
   {
      if(RTCC_flag)
      {
         RTCC_flag = FALSE;
         sec++;
         if(sec>=60)
         {
            sec = 0;
            min++;
            if(min>=10)
            {
               min = 0;
               lcd_gotoxy(1,4);
               printf(lcd_putc,"marcelino pogi mo!");
               
            }
         }
      }
      lcd_gotoxy(7,1);
      printf(lcd_putc,"%02u:",min);
      lcd_gotoxy(10,1);
      printf(lcd_putc,"%02u",sec);
   }

^^nyahaha ayos a...

pero sir marce yung 10 min delay pala is not really part of the interrupt routine no? pupunta lang sya sa isr every 1 sec para iset yung flag tapos balik sa sa while loop. the isr allows it na makalabas ng while loop every second hanggang mag 10 minutes, tapos yun na lalabas na yung message na GWAPO ako.nyahaha

ayos to sir marce nagkaidea nako kahit papano.

pero one time lang yan sir diba, di na nya ululitin ang buong routine. papano kaya gagawin to, maglalagay na lang ng expression sa loob ng while(expression)?
if you think you can or think you can't, you're probably right -h.ford

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #7 on: February 27, 2009, 03:42:43 PM »
actually, try mo muna yan sa proteus... hinintay ko talga kanina ang 10mins. Biglang na bobo, pwede naman gawing 1min.

NWEI, if you test that pagnareach na ang condition na if (min>=10), magpopost lang naman yung POGI AKO. then restart ang time. ibig sabihin, pwede kang maglagay ng kahit anong function sa loob ng if-statement na yun. say, explode_bomb_1(), the pagnareach uli yung 10mins explode_bomb_2()... bahala ka na.

and yes, uulitin nya pa din. bawasan mo muna to 1 ang min variable, then simulate mo. :)
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #8 on: February 27, 2009, 03:49:21 PM »
ay oo nga pala, kasi ginagawang zero ulit sa kada loop yung sec tapos min.



OT.

sige na nga kaw na yung pogi, kaw naman gumawa nya e. ;D pag tinest ko sa proteus ko na lang palitan na clarkent pogi.nyahaha
if you think you can or think you can't, you're probably right -h.ford

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #9 on: February 27, 2009, 03:52:12 PM »
nga po pala sir marce, kung sakali pong gagamit ako ng multiplexed na seven segment display(say 3 digits) saan ko po kaya pwede ilagay ang routine para dun sa code na ginawa mo?
if you think you can or think you can't, you're probably right -h.ford

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #10 on: February 27, 2009, 03:56:39 PM »
nga po pala sir marce, kung sakali pong gagamit ako ng multiplexed na seven segment display(say 3 digits) saan ko po kaya pwede ilagay ang routine para dun sa code na ginawa mo?

you can delete this part....
Quote
      lcd_gotoxy(7,1);
      printf(lcd_putc,"%02u:",min);
      lcd_gotoxy(10,1);
      printf(lcd_putc,"%02u",sec);

of course replace it. hehehe ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #11 on: February 27, 2009, 04:01:15 PM »
multiplexed, so... parang mabilis lang ang ilaw nung isang seven seg, di ba ??? parang dapat mong bawasan ang overflow... para ang refresh rate mas mabilis...

I had once used seven seg pero isa lang. so didicated! nagoverflow ako nun ng 250ms kasi may push bottoms for set ups... eh sayo multiplexed!

experiment ka nalang ng overflow nyan
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #12 on: February 27, 2009, 04:05:41 PM »
you can delete this part....
of course replace it. hehehe ;D

nyak!!!hehe di kasi nagbabasa e. namiss ko pala ang part na to. na para syang nagkacount.

tama sir need kong pagexperimentohan ang overflow kasi baka panget ang kalabasan ng display kung every sec sya pupunta ng isr. pwede sigurong habaan ko ng konti para mas maraming time nyang gagawin yung pagpapailaw sa tatlong display.
if you think you can or think you can't, you're probably right -h.ford

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #13 on: February 27, 2009, 04:09:40 PM »
nyak!!!hehe di kasi nagbabasa e. namiss ko pala ang part na to. na para syang nagkacount.

tama sir need kong pagexperimentohan ang overflow kasi baka panget ang kalabasan ng display kung every sec sya pupunta ng isr. pwede sigurong habaan ko ng konti para mas maraming time nyang gagawin yung pagpapailaw sa tatlong display.

ang pagkakaintindi ko ng multiplexed at may roon lang common datalines pero yung switch for supply ang nagkakaiba-iba...
kung tama ang pagkakaintindi ko, dapat bilisan mo pa...
sa pagkakaalam ko nga, para matrick natin ang mata ng tao, ay as low as 40ms dapat ang transition...
di ko actually alam. hehehe ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #14 on: February 27, 2009, 04:17:30 PM »
ah... hehe ganito kasi sir. ang balak kong gawin is an up/down counter. ididisplay ng multiplexed display ang count and after 10 mins issave nya to sa eeprom. tama ka sir gagamit ako ng ibang pins para maswitch ko yung bawat isang display alternately.

40ms pala kelangan ko dun,hehe  ;D lagyan ko na lang cguro ng delay_ms(40); ano sir?hehe
if you think you can or think you can't, you're probably right -h.ford

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #15 on: February 27, 2009, 04:20:28 PM »
ah... hehe ganito kasi sir. ang balak kong gawin is an up/down counter. ididisplay ng multiplexed display ang count and after 10 mins issave nya to sa eeprom. tama ka sir gagamit ako ng ibang pins para maswitch ko yung bawat isang display alternately.

40ms pala kelangan ko dun,hehe  ;D lagyan ko na lang cguro ng delay_ms(40); ano sir?hehe

di ko alam...
hehehe
ilang time ba ang required para madaya ang mata sa mga multiplexed seven segment (in your case, tatlo yan)...? hehehe ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #16 on: February 27, 2009, 04:24:43 PM »
ewan ko sir, sa pagkakaalam ko pag gabi nagmumukhang maganda ang ibang babae e.nyahaha nadadaya ang mata natin. ;D


siguro trial and error na lang, kung anong delay ang makakapagbigay ng magandang resolution yun na lang.hehe
if you think you can or think you can't, you're probably right -h.ford

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #17 on: February 27, 2009, 04:33:57 PM »
sir marce natry mo na rin po bang gamitin ang eeprom ng pic16f84a?

write_eeprom(variable,address);

ito po yung syntax sa pagwrite sa eeprom diba?
ano po kaya ang routine if i'm going to write 3 variables to 3 different addresses?

say ones, tens, hundred are count files and i want to save their contents to 3 different locations in the eeprom.
if you think you can or think you can't, you're probably right -h.ford

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: Q&A sa CCS C
« Reply #18 on: February 27, 2009, 04:40:43 PM »
ewan ko sir, sa pagkakaalam ko pag gabi nagmumukhang maganda ang ibang babae e.nyahaha nadadaya ang mata natin. ;D


siguro trial and error na lang, kung anong delay ang makakapagbigay ng magandang resolution yun na lang.hehe

nangyayari yan at 2am kung di ka nakainom. pero kahit 12midnight kapag maynainom na, maganda na lahat! hehehe

trial ang error na nga lang...

sir marce natry mo na rin po bang gamitin ang eeprom ng pic16f84a?


di pa ako nakakatry nyan... wala pa akong apps na naiisip tungkol dyan.
ang alam ko maraming cpu time ang kinakain ng function na yan so beware on the timing...
ayon lang to sa nabasa ko... heheh ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: Q&A sa CCS C
« Reply #19 on: February 27, 2009, 04:47:51 PM »
oo nga sir, nung nagtry nga ako ng routine na to yung RAM ko halos 50% agad yung nagamit. pakioras na magastos pa.
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Re: Q&A sa CCS C
« Reply #19 on: February 27, 2009, 04:47:51 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com