mackrackit's ConnectOne example code


Closed Thread
Results 1 to 40 of 92

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    Dave, I have adapted your 18F4550 code you included in your above post into a version that uses my schematic and an 18F2550. I have a protoboard configured to my schematic with the MiniSocket mounted on it. I have studied the AT+ Programmers Manual and I believe I understand all the coding and have it correct, but it wouldn't work. The only way I have to trouble shoot this is to embed WRITE to EEPROM statements at incremental locations to isolate where the problems are. I have discovered that in two places the code will not execute beyond certain statements even though this code compiles and assembles OK. If you look at my attached code (which is closely adapted from yours) you will see where the embedded WRITE statements bracket two statements that don't execute. One is a PAUSE 2000 statement that for the life of me I don't understand why it won't execute when uncommented. Can you see why?
    The other is obviously telling me that the MiniSocket module is not resonding to the AT+I message and is therefore going to the BROKE label, which tells me that either the MiniSocket module is dead or my board level serial interface is not wired correctly.
    I am hoping you might help me trouble shoot this by looking at this code and my attached interface and tell me where I have gone wrong. Would GREATLY appreciate it!
    Code:
    '<FL_PIC18F2550>'
    DEFINE OSC 48    ' Using 8 MHz crystal
    @ __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L
    '#############################
        'ADCON1 = 001110          ' different A/D setup in temperature routine
        CNT      VAR BYTE
        CNT = 0
        temp     VAR BYTE
      WRITE 3,3      'EEPROM test to see if program executes to here..it does
        'ADC_TEMP VAR WORD        'not used in new temperature routine
        'S_TEMP   VAR BYTE        'not used in new temperature routine
        D_LAY    VAR BYTE
        ADR      VAR BYTE [9]     'array for IP address elements
        TX       VAR PORTC.6      'differnt ports used for WiFi module interface
        RX       VAR PORTC.7
        'X_TEMP   VAR BYTE        'not used in new temperature routine
    WRITE 3,3  'EEPROM test to see if program executes to here..it does
        'PAUSE 2000   'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
    WRITE 4,4  'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
        'INTCON.5 = 1    'ENABLE TMR0  interrupt not used
        'T0CON = 000101
        'ON INTERRUPT GOTO TLOOP
    '*****************SETUP FOR USING LM34 Temperature Sensor**************
        'DEFINE osc 8           ' Using a 16 MHz oscillator..already defined
        DEFINE ADC_BITS 10      ' Set A/D for 10-bit operation
        DEFINE ADC_CLOCK 5      ' Set A/D clock Fosc/16
        DEFINE ADC_SAMPLEUS 50  ' Set A/D sampling time @ 50 uS
        samples VAR WORD        ' Multiple A/D sample accumulator
        sample  VAR BYTE        ' Holds number of samples to take
        value   VAR WORD        ' Holds LM34 measured temperature value
    BOOT:   'iCHIP SET UP
      'SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC temp,$d,$a,$d ,$a] 'test not used
      PAUSE 500
      SEROUT2 TX,6,[ "AT+I",$d ,$a]
    WRITE 5,5       'EEPROM test to see if program executes to here..it does
      SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK")]
    WRITE 6,6   'EEPROM test to see if program executes to here..it doesn't!
         ' ABOVE TEST INDICATESInterface to iChip is NOT working!
      'SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ]  'test not used
      'SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ]  'test not used
      SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
      SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
      WRITE 10, ADR[0] ' Write the received IP address to EEPROM as a test
      WRITE 11, ADR[1]
      WRITE 12, ADR[2]
      WRITE 13, ADR[3]
      GOSUB DIP
      PAUSE 2000
      'SEROUT2 TX,6,["AT+iWLWM=1",$d,$a] ' Sets WEP enabled with 64bit key
      'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
      'SEROUT2 TX,6,["AT+iWLKI=1",$d,$a] ' Sets the Wireless LAN transmission WEP-Key index
      'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
      'SEROUT2 TX,6,["AT+iWLKn1=xxxxxxxxxx",$d,$a] ' Sets the Wireless LAN WEP key
      'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
      SEROUT2 TX,6,["AT+iWLSI=Buckskin",$d,$a] ' Sets the destination Wireless LAN SSID
      SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
      SEROUT2 TX,6,["AT+iWWW",$d,$a]        ' Activates iChip's internal web server
      SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
      ;#############################
        EMAIL_SET:
            SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iTOA:[email protected]",$d,$a]  'Permanently sets Email addressee
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+ito:jellis00",$d,$a]      'Permanently sets Email header s =To:  description
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iREA:[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a]        'Permanently sets Email header =From: description.
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iSMTP:mail.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iSMA=1",$d,$a]            'Permanently sets SMTP authentication method
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a]       'Permanently sets authenticated SMTP login
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
            SEROUT2 TX,6,["AT+iSMU:[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
            SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
       FTP:        'not using FTP but left this for timing
           CNT = CNT + 1
           GOSUB GET_T
           FOR D_LAY = 1 TO 120    ' 60 seconds delay
               PAUSE 500
           NEXT D_LAY
           IF CNT = 2 THEN EMAIL   ' Send EMAIL every 2 minutes
           IF CNT > 2 THEN CNT = 0 ' During testing set for two minute cycle
           WRITE 15, temp      'test of temperature reading
           GOTO BOOT
      END
      EMAIL:
            SEROUT2 TX,6,["AT+iEMA:",$d,$a]  'Defines a plain text e-mail body
            SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
            SEROUT2 TX,6,["SENT EVERY 2 minutes.",$d,$a]
            SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
            SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
            SEROUT2 TX,6,["GO TO:",$d,$a]
            SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
            SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
            'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
                   SEROUT2 TX,6,[$d,$a,".",$d,$a]
                   SERIN2 RX,6,[WAIT("I/ONLINE")]
            PAUSE 1000
            'SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a]  'test not used
            WRITE 5,$01       ' Write 1 to EEPROM as test if Email sent
            HIGH PORTC.5      ' blink green led as test to show email sent
            PAUSE 1000
            LOW PORTC.5
      GOTO BOOT
      DIP:
          'IF (!ADR[1]) AND )!ADR[1]) AND (!ADR[2]) AND (!ADR[3]) THEN
            HIGH PORTC.6      'blink red led as test if not connected
            PAUSE 1000
            LOW PORTC.6
          'ENDIF
          'SEROUT2 PORTC.0,16468,[" CONNECTED ",$d,$a] ' test not used
          'SEROUT2 PORTC.0,16468,["ADR - " ,DEC3 ADR[0],".",DEC3 ADR[1],".",DEC3 ADR[2],".",DEC3 ADR[3],$d,$a]
          PAUSE 1000
      RETURN
      BROKE:
            SEROUT2 PORTC.0,16468,["NOT WORKING",$d,$a] 'Commented out for now
            WRITE 16, "B"     'Record in EEPROM as test if Broke
            PAUSE 500
            GOTO BOOT
    GET_T:        ' Subroutine to measure temperature from LM34
    '===========
    ' This subroutine is an adaptation from below reference to 10-bit A/D
    '****************************************************************
    '*  Name    : LM34.BAS                                          *
    '*  Author  : Bruce Reynolds                                    *
    '*  Date    : 10/23/2001                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :  8-bit A/D temperature conversion with National   *
    '*          ;  LM34CAZ analog temperature sensor.               *
    '*          :  See http://www.rentron.com/PicBasic/LM34.htm     *
    '****************************************************************
        samples = 0             ' Clear samples accumulator on entry
        ' Setup registers for A/D input per Sec 21.0 of datasheet
        '1. Configure the A/D module:
          '  Configure analog pins, voltage reference AND I/O (ADCON1)
              ADCON1 = %00000011 'Vdd as ref; all analog except AN12 (RB0)
          '  SELECT A/D INPUT channel (ADCON0)
              ADCON0 = %001011000  'Set AN11 (PORTB.4) as A/D input but disabled
          '  SELECT A/D acquisition time & A/D conversion clock (ADCON2)
              ADCON2 = %10110101  'Right justified;TAD=16;A/D clock=Fosc/16
          '  Turn ON A/D module (ADCON0)
            ADCON0.0 = 1        'Enable the A/D module
        '2. Configure A/D INTERRUPT (IF desired):
            '  CLEAR ADIF BIT
            '  Set ADIE BIT
            '  Set GIE BIT
        '3. WAIT the required acquisition time (IF required).
            'PAUSE 250          ' Wait approximately 1/4 seconds per loop
        '4. Start conversion-Set GO/DONE BIT (ADCON0 register)
            ADCON0.1 = 1
        '5. WAIT FOR A/D conversion TO complete, by either:
            '  Polling FOR the GO/DONE BIT TO be cleared
                'OR
            '  Waiting FOR the A/D INTERRUPT
        FOR sample = 1 TO 20    ' Take 20 samples
            ADCIN 11, value      ' Read channel 11 into temp variable
            'PAUSE 2
            ' or use alternative manual method to read A/D input
                'WHILE ADCON0.1 : WEND
                '6. READ A/D Result registers (ADRESH:ADRESL);
                    'CLEAR BIT ADIF, if required.
                   'value.HIGHBYTE = ADRESH
                   'value.LOWBYTE = ADRESL
             samples = samples + value ' Accumulate 20 samples
            '7. FOR NEXT conversion, go TO STEP 1 or STEP 2, as
                'required. The A/D conversion time per BIT IS
                'defined as TAD. A minimum WAIT of 3 TAD IS
                'required before the NEXT acquisition starts.
            PAUSE 250          ' Wait approximately 1/4 seconds per loop
        NEXT sample
        value = samples/20      ' Determine average of 20 measurements
        'ADC Math for 10-bit A/D when using Vdd as referenc
            'ADC Resolution = 4.99 V/1024 COUNT = 4.912109 mV/COUNT
            '=> LM34DZ OUTPUT voltage (mV) = 2 x COUNT
            'Temperature ( F) = LM34 OUTPUT voltage in mV/10
            '=> Temperature ( F) = 4.912109 x COUNT/10 = 0.4912109*COUNT
            ' Therefore temp = 0.4912109*Count or approx. = Count/2.036
        ' To avoid floating point math, multiply by 1000 and then DIV32
        value  = 1000 * value
        temp = DIV32 2036
        'temp = value
        samples = 0             ' Clear old sample accumulator for next cycle
        ADCON1 = 255            ' Go to all digital ops
      RETURN
      'DISABLE   'Interrupt not used
        'TLOOP:
        'INTCON.2=0:
        'TOGGLE PORTC.5
        'RESUME: ENABLE
    Name:  PartialSchem.jpg
Views: 4059
Size:  105.3 KB

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    With 8 MHz in and wanting to run the chip at 48 MHz
    Code:
    @ __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    And the "level" converter should not be used with mode 6, with the converter in place try mode 16390.
    http://melabs.com/resources/ser2modes.htm

    The iChip config utility might help make sure the module is setup correctly
    http://www.connectone.com/support.asp?did=30
    They say vista is not supported by I run it on win 7. Set a restor point just to be safe...

    Thats what I see....
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    Thanks, Dave. I implemented all of your suggested changes to my 18F2550 adaptation of your example code and the MiniSocket module still doesn't connect to my wireless router/PC. I also tried to use the iChip Config Utility to setup and test the module, but discovered you have to have a serial interace that connects directly to the WiFi module to use it... which I don't have on my PCB implementation. So I looked for another way to setup and test my MiniSocket module and discovered in the Programmers Manual the Easy Configuration method (pg 142 of Programmer's Manual). Per that method, I programmed the MCU to send an AT+iFD command to the module to reset it to Factory Default settings, which will supposedly search for and link up with any AD-HOC AP in range so that you can use this method to get your PC connected to the module to setup the desired configuration for your application. What I discovered leads me to believe that my particular MiniSocket module is a bad one. Take a look at this code and the embedded and commented WRITE EEPROM test and please tell me if you concur with that conclusion.
    Code:
    '<FL_PIC18F2550>'       ' Set MCU type for FineLine Editor
    '**************** Configure MCU and set port registers ********************
    DEFINE OSC 48    ' Using 8 MHz crystal
    @ __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L
    TRISA = 0           ' Reserve PortA as outputs for LCD use
    TRISB = %00011100   ' RB2 & RB3 reserved as RTC Alarm1 & Alarm2 inputs
                        ' PORTB.2 is also an interrupt from manual switch GND
                        ' PORTB.4 is set as A/D Channel 11 input
    TRISC = %10000000   ' Set PortC to all outputs except PortC.7 which is
                        ' reserved as RX input.
                        ' PortC.1 is output for MSEL to WiFi module
                        ' PortC.2 is used for the LCD R/W connection when
                        ' LCD present..otherwise as _RES_PD to Wifi Module.
                        ' PortC.4 is output to LED_RED
                        ' PortC.5 is output to LED_GRN
    '********************* Declare Variables and Aliases **********************
    WRITE 2,2      'EEPROM test to see if program executes to here..it does
        LED_RED  VAR PortC.4      ' Red LED
        LED_GRN  VAR PortC.5      ' Green LED used to indicate Routine entries
        MSEL     VAR PORTC.1      ' iChip Mode Select
        _RES_PD  VAR PORTC.2      ' iCHIP RESET/Power-Down
        TX       VAR PORTC.6      ' ports used for WiFi module serial interface
        RX       VAR PORTC.7
        'X_TEMP   VAR BYTE        'not used in new temperature routine
    WRITE 3,3  'EEPROM test to see if program executes to here..it does
        PAUSE 2000   'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
    WRITE 4,4  'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
          ' Blink LED_GRN 2X times to indicate iChip test started
               FOR I = 0 TO 1
                   HIGH LED_GRN
                   PAUSE 500
                   LOW LED_GRN
                   PAUSE 500
               NEXT
    '***************** SETUP FOR USING iWiFi MiniSocket Module ***************
    BOOT:   'iCHIP SET UP
      HIGH _RES_PD     ' Set high for normal ops
      PAUSE 500        ' Delay to stabilize coming out of power down mode
      LOW MSEL         ' Exit SERIALNET mode and return iChip to normal AT+i mode
      PAUSE 10000
      HIGH MSEL        ' Set high for normal AT+i ops
      PAUSE 500
      SEROUT2 TX,16390,[ "AT+iFD",$d ,$a]   ' Reset iChip to factory defaults
    WRITE 5,5   'EEPROM test to see if program executes to here..it does
      SERIN2 RX ,16390,2500,BROKE,[ WAIT("I/OK")]
    WRITE 6,6   'EEPROM test to see if program executes to here..it doesn't!
         ' ABOVE TEST INDICATES Interface to iChip is NOT working!
    BROKE:
            WRITE 16, "B"     'Record in EEPROM as test shows iChip broke
    WRITE 7,7   'EEPROM test to see if program executes to here..it doesn't!
            ' Blink LED_RED 2X times to indicate iChip not working
               FOR I = 0 TO 1
                   HIGH LED_RED
                   PAUSE 500
                   LOW LED_RED
                   PAUSE 500
               NEXT
            GOTO BOOT

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    CORRECTION TO CODE. Please ignore the code in previous post in favor of this one. Would really appreciate opinion as to whether this test code is telling me the MiniSocket has failed or not.
    Code:
    '<FL_PIC18F2550>'       ' Set MCU type for FineLine Editor
    '**************** Configure MCU and set port registers ********************
    DEFINE OSC 48    ' Using 8 MHz crystal
    @ __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L
    TRISA = 0           ' Reserve PortA as outputs for LCD use
    TRISB = %00011100   ' RB2 & RB3 reserved as RTC Alarm1 & Alarm2 inputs
                        ' PORTB.2 is also an interrupt from manual switch GND
                        ' PORTB.4 is set as A/D Channel 11 input
    TRISC = %10000000   ' Set PortC to all outputs except PortC.7 which is
                        ' reserved as RX input.
                        ' PortC.1 is output for MSEL to WiFi module
                        ' PortC.2 is used for the LCD R/W connection when
                        ' LCD present..otherwise as _RES_PD to Wifi Module.
                        ' PortC.4 is output to LED_RED
                        ' PortC.5 is output to LED_GRN
    '********************* Declare Variables and Aliases **********************
    WRITE 2,2      'EEPROM test to see if program executes to here..it does
        I        VAR BYTE         ' For-Next Loop index
        LED_RED  VAR PortC.4      ' Red LED
        LED_GRN  VAR PortC.5      ' Green LED used to indicate Routine entries
        MSEL     VAR PORTC.1      ' iChip Mode Select
        _RES_PD  VAR PORTC.2      ' iCHIP RESET/Power-Down
        TX       VAR PORTC.6      ' ports used for WiFi module serial interface
        RX       VAR PORTC.7
        'X_TEMP   VAR BYTE        'not used in new temperature routine
    WRITE 3,3  'EEPROM test to see if program executes to here..it does
        PAUSE 2000   'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
    WRITE 4,4  'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
          ' Blink LED_GRN 2X times to indicate iChip test started
               FOR I = 0 TO 1
               WRITE 5,5   'EEPROM test to see if program executes to here..it does
                   HIGH LED_GRN
                   PAUSE 500
                   LOW LED_GRN
                   PAUSE 500
               NEXT
    
    '***************** SETUP FOR USING iWiFi MiniSocket Module ***************
    BOOT:   'iCHIP SET UP
      HIGH _RES_PD     ' Set high for normal ops
      PAUSE 500        ' Delay to stabilize coming out of power down mode
      LOW MSEL         ' Exit SERIALNET mode and return iChip to normal AT+i mode
      WRITE 6,6   'EEPROM test to see if program executes to here..it does
      PAUSE 10000
      HIGH MSEL        ' Set high for normal AT+i ops
      PAUSE 500
      SEROUT2 TX,16390,[ "AT+iFD",$d ,$a]   ' Reset iChip to factory defaults
      SERIN2 RX ,16390,2500,BROKE,[ WAIT("I/OK")]
    WRITE 7,7   'EEPROM test to see if program executes to here..it doesn't!
         ' ABOVE TEST INDICATES Interface to iChip is NOT working!
    END
    BROKE:
            WRITE 16, "B"     'Record in EEPROM as test shows iChip broke
    WRITE 8,8   'EEPROM test to see if program executes to here..it doesn't!
            ' Blink LED_RED 2X times to indicate iChip not working
               FOR I = 0 TO 1
                   HIGH LED_RED
                   PAUSE 500
                   LOW LED_RED
                   PAUSE 500
               NEXT
            GOTO BOOT

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    This part really has me baffled
    Code:
    WRITE 3,3  'EEPROM test to see if program executes to here..it does    
    PAUSE 2000   'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
    WRITE 4,4  'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
    Obviously pointing to a larger problem but I can not think what it is. Need to get this fixed first.

    Anyone see what I am missing?
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: mackrackit's ConnectOne example code

    I don't see any reason for it not to be, but are you able to verify the PIC is actually running at 48Mhz? It seems there can only be 3 reasons to get stuck on a pause: Just taking forever because the clock is wrong, PIC is resetting - WDT maybe? or something is corroupting system variables causing PAUSE to mess up. I don't think it's the last option, no interrupts shown so what else could corrupt it? WDT and MCLR are both turned off. so that seems like it takes option 2 out. Leaves us to clock. The configs look correct, Maybe the crystal is not working/connected/...
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    Delay of this reply was due to me having to get a new ConnectOne iWiFi Mini Socket Module. I fried the other one.
    Also spent time while waiting for new module to get the application code working to requirements up to integration of the iWiFi. My application works perfectly up to the point of integration of the module, which I got yesterday. Spent today trying to get it to work with my application. Here is how my applications works.
    1) My application receives a periodic RBC_INT interrupt from the Alarm1 (_INTA) signal sent from a DS1337 RTC.
    2) Upon receipt of the interrupt the service routine measures a temperature and depending on the temperature initiates an email via iWiFi.
    Everything is working up to here. I hope you guys will help me figure out why the iWiFi and email process isn't working. If you need to see the full schematic of the application it is in a post I made in the Schematic forum regarding a question I had on Oring the backup battery with the Vcc supply for the RTC.

    I adapted Dave's ConnectOne example code by breaking it into a set of subroutines to integrate the iWiFi function into my application. My appliction is running on a 16F886 MCU that has a serial interface to the module via a SparkFun serial level converter (MCU is at 5 v....module is at 3.2v). I have double checked the pin/trace interfaces on the PCB and I think they are correct. I will list the subroutines and explain how I intended the process to work below. You will notice I use a lot of WRITE statements to EEPROM for post run evaluation/testing and also a lot of RED and GREEN LED blinking codes for run-time testing. I have annotated each write statement as to whether the code works to that point or not.

    Here is the routine called by the interrupt service handler to initiate the Email process...every thing works up to here:
    Email:
    ' Blink Green LED 1x long at start of Email routine
    TOGGLE LED_GRN
    PAUSE 1000
    TOGGLE LED_GRN
    PAUSE 2000

    GOSUB BOOT ' Setup WiFi module for ops if installed
    ' Executuon fails in BOOT and never gets to this point...see WRITE statement notes in BOOT routine below
    EMAIL_SET:
    SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iTOA:[email protected]",$d,$a] 'Permanently sets Email addressee
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+ito:jellis00",$d,$a] 'Permanently sets Email header s =To: description
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iREA:[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a] 'Permanently sets Email header =From: description.
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iSMTP:mail.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iSMA=1",$d,$a] 'Permanently sets SMTP authentication method
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a] 'Permanently sets authenticated SMTP login
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    SEROUT2 TX,6,["AT+iSMU:[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]

    ' Put code here to email low temperature warning via WiFi
    SEROUT2 TX,6,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
    SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
    SEROUT2 TX,6,["SENT EVERY 2 minutes.",$d,$a]
    SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
    SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
    SEROUT2 TX,6,["GO TO:",$d,$a]
    SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
    SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
    'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
    SEROUT2 TX,6,[$d,$a,".",$d,$a]
    SERIN2 RX,6,[WAIT("I/ONLINE")]
    PAUSE 1000
    'SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a] 'test not used
    WRITE 5,$01 ' Write 1 to EEPROM as test if Email sent
    ' Blink Green LED 2x long after email sent
    FOR I = 0 TO 1
    TOGGLE LED_GRN
    PAUSE 1000
    TOGGLE LED_GRN
    PAUSE 1000
    NEXT
    PAUSE 2000
    RETURN
    Here is the BOOT subroutine where the execution stops. I can't figure out why communication with the module isn't established.

    '*********SETUP FOR USING ConnectOne Mini Socket iWiFi module**********
    BOOT: 'iCHIP SET UP
    ' Blink Green LED 2x short at start of BOOT routine
    FOR I = 0 TO 1
    HIGH LED_GRN
    PAUSE 250
    LOW LED_GRN
    PAUSE 250
    NEXT
    PAUSE 2000

    HIGH _RES_PD ' Set high for normal ops
    PAUSE 500 ' Delay to stabilize coming out of power down mode
    LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
    PAUSE 10000
    HIGH MSEL ' Set high for normal AT+i ops
    'SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC temp,$d,$a,$d ,$a] 'test not used
    PAUSE 500
    WRITE 4,4 'EEPROM test to see if program executes to here..it does
    SEROUT2 TX,6,[ "AT+I",$d ,$a]
    WRITE 5,5 'EEPROM test to see if program executes to here..it does
    SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK")]
    WRITE 6,6 'EEPROM test to see if program executes to here..IT DOESN"T!

    ' ABOVE TEST INDICATESInterface to iChip is NOT working! Execution doesn't to this point!

    'SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ] 'test not used
    'SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ] 'test not used
    SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
    SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
    WRITE 10, ADR[0] ' Write the received IP address to EEPROM as a test..NEVER HAPPENS!
    WRITE 11, ADR[1]
    WRITE 12, ADR[2]
    WRITE 13, ADR[3]
    GOSUB DIP
    PAUSE 2000
    'SEROUT2 TX,6,["AT+iWLWM=1",$d,$a] ' Sets WEP enabled with 64bit key
    'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
    'SEROUT2 TX,6,["AT+iWLKI=1",$d,$a] ' Sets the Wireless LAN transmission WEP-Key index
    'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
    'SEROUT2 TX,6,["AT+iWLKn1=xxxxxxxxxx",$d,$a] ' Sets the Wireless LAN WEP key
    'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
    SEROUT2 TX,6,["AT+iWLSI=Buckskin",$d,$a] ' Sets the destination Wireless LAN SSID
    SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
    SEROUT2 TX,6,["AT+iWWW",$d,$a] ' Activates iChip's internal web server
    SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
    RETURN
    For completeness, here is the code for the BROKE segment that is used in BOOT when communication fails. I do see the character B written int EEPROM at the point in this code that confirms the failure in BOOT.
    BROKE:
    'SEROUT2 PORTC.0,16468,["NOT WORKING",$d,$a] 'Commented out for now
    WRITE 16, "B" 'Record in EEPROM as test if Broke...it does this!
    ' Blink LED_RED 3X long to indicate iChip not working
    FOR I = 0 TO 2
    TOGGLE LED_RED
    PAUSE 1000
    TOGGLE LED_RED
    PAUSE 1000
    NEXT
    PAUSE 2000
    Can you see anything in this that would cause failure other than a broken module? I can't believe that this brand new module is broken. I took extra precautions with it after breaking the previous one. Used static sensitive protection measures and never exposed it to wrong voltage. Please take a look and give me your observations and recommendations. Your help is GREATLY appreciated!

    Last edited by jellis00; - 10th October 2011 at 05:05.

  8. #8
    Join Date
    Nov 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    i was just confuse of what PIC should i use to interface the WizFi210-EVB sir...i'm a beginner sir so any suggestion of wat PIC should i use?...tnx...i want to design a PIR sensor like john design nw but i use WizFi210-EVB instead of connectone ant PIR instead of ultrasonic.and iwant to interface to PC unit with an application of Visual Basic as my GUI...i want to monitor my sensor through wireless..

  9. #9
    Join Date
    Nov 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    thank you very much sir...

  10. #10
    Join Date
    Nov 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    can i see your whole schematic if its okay to u sir..because i want to use the WizFi210-EVB module sir.its more alike in connectone sir..tnx

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    It will be tomorrow before I can post it as I do not have it with me.
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by kenruizal View Post
    ... i want to use the WizFi210-EVB module sir.its more alike in connectone sir..tnx
    The WizFi210-EVB bears no resemblance to the Connect One module. It has a DB-9 connector for the serial connection and uses RS232 levels and polarity. You'll just confuse yourself looking at Dave's schematic. Refer, instead, to the WizFi210-EVB schematic and their other documentation.

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