|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
digital output frequency
Hello everyone!
Is there any command in C language equivalent to freqout in Pbasic language, or a way to do a digital output oscillate in a 38500 frequency? Thanks in advance |
|
#3
|
||||
|
||||
|
Re: digital output frequency
Quote:
|
|
#4
|
|||
|
|||
|
Re: digital output frequency
You can use the CCP module on the PICs to get a signal on pwms 13-16 there is an example of that in the code I believe. If not its in one of the programming .pdf's somwhere. Not 100% sure all what you need to do, but check out some of the programming guides and datasheets on microchip.com about programming it too.
|
|
#5
|
|||||
|
|||||
|
Re: digital output frequency
Quote:
Oliver, I was kind of in a hurry (watching two webcasts at the same time ), so here's a bit of clarification from my previous post:If you don't need to send those pulses at a precise rate, as the beacon code did last year, you can probably just use Kevin's LED Dimmer code to generate PWM signals. Using that file and the PIC18F8520 data sheet (pages 143-144 and 156-157) you can select the frequency you want. As a matter of fact, I believe the following code (copy'n'paste inside the User_Initialization function in your user_routines.c file) will generate you a nice 38.46 KHz PWM with a 50% duty cycle. I don't have an RC or EDU in front of me right now to test it; if your application involves human safety, wait till someone more knowledgeable (yes, Kevin Watson ) approves this code, otherwise, just test it! (be aware that using IFI's PWM will 'cause you trouble if using interrupt intensive code, especially Kevin's gyro code - both use Timer2) Code:
PR2 = 0x40; // sets 38461 Hz freq.
CCPR2L = 0x20; // sets 50% duty cicle
T2CONbits.T2CKPS0 = 1; // sets 1:4 prescale
T2CONbits.T2CKPS1 = 0; // same as above
T2CONbits.TMR2ON = 1; // starts timer 2
Setup_PWM_Output_Type(USER_CCP,IFI_PWM,IFI_PWM,IFI_PWM);
[EDIT] Why not just use last year's IR receivers (am I wrong assuming you want that particular 38500 Hz frequency for that? ), rated at 40 KHz, and use the code that's already available from a much much more reliable source? ![]() Last edited by Manoel : 06-03-2005 at 01:07. Reason: Added info |
|
#6
|
||||
|
||||
|
Re: digital output frequency
Quote:
-Mike EDIT: ok, i didn't read ahead, it was already said, but the boe bots were a neat little device. |
|
#7
|
|||
|
|||
|
Re: digital output frequency
Thanks Manoel and Jonathan, I looked the codes with attention and I belive that using signal on pwms 13-16 it will works. Only a question, What does CCP mean?
Yes Manoel, you are right, I want do the same that we do with BOEBots, use IR sensor to detect objects. Don't worry my applications don't involves human safety. I will try to do it monday and later I tell the results! |
|
#8
|
|||||
|
|||||
|
Re: digital output frequency
Quote:
|
|
#9
|
|||
|
|||
|
Re: digital output frequency
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Digital Caliper as a Digital Readout on Small Mill | sanddrag | Technical Discussion | 9 | 13-10-2005 22:51 |
| Updated Encoder Code Available | Kevin Watson | Programming | 2 | 04-01-2005 01:00 |
| Dynamic Input/Output Changing | Paolo | Control System | 6 | 23-09-2004 19:09 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| digital inputs not valid just after initialization? | WizardOfAz | Programming | 2 | 26-01-2004 13:21 |