CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

TIMER 2
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

TIMER 2
PostPosted: Fri May 24, 2013 2:17 am     Reply with quote

Hi friends
I often am upset with timer duration specs.

I need to do a FSK modem and begin with a prototype to test the principle.
I have Timer2 as carrier and Timer3 as modulation.
My project is to have Timer2 frequency ~= 100 kHz for a 1 value of Timer 3 and other (eg 120 or 80 kHz) for 0 value of Timer 3.

If I calculate correctly, when I want to transmit at 1200 Bdx, the bit duration is approx 830µs for Timer3.
So I need the carrier is much speeder, for example 10 (80µs) or 20 (40µs) times for Timer2 in order to have a quite correct "reaction time" and s/n ratio.

I want to setup timer 2.
And, there, the things become complicated.

setup_timer_2(T2_DIV_BY_1, period, postscale) works curiously
(my crystal is a 20MHz one, configured as HS).

(period, postscale)=(0x40,4) -> 52µs
(period, postscale)=(0x20,4) -> 26,4µs OK it is approx the half
(period, postscale)=(0x40,2) -> 26µs OK it is the half

But
(period, postscale)=(0x40,1) -> 19,6µs !
(period, postscale)=(0x20,2) -> 18,8µs !
(period, postscale)=(0x20,1) -> 18,8µs also !
(period, postscale)=(0x10,4) -> 21,4µs !

I understood that 0x20,4 == 0x40,2
or 0x40,8 (104µs) == 0x80,4 (104µs)

Am I wrong ?

I observe 0x10,4 != 0x20,2 != 0x40,1
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri May 24, 2013 3:59 am     Reply with quote

Why not throw a programmable divider at it, and save all the hassle?

Mike
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

PostPosted: Fri May 24, 2013 7:51 am     Reply with quote

Mike Walne wrote:
Why not throw a programmable divider at it, and save all the hassle?

Mike


????


The emmision will be done with this method (modem like) and thru mains line and the reception will be done via a LM567 wich decodes the 100kHz carrier and output the data signal to a RX pin of a PIC18.

Don't you think it will work ?
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri May 24, 2013 7:59 am     Reply with quote

You haven't told us the data rate.

Mike
temtronic



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

View user's profile Send private message

PostPosted: Fri May 24, 2013 8:12 am     Reply with quote

Wow ! LM567 !! I haven't used them for 30 years ....
Low speed data rate <1200 baud, think X-10 style communications.

jay
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

PostPosted: Fri May 24, 2013 8:17 am     Reply with quote

temtronic wrote:
Wow ! LM567 !! I haven't used them for 30 years ....
Low speed data rate <1200 baud, think X-10 style communications.

jay


Hé hé ...
Do you know a more modern solution ?

The data rate could be 1200Bdx, the usefull message is one byte long, so the transmitted message can be 2 or 3 bytes including a CRC.
The distance is approx 2 or 3 km
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri May 24, 2013 8:37 am     Reply with quote

I have a pile of LM567 left form a DTMF control proyect!

I am amazed you are using those too.... are they not extinct?

Sometime ago i was thinking of what kind of "hack" i could do to get similar functionality...

The only thing i came up with was to modulate signals at 38khz, and on the reciever end, feed them to a IR led and into a IR decoder....

... seemed like a Rube Goldberg machine, so i didnt test it.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri May 24, 2013 8:43 am     Reply with quote

Hi,

The MX-COM MX-614 FSK modem chip is popular with the 1200 baud Amateur packet radio crowd. It's a transceiver IC, and can be implemented with a minimum number of external components!

John
temtronic



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

View user's profile Send private message

PostPosted: Fri May 24, 2013 9:02 am     Reply with quote

Is this over existing power lines or can you run/use your own copper?
If own copper or leased lines from local telephone company it is super easy to do 3 kliks. I could get almost 20 miles on ONE solid copper wire( NO signal conditioning), using 24 baud( yes, 24 bits per second).hacker proof, lightning proof,rate ULC AA(think bank security systems).
Simple 16F877 master and up to 64 ,16F84 slaves..

hth
jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 24, 2013 10:05 am     Reply with quote

Quote:
setup_timer_2(T2_DIV_BY_1, period, postscale) works curiously
(my crystal is a 20MHz one, configured as HS).

(period, postscale)=(0x40,4) -> 52µs
(period, postscale)=(0x20,4) -> 26,4µs OK it is approx the half
(period, postscale)=(0x40,2) -> 26µs OK it is the half

But
(period, postscale)=(0x40,1) -> 19,6µs !
(period, postscale)=(0x20,2) -> 18,8µs !
(period, postscale)=(0x20,1) -> 18,8µs also !
(period, postscale)=(0x10,4) -> 21,4µs !


This is most likely a problem caused by the interrupt overhead and
user code processing time. Post your #int_timer2 routine.
See these threads:

Maximum Timer ISR Speed -
http://www.ccsinfo.com/forum/viewtopic.php?t=43399

Timer 1 interrupt in high speed -
http://www.ccsinfo.com/forum/viewtopic.php?t=46522

External interrupt speed -
http://www.ccsinfo.com/forum/viewtopic.php?t=40169
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

PostPosted: Tue May 28, 2013 4:08 am     Reply with quote

PCM programmer wrote:

Post your #int_timer2 routine.


Code:
//génération des pulses flash et horloge---------------------------------------


#int_TIMER2 HIGH
void HF()
{
   Output_toggle(PIN_B5);
}   


This gives 26µs with 0x40,2

Code:
#int_TIMER2 HIGH
void HF()
{
   B_Interrupt2_seen=TRUE;
}   
//--------------------------------------------------------------------------Main

void main()
{
   while(true)
   {
      if(B_Interrupt2_seen)
      {
         B_Interrupt2_seen=FALSE;
         Output_toggle(PIN_B5);
      }
   }
}


Gives the same 26s
With 0x20,2 I have 40µs !! not 13, the half
With 0x80,2 I have a jitter betwen 51 and 52µs nearly the double, but instable.
Also with 0x40,4
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

PostPosted: Tue May 28, 2013 4:25 am     Reply with quote

And with #FUSE H4 instead of #FUSE HS I have 9,4µs which is not in correlation any more, is it ?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue May 28, 2013 5:08 am     Reply with quote

Jean FOUGERON wrote:
And with #FUSE H4 instead of #FUSE HS I have 9,4µs which is not in correlation any more, is it ?
Quote:
my crystal is a 20MHz one, configured as HS
You didn't specify which PIC18 you are using, but I don't think there is one that can run at 4 * 20MHz = 80MHz.
For most PICs the maximum frequency you can get is a 10MHz crystal at H4 = 40MHz.
Jean FOUGERON



Joined: 30 Nov 2012
Posts: 110
Location: France

View user's profile Send private message Visit poster's website

PostPosted: Tue May 28, 2013 6:35 am     Reply with quote

ckielstra wrote:
You didn't specify which PIC18 you are using


PIC 18F1220

But I observe a difference between HS and H4 with the same crystal 20MHz
Ttelmah



Joined: 11 Mar 2010
Posts: 19366

View user's profile Send private message

PostPosted: Tue May 28, 2013 7:32 am     Reply with quote

You would.
Either the chip will try to run at 80MHz, and lots of parts won't work, or the PLL will lock onto an undertone of the crystal, and you could be running at almost any frequency....

Taking things wildly out of spec is a very reliable way of ensuring they don't work.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group