Ghange code picbasic


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Ghange code picbasic

    I have the below code and it's work
    I want to change to work for FM 88-108MHZ
    How i can change it;

    'Fmin =1200 MHz, F max= 1650 MHz
    ' ** DECLARATION OF THE VARIABLES

    b1 var BYTE
    b2 var BYTE
    b3 var BYTE
    b5 var BYTE

    F1 var WORD
    F2 var WORD
    F3 var WORD


    ADDR1 VAR BYTE
    TMP VAR WORD
    TMP_LO VAR TMP.LOWBYTE
    TMP_HI VAR TMP.HIGHBYTE
    PLLBASE VAR WORD
    PLL VAR WORD
    LO VAR PLL.LOWBYTE
    HI VAR PLL.HIGHBYTE
    PAS VAR BYTE '1=125kHz, 2=250kHz, 4=500kHz, 8=1MHz

    '*** INITIAL DATA ***

    ADDR1=$C2 'adress I2C of SDA5055 (ADDR1=$C0 , adress I2C of TSA5511)
    PLLBASE=9600 'beginning with 1200 MHz : 1200 / 0,125 = 9600
    PAS = 1 'pas of 0.125 MHZ by defect
    PAUSE 100
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT " PLL FM 88-108" ' post text during 1 second
    LCDOUT $FE,$C0
    LCDOUT " NIKOS"
    PAUSE 1000

    EEPROM 0,[$90,$01] 'initial data TMP = 400 ($190) corresponds to F = 1250 MHz


    'The starting point is 1200 MHz given by PLLBASE. One adds a shift of 125kHz * TMP
    'TMP is on 16 bits, therefore 65535 possible frequencies.
    '
    '*** READING OF THE DECALAGE TMP ***

    READ 0,TMP_LO 'reads the 8 bits of weak weight
    READ 1,TMP_HI 'reads the 8 bits of strong weight


    ' *** BEGINNING OF THE PROGRAM***

    MAIN:
    PLL = PLLBASE + TMP

    I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] 'Sending of the data to the module

    GOSUB CALCUL 'calculate the frequency for posting
    GOSUB AFFICHAGE 'post the frequency
    PAUSE 500


    '*** PRINCIPAL LOOP ***

    BOUCLE:
    BUTTON UP,1,10,2,b1,1,MONTE 'supervise the button UP
    BUTTON DOWN,1,10,2,b2,1,DESCEND 'supervise the button DOWN
    BUTTON MEMO,1,255,0,b5,1,STORE 'supervise the button MEMO
    BUTTON CH_PAS,1,255,0,b3,1, CHOIX 'supervise the button PAS
    PAUSE 100 'pauses of 0.1s
    GOTO BOUCLE


    MONTE: '** INCREASE THE FREQUENCY OF 1 PAS (STEP)

    TMP = TMP + PAS
    IF TMP > 3600 THEN TMP = 0 'Fmax = 1600 MHz
    GOTO MAIN

    DESCEND: '** DECREASE THE FREQUENCY OF 1 PAS (STEP)

    IF TMP<PAS THEN RAZ_TMP
    IF TMP = 0 THEN TOP
    TMP = TMP - PAS
    GOTO MAIN

    TOP: TMP=3600
    GOTO MAIN

    RAZ_TMP: TMP = 0
    GOTO MAIN

    CHOIX: '** CHOICE OF THE PAS (STEP)

    IF PAS = 8 THEN SAUTE
    PAS = PAS*2
    GOSUB AFFICHE_PAS
    GOSUB AFFICHAGE 'post the frequency
    GOTO BOUCLE

    SAUTE: PAS = 1
    GOSUB AFFICHE_PAS
    GOTO BOUCLE

    CALCUL: ' ** CALCULATION OF THE FREQUENCY

    F1= PLL-800 'cut off 1GHz
    F2=F1/8 'give them MHz
    F3=125*(F1//8) 'give them kHz
    RETURN

    AFFICHAGE:
    LCDOUT $FE, 1 'Clear LCD screen
    LCDOUT #1 'post the 1 of Giga
    LCDOUT #F2 'post the other digits
    LCDOUT "." 'post the comma
    LCDOUT #F3 'post the Khz
    LCDOUT " MHz "

  2. #2
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    anyone to know how to change the code;

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    any help ;

  4. #4
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    anyone to help me;

  5. #5
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Hello Savnik!

    I try to send You PM but You didn't answer.....I'm working on same thing and I saw that You have found some code fro TSA but on upper band....

    Did You try something to do with it or?

    I think we could do this.....it seems to not be a problem!

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Marin View Post
    Hello Savnik!

    I try to send You PM but You didn't answer.....I'm working on same thing and I saw that You have found some code fro TSA but on upper band....

    Did You try something to do with it or?

    I think we could do this.....it seems to not be a problem!
    I have answer to your PM

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Code:
    I have changed it to work for FM 88-108MHZ.  Of course, you have to make it work for 250KHz, 500KHz and 1MHz steps
    
    'Fmin =88 MHz, F max= 108 MHz 
    ' ** DECLARATION OF THE VARIABLES
    
    b1 var BYTE
    b2 var BYTE
    b3 var BYTE
    b5 var BYTE
    
    F1 var WORD
    F2 var WORD
    F3 var WORD
    
    
    ADDR1 VAR BYTE
    TMP VAR WORD
    TMP_LO VAR TMP.LOWBYTE
    TMP_HI VAR TMP.HIGHBYTE
    PLLBASE VAR WORD
    PLL VAR WORD
    LO VAR PLL.LOWBYTE
    HI VAR PLL.HIGHBYTE
    PAS VAR BYTE '1=125kHz, 2=250kHz, 4=500kHz, 8=1MHz 
    
    '*** INITIAL DATA *** 
    
    ADDR1=$C2 'adress I2C of SDA5055 (ADDR1=$C0 , adress I2C of TSA5511)
    PLLBASE=88/0.125  'beginning with 88 MHz : 88 / 0,125 = 704
    PAS = 1 'pas of 0.125 MHZ by default
    PAUSE 100
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT " PLL FM 88-108" ' post text during 1 second
    LCDOUT $FE,$C0 
    LCDOUT " NIKOS" 
    PAUSE 1000 
    
    EEPROM 0,[$90,$01] 'initial data TMP = PLLBASE  corresponds to F = 88 MHz
    
    
    'The starting point is 88 MHz given by PLLBASE. One adds a shift of 125kHz * TMP
    'TMP is on 16 bits, therefore 65535 possible frequencies.
    ' 
    '*** READING OF THE DECALAGE TMP ***
    
    READ 0,TMP_LO 'reads the 8 bits of weak weight
    READ 1,TMP_HI 'reads the 8 bits of strong weight
    
    
    ' *** BEGINNING OF THE PROGRAM***
    
    MAIN: 
    PLL = PLLBASE + TMP
    
    I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] 'Sending of the data to the module 
    
    GOSUB CALCUL 'calculate the frequency for posting
    GOSUB AFFICHAGE 'post the frequency
    PAUSE 500
    
    
    '*** PRINCIPAL LOOP ***
    
    BOUCLE: 
    BUTTON UP,1,10,2,b1,1,MONTE 'supervise the button UP
    BUTTON DOWN,1,10,2,b2,1,DESCEND 'supervise the button DOWN
    BUTTON MEMO,1,255,0,b5,1,STORE 'supervise the button MEMO
    ' only step size of 125KHz is handled
    ' BUTTON CH_PAS,1,255,0,b3,1, CHOIX 'supervise the button PAS 
    PAUSE 100 'pauses of 0.1s
    GOTO BOUCLE
    
    
    MONTE: '** INCREASE THE FREQUENCY OF 1 PAS (STEP)
    
    TMP = TMP + PAS
    IF TMP > 160 THEN TMP = 0 'Fmax = 108 MHz
    GOTO MAIN
    
    DESCEND: '** DECREASE THE FREQUENCY OF 1 PAS (STEP)
    
    IF TMP IF TMP = 0 THEN TOP
    TMP = TMP - PAS
    GOTO MAIN
    
    TOP: TMP=(108-88)/0.125   ' max reading in Tmp
    GOTO MAIN
    
    RAZ_TMP: TMP = 0
    GOTO MAIN
    
    CHOIX: '** CHOICE OF THE PAS (STEP) 
    
    IF PAS = 8 THEN SAUTE
    PAS = PAS*2
    GOSUB AFFICHE_PAS
    GOSUB AFFICHAGE 'post the frequency
    GOTO BOUCLE
    
    SAUTE: PAS = 1
    GOSUB AFFICHE_PAS
    GOTO BOUCLE
    
    CALCUL: ' ** CALCULATION OF THE FREQUENCY
    
    F1= PLL-800 'cut off 1GHz 
    F2=F1/8 'give them MHz
    F3=125*(F1//8) 'give them kHz
    RETURN
    
    AFFICHAGE: 
    LCDOUT $FE, 1 'Clear LCD screen 
    LCDOUT #1 'post the 1 of Giga
    LCDOUT #F2 'post the other digits 
    LCDOUT "." 'post the comma
    LCDOUT #F3 'post the Khz
    LCDOUT " MHz "

  8. #8
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Hello Jerson!!!

    Thanks for work!

    But i have smaller errors about it, if You please can explain I doing something wrong or?

    regards!
    Attached Images Attached Images  

  9. #9
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    I've set this code to work from 87 to 108 MHz......but I have problem:

    When I press UP it goes ok from 87,0 87,1 87,2 87,3 87,4 87,5 87,6 87,7 and thjen jumps directly to 88?????? And whole time like this on whole band to 108MHz, up or down....

    everytim it steps ok from 100,0 to 100, 7 with step of 0,1 and then after 100,7 directly step to 101,0......I don't know why jumps over 100,8 100,9????? This is on whole band I just took 100 as example.


    this i the code:

    Code:
       
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    
    
    DEFINE I2C_SCLOUT 1
    	
    
    
    ' definition I2C communication
    	SCL   	var     	PORTB.1        	 ' SCL on RB1  
    	SDA	    var     	PORTB.0	      	 ' SDA on RB0 
    
    'press:
    	MEMO	var	PORTB.3		' 
    	UP   	var	PORTB.4		' press for FREQ UP RB.4
    	DOWN	var	PORTB.5		' press for FREQ DOWN RB.5
    
    
    	
    	INPUT	UP			'Up et Down sont des entrées
    	INPUT	DOWN
    	INPUT	MEMO
    
    
    
       
       
        'Fmin =88 MHz, F max= 108 MHz 
    ' ** DECLARATION OF THE VARIABLES
    
    b1 var BYTE
    b2 var BYTE
    b3 var BYTE
    b5 var BYTE
    
    F1 var WORD
    F2 var WORD
    F3 var WORD
    
    
    ADDR1        VAR BYTE
    TMP          VAR WORD
    TMP_LO       VAR TMP.LOWBYTE
    TMP_HI       VAR TMP.HIGHBYTE
    PLLBASE      VAR WORD
    PLL          VAR WORD
    LO           VAR PLL.LOWBYTE
    HI           VAR PLL.HIGHBYTE
    PAS          VAR BYTE '1=125kHz, 2=250kHz, 4=500kHz, 8=1MHz 
    
    '*** INITIAL DATA *** 
    
    ADDR1=$C2 'adress I2C of SDA5055 (ADDR1=$C0 , adress I2C of TSA5511)
    PLLBASE=696  'beginning with 87 MHz : 87 / 0,125 = 696
    PAS = 1 'step of 0.1 MHZ by default    ?????
    PAUSE 100
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT " PLL FM 88-108" ' post text during 1 second
    LCDOUT $FE,$C0 
    LCDOUT " BT-20" 
    PAUSE 1000 
    
    EEPROM 0,[$90,$01] 'initial data TMP = PLLBASE  corresponds to F = 88 MHz
    
    
    'The starting point is 88 MHz given by PLLBASE. One adds a shift of 125kHz * TMP
    'TMP is on 16 bits, therefore 65535 possible frequencies.
    ' 
    '*** READING OF THE DECALAGE TMP ***
    
    READ 0,TMP_LO 'reads the 8 bits of weak weight
    READ 1,TMP_HI 'reads the 8 bits of strong weight
    
    
    ' *** BEGINNING OF THE PROGRAM***
    
    MAIN: 
    PLL = PLLBASE + TMP
    
    I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] 'Sending of the data to the module 
    
    GOSUB CALCUL 'calculate the frequency for posting
    GOSUB AFFICHAGE 'post the frequency
    PAUSE 500
    
    
    '*** press routine ***
    
    BOUCLE: 
    BUTTON UP,0,10,2,b1,1,MONTE 'supervise the button UP
    BUTTON DOWN,0,10,2,b2,1,DESCEND 'supervise the button DOWN
    BUTTON MEMO,0,255,0,b5,1,STORE 'supervise the button MEMO
    ' only step size of 125KHz is handled
    ' BUTTON CH_PAS,1,255,0,b3,1, CHOIX 'supervise the button PAS 
    PAUSE 100 'pauses of 0.1s
    GOTO BOUCLE
    
    
    MONTE: '** INCREASE THE FREQUENCY OF 1 PAS (STEP)
    
    TMP = TMP + PAS
    IF TMP > 168 THEN TMP = 0 'Fmax = 108 MHz  ---> (Fmax - Fmin) / 0,125   -> (108-87)/0,125  = 168
    GOTO MAIN
    
    DESCEND: '** DECREASE THE FREQUENCY OF 1 PAS (STEP)
    
    IF TMP = 0 THEN TOP
    TMP = TMP - PAS
    GOTO MAIN
    
    TOP: TMP=168   ' max reading in Tmp
    GOTO MAIN
    
    RAZ_TMP: TMP = 0
    GOTO MAIN
    
    CHOIX: '** CHOICE OF THE PAS (STEP) 
    
    IF PAS = 8 THEN SAUTE
    PAS = PAS*2
    
    GOSUB AFFICHAGE 'post the frequency
    GOTO BOUCLE
    
    SAUTE: PAS = 1
    
    GOTO BOUCLE
    
    CALCUL: ' ** CALCULATION OF THE FREQUENCY
    
    F1 = PLL 'cut off 1GHz 
    F2 = F1/8 'give them MHz
    F3 = 100*(F1//8) 'give them kHz        ?????
    RETURN
    
    AFFICHAGE: 
    LCDOUT $FE, 1 'Clear LCD screen 
    'LCDOUT #1 'post the 1 of Giga we don't need this because we only have 100 of MHz!!!
    LCDOUT #F2 'post the other digits 
    LCDOUT "." 'post the comma
    LCDOUT #F3 'post the Khz
    LCDOUT " MHz "
    
    STORE:				
    		WRITE 0, TMP_LO		
    		WRITE 1, TMP_HI		
    		GOTO BOUCLE

  10. #10
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Marin

    Change the line for calculating F3 as shown

    Code:
       F3=(100*F1)//8

  11. #11
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    HI....I try but that i only get 0,4 steps.......


    F3 = 100*(F1//8) with this code I've got steps with 0,1 but when come to 0,7 directly jump to 0????

  12. #12
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Also,.,,,,whats // means?

  13. #13
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Marin

    I have PMed you. If you have the code working by now, please post it here to complete the thread.

    Jerson

  14. #14
    Rimtrim's Avatar
    Rimtrim Guest


    Did you find this post helpful? Yes | No

  15. #15
    Join Date
    Aug 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Actually all this codes have step size of 125KHz....and we here want to do a 100KHz step size....

    So fisti thing to do with TSA is to change quartz to 3,2MHz because then it can be programed with step sizes of 50KHz which is good!

    Another question is to change the code and do the PIC xtal must be changed?

  16. #16
    Join Date
    Jun 2011
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Ghange code picbasic

    bueno un gran saludo para todos soy marcelo de chile y quisiera ver si me pueden ayudar con un tsa 5511 y pic16f84
    prara la banda de 88 a 108 mhz por favor gracias estare atento

Similar Threads

  1. sample code for AT45DB642D in Picbasic Pro
    By itsssyam in forum General
    Replies: 0
    Last Post: - 10th March 2010, 06:01
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 14:17
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31
  4. PicBasic code problems with a 16F84A
    By Lauren Barta in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 22:50
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts