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 CCS Technical Support

how to measure a 6600hz signal?
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Dec 02, 2004 10:19 am     Reply with quote

Thank you:

I did google out as you adviced. I tried before, I typed in X0-543 which should be XO-543, and failed. Right now I find
Pin 1 N.C.
7 Ground
8 output
14 3.3VDC

I connected 14 to +5 volt, it seems output 20Mhz at Pin 8 also.

The problem is which pin on the controller should I connect with Pin8.
should I just connnect with OSC1 or OSC2? or should I connect Pin8 with both of OSC1 & OSC2?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 02, 2004 10:22 am     Reply with quote

OSC1 is also clockin, that is where it goes. You know the datasheet says that it is a 3.3volt part, right?
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Dec 02, 2004 10:25 am     Reply with quote

Your right. I was just wondering if it would work at 5V.
ckielstra



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

View user's profile Send private message

PostPosted: Thu Dec 02, 2004 10:48 am     Reply with quote

Quote:
Come on now, 2 minutes! Aren't you being conservation Very Happy More like 20 seconds Wink But seriously really easy to find.
Yes, it was under 2 minutes, but I didn't want to show off. Cool
Quote:
That's why I am selective about some posts. People do have to do some of the work!
I do agree. Some people really are too lazy. Wink
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 02, 2004 2:32 pm     Reply with quote

young wrote:
Your right. I was just wondering if it would work at 5V.

If the data sheet says it is a 3.3V part then it is a 3.3V part. Trying to run it at 5V will likely kill the part.

Look carefully at the data sheet and find the section that gives ABSOLUTE MAXIMUM/MINIMUM values. I'd bet the maximum Vdd allowed is between +3.6V and +3.8V.

Honestly, for all the time you spend posting you could just stop and do a little thinking on your own. Remember, Google is your friend and so are the datasheets!
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Mon Dec 06, 2004 10:30 am     Reply with quote

I am facing another problem. I could read and printf data (including the frequency data) correctly through RS232, However, When I put the remote data transfering function, I sometimes get frequency signal doubled what it should be, for example, I have frequency ranges from 710-780, I sometimes get printf data as 1410-1560. I fell that in my #int_CCP1, the start_tie was not updated sometime? I do not know why this happened? and how could I avoid the problem?

Code:


#if defined(__PCM__)
#include <16F76.h>
#include <stdio.h>
#include <stdlib.h>
#fuses HS,WDT,NOPROTECT
//#device ADC=10
#use delay(clock=20000000)
#use rs232(baud=2400, parity=N, xmit=PIN_C6, rcv=PIN_C7)

#ifndef EEPROM_SDA
#define EEPROM_SDA  PIN_C4
#define EEPROM_SCL  PIN_C3
#endif
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)

#define EEPROM_ADDRESS long int
#define EEPROM_SIZE   65536

int8 temperature,tilt;
int8 frequency,i, length;
int32 j=0, humidity,danum=0;
char status, status1[10];
int millisecs=0;
char datachar[20];

//for frequency
int16 overflow_count;
unsigned int32 start_time, end_time;
int32 pulse_ticks;

void remoteprintf(char *c)
{
   char synch;
   char junk;
   length=strlen(datachar);
   junk = 126;
   synch = 'A';

   while(1)
   {
   for (i=0; i<length;i++)
    {
      putc(junk);
      putc(synch);
      putc(datachar[i]);
      delay_ms(5);
    }
   putc(junk);
   putc(synch);
   putc(0);
  }
}

#int_TIMER1
TIMER1_isr()
{
   ++overflow_count; //increment whenever an overflow occurs;
}

#int_CCP1
CCP1_isr()
{
   end_time=CCP_1; //read captured timer ticks
   pulse_ticks=(0x10000*overflow_count)-start_time+end_time;
   start_time=end_time;
   overflow_count=0;   //clear overflow counts
}


void main()
{

   setup_port_a(AN0_AN1_AN3);
   setup_adc( ADC_CLOCK_INTERNAL );
 //  set_tris_a(0xFF);

   //time clock pulse 64*1/4000000=64*0.25microsecond=16microsecond
//   setup_counters(RTCC_INTERNAL,RTCC_DIV_64);
   setup_CCP1(CCP_CAPTURE_RE);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
//   enable_interrupts(INT_TIMER0);
   enable_interrupts(INT_TIMER1);   //unmask timer1 overflow interrupt
   enable_interrupts(INT_CCP1);
 //  enable_interrupts(INT_RDA);
   enable_interrupts(global);
 //  init_ext_eeprom();

   while(1)
   {
   set_adc_channel( 0 );
   delay_us(50);
   temperature = Read_ADC();

   //Without remote part (the following two lines, everything works just fine, with it I got the problem
   sprintf(datachar,"%u %lu t",temperature, pulse_ticks);
   remoteprintf(datachar);
  //printf("%u %lu\r\n",temperature, pulse_ticks);

 //20ms delay is a must for good data transferring
   delay_ms(50); 
   }
}

Guest








PostPosted: Mon Dec 06, 2004 12:34 pm     Reply with quote

some of my output are like these
Quote:

\0A137 1448 \0D
\0A137 137 724 \0D
\0A137 724 \0D
\0A137 724 \0D
\0A137 724 \0D
\0A137 724 \0D

0A137 724 \0D
\0A137 724 \0D
\0A137 724 \0D
\0A1137 726 \0D
\0A137 726 \0D
\0A137 726 \0D
\0A137 726 \0D


\0A137 726 \0D
\0A137 726 \0D
\0A137 726 \0D
\0A137 726 \0D
\0A137 726 \0D
\0A1136 1445 \0D
\0A136 1445 \0D
\0A136 1445 \0D



I am confused my the output by BLACK, and Do not know how to correct the problem?
Guest








PostPosted: Mon Dec 06, 2004 12:58 pm     Reply with quote

any clues, please?
drh



Joined: 12 Jul 2004
Posts: 194
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Mon Dec 06, 2004 3:08 pm     Reply with quote

Try putting a delay after the sprintf() call.
_________________
David
Guest








PostPosted: Mon Dec 06, 2004 3:31 pm     Reply with quote

Thank you:

I tried as you suggested, It did not improve the performance of the printf output.
Guest








PostPosted: Mon Dec 06, 2004 3:35 pm     Reply with quote

Expercially I do not understand why the output frequency value doubled what it sould be?
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Mon Dec 06, 2004 3:47 pm     Reply with quote

1) Check the assembly listing for your CCP1 interrupt. You may need to add a casting operation before you multiply "overflow_count" to make it an unsigned 32-bit integer.

2) Turn off the timer or in some otherway "freeze" the value of "pulse_ticks" just before you sprintf it into the string. Are you sure that an interrupt is not occuring in the middle of the sprintf call? Reenable the interrupt after you are done sprintf-ing the variable into the string.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Guest








PostPosted: Tue Dec 07, 2004 8:14 am     Reply with quote

rwyoung:

Than you very much, I think you did have some very good point.
I trired to modified my program, like this:

Code:

void main()
{

   int32 humidity;
   setup_port_a(AN0_AN1_AN3);
   setup_adc( ADC_CLOCK_INTERNAL );


   setup_CCP1(CCP_CAPTURE_RE);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   enable_interrupts(INT_TIMER1);   //unmask timer1 overflow interrupt
   enable_interrupts(INT_CCP1);
    enable_interrupts(global);

   while(1)
   {
   set_adc_channel( 0 );
   delay_us(50);
   temperature = Read_ADC();
   humidity=pulse_ticks;
   setup_CCP1(CCP_OFF);
   setup_timer_1(T1_DISABLED);
 
   DISABLE_INTERRUPTS(global);
   sprintf(datachar,"%u %lu t",temperature, humidity);
   remoteprintf(datachar);
   overflow_count=0;
   pulse_ticks=0;
   setup_CCP1(CCP_CAPTURE_RE);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   enable_interrupts(INT_TIMER1);   //unmask timer1 overflow interrupt
   enable_interrupts(INT_CCP1);
   enable_interrupts(global);

  //printf("%u %lu\r\n",temperature, pulse_ticks);

 //20ms delay is a must for good data transferring
   delay_ms(20);
   }
}


However I got more variable changes, I got the following results:


\0A124 494 \0D
\0A124 494 \0D
\0A124 494 \0D
\0A124 494 \0D
\0A124 742 \0D
\0A124 742 \0D
\0A124 742 \0D
\0A124 742 \0D

\0A125 792 \0D
\0A125 792 \0D
\0A125 792 \0D
\0A125 578 \0D

\0A124 578 \0D
\0A124 578 \0D
\0A124 578 \0D
\0A124 1377 \0D
\0A124 1377 \0D
Which I think I should follow to freeze timer1 and CCP1 during data transferring, but I failed to do that, would you please check it for me to find a solution!

Thanks again
Guest








PostPosted: Tue Dec 07, 2004 12:31 pm     Reply with quote

I am getting much better result than before, however, why the frequency is not stable, I mean relatively not stable for example, when the frequency is just a few Hz changes, there should be not reading various or very little, however, I am have a large various change, for example

a range
\0A132 738\0D
\0A132 735\0D
\0A133 738\0D
\0A133 741\0D
\0A133 735\0D
\0A133 733\0D

while the frequency is just around 6793-6795?

It looks like that I am still not getting the right result.

why this happens?
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue Dec 07, 2004 2:15 pm     Reply with quote

Have you tried "playing computer" at your desk? Take the assembly listing and a clean sheet of paper. Start plugging in reasonable numbers for your timer values and see if you can reproduce the error. It really sounds like there is a math error present. Either a roll-over/round-off issue or a bug in the way CCS is translating one or more of your functions.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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 Previous  1, 2, 3  Next
Page 2 of 3

 
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