Announcement

Collapse
No announcement yet.

Wirelessly Programming Arduino Uno with RF100 Engines

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wirelessly Programming Arduino Uno with RF100 Engines

    Hi there Synapse developers and enthusiasts,

    This is my first post and I just wanted to say that these forums have been quite helpful. I've been all over them checking out stuff.

    Now I couldn't seem to find a straight answer in the forums to whether the RF100 modules could transparently serially communicate at 115200 baud or not. I know you can successfully configure them to do so but I'm not sure in reality if they can talk that fast.

    So here's what I'm trying to do:

    Establish a transparent serial link between my PC and a Arduino Uno in order to program it wirelessly. Note: The Arduino Uno bootloader sets up the communication speed to 115200 for serial programming.

    Here's are my results:

    I could not seem to upload code from my PC to the Uno with the Arduino-0022 IDE. For hardware I am using the PC usb port to Solarbotics Synapse-FTDI-adapter to RF100 engine and then to other RF100 engine to Solarbotics Synapse-Xbee apater board to Xbee-shield to Arduino Uno

    Please note: I have tested this same hardware and software (configured to 57600 baud) with a Freeduino (bootloader communicates at 57600 baud) instead of the Uno and it works flawlessly.

    Here is the code for the PC side:

    Code:
    from synapse.switchboard import *
    from synapse.platforms import *
    otherNodeAddr = "\x00\x00\x00" #blanked out node address for obvious reasons
    
    @setHook(HOOK_STARTUP)
    def startupEvent():
        initUart(1, 1) 
        flowControl(1, False)
        crossConnect(DS_UART1, DS_TRANSPARENT)
        ucastSerial(otherNodeAddr)
        setPinDir(9, False)     #Output
        writePin(9, True)   #Set Low 
        setPinDir(10, False)   #Input
        monitorPin(10, True)   #monitor changes to this pin. 
        setRate(3)  #1 ms monitoring of pin
        
    @setHook(HOOK_GPIN)
    def pinChg(pinNum, isSet):
        if (isSet == False):
            rpc(otherNodeAddr, 'writePin', 9, True)
        else:
            rpc(otherNodeAddr, 'writePin', 9, False)
    Here is the code for the Arduino Uno side:

    Code:
    from synapse.switchboard import *
    from synapse.platforms import *
    otherNodeAddr = "\x00\x00\x00" #blanked out node address for obvious reasons
    @setHook(HOOK_STARTUP)
    def startupEvent():
        initUart(1, 1) # <= put your desired baud rate here!
        flowControl(1, False)
        crossConnect(DS_UART1, DS_TRANSPARENT)
        ucastSerial(otherNodeAddr)
        setPinDir(9, True)   #Output
        writePin(9, True)   #Set Low
    I have tried using flowControl(1, False, True) with the same negative results. I have also tried using both the RF100PC6 and RF100PD6 RF engines with the same results. Another thing I have tried is adjusting the NV Parameters with the following code injected just below the def startupEvent(): portion:

    Code:
    NeedRestart=saveNvParam(13, 0, NeedRestart)
        NeedRestart=saveNvParam(14, 110, NeedRestart)
        NeedRestart=saveNvParam(15, 5, NeedRestart)
        
        if NeedRestart:
            reboot()
    But it didn't seem to make a difference.

    I have used my logic analyzer (with Ardunio-0022 IDE) to analyze the timing of the first few bits of serial data when i upload code and it seems that they are at the same timing (0.5s apart) as with the 57600 speed. I measure the timing between initial pulses with the Uno directly hooked up to my PC and the initial few responses are 0.2s apart.

    I guess simply put my question is: Can the RF100 modules transparently serially communicate at 115200 baud or am I chasing a ghost?

  • #2
    wireless programming

    The RF modules will communicate at 115.2 baud rate.

    Are you trying to upload a script or SNAP firmware?

    Comment


    • #3
      Thanks for your response I guess I can clarify, the question should have read Will the RFET RF100 (MC1321x) modules communicate over the air as a transparent serial link at 115200 baud?

      I'm not uploading a script or upgrading firmware, I am trying to establish a 115200 baud transparent serial link between 2 modules, although if it helps I did make sure both modules were running the 2.4.9 firmware.

      Comment


      • #4
        wireless programming

        The serial interface (UART) supported baud rate is 115.2 Kbps

        Thr OTA (over the air) rate is 250 Kbps for the RF100 and uo to 2Mbps for the RF200

        Thr RF300 OTA is 150Kbps.

        Comment


        • #5
          Thanks! Now that you've answered that question, what do you figure might be incorrect with my code/configuration?

          Comment


          • #6
            wireless programming

            Not sure I am not familiar with the other hardware you are using but it sounds like you are basically trying to run the datamode script that comes with Portal.

            Are you getting errors, no data, ??

            Comment


            • #7
              Yes, in the Arduino IDE i am getting an error that is generally seen as no serial communication. But as I said, with the same setup with an Arduino that talks at 57600 baud it's all good (with code modified for 57600).

              Comment


              • #8
                You'll likely need to adjust the UART settings to achieve the best results for your application. Your application may require lower latency to work correctly. Look at the Buffering Timeout, Buffering Threshold, and Inter-character Timeout settings in the SNAP reference manual.

                Comment


                • #9
                  Hi there IbarraE, thanks for the reply as well!

                  So I don't know if you have seen the code at the top of the post but I did adjust the Buffering Timeout, Buffering Threshold, and Inter-character Timeout settings with no real change. (NV Params 13,14,&15 adjusted)

                  And I realize I was mistaken, the RFET RF100s I have are not based on the MC1321x but the MC13191.

                  I was reading another post and he was also measuring 0.5s between packets (I need 0.2s between packets) as I was also seeing on 115200 baud, is it possible that 115200 is some how configured to 57600 in the background?

                  Has anyone successfully communicated (transparent serial) at 115200 with the modules I have (RF100, MC13191)? Gvoce said that the specs say it can be done but has anyone had experience trying this?

                  If I had to move up in baud rate would anyone know how to configure for a higher baud rate i.e. the max of 250kbps?

                  Would it be initUart(1, 2)?

                  Comment


                  • #10
                    The max baud rate (UART), serial port, is 115.2Kbps

                    The 250 Kbps is the over the air rate, wireless not UART

                    Comment


                    • #11
                      Gvoce thanks for the max UART specs!

                      I did read another post that mentioned that the RF100 max transparent serial throughput was 38400 baud. I don't need true throughput just a one way serial transmission. And I have it working at 57600 baud, just need 115200 now.

                      Now I will reiterate my other question:


                      Has anyone successfully communicated (transparent serial) at 115200 baud with the modules I have (RF100, MC13191)? Is it possible in real world applications or is just an ideal conditions spec?

                      Comment


                      • #12
                        @skater_j10:

                        Welcome to the forum!

                        A couple of thoughts on all posts:
                        RF100/200 (and maybe 300) max uart is 115200. On the RF200, it is possible to poke the registers to get to 250K, 500K, and 1M. However, I would not rely on that for a sustained transfer rate at that speed. Initial testing shows ok transfers at 250K, but start getting packet loss at 500K (even with radio set to 2M).

                        To anyone unaware/unfamiliar, programming an arduino through the serial bootloader is typically done at 57,600 or 115,200 as skater_j10 mentioned before. An arduino using an atmega328 will be doing a sustained transfer at set rate up until done, up to 32 KBytes.

                        @skater_j10:

                        I am assembling boards right now. (Somehow I got rid of all my breakout boards) I will test with RF100 and see what happens, then try RF200.

                        JC

                        Comment


                        • #13
                          Originally posted by skater_j10 View Post
                          Has anyone successfully communicated (transparent serial) at 115200 baud with the modules I have (RF100, MC13191)? Is it possible in real world applications or is just an ideal conditions spec?
                          Yes, I've used 115,200 before, but not as a sustained serial link. In bursts, it works fine. About to find out for sustained speed.

                          Comment


                          • #14
                            IT WORKS, it woooorrrrkkkkssss!!! Thanks to the outside assistance of J.C. Woltz we have now solved this issue, we can now program the Arduino UNO wirelessly over great distances with the Syanspe Wireless RF100PC6 nodes![Forum moderators feel free to place [Solved] beside the thread title]

                            So after many hours of doing manual resets of the UNO trying to time the serial packets in correctly, we did finally achieve positive results.

                            We have confirmed that yes, as J.C. stated, that the RF100 modules can communicate at 115200 baud in real world conditions . But do be aware, that as he alluded to, that serial throughput at that speed isn't perfect. Communicating with the RF100s over extend time at 115200 does have it's pitfalls, such as diminished transmission range.

                            In our testing we found that if you are uploading small file such as 2kB to the UNO the range is quite good (250ft+ indoor-to-outdoor transmission) but when uploading a larger file such as 27kB (extended time, it's about a 45 second upload) it cuts your transmission range down considerably (50ft indoors).

                            Remember those results are just testing in the environment we are located in which is saturated with 2.4Ghz Wifi and we have power lines in the area as well. Your mileage may vary.

                            We have written up a little PDF about our issues with the UNO's Optiboot bootloader if anyone is interested. And I also wanted to note that we are using the newly released Arduino1 IDE which did help us as well. The serial programming protocol was changed from the previous "stk500" protocol to the custom "arduino" protocol.

                            And here's a link to our "how to" PDF for programming an UNO wirelessly with RF100 modules. It includes all the Portal basics and hardware needed.

                            Without further adieu here's the code, PC side node first then Arduino side. Please note that this code it not optimized, as we are still new at this, but it works!

                            PC-side Node

                            Code:
                            """
                            Example of using two SNAP wireless nodes to replace a RS-232 cable
                            Edit this script to specify the OTHER node's address, and load it into a node
                            Node addresses are the last three bytes of the MAC Address
                            MAC Addresses can be read off of the SNAP Engine sticker
                            For example, a node with MAC Address 001C2C1E 86001B67 is address 001B67
                            In SNAPpy format this would be address "\x00\x1B\x67"
                            
                            Modified code written by J.C. Woltz
                            Further modified by Solarbotics Sept. 2011
                            
                            Hardware used: Solarbotics FTDI-Synapse Adapter Kit + Syanpse Wireless RF100 module
                            """
                            from synapse.switchboard import *
                            from synapse.platforms import *
                            otherNodeAddr = "\x00\x92\x3B"      # <= put the address of the Arduino-side node here
                            @setHook(HOOK_STARTUP)
                            def startupEvent():
                                saveNvParam(13, 0)              #Buffering Timeout, Default value: 5
                                saveNvParam(14, 100)            #Buffering Threshold, Default value: 75
                                saveNvParam(15, 10)             #Inter-character Timeout settings, Default value: 0
                                initUart(1, 1)                  #set UART1 baud rate to bootloader speed of Arduino UNO 115200kbps
                                flowControl(1, False)           #set UART1 flow control to off 
                                crossConnect(DS_UART1, DS_TRANSPARENT)  #set up UART1 for Transparent serial communication
                                ucastSerial(otherNodeAddr)      #set the destination node of our serial transmission
                                setPinDir(9, True)              #set node GPIO 9 to Output
                                writePin(9, True)               #set pin High 
                                setPinDir(10, False)            #set node GPIO 10 to Input
                                monitorPin(10, True)            #monitor changes to the FTDI RTS pin
                                setRate(3)                      #setting 3 = 1mS intervals of pin monitoring
                                
                            @setHook(HOOK_GPIN)                 #function to Reset Arduino when uploading code
                            def pinChg(pinNum, isSet):
                                if (isSet == False):
                                    rpc(otherNodeAddr, 'pulsePin', 9, 1000, True) #set GPIO 9 as a 1S reset pulse on the Arduino-side node  
                                else:
                                    rpc(otherNodeAddr, 'writePin', 9, False) #set GPIO 9 low on the Arduino-side node
                            Arduino-Side Node

                            Code:
                            """
                            Example of using two SNAP wireless nodes to replace a RS-232 cable
                            Edit this script to specify the OTHER node's address, and load it into a node
                            Node addresses are the last three bytes of the MAC Address
                            MAC Addresses can be read off of the SNAP Engine sticker
                            For example, a node with MAC Address 001C2C1E 86001B67 is address 001B67
                            In SNAPpy format this would be address "\x00\x1B\x67"
                            
                            Modified code written by J.C. Woltz
                            Further modified by Solarbotics Sept. 2011
                            
                            Hardware used: Freeduino (or Arduino Duemilanove) + Arduino Xbee shield +
                            Solarbotics Synapse-to-Xbee Adapter Kit + Syanpse Wireless RF100 module
                            
                            Xbee Shield jumpers must be set to "XBEE" for serial communication to get to Arduino chip
                            GPIO 9 is attached to the Arduino Reset via resistor R1 and transistor T1
                            """
                            from synapse.switchboard import *
                            from synapse.platforms import *
                            otherNodeAddr = "\x00\x92\x4D"      # <= put the address of the PC-side node here
                            @setHook(HOOK_STARTUP)
                            def startupEvent():
                                saveNvParam(13, 0)              #Buffering Timeout, Default value: 5
                                saveNvParam(14, 100)            #Buffering Threshold, Default value: 75
                                saveNvParam(15, 10)             #Inter-character Timeout settings, Default value: 0
                                initUart(1, 1)                  #set UART1 baud rate to bootloader speed of Arduino UNO 115200kbps
                                flowControl(1, False)           #set UART1 flow control to off 
                                crossConnect(DS_UART1, DS_TRANSPARENT)  #set up UART1 for Transparent serial communication
                                ucastSerial(otherNodeAddr)      #set the destination node of our serial transmission
                                setPinDir(9, True)              #set node GPIO 9 to Output 
                                writePin(9, True)               #set pin High
                            Thanks again to J.C. Woltz! I also wanted thank gvoce here in the forums for the info and Dave at Solarbotics for insisting we needed to get this working .

                            Oops, almost forgot to mention that this code also works (in Arduino1) with the Freeduino and Arduino Duemilanove with the code change of initUart(1, 1) to initUart(1, 57600)

                            Comment


                            • #15
                              @skater_j10

                              Can you please pack these up and post them under the "SNAPpy Script Exchange" for others to find them easily?

                              Thank you,
                              J.C. Woltz

                              Comment

                              X