Help needed to include AT commands in a PIC prog


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    2

    Default Help needed to include AT commands in a PIC prog

    ' Define LCD pins
    Define LCD_DREG PORTD
    Define LCD_DBIT 0
    Define LCD_RSREG PORTD
    Define LCD_RSBIT 5
    Define LCD_EREG PORTD
    Define LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    '-----------------------------------------------------------------
    DEFINE OSC 4 ' We're using a 4 MHz oscillator
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 3 ' Set A/D clock Fosc/8 ' Set clock source (3=rc)
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
    '-----------------------------------------------------------------
    PAUSE 500 ' Wait .5 second
    '-----------------------------------------------------------------
    SW_SET VAR PORTB.0
    SW_INC VAR PORTB.1
    SW_DEC VAR PORTB.2
    RELAY1 VAR PORTD.6
    RELAY2 VAR PORTD.7
    RS485 VAR PORTD.4 ' RS485 CONTROL PIN
    SER_IN VAR PORTC.7 ' DATA INPUT PORT
    SER_OUT VAR PORTC.6 ' DATA INPUT PORT
    SCLpin VAR PORTC.3 ' SCL PIN ON DS1307
    SDApin VAR PORTC.4 ' SDA PIN ON DS1307
    SQWpin VAR PORTC.5 ' SQW PIN ON DS1307
    '-----------------------------------------------------------------
    RTCSec var byte ' Seconds
    RTCMin var byte ' Minutes
    RTCHour var byte ' Hours
    RTCWDay var byte ' Weekday
    RTCDay var byte ' Day
    RTCMonth var byte ' Months
    RTCYear var byte ' Year
    RTCCtrl var byte ' Control
    CounterA var byte ' General purpose Variable
    CounterB var byte ' General purpose Variable
    ALARMHOUR VAR BYTE ' ALARM SET HOUR
    ALARMMIN VAR BYTE ' ALARM SET MIN
    ALARM VAR BIT ' ALARM CONDITION
    ALARMNO VAR BYTE ' EEPROM LOCATION
    MENU VAR BYTE ' MENU COUNTER VARIABLE
    ADVAL1 VAR BYTE ' FIRST SENSOR
    ADVAL2 VAR BYTE ' SECOND SENSOR
    TEMPLO var Byte ' LM35 Temp. Low byte
    TEMPHI var Byte ' LM35 Temp. High byte
    HI_LO VAR BIT ' HI LOW FOR MENU CONTROL
    SMP_CNT VAR BYTE ' SAMPLE COUNT IF IT GOES HIGH
    '-----------------------------------------------------------------
    'GOTO SetUpPreset
    GOTO START
    READ_RTC:

    I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]
    '-----------------------------------------------------------------
    RTCHour=((RTCHour>>4)&$0F)*10+(RTCHour&$0F)
    RTCMin=((RTCMin>>4)&$0F)*10+(RTCMin&$0F)
    RTCSec=((RTCSec>>4)&$0F)*10+(RTCSec&$0F)
    '-----------------------------------------------------------------
    RETURN

    ConvertBCD:
    CounterB=CounterA DIG 1
    CounterB=CounterB<<4
    CounterB=CounterB+CounterA DIG 0
    Return

    READ_TEMP:
    Adcin 3, ADVAL1 ' Read channel 0 into temp variable
    IF ADVAL1 < temphi THEN LOW RELAY1
    IF ADVAL1 > tempLO THEN LOW RELAY2
    IF ADVAL1 > TEMPLO AND ADVAL1 < TEMPHI THEN SMP_CNT = 0
    Return

    START:
    TEMPLO = 5 : TEMPHI = 21 : SMP_CNT = 0
    LOW RELAY1 : LOW RELAY2 :
    Lcdout $fe, 1, "SMART CONTROLLER" ' Send to LCD
    Lcdout $fe, $C0, "DATALOGGER v3B" ' Second Line
    Pause 3000 ' PAUSE FOR 3 SEC

    LOOP:
    If SW_SET = 0 Then Gosub SET_LO_TEMP
    GOSUB READ_TEMP
    If ADVAL1 >= temphi Then ALARM_HI
    If ADVAL1 <= tempLO Then ALARM_LO
    GOSUB READ_RTC
    Lcdout $fe, 1, "TEMP: " , DEC ADVAL1 ," (", DEC tempLO , "/" , DEC tempHI ,")"
    LCDOut $FE,$C0, "TIME: " , DEC2 RTCHour ,":" , DEC2 RTCMin , ":" , DEC2 RTCSec
    Pause 500 ' Repeat about 2 times/sec
    GOTO LOOP

    End

    SET_LO_TEMP:
    HI_LO = 0
    Lcdout $fe, 1, "TEMP SET ROUTINE"
    Lcdout $fe, $c0, "LOW SET: ", dec tempLO
    While sw_set = 0: Wend: pause 100
    SET_LO_LOOP:
    If sw_inc = 0 Then Gosub press_inc
    If sw_dec = 0 Then Gosub press_dec
    If sw_set = 0 Then Gosub SET_HI_TEMP
    Goto SET_LO_LOOP
    RETURN

    SET_HI_TEMP:
    HI_LO = 1
    Lcdout $fe, 1, "TEMP SET ROUTINE"
    Lcdout $fe, $c0, "HI SET: ", dec tempHI
    While sw_set = 0: Wend: pause 100
    SET_HI_LOOP:
    If sw_inc = 0 Then Gosub press_inc
    If sw_dec = 0 Then Gosub press_dec
    If sw_set = 0 Then
    While sw_set = 0: Wend: pause 100
    HI_LO = 0 : GOTO LOOP
    ENDIF
    Goto SET_HI_LOOP
    RETURN

    press_inc:
    While sw_inc = 0: Wend: pause 100
    IF HI_LO = 1 AND temphi < 100 Then temphi = temphi + 1
    IF HI_LO = 0 AND tempLO < temphi Then tempLO = tempLO + 1
    IF TEMPHI = TEMPLO THEN TEMPHI = TEMPLO + 1
    IF HI_LO = 1 THEN Lcdout $fe, $c0, "Temp Set: ", dec temphi
    IF HI_LO = 0 THEN Lcdout $fe, $c0, "Temp Set: ", dec tempLO
    Return

    press_dec:
    While sw_dec = 0: Wend: pause 100
    IF HI_LO = 1 AND temphi > tempLO Then temphi = temphi - 1
    IF HI_LO = 0 AND tempLO > 0 Then tempLO = tempLO - 1
    IF TEMPHI = TEMPLO THEN TEMPHI = TEMPLO + 1
    IF HI_LO = 1 THEN Lcdout $fe, $c0, "Temp Set: ", dec temphi
    IF HI_LO = 0 THEN Lcdout $fe, $c0, "Temp Set: ", dec tempLO
    Return

    ALARM_HI:
    IF SMP_CNT < 5 THEN
    SMP_CNT = SMP_CNT + 1
    ELSE
    Lcdout $fe, 1, "HIGH TEMP ALARM"
    Lcdout $fe, $c0, "RELAY1 ON "
    HIGH RELAY1 : LOW RELAY2
    PAUSE 1000
    WHILE ADVAL1 >= temphi
    GOSUB READ_TEMP
    WEND
    ENDIF
    GOTO LOOP

    ALARM_LO:
    IF SMP_CNT < 5 THEN
    SMP_CNT = SMP_CNT + 1
    ELSE
    Lcdout $fe, 1, "LOW TEMP ALARM"
    Lcdout $fe, $c0, "RELAY2 ON "
    HIGH RELAY2 : LOW RELAY1
    PAUSE 1000
    WHILE ADVAL1 <= tempLO
    GOSUB READ_TEMP
    WEND
    ENDIF
    GOTO LOOP




    This is the prog and i would like to put AT commands to send an sms in the Alarm HI Routine when the temperature increases beyond the set limit and after the relay is 'ON'.Any help would be appreciated.Im using a simcomm brand gsm modem and PIC 16F74.
    Last edited by someshnegi; - 26th April 2007 at 20:28.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    maybe you could find some snip in the thread bellow
    http://www.picbasic.co.uk/forum/showthread.php?t=219

    At least, it should be enough to start.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2007
    Posts
    2

    Default

    Thanks for the reply.I appreciate it.The problem is i have to submit this code as my project in about 3 days and due to some reasons i cannot get the work done from my friend who wrote the code.And i have no idea about how pic basic pro works.I just need those 2 lines(to send an sms) i can fit in the ALARM HI routine in the code.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by someshnegi View Post
    Thanks for the reply.I appreciate it.The problem is i have to submit this code as my project in about 3 days and due to some reasons i cannot get the work done from my friend who wrote the code.And i have no idea about how pic basic pro works.I just need those 2 lines(to send an sms) i can fit in the ALARM HI routine in the code.
    ??????????

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 10:54
  2. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 22:42
  3. Replies: 67
    Last Post: - 8th December 2009, 03:27
  4. PIC to PIC Serial Communication
    By v_merino in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd July 2004, 08:05
  5. PIC Basic Pro Help Needed.
    By Panash in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th October 2003, 10:29

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