Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

convert hex to decimal using proton picbasic

Status
Not open for further replies.

nomad13

Full Member level 3
Joined
Jan 29, 2007
Messages
150
Helped
18
Reputation
36
Reaction score
6
Trophy points
1,298
Activity points
2,196
byte to decimal converter picbasic

I am using proton picbasic and proteus.

On my circuit I use a RTC (ds1302) after getting the time from the RTC I want to compare it to a decimal number. My problem is I connot compare the two number if the value of the time is greater than 9 because after 9 the next number is 16. I am using the RTC as a counter.

My other option is to use countup or countdown timer ic but I don't know which on to use so if someone could give me another option then I'm willing to change my design.

Thanks in avance.

:D :D :D
 

hex to decimal picbasic

Really that's not much to go on, It can be done but you may need to do it in smaller numbers

sample code would be good has we may be to able to come up with something

Or eveb better still go here and this is where you get better support

**broken link removed**

wizpic
 

picbasic dec

Here is the code it is at charge label where I want to compare the value from the rtc and the decimal value.

Code:
    ' Device declaration
        DEVICE 16F877					    ' Produce BCODE for a 16F877
		XTAL = 20 				  	        ' Use a 20MHz crystal
		ALL_DIGITAL = TRUE				  	' Set analog pins to digital
		TRISA = %00011100					' Set all of PORTA to outputs 
		OUTPUT PORTE

    ' Declaration for LCD
	  	DECLARE LCD_DTPIN = PORTD.4		  ' 4-line interface PORT
	  	DECLARE LCD_ENPIN = PORTD.3		  ' LCD EN pin	  	
	  	DECLARE LCD_RSPIN = PORTD.2		  ' LCD RS pin
	  	DECLARE LCD_INTERFACE = 4		  ' 4 bit interface
	  	DECLARE LCD_LINES = 4			  ' 4-line LCD
	  	DECLARE LCD_TYPE = 0			  ' Alphanumeric LCD
	  	
	' Alias pins
		SYMBOL SCLK	= PORTa.0
		SYMBOL IO	= PORTa.1
		SYMBOL RST  = PORTa.2
		SYMBOL POL  = PORTA.3
		SYMBOL AMT  = PORTA.4
		SYMBOL DOR  = PORTA.5
		SYMBOL CRG  = PORTE.0

	' Allocate variables
		Dim RTCYRS		AS  BYTE		  ' Year variable
		Dim RTCDAY		AS  BYTE		  ' Day variable
		Dim RTCMNT		AS  BYTE		  ' Month variable
		Dim RTCDAT		AS  BYTE		  ' Date variable
		Dim RTCHRS 		AS  BYTE		  ' Hour variable
		Dim RTCMIN		AS  BYTE		  ' Minute variable
		Dim RTCSEC		AS  BYTE		  ' Second variable
		Dim RTCCTRL		AS  BYTE		  ' Control byte
		DIM AMOUNT      AS  BYTE          ' Charging amount
		DIM DAMOUNT      AS  BYTE          ' Charging amount
        DIM VARX		AS  BYTE		  ' General variable
		DIM COMM		AS  BYTE		  ' Command Variable
        
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>        
' Start of program
        LOW RST         				  ' Reset RTC
        LOW SCLK
        low porte
        clear AMOUNT
		CLEAR VARX
        DELAYMS 100       					' Wait for LCD to startup
		CLS

        GOTO MAIN   					' Skip subroutines        
		
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
' Subroutine to write time to RTC
SETTIME:
' Set initial time to 10:42:00AM 01/29/05
        RTCYRS = $07
        RTCDAY = $06
        RTCMNT = $07
        RTCDAT = $21
        RTCHRS = $00
        RTCMIN = $00
        RTCSEC = $00
        RST = 1         					' Ready for transfer
        SHOUT IO,SCLK,LSBFIRST,[$8e,0]		' Enable write
        RST = 0         					' Reset RTC
        RST = 1         					' Ready for transfer
' Write all 8 RTC registers in burst mode
        SHOUT IO,SCLK,LSBFIRST,[$be,RTCSEC,RTCMIN,RTCHRS,RTCDAT,RTCMNT,RTCDAY,RTCYRS,0]
        RST = 0         					' Reset RTC
        RETURN
		
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
' Subroutine to read time from RTC
GETTIME:
        RST = 1         					' Ready for transfer
        SHOUT IO,SCLK,LSBFIRST,[$bf]     	' Read all 8 RTC registers in burst mode
        SHIN IO,SCLK,LSBPRE,[RTCSEC,RTCMIN,RTCHRS,RTCDAT,RTCMNT,RTCDAY,RTCYRS,RTCCTRL]
        RST = 0         					' Reset RTC
        RETURN
		
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
' Main program loop - updates the LCD with the time
MAIN:   IF AMT = 1 THEN 
           DELAYMS 500
           AMOUNT = AMOUNT + 5                              
           ENDIF        
        PRINT AT 1,5,"AMOUNT: ",DEC AMOUNT," MIN  "
        IF AMOUNT > 0 THEN
           if dor = 1 then 
              SET CRG
              GOSUB SETTIME 
              GOTO CHARGE   					' Do it forever
              endif
           ENDIF
        GOTO MAIN

CHARGE:
        GOSUB GETTIME   					' Read the time from the RTC
' Display time on LCD
		PRINT AT 2,3,"   ",HEX2 RTCHRS,":",HEX2 RTCMIN,":",HEX2 RTCSEC
		VARX = HEX2 RTCSEC
		PRINT AT 3,10,DEC VARX		 		
        DAMOUNT = DEC AMOUNT 
        PRINT AT 4,10,DEC DAMOUNT
        IF VARX = AMOUNT THEN
           LOW CRG
           PRINT AT 2,3, "CHARGING COMPLETE"
           CLEAR AMOUNT
           GOTO MAIN
           ENDIF
        GOTO CHARGE   					' Do it forever
		
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
 

proton picbasic

dearfriend, actually I am using Proton Plus Complier too

the best way to ask is to use forum from : www.picbasic.org


there are a help men there.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top