+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 40 of 92
  1. #1
    Join Date
    Dec 2005
    Posts
    1,073

    Default mackrackit's ConnectOne example code

    Here's a link to his ConnectOne example.

    Pros: The ConnectOne modules have a complete set of internet protocols and all the coding is similar to that in the mackrackit example. Configuration can be done via the ethernet or serial connection. The modules do all of the heavy lifting. IMO, these are the easiest to use.

    Drawbacks: Their modules take up more real estate than some others and mounting them to a mainboard is problematic in some cases. They do not fit breadboards. The code burden of the AT commands can add up quickly.
    Last edited by dhouston; - 25th May 2011 at 14:59.

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

    Default Re: mackrackit's ConnectOne example code

    Another drawback with the ConnectOne is it can not be setup to use "non-standard" ports when using it as a web server. Port 80 and 443 are it.

    About a year ago I asked them about it and they told me they were working on new firmware. Maybe the new firmware is out but I have not seen it..
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    Quote Originally Posted by dhouston View Post
    Here's a link to his ConnectOne example.

    Pros: The ConnectOne modules have a complete set of internet protocols and all the coding is similar to that in the mackrackit example. Configuration can be done via the ethernet or serial connection. The modules do all of the heavy lifting. IMO, these are the easiest to use.
    Dave, I am considering using a ConnectOne MiniSocketWiFi Module for a battery operated wireless application because it has a shutdown mode that only consumes 40 uA...which is lowest consumption that we have found in any other wireless module.

    We intend on sending it data via its asynchronous serial interface (no flow control) for WiFi transmission. However, after reviewing the data sheet for the MiniSocketWiFi module we are confused as to whether it requires use of the DTS and DSR handshaking interfaces. Your posting here doesn't say which ConnectOne module you are using, but I would very much like to see a reference design if you have one and an explanation of how you are wiring the serial interface...maybe even a schematic?

    Would also like to know from your example the delay time from AT message transmission to the ConnectOne until the WiFi message is actually transmitted via WiFi if you by chance have measured it or can estimate it?
    Last edited by jellis00; - 21st June 2011 at 17:37.

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

    Default Re: mackrackit's ConnectOne example code

    Just tie the handshaking lines (nCTS,nRTS) together if you are not using them.

    In the ethernet shields, I bring them out to a point where you can solder a wire jumper between them.

    I've put up a web page with the shields and some other related things here...
    All the connections are shown on the shields.

    I don't have the iWiFi but only the SocketLAN so I cannot answer about the delay. Maybe the other Dave can.

    In general I've found that the translation delay between serial and other protocols isn't noticed until you try something intensive like updating firmware over the link where the translation time and handshaking for error checking become a larger factor.

    As for the current draw, the various serial-to-WiFi adapters are all over the map. I was considering a shield using a WIZNet module (which I do have) until I saw it used about twice as much current when transmitting than others.

    BTW, look into BR type batteries if you haven't already.
    Last edited by dhouston; - 21st June 2011 at 19:43.

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

    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.

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

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

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

    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.

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

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

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

  12. #12
    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?

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

  14. #14
    Join Date
    May 2004
    Location
    brighton
    Posts
    149

    Default Re: mackrackit's ConnectOne example code

    i am waiting for delivery of Nano Lan Reach
    http://www.connectone.com/media/uplo...each_PB_01.pdf
    but i am not clear as to if i use one of your shelds as belowjust a few questions
    i would be using this with a pic18f452 running at 5v and i know the data sheets for the nano runs at 3v3
    if i do supply if it 3v3 do i need to to anything to the Tx/Rx lines or do they have to be 3v3 as well.
    On you board is this already taken care of

    Regards

    isaac

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

    Default Re: mackrackit's ConnectOne example code

    Yes, if you run the PIC at 5V and the ConnectOne module at 3.3V you will need to do level conversion in both directions.

    My shields have been delayed. I had a bout of atrial fibrillation resulting in a brief (4 day) hospitalization but some not so brief medical bills which have blown holes in my budget. All my projects have been set aside for the time being.

    The Spark Fun level shifter mentioned above should do what you need. (The AN213 link also shows a few different methods.) You need to deal with TX, RX & RESET. Outputs from the module (TX) need to be shifted up to 5V for input to the PIC, inputs to the module (RX, RESET) need to be shifted down to 3.3V.

  16. #16
    Join Date
    May 2004
    Location
    brighton
    Posts
    149

    Default Re: mackrackit's ConnectOne example code

    I hope you get better as quick as possible i now get it clearly

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

    Default Re: mackrackit's ConnectOne example code

    Speedy recovery, take it easy in meantime.
    Steve

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

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

    Default Re: mackrackit's ConnectOne example code

    I'm fine. I've had Congestive Heart Failure for about 9 years and all is under control by medication. My primary care doc even commented that I have the vital signs of a 20 year old (seems a shame to waste them on a 70 year old). And, tests in the hospital confirmed that my heart is still normal in size and pumping efficiency (ejection fraction) with no water around it.

    I just got caught in a couple of bureaucratic snafus not of my own making. I get my meds from the Veterans Administration. I was moving and the VA refused to accept my change of address over the phone, telling me I had to come, in person, with a piece of mail in-hand that I received at the new address. Simultaneously, my cardiologist for the past 9 years (outside the VA) was forced to close his practice by a non-compete lawsuit brought by the very hospital I ended up in which had recently bought the group practice he had been a member of but chose to leave after the sale. I could not reach him to get a prescription so I ran out of two critical meds which regulate BP and pulse rate. I'm back on my medication and even the VA accepted my new address with no further red tape so my supply is assured for awhile.

    I just need to clear all the hospital/doctor bills before spending anything on toys.

    But, thanks for the good wishes.
    Last edited by dhouston; - 19th August 2011 at 22:29.

  19. #19
    Join Date
    Feb 2011
    Posts
    26

    Default Re: mackrackit's ConnectOne example code

    Dave H,

    Glad you're doing well and still on this side of the grass.

    And THANK YOU for your service.

    Fuzzy

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

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

    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:mackrackit@gmail.com",$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:mac@mackrackit.com",$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:mac@mf3x3.com",$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.

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

  23. #23
    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:jellis00@comcast.net",$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:jellis00@comcast.net",$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:je.lodestar@comcast.net",$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: 1805
Size:  105.3 KB

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

    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.

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

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

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

    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.

  28. #28
    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!

  29. #29
    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:jellis00@comcast.net",$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:jellis00@comcast.net",$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:je.lodestar@comcast.net",$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.

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

    Default Re: mackrackit's ConnectOne example code

    I am not familiar with Sparkfun stuff, that module converts 5 to 3? Why not just run the whole thing from a 3 volt supply and be done with it?

    Is your router set for DCHP? Does it see a new device?

    I have always used the ConnectOne software to set the passkey and baud rate.

    When I get back to the shop I will look at this closer.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    My application is also using a SRF02 ultrasonic ranger sensor as controlled by my 16F886 MCU. The SRF02 will only work on 5v so I made the choice of running the MCU also at 5v and then I had to use the Sparkfun level converter between it and the ConnectOne iWiFi module.

    I will double check my router setting for DCHP.

    What code are you referring to from ConnectOne to set the passkey and baud rate? Can you share or point me to it with a URL?

    I really appreciate your looking at my code.

    John

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

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

    Default Re: mackrackit's ConnectOne example code

    Up date..
    Trying to set up the iChip using only AT commands like you are. Not having much luck. Have to get back to work. Will continue later.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    Up date..<br>Trying to set up the iChip using only AT commands like you are. Not having much luck. &nbsp;Have to get back to work. Will continue later.

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

    Default Re: mackrackit's ConnectOne example code

    Do you have a URL link that will get me to where I can download the iChipConfig utilility and its user manual?

    I will have to use it on a Windows XP lapto. My application PCB doesn't have a serial interface to it that I can use to connect to PC terminal. Does that mean I can't use iChipConfig utility?

    Here is a URL to the SparkFun level converter. http://www.sparkfun.com/products/8745

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

    Default Re: mackrackit's ConnectOne example code

    Dave, I began to wonder if in my process of converting your ConnectOne example code to my 16F886 MCU and my parsing of the code into subroutines that I could call from my application might have done something that screwed up its ability to communicate with the iChip module. So I went back to your original example code which is a lot simpler and modified it slightly so it is supposedly compatible with 16F886, without parsing into subroutines. Below is the resulting code where I have annotated where it stops and won't execute any further. Still looks like I can't get communication with the iChip. Would appreciate you trying it to see if you can get it to communicate with your module.

    I also tried using the AT+iFD command to reset the iChip
    to Factory Defaults, in hopes that it would connect.....I did this because of this quote in the iChip WiFi Configuration Manual which says " Assuming all WiFi related parameters are cleared to their default value, as is the case after a Factory-Defaults setting (AT+iFD), iChip will attempt to associate and connect to the closest available Access Point (AP) that does not have any security configured. " I used this statement to try to do this and it won't even compile as if there is a syntax error: SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
    I don't see anything wrong with this. Any ideas why this won't compile?


    'Adapted from http://mackrackit.com/mac/ichip/ichip.html
    'Every 60 seconds OR so the PIC sends the commands TO the iChip TO FTP a file along with a new number in the file.
    'Every 60 seconds OR so the page will reload with a new number generated by a PIC.
    'Every 60 minutes OR so the DATA IS also emailed.

    'The PIC code which will compile:
    '#####################################
    '< FL_PIC16F886 >' ' First valid PIC found within the first 200 lines will
    ' highlight AND set device.
    '< FL_PBPW >' ' OR < FL_PBPL >
    '< FL_MPASM >' ' OR < FL_PM >
    ' Set configuration fuses for the MCU
    ' To use standard config include file, comment out below statement
    @ __config _CONFIG1, _HS_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    ASM
    ERRORLEVEL -306
    ENDASM

    DEFINE OSC 8
    ADCON1 = %00001110
    TRISC.4 = 0 ' Used as output for LED_GRN
    TRISC.5 = 0 ' Used as output for LED_RED
    TRISC.6 = 0 ' Used as output for serial TX
    TRISC.7 = 1 ' Used as input for serial RX

    ' Define variables and aliases
    CNT VAR BYTE
    CNT = 0
    temp VAR BYTE 'Already declared in main program as temp
    D_LAY VAR BYTE
    ADR VAR BYTE [9]
    TX VAR PORTC.6
    RX VAR PORTC.7
    PAUSE 2000

    BOOT: 'iCHIP SET UP
    ' Blink LED_GRN 1x LONG
    HIGH PORTC.5 :PAUSE 1000
    LOW PORTC.5: PAUSE 2000
    'SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
    WRITE 2,2 'Above statement won't compile when uncommented
    SEROUT2 TX,6,[ "AT+I",$d ,$a] 'Verify that the iChip is communicating
    WRITE 3,3 'EEPROM test to see if program executes to here..it does.
    SERIN2 RX,6,2500,BROKE,[ WAIT("I/OK") ]
    WRITE 4,4 'EEPROM test to see if program executes to here..IT DOESN'T!
    SEROUT2 PORTC.3 , 16780 , [ "iChip OK" ]
    SEROUT2 PORTC.3 , 16780 , [ "TEST_" , DEC3 CNT , 13 , 10 ]
    SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ] 'Report the current IP address
    SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ] 'Store IP in array
    GOSUB DIP ' If IP address is empty, report not connected
    PAUSE 2000
    SEROUT2 TX,6,["AT+iWWW",$d,$a] 'Activate iChip s internal web server
    SERIN2 RX,6,1000,BOOT,[WAIT("I/(")] ' 1 sec timout to BOOT label..I/(<Local IP addr>)where,<Local IP addr> IS the iChip local IP address
    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:je.lodestar@comcast.net",$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:je.lodestar@comcast.net",$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.com",$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:je.lodestar@comcast.net",$d,$a]'Permanently sets Authenticated SMTP login User Name.
    SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
    FTP:
    CNT = CNT + 1
    FOR D_LAY = 1 TO 12
    PAUSE 5000
    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] 'Defines a plain text e-mail body
    SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
    SEROUT2 TX,6,["SENT EVERY HOUR.",$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
    GOTO BOOT

    DIP:
    IF !ADR[1] AND !ADR[1] AND !ADR[2] AND !ADR[3] THEN SEROUT2 PORTC.3,16780,[" NOT "]
    SEROUT2 PORTC.3,16780,[" CONNECTED ",$d,$a]
    SEROUT2 PORTC.3,16780,["ADR - " ,DEC3 ADR[0],".",DEC3 ADR[1],".",DEC3 ADR[2],".",DEC3 ADR[3],$d,$a]
    PAUSE 1000
    RETURN

    BROKE:
    SEROUT2 PORTC.3 ,16780,["NOT WORKING",$d,$a]
    PAUSE 500
    GOTO BOOT

    GET_T:
    ADCON0=00000001
    GOSUB READ_AD
    temp = ADRESH
    temp = temp * 2
    RETURN

    READ_AD:
    PAUSE 50
    ADCON0.2=1
    WHILE ADCON0.2=1:WEND
    RETURN




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

    Default Re: mackrackit's ConnectOne example code


    I used this statement to try to do this and it won't even compile as if there is a syntax error: SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
    I don't see anything wrong with this. Any ideas why this won't compile?
    I at least figured out why this statement wouldn't compile....I forgot to put a comma after the SEROUT2 TX,6 . However, after fixing this and compiling/running it, the factory defaults didn't seem to happen.

    I may have found part of the problem. I have placed a voltmeter on the pin that is RX going into the iWiFi and it stays at a constant 3.3 volts throughout this program...no fluctuations indicating any serial transmission. Also put it on the TX pin comming out of my MCU...also constant. This tells me that the serial interface from the MCU is not working. That would mean that the AT+iFD message never got to the module, hence no Factory Defaults. However, I don't know why or how to fix it. Any ideas?

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

    Default Re: mackrackit's ConnectOne example code

    I changed all the SEROUT2 TX statements in the code to mode 396 to lower the baud rate to 2400 to see if this made the serial interface work. Still doesn't appear to work. BAFFLED!!
    Is there any way to tell whether the asynchronous serial interface on a PIC chip that is using PortC.6 and PortC.7 is working?? I don't have an external serial interface to my PCB to use to see if it is working with a PC terminal or I would. I have the TX and RX pins hooked up only internally to the iChip module.

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

    Default Re: mackrackit's ConnectOne example code

    Post #32 has the link to the config utility. You will need a serial interface to your PC to use it along with a MAX232. A USB to serial adapter works fine.

    A USB to serial adapter will also let you test you TX, also will help in debugging.

    Hang in there, we will get this figured out.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: mackrackit's ConnectOne example code

    Just received the below email for ConnectOne tech support confirming what you said about Config utility, so looks like the option is out for me since I don't have an external serial interface on my board.

    From what I know now, my problem is really getting the PIC to establish serial communications on my board with my code to the iChip. Once that is done I should be able to use the http:// approach he mentions in the email to setup the iChip configuration. So if you ca help me figure out why the PIC isn't executing the serial interface, that will be the big step.
    Regards, John

    Here is their email:
    Hi John,

    According to our R&D, the LAN to WiFi Wizard is not operational and should not be used (it should have been removed from the s/w).

    To configure the unit either use the FULL CONFIGURATION tool in the iChipConfig or manually type in AT+I commands using the “Dumb terminal”.
    Once the unit is configured, it will save the parameters in non volatile memory.
    You will need to power down the unit for the parameters to take effect.

    Once you’ve setup the module for the AP you want to connect to and enabled the internal web server, you can than access directly the ichip web configuration page via http://x.x.x.x/ichip

    All the information you need for setting up the module is available in the documentation I previously sent you.

    Best regards,
    Daniel Doron
    Customer Support & FAE Manager

    Connect One
    20 Atir Yeda st.
    Kfar Saba 44643 Israel
    Phone: 972-9-7660456 x138

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