Jump to content

Recommended Posts

I am a new user of source boost. I used to prog pics with assembly before but now have a more complex project and so choose Source Boost which seems very well supported.

I am using the new enhanced pic 16F1934 for my project.

 

1st problem - When debugging my project, Port A is always 0, port B works as it should, Port C and PortD have the lower 3 or 4 bits always 0 too. However if I program the Pic, all ports work fine.

Did I miss some settings?

 

2nd problem - My project consists of 10 modules (pic in each module) connected via RS485 to PC. When I send the start command (from PC) each module must read data from eeprom - consisting of port values and delay to the next eeprom read. Total loop time is about 30mins.

My problem is that the clock of the pics seems not very accurate. After about 10 mins there is already an error of 1s while I need syncronisation to at least 50ms. I am using the internal clock at 16Mhz.

Any help how to solve this?

Edited by Moonwalker
Link to post
Share on other sites

Thanks m8 as you say 1s in 10mins is less than 1% after all. However I cant use an external crystal because I am using the OSC pins as output and all other pins are used up. I think what I need is some sort of calibration of the internal oscillator using OSCTUNE.

So whats the best way to go about it and once I get a value for OSCTUNE, will that stay valid forever or it will need recalibration from time to time?

Link to post
Share on other sites
  • 4 weeks later...

Will this help?

 

On the WIKI

 

The Perfect Second

 

There is a link to the Roman Black timing algorithm

 

"www.RomanBlack.com

 

Zero-error 1 second Timer

A very versatile Zero Cumulative Error timing system with PIC source code

Roman Black - orig June 2001 - update Aug 2006 - update 21 Nov 2009.

 

What is it?

 

Bresenham's Algorithm is a system where 2 imperfect periods can be alternated to produce an average that matches any "perfect" period.

 

With most modern micros the easiest time period to generate is an overflow of the internal timer, generally 256 ticks or 65536 (256x256) ticks. Unfortunately, since most of these Micros run at crystal speeds like 4MHz and 20MHz, these overflow timed periods generated are binary and cannot be evenly divided into 1 second or any easily usable real-world clock value.

 

Brilliant programmer Bob Ammerman recognised this fact and mentioned his use of a Bresenham-type system for PIC micros. Later I did some more work on the idea to speed-optimise it for the PIC timer0 overflow which is available on all PICs and release the results as public domain open source. It should also work on any other micro with a binary-multiple internal timer.

"

 

Ted

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...