mackrackit's ConnectOne example code


Closed Thread
Results 1 to 40 of 92

Hybrid View

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

    Default Re: mackrackit's ConnectOne example code

    I have only used the Nano LANReach, Nano SocketLAN, and Nano Socket iWiFi modules. The only data connections used are the TX and RX from MCU to the ConnectOne module.

    I never noticed a delay and have not taken the time to measure what it is, has to be some. For what it is worth, the
    SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
    has to be the very next line of code after an "AT+Ixx" command is sent. The "I/OK" will be missed if the SERIN command is placed in a sub routine, so the ConnectOne seems pretty fast.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by mackrackit View Post
    I have only used the Nano LANReach, Nano SocketLAN, and Nano Socket iWiFi modules. The only data connections used are the TX and RX from MCU to the ConnectOne module.
    Dave,
    I have been reviewing the data sheet for the MiniSocket WiFi module and can't find ansers to following questions. Can you or anyone else on this thread answer them??
    1)When using a UART serial interface from the MCU to the MiniSocket to perform asynchronous data transfer, should the TXD pin of the MiniSocket be connected to the RX pin of the MCU? Similarly, should the RXD pin of the MiniSocket be connected to the TX pin of the MCU? I ask this because the Nano WiReach reference design sent to me by ConnectOne has TXD to TX and RXD to Rx, which is contrary with most MCU serial interfaces I have seen.
    2)We are not going to use flow control on the serial interface so we are tying the -CTS and –RTS pins together. However, we can’t determine from the MiniSocket data sheet whether we need to use the handshaking interfaces with DTR and DSR or not when performing asynchronous serial data transfer with the MiniSocket from the MCU. I notice the ConnectOne reference design for the Nano WiReach did show the DTR and DSR interfaces implemented, yet in most asynchronous serial interfaces we have seen with a PIC MCU they are not used. Please clarify??
    3) It is my understanding that the MiniSocket (which is a 3.3 v device) is not tolerant to 5v logic signals. Our application is all 5v circuits. Any suggestions on how to convert the 5v logic of the MCU to 3.3v logic for the MiniSocket with minimum hardware....our board is already very densely populated and can't afford a lot of additional components.

    Really appreciate any comments/answers to these questions.

    John
    Last edited by jellis00; - 23rd June 2011 at 01:35.

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

    Default Re: mackrackit's ConnectOne example code

    I'm the other Dave but I'll give you my responses to your questions, anyway.

    1. Cross-connect them.

    2. The Mini Socket iWiFi datasheet explicitly says to connect CTS/RTS if they are not used but says nothing about DTR/DSR so I don't think you need to connect them but you probably should ask this of Connect One Support.

    3. I dropped my intent to make the shield work with 5V and 3.3V because it was just to complicated with all the SPI lines on the other modules. However, with the Mini Socket iWiFi, we are only dealing with two inputs and one output. The way I prefer to handle this is with a transistor and two resistors for each line. You can see example circuits in FIG 15 of AN213.
    Last edited by dhouston; - 23rd June 2011 at 02:50.

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

    Default Re: mackrackit's ConnectOne example code

    What Dave said...
    I will add..
    When ConnectOne says TXD to TX they are meaning cross over.

    If I were you I would make a point to start designing things for 3.3... But in the mean time
    here are more possible solutions, or the same ?
    http://ww1.microchip.com/downloads/e...hapter%208.pdf
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    I should have mentioned that the Mini Socket iWiFi datasheet says for RXD...
    Input - Host Data Receive – Asynchronous serial data received from host.
    anf for TXD...
    Output - Host Data Send – Asynchronous serial data sent to host.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by dhouston View Post
    I should have mentioned that the Mini Socket iWiFi datasheet says for RXD...anf for TXD...
    Thanks, Dave. I also got a Tech Support input from OneConnect saying to connect TXD to MCU's RX and RXD to MCU's Tx, -DTR to ground, -DSR unconnected, and -CTS connected to -RTS. So this clarifies the serial interface requirements for their MiniSocket WiFi module with a PIC MCU.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by mackrackit View Post
    What Dave said...
    If I were you I would make a point to start designing things for 3.3...
    Thanks for the URL to the Tips file. The only reason I am still using 5.0 volts for the MCU is I am using one of the GPIO pins to power on and off a SRF02 Ultrasonic Ranger, which only operates on 5.0v. I am using two LDO regulators, one for 9v to 5.0 v to power the MCU (and the SRF02), and one further downstream for 5.0v to 3.3v to power the ConnectOne WiFi module.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by dhouston View Post
    3. I dropped my intent to make the shield work with 5V and 3.3V because it was just to complicated with all the SPI lines on the other modules. However, with the Mini Socket iWiFi, we are only dealing with two inputs and one output. The way I prefer to handle this is with a transistor and two resistors for each line. You can see example circuits in FIG 15 of AN213.
    Other Dave,
    I appreciate your referral to this app note...it has a lot of good ideas in it. However, for the level shifting I have to do between the 5V logic on the PIC MCU and the 3.3v logic on the MiniSocket iWiFi module, I am going to give the Sparkfun device a try (see http://www.sparkfun.com/products/8745 ). It is low cost and gives me enough channels to handle the problem. Have you or anyone had any experience with it?

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by jellis00 View Post
    Have you or anyone had any experience with it?
    Yes, I've used it when breadboarding. In fact, I meant to include it in my post but could not find it with a quick search at Spark Fun. (I lost a network drive a few months back which had a lot of my notes, etc. and most of my toys are still in storage after a lengthy hospitalization last year.) It should work fine here.

    Also, either the Tips file referenced by mackrackit or a similar one from Microchip (I think.) has tips on getting 5V from 3.3V. For example, if you're using a MAX232 or similar line driver, you can steal 10-12V from it. Of course, it depends on the current needs of your 5V device.

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

    Default Re: mackrackit's ConnectOne example code

    Mackrackit, I know your ConnectOne example code is for a Nano Socket iWiFi module configurtion, whereas I am working with a iWiFi MiniSocket module, but I am trying to interpret some of your code to help me figure out how to program my 18F4550 as the embedded host for the MiniSocket. Without your schematic I am confused as to what connections on the iWiFi module are used with the PortC.4 and PORTC.3 connections on the MCU. Could you please post a schematic to help understand the purpose of the different connections between your 16F873A/iWifi module?

    Am also confused by some of your code:
    Are you using the sequential HIGH and then LOW statements for PORTC.4 to perform somekind of reset of the iWiFi module?
    When you use the SEROUT2 statements with PORTC.3, what are you doing when you send ["iChipO OK"] and ["TEST_",DEC3 CNT, 13, 10]?
    I also don't understand the purpose of the DIP subroutine??

    Can you please explain these statements to me?

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

    Default Re: mackrackit's ConnectOne example code

    The DIP routine is for parsing the address that the router assigned to the iChip.
    When you use the SEROUT2 statements with PORTC.3, what are you doing when you send ["iChipO OK"] and ["TEST_",DEC3 CNT, 13, 10]?
    PORTC.3 goes straight to a terminal for debugging. ["iChipO OK"] is what the iChip returns after a successful operation, I would pass that to a terminal to see if things were working. The code counts to 60 before an email is sent, ["TEST_",DEC3 CNT, 13, 10] is to see what the count is.
    Code:
    HIGH PORTC.4 :PAUSE 250: LOW PORTC.4: PAUSE 500 
    ' Is a crude "heart beat" to see if the MCU is running.
    Below is pretty much the same code but for a 18F4550 along with the hookup.
    I know, I should use more comments...
    Code:
    
    '<FL_PIC18F4550>'
    
    DEFINE OSC 48
    @ __CONFIG   _CONFIG1L, _PLLDIV_1_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 & _ICPRT_OFF_4L &_XINST_OFF_4L
    
        '############################  #
        ADCON1 = 001110
        CNT VAR BYTE
        CNT = 0
        OUT_TEMP VAR BYTE
        ADC_TEMP VAR WORD
        S_TEMP   VAR BYTE
        D_LAY   VAR BYTE
        ADR VAR BYTE [9]
        TX  VAR PORTD.6   ;ORANGE 
        RX  VAR PORTD.7   ;YELLOW 
        X_TEMP   VAR BYTE
        PAUSE 2000
        INTCON.5 = 1    'ENABLE TMR0
        T0CON = 000101  ON INTERRUPT GOTO TLOOP 
    
    
     BOOT:   'iCHIP SET UP
      SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC OUT_TEMP,$d,$a,$d ,$a]   
      PAUSE 500SEROUT2 TX,6,[ "AT+I",$d ,$a]
      SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
      SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ]
      SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ]
      SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
      SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
      GOSUB DIP
      PAUSE 2000
      SEROUT2 TX,6,["AT+iWWW",$d,$a]
      SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
      ;#############################
        EMAIL_SET:
      SEROUT2 TX,6,["AT+iSBJ:MAC_ETHERNET",$d,$a] 
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iTOA:[email protected]",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+ito:MACKRACKIT",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iREA:[email protected]",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iFRM:MAC_ETH",$d,$a] 
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iSMTP:mail.mf3x3.com",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iSMA=1",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iSMP:booger",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
      SEROUT2 TX,6,["AT+iSMU:[email protected]",$d,$a]
      SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
       FTP:
      CNT = CNT + 1 
      SEROUT2 TX,6,["AT+i",$d,$a]
      SEROUT2 TX,6,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
      SEROUT2 TX,6,["AT+iFOPN:192.168.2.16:mac,999999",$d,$a]'OPEN SESSION
      SERIN2 RX,6,1000,BOOT,[WAIT("I/000")] 
      PAUSE 100
      SEROUT2 TX,6,["AT+iFCWD:000,ichip",$d,$a]
      SERIN2 RX,6,1000,BOOT,[WAIT("I/OK")]  
      SEROUT2 TX,6,["AT+iFSTO:000,",$22,"ichip.txt",$22,$d,$a] 
      SERIN2 RX,6,1000,BOOT,[WAIT("I/OK")]  
      SEROUT2 TX,6,["AT+iFSND:000,19:"," The temperature is",$d,$a]:PAUSE 100
      SEROUT2 TX,6,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
      SEROUT2 TX,6,["AT+iFSND:000,18:",DEC OUT_TEMP," F In the shop.",$d,$a]:PAUSE 100  
      SEROUT2 TX,6,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
      SEROUT2 TX,6,["AT+iFSND:000,12:",DEC CNT," MINUTES.",$d,$a]:PAUSE 100
      SEROUT2 TX,6,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
      PAUSE 100
      SEROUT2 TX,6,["AT+i",$d,$a]':PAUSE 100
      SERIN2 RX,6,100,BOOT,[WAIT("I/OK")] :PAUSE 100
      GOSUB GET_TFOR D_LAY = 1 TO 120 
      PAUSE 500 
      NEXT D_LAY
      IF CNT = 2 THEN EMAIL
      IF CNT > 60 THEN CNT = 0  
      GOTO BOOT
      END
      EMAIL:
      SEROUT2 TX,6,["AT+iEMA:",$d,$a]
      SEROUT2 TX,6,["HI, THIS IS FROM MAC_ETH",$d,$a] 
      SEROUT2 TX,6,["SENT EVERY HOUR.",$d,$a]
      SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
      SEROUT2 TX,6,[DEC OUT_TEMP,"F IN THE SHOP.",$d,$a] 
      SEROUT2 TX,6,["GO TO:",$d,$a]
      SEROUT2 TX,6,["http://mackrackit.com/mac/ichip/ichipw.py",$d,$a] 
      SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
      SEROUT2 TX,6,[$d,$a,".",$d,$a]
      SERIN2 RX,6,60000,BOOT,[WAIT("I/ONLINE")] 
      PAUSE 1000
      SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a]
      HIGH PORTD.0
      PAUSE 1000
      LOW PORTD.0
      GOTO BOOT
    
      DIP:
      IF !ADR[1] AND !ADR[1] AND !ADR[2] AND !ADR[3] THEN SEROUT2 PORTC.3,16780,[" NOT "]
      SEROUT2 PORTC.0,16468,[" CONNECTED ",$d,$a]
      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]
      PAUSE 500
      GOTO BOOT
    
      GET_T:
      ADC_TEMP = 0
      FOR X_TEMP = 1 TO 20
      ADCON0=00000001
      GOSUB READ_AD
      S_TEMP = ADRESH
      ADC_TEMP = ADC_TEMP + S_TEMP
      PAUSE 250
      NEXT X_TEMP
      OUT_TEMP = ADC_TEMP / 20
      OUT_TEMP = OUT_TEMP * 13/10
      RETURN
    
      READ_AD:
      PAUSE 50
      ADCON0.1=1
      WHILE ADCON0.2=1:WEND
      RETURN
    
      DISABLE
        TLOOP:
        INTCON.2=0:TOGGLE PORTD.0
        RESUME: ENABLE
    Attached Images Attached Images  
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    And you can see the mini iWiFi connections here and here.
    Last edited by dhouston; - 17th September 2011 at 12:40.

  13. #13
    Join Date
    Nov 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    hello sir..your post in this thread is not complete theres a certain part of your schematic i cannot see or it was cut..tnx

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

    Default Re: mackrackit's ConnectOne example code

    It shows how the ConnectOne is connected.
    Dave
    Always wear safety glasses while programming.

  15. #15
    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

  16. #16
    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.

  17. #17
    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

  18. #18
    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

  19. #19
    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

  20. #20
    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.

  21. #21
    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.

  22. #22
    Join Date
    Nov 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    Do you have a schematic diagram of your design?...

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

    Default Re: mackrackit's ConnectOne example code

    Read the whole thread. John and I have both posted schematics.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by kenruizal View Post
    Do you have a schematic diagram of your design?...
    Not sure whether you are asking me for schematic or from mackrackit.
    As mackrackit says in one of his posts, we have both posted schematics. However, the previous one I posted had some errors in how to connect the ConnectOne iWiFi MiniSocket module, which I discovered the hard way in my PCB and had to re-do the wiring on the PCB. Therefore, if you want this updated schematic that shows how to wire the MiniSocket and how to use a SparkFun level converter module in the interface between the PIC MCU and the MiniSocket, here it is attached.
    Name:  ConnectOneMiniModuleSchematic.jpg
Views: 4464
Size:  114.3 KB

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