Temperature

spinnaker

Joined Oct 29, 2009
7,830
See how much easier that was? Do you know about the word Thank you????


10 seconds in only 24 minutes seems like a lot but RTC chips have the ability to adjust them for differences in crystals and the rest of the circuit. You might try the same by slightly adjusting your prescaler.

Edit: pre load registers not prescaler.
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
Have tried. But i do not seem to help
have set 32675 HEX 3FFD
should be 3 cause have 3 instruction. Before new value ib TMR1
Again please post in full complete sentences. Have tried what? Set what?

Your English does not need to be perfect but you need to express complete information to be understood.

What does "should be 3 cause have 3 instruction" mean?
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
Have tried to change preload to 32765 instead of 32768
Have 3 instruction before timer1 counts again after interrupt
used the calculater program u mension.
But maybe i just have to change it more.
24 minutes= 1440 sec should have counted 1450 sec
aprox 6,98% ~~ 32768 - 6,98% = 30480 . Is that the way to fix the time ?
 

spinnaker

Joined Oct 29, 2009
7,830
You are on the right track. I am not sure I would worry about instructions to fix the timing issue. I think the processor is running at a pretty fast speed? If so it is not going to matter much. If you are using instructions you could embed assembler noop instuctions.

I think the real key is that preload. Keep playing with it. Make sure it is making a difference as you change it. You might want to change it to something extreme just to check that there is a difference. Remember to change in your ISR as well as when the timer is initialized.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
In order to make the rime run faster, i will need less counts to interrupts. right ?
32768 down to 32256 ( 7E00 ) should get the time to run faster, right ?
It get it to run slow, allmost a minute on every 10 minuts.
Now i have set Timer1 to 8200 (33280 ) , now it run to fast,
Test now with 8100 (33024 ), it runs perfect,
Now i just wondering why, do the voltage has anything to say ?
if it does, then i proberly should leave it af 32768, cause i have esact 5.00v in my real circuit, test board only 4,72v

Edit.
Next issue, when i use delays, ex
Rich (BB code):
__delay_ms(500)
the delay should be a halv second ?
but delay i near 5 seconds. any hint why ?
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
There are a lot of ways to fix this.

Here is what I would do.

Use the current timer interrupt as my time keeper interrupt. It would set a timeReady flag when the time was updated. The main loop would wait for this flag to be set then update the display and then clear the flag.

Create a second timer interrupt to read the temperature, (this could also be done on the main loop but once a second might be too often to read temperature). The ISR would either read the temperature and set a temperatureReady flag or you could read the temperature in the main loop. The main loop would clear the flag once the temperature was updated on the display.

Also there is no need to wait for the ADC to be read. There is an interrupt that generates when the ADC value is ready. So what you could do is have the temperature interrupt start the read of the ADC then the ADC interrupt would set the temperatureReady flag. This really is the right why to do it but might be a bit complicated for you now so it is not really needed.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
The Delay routine is for when pressing a switch, and until it should retur to "normal" readout.
I think it would be to complicated to make it with more timers.
delay function should work, but is to slow..

The ADC i mostly have got working,
Just the part with decimal point i numbers is missing.

And the final thing, is how to store things in memory, like in EEProm in 16F690 ???
Is this not possible , i cant use this chip.
I will need at least 30-35 numbers to be stored.
 

spinnaker

Joined Oct 29, 2009
7,830
I think it would be to complicated to make it with more timers.
delay function should work, but is to slow..
Not really. You just pretty much duplicate what you have. I gave you good advice but I can't force you to follow it.


The ADC i mostly have got working,
Just the part with decimal point i numbers is missing.

Here is how I do it. This might not work for your compiler.

Rich (BB code):
    sprintf(string,(const far rom char*)"Panel    %2d.%02dV    ",(int)fPanelVolts ,(int)((fPanelVolts - (int)fPanelVolts) *100)); 
  LCD_string(string,2);    // Write to the LCD display
And the final thing, is how to store things in memory, like in EEProm in 16F690 ???
Is this not possible , i cant use this chip.
I will need at least 30-35 numbers to be stored.

Not easily. There might be a way to store values in program memory but I would not know how. It is always best to check out a Pic before buying.
 

t06afre

Joined May 11, 2009
5,934
In your program you have defined
__CONFIG (......... FOSC_XT);//INTOSC);//XT
The idea behind your setup is to use the internal oscillator for the MCU. So this does match at all. Replace FOSC_XT with FOSC_INTOSC and your delays should be correct
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
In your program you have defined
__CONFIG (......... FOSC_XT);//INTOSC);//XT
The idea behind your setup is to use the internal oscillator for the MCU. So this does match at all. Replace FOSC_XT with FOSC_INTOSC and your delays should be correct
Maybe delays will be ok, but then the time will not run, have been over that.
 

t06afre

Joined May 11, 2009
5,934
Sure, but flash looses the info after a powerlose.
Have read a lot, but cant find any thing that explain otherwise.
Then i could just use a varibel to "store" in, if it is lost anyway.
Nah the flash memory is the same as program memory. Instead of EEPROM. Your chip has a 128 Bytes High-Endurance Flash Memory Address Range 1F80h-1FFFh. That will be good for 100000 write cycles minimum. We just need to tell the compiler that this range is off limit for program code. And then you can use the flash_read or flash_write function to read/write data to this sections.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
. We just need to tell the compiler that this range is off limit for program code. .
How, ?
Have check options in mplab, and cant find anything.

Edit
Have read the manual, and found that i should put it in picc.ini file,
But i am unsure how.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
You define just this line in your code
Rich (BB code):
const char rain_mem[32] @ 0x1F80;
However the flash_read() and flash_write() will not do the job. On your chip. It is easy to read from the flash. But then writing to the flash you have read a block of 32 words into the memory. Do the changes and then write this block back to the flash. Quite doable. I think the solution is to look at how this is solved in the libraries for 18F series chips. And then just copy/modify that code. As of now, I have some beer and the 2 last episodes of forbrydelsen(the killing) calling my name.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
Have been study a lot.
But i cant fint any samples to do it., only some in ASM code.
32 Words. is that 32 places to store a number from 0-255 (00 to FF ) ?
or `?

How do i define that i should read from "place nr 1" ect.

Have found that i need to unlock some register to read and write, but how.
 

spinnaker

Joined Oct 29, 2009
7,830
Have been study a lot.
But i cant fint any samples to do it., only some in ASM code.
32 Words. is that 32 places to store a number from 0-255 (00 to FF ) ?
or `?

How do i define that i should read from "place nr 1" ect.

Have found that i need to unlock some register to read and write, but how.

Again. Post in full complete thoughts. I am going to assume you are talking about flash read and flash write.

It took me all of 5 minutes to find this article on google.

http://www.ronybc.com/pic-flash.php

Check it out. See if it helps. I did not read it in detail.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
708
lucky i have antivirus, attack from the site.
have a look at it, but it looks very complicated,
maybe i just have 30 variables. maybe i have space for it.
 
Top