Serin


Closed Thread
Results 1 to 6 of 6

Thread: Serin

  1. #1

    Default Serin

    Hi there
    i am trying to use serin to read a array of data from a UPS, at this stage i have used all the other serial ports, can someone give me a hint if there is a easer way instead of typing in the whole array , i have tried {str array/size} but get compile errors also my timeout does not want to work
    Ann help would be appreciated

    INCLUDE "MODEDEFS.BAS"

    DEFINE OSC 20 ' Define crystal as 20Mhz


    TRISE = %00000010

    'Configure debug
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 2
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 0


    UPS VAR BYTE[46]

    MAIN:
    DEBUG "MAIN PROGRAM",13,10

    GOTO READUPS
    DEBUG UPS[0],UPS[1],UPS[2],UPS[3],UPS[4],UPS[5],UPS[6],UPS[7],UPS[8],UPS[9],UPS[10],UPS[11],UPS[12],_
    UPS[13],UPS[14],UPS[15],UPS[16],UPS[17],UPS[18],UPS[19],UPS[20],UPS[21],UPS[22],UPS[23],UPS[24],UPS[25],UPS[26],UPS[27],UPS[28],_
    UPS[29],UPS[30],UPS[31],UPS[32],UPS[33],UPS[34],UPS[35],UPS[36],UPS[37],UPS[38],UPS[39],UPS[40],UPS[41],UPS[42],UPS[43],UPS[44],UPS[45],13,10
    goto MAIN


    READUPS:
    DEBUG "READ UPS SUBRUTINE",13,10
    SEROUT PORTE.0,T2400,["Q1",13]
    SERIN PORTE.1,T2400,200,MAIN,[UPS[0],UPS[1],UPS[2],UPS[3],UPS[4],UPS[5],UPS[6],UPS[7],UPS[8],UPS[9],UPS[10],UPS[11],UPS[12],_
    UPS[13],UPS[14],UPS[15],UPS[16],UPS[17],UPS[18],UPS[19],UPS[20],UPS[21],UPS[22],UPS[23],UPS[24],UPS[25],UPS[26],UPS[27],UPS[28],_
    UPS[29],UPS[30],UPS[31],UPS[32],UPS[33],UPS[34],UPS[35],UPS[36],UPS[37],UPS[38],UPS[39],UPS[40],UPS[41],UPS[42],UPS[43],UPS[44],UPS[45]]
    GOTO MAIN

    END

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    .........................dumped
    Last edited by skimask; - 18th July 2008 at 13:51.

  3. #3
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Andre_Pretorius View Post
    Hi there
    i am trying to use serin to read a array of data from a UPS, at this stage i have used all the other serial ports, can someone give me a hint if there is a easer way instead of typing in the whole array , i have tried {str array/size} but get compile errors also my timeout does not want to work
    Ann help would be appreciated
    Well, if you tried {str array/size}, then you may need to consult your manual...
    Try [ str array\size ] instead.

    As far as the array goes, a simple loop will do
    Code:
    t var byte
    for t = start (0 whatever) to finish (100 whatever)
    debug [ ups(t) ]
    next t

  4. #4

    Smile Sulution

    For those who are interested in the code i ended up using, mabe it helps someone out there, i used the 16F877 micro

    INCLUDE "MODEDEFS.BAS"

    DEFINE OSC 20 ' Define crystal as 20Mhz

    'Define ACDIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC )
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds

    'This Part set PORTA 0-5 an analog inputs
    TRISA = %00011111 'set PORTA 0-5 as inputs
    ADCON1 = %10000010 'Right justify output of ADC use vss and vdd as ref.
    ADCON0 = %11100000 'FRC (clock derived from a dedicated internal oscillator)

    TRISC = %10000000 'RC7 as RX(input) rest as output
    TRISD = %11110000 'Set port d 0-3 as outputs and 4-7 as inputs
    TRISB = %10011000
    TRISE = %00000001

    'Configure debug out
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 2
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 0

    'Configure debug in
    DEFINE DEBUGIN_REG PORTE
    DEFINE DEBUGIN_BIT 0
    DEFINE DEBUGIN_BAUD 2400
    DEFINE DEBUGIN_MODE 0

    UPS VAR BYTE[46]

    MAIN:
    DEBUG "MAIN PROGRAM",13,10
    PAUSE 2000
    GOSUB READUPS
    DEBUG str ups\45,13,10
    goto MAIN


    READUPS:
    DEBUG "READ UPS SUBRUTINE",13,10
    SEROUT PORTE.1,T2400,["Q1",13]
    DEBUGIN 200,MAIN,[STR UPS\45]
    RETURN

    END

  5. #5

    Question Debug

    can anyone give me some isea as to why if i use the below mentioned code and i send {(227.9 218.2 221.0 031 50.1 2.29 25.0 00000001} in on debugin i get {ÀxÀ€€€€€€€€€€xÀ< €ð€€€€xþ€À€€xÀ€€€ð€€} out on debug

    MAIN:
    DEBUG "MAIN PROGRAM",13,10
    PAUSE 2000
    GOSUB READUPS
    DEBUG str ups\45
    goto MAIN

    READUPS:
    DEBUG "READ UPS SUBRUTINE",13,10
    SEROUT PORTE.1,T2400,["Q1",13]
    DEBUGIN 200,MAIN,[STR UPS\45]
    RETURN

  6. #6

    Smile

    Found the problem debug in and out must have the same baud rate, helps to read the manual i gues

Similar Threads

  1. Serin EEPROM Programmer
    By dirtbiker5627 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 24th February 2010, 23:48
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  4. Serin with low voltage
    By f_lez in forum General
    Replies: 3
    Last Post: - 21st August 2006, 11:52
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

Members who have read this thread : 1

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