Data conversions


Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Aug 2015
    Posts
    4

    Default Data conversions

    Wanted to do a temp probe using the 1822 but then got into a situation. The sample code provided to me does an Lcdout command with a dec(temperature) to display. According to the manual this is a decimal conversion from ascii. Then I wanted to be able to store data. Up to here I was ok. Write to eeprom. But I decided to use a serout command instead of LCDout which totally barfed when I tried to compile. I have tried to convert the data into something more friendly like a standard string but am unable to come up with any solution. Yes, I can just use the lcdout command but now it's turned into a challenge/learning experience. Any one have an idea of how to start to convert this into a standard string or how to get this to use the serout command? Even if it's not practical to program into the chip I'm interested from a learning perspective now.

    Thanks much
    Code:
    SerPin VAR PortA.0 ' Serial output pin
    temperature     VAR     WORD            ' Temperature storage
    count_remain    VAR     BYTE            ' Count remaining
    count_per_c     VAR     BYTE            ' Count per degree C
    
    DQ      VAR     PORTC.0                 ' One-wire data pin
    
    ' Define LCD registers and bits
    DEFINE  LCD_DREG        PORTD
    DEFINE  LCD_DBIT        4
    DEFINE  LCD_RSREG       PORTE
    DEFINE  LCD_RSBIT       0
    DEFINE  LCD_EREG        PORTE
    DEFINE  LCD_EBIT        1
    
    AA var byte
    BB var byte
    CC var byte
    DD var byte
    
    
            ADCON1 = %00000111              ' Set PORTA and PORTE to digital
            Low PORTE.2                     ' LCD R/W line low (W)
    
    
    mainloop:
            OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
    
            pause 2000
    
            OWOUT DQ, 1, [$CC, $BE]         ' Read the temperature
            OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
    
            ' Calculate temperature in degrees C to 2 decimal places
            ' (not valid for negative temperature)
            temperature = temperature */ 1600
            LCDOUT $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, " C"
    
            ' Calculate temperature in degrees F to 2 decimal places 
            ' (not valid for negative temperature)
            temperature = (temperature */ 461) + 3200
            LCDOUT $fe, $c0, DEC (temperature / 100), ".", DEC2 temperature, " F"
            
    serout serpin,N9600,{(temperature/100)] 'won't even compile               
    
    GoTo mainloop                   ' Do it forever
    Last edited by Archangel; - 25th August 2015 at 01:13.

Similar Threads

  1. linear data memory & large data arrays
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th June 2011, 23:21
  2. storing data and dumping data?
    By earltyso in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th November 2007, 15:57
  3. Help with Data of fiberoptic
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th June 2007, 14:23
  4. Data
    By gzorzi in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th July 2004, 14:21
  5. ADC Conversions
    By Corey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th October 2003, 04:32

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