View Single Post
  #5   Spotlight this post!  
Unread 06-03-2005, 00:40
Manoel's Avatar
Manoel Manoel is offline
Registered User
FRC #0383 (Brazilian Machine)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Porto Alegre, RS, Brazil
Posts: 608
Manoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond repute
Send a message via ICQ to Manoel Send a message via MSN to Manoel
Re: digital output frequency

Quote:
Originally Posted by Mike Betts
"freqout" is not a PBASIC command as far as I know...
As a matter of fact, it is, we just didn't use it to program the robots in the PBasic era (2000-2003). This, and many other commands that weren't used can be found in the Basic Stamp Manual, from Parallax. Oliver probably used freqout with the BOEBots, some really nifty mini-robots that we also use at our school to teach robotics.

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);
Also, don't forget calling Generate_Pwms(pwm13,pwm14,pwm15,pwm16); to generate the above signal in the PWM 13 output. [EDITED - This step is unnecessary, wrong and will probably give you an error. Disregard it!]

[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?
__________________
Manoel Flores da Cunha
Mentor
Brazilian Machine
Team # 383

Last edited by Manoel : 06-03-2005 at 01:07. Reason: Added info