CCS does not monitor this forum on a regular basis. Please do not post bug Reports on this forum. Send them to support@ccsinfo.com
 PIC16F877A with GLCD (HDM64GS12 with KS01108) Goto page Previous  1, 2, 3, 4  Next
Author Message
Ttelmah

Joined: 11 Mar 2010
Posts: 18072

 Posted: Tue Dec 14, 2021 8:02 am First thing honestly don't use floating point. This makes code bulky and slow. You could get '10' much easier with just integer numbers and just divide by 102. For 0-15, use /64. However using float as you show, if you want 15, then just use /160 instead of 255.
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Tue Dec 14, 2021 9:55 am I did but I can't obtain 0-15 one by one. It is being 0-1-3-4-6-7-8-9, jumps two step value. What can I do for this?
temtronic

Joined: 01 Jul 2010
Posts: 8525
Location: Greensville,Ontario

 Posted: Tue Dec 14, 2021 10:32 am quick comments.. 1) What are you using as the ADC Vref ? 2) What kind of 'filtering' have you on the ADC input pin ? 3) Show the program with how you read the pot. You'd probably be better using 8 bit ADC mode than the 10 bit.
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Tue Dec 14, 2021 11:07 am Vref=+5VLast edited by Khansokhua on Tue Dec 14, 2021 1:31 pm; edited 1 time in total
PrinceNai

Joined: 31 Oct 2016
Posts: 327
Location: Montenegro

Posted: Tue Dec 14, 2021 1:12 pm

I'd do three things. First some kind of averaging of the readings, maybe as simple as taking 8 samples, add them together and than divide the sum by 8. Second, the way my mind works, I'd forget the calculations and go with ranges, write a function to get the birler and onlar values directly with something like:

 Code: if(adc_value <= 68){    birler = 0;    onlar = 0; } else if (adc_value <= 137){    birler= x;    onlar = y;            // x and y represent the desired pattern in your digit constant to display 00 - 15 } . . . else{                     // do it for 0 - 15    birler = n;    onlar = m; }

And third, probably the easiest, I'd get a multiturn pot.
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Tue Dec 14, 2021 1:29 pm I just solved the issue. The POT I have been using had missing the voltage range. So I will be here for some new problems soon, I am sure. Thank you all
PrinceNai

Joined: 31 Oct 2016
Posts: 327
Location: Montenegro

 Posted: Tue Dec 14, 2021 1:45 pm Very nice to hear you solved the problem. I, for one, feel great when the code and hardware click together and work as intended. Without this forum and all the nice guys out there, I'd probably still be trying to blink a LED. I'm also not a native speaker of English language, but it made me laugh (do trust me, not in any bad way) the way you put it why you'll come back :-)
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Tue Dec 14, 2021 5:43 pm I have done so far these things "ready 0-15 POT ", "and will be displayed images", not much. Now I need to select and giving time processing. So what do you suggest? Respects
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Fri Dec 17, 2021 4:56 pm Greetings... I am stuck, I have 7 picture in program memory. Each of them 1024 byte. At last situation each time I press the button, I display the pictures by turn (0-1-2-3-4-5 6-0-1...(with arrays's index)). I want to write data (image) which I am being display at that moment with another button. However, PIC18F46K22 has 1024 byte EEPROM memory. Can I save index of array to show 1024 byte picture?Could you guide me what can I do to save chosen pictures with a button ? I should band together all of chosen. I hope I could explain. Respects...
temtronic

Joined: 01 Jul 2010
Posts: 8525
Location: Greensville,Ontario

 Posted: Sat Dec 18, 2021 6:36 am In the Q&A section of the CCS manual there's this .. How do I wait only a specified time for a button press? It actually does what you want to do ! Just change the 'timeout' vaule to give you maybe 5 seconds,that's lots of time to see the picture and decide IF you want to press button to select it. Code it as a function, then in 'main().. ... set index to zero 'loop to show pictures display a picture call 'buttonpressed' function check if 'button pressed is true'.....-> save the index value,and exit the 'show pictures loop' 'loop back for next picture(index++) .... .... now do 'something' with the saved index, maybe display THAT picture for ever ?
Khansokhua

Joined: 06 Nov 2021
Posts: 45

Posted: Sat Dec 18, 2021 1:58 pm

My apologies sir, excuse my ignorance.I just try to learn.Here I tried to save index into another array but couldn't happen.There is no error message.Without timing I just try to display selected pictures.Thank you. Respects...
Khansokhua

Joined: 06 Nov 2021
Posts: 45

 Posted: Mon Dec 20, 2021 6:33 pm Above, How do I can set display time using timer with ADC POT for each picture?
temtronic

Joined: 01 Jul 2010
Posts: 8525
Location: Greensville,Ontario

 Posted: Mon Dec 20, 2021 7:22 pm Once again ,have a look at this... In the Q&A section of the CCS manual there's this .. How do I wait only a specified time for a button press? Easily modified for what you want to do... within the loop to display the pictures add some code like.. ... preset the 'timed button press' for say 10 seconds now enter the ''button press loop' inside this loop, read the ADC and display on your 2 digit 7 segments turn pot until you get the number you want save the 'time value' for the picture. press the button ( or wait until timer ends) .... ... rest of main code.... 1) remember once you're in the 'get time 'loop, you only have , in this case 10 seconds to turn the pot. Really it's more than enough time. 2) you only need to update the 'time display, say every 1/2 second, otherwise it'll be a blur... 3) the time for each picture needs to be store with the picture data, so I suspect you'll use a 2d array. if the time is zero, that picture doesn't get displayed.
Khansokhua

Joined: 06 Nov 2021
Posts: 45

Timer1
Posted: Mon Jan 24, 2022 8:22 pm

Greetings
I want to use timer1 instead of delay_ms(3000). So what can I do about it ? Because I am receiving Interrupts disabled to prevent re-entrancy? I thought but did not found anything.

I arranged those

 Code: if(input(slayt))//slayt       {                            set_timer1(3036);              setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);              enable_interrupts(int_timer1);              enable_interrupts(GLOBAL);    }

timer1

 Code: #int_timer1 void kesme () {            set_timer1(3036);       a++;       if(a>=9){ int x=0;               int y=0; for(sunum=0;sunum<7;sunum++){//tüm indexleri tara 0-6        if(bosdizi[sunum]!=9){//eğer indexe ait 9 değeri değişmişse bir resim indexlenmiştir, tüm elemanların "9" olamsının sebebi budur.    glcd_init(on);    for(i=0;i<64;i+=8)       {             for(j=0;j<128;j++)          {             for(k=0;k<8;k++)             {                if(bit_test(imagineall[bosdizi[sunum]][sayac],k))//bosdiziye indexleri kaydetmiştik şimdi  her bir kaydedilen değer için resim gösterimi oluyor.                {                   glcd_pixel(x+j,y+i+k,ON);                }             }             sayac++;          }       }   }    sayac=0; }       }           }
temtronic

Joined: 01 Jul 2010
Posts: 8525
Location: Greensville,Ontario

 Posted: Tue Jan 25, 2022 6:22 am have a look at this... http://www.ccsinfo.com/forum/viewtopic.php?t=26177 it's a software based RTC in the code library. You can use the 'core' of it to set a flag that '3 seconds is done', to do 'stuff' in main. you have a programming issue with doing so much code inside the ISR !. ISRs are supposed to be small, tight code that set a few flags and change a few variables. They are NOT supposed to have 'delays' in them, no printing functions, no 'high math calculations(SINS, floating point, etc.)
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 HoursGoto page Previous  1, 2, 3, 4  Next Page 3 of 4

 Jump to: Select a forum Software----------------General CCS C DiscussionCode LibraryEZ App LynxBest OfKnown Issues Hardware----------------CCS ICD / Mach X / Load-n-Go
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum