Shop OBEX P1 Docs P2 Docs Learn Events
Need help communicating between mutltiple arduinos with Parallax 27982 433's — Parallax Forums

Need help communicating between mutltiple arduinos with Parallax 27982 433's

UMLstudentUMLstudent Posts: 3
edited 2013-08-23 10:33 in General Discussion
Hello forum!

I'm scratching my head trying finish my senior project. I'm trying to program a robot controlled by 2 arduino UNO's with Parallax 27982 433 transcievers, one on the RF controller and the other on the robot. It was recommended to use the "Virtual Wire" for the use of these transcievers. There is feedback too so i will be using Bi-directional serial communication. Wondering if anyone has experience that could be of help....

the issue i'm having is that the 27982's only have 1 "data" pin... whereas the arduinos have seperate TX and RX

-Paul
«1

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-25 05:46
    The 27982's have a DATA pin and a TX/RX pin. So, you have have to set the TX/RX pin as req'd. and change the status of your I/O pin to suit.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-25 06:13
    As PJ Allen mentioned, you have to switch back and forth in your program between transmit (output) mode and receive (input) mode. Do a search of the Arduino website for information on software serial I/O, where all of the bit manipulation and timing is done in software rather than in hardware. It's often not easy to handle a bidirectional half duplex serial channel using a hardware implementation (UART).
  • UMLstudentUMLstudent Posts: 3
    edited 2011-04-25 08:34
    I believe thats when the "Virtual Wire" library comes in. Thing though, i believe before calling the functions for the software implementation, i will have to set the TX/RX accordingly before making a transfer/receive


    Since i will be using the arduino that has seperate TX and RX and the Parallax only having a Bi-direciton Data pin... would i need to use diodes on the arduino to make sure noise does not come into the other direction?


    -Paul
  • Mike GMike G Posts: 2,702
    edited 2011-04-25 09:19
    If I understand the problem correctly, you can use a NPN/PNP transistor circuit to convert between Rx/Tx to single 1/2 duplex wire. I don't have the schematic handy right now (at work). It's a pretty easy circuit and I've used it for years. You can also find ICs that do the same thing.

    Edit: found the schematic
    http://forums.parallax.com/showthread.php?83144-How-to-connect-PSC-to-computer-s-serial-port
  • UMLstudentUMLstudent Posts: 3
    edited 2011-04-25 09:43
    Mike G wrote: »
    If I understand the problem correctly, you can use a NPN/PNP transistor circuit to convert between Rx/Tx to single 1/2 duplex wire. I don't have the schematic handy right now (at work). It's a pretty easy circuit and I've used it for years. You can also find ICs that do the same thing.

    Edit: found the schematic
    http://forums.parallax.com/showthread.php?83144-How-to-connect-PSC-to-computer-s-serial-port


    So it is not practical to just set the TX/RX of the parallax, say to RX, by setting the appropriate bit in the software... then starting the transmission? This NPN/PNP looks like its on seperate Tx/Rx pins....


    -NissanTracker
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-25 10:08
    I can't advise you on the "Virtual Wire" library, but, in the software serial routines, you can use the same I/O pin for both receive and transmit. You do have to change the Arduino I/O pin from input to output mode and back again. If you're really careful about I/O direction, you could just connect the I/O pin to the Transceiver, but it's really easy to forget to set the I/O direction properly to match the Transceiver's mode. You'd be best off putting something like a 1K resistor in the lead between the I/O pin and the Transceiver data line.
  • Mike GMike G Posts: 2,702
    edited 2011-04-25 10:45
    I guess I don't understand the issue then. It sounded like you wanted to connect a hardware UART (Rx/Tx) to a single wire (1/2 duplex) bus. From the AVR side all you have to do is set the Rx/Tx logic level (and handle the UART). The circuit would handle the Ins and OUTs of the serial data to/from the transceiver.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-25 10:58
    See what I mean about arduina?
    It's all about glomming "libs" that somebody else did.
    They have "input/output" (I/O) pins, but after that the phone goes dead.
  • FranklinFranklin Posts: 4,747
    edited 2011-04-25 14:31
    See what I mean about arduina?
    It's all about glomming "libs" that somebody else did.
    Yeah, sorta like Propeller objects and stamp example code. :innocent:
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-25 19:59
    If Stamp example code was a black-hole, like arduina libs, you would have a point, Franklin.

    Some people feel that it'd be an achievement to bring the Propeller down to the abysmal arduina kultur of "libs" and their equally mindless "shields", but the OBEX isn't there yet.

    The OP seemed, at first, like he needed an insight as to the XCVR's ops, so I correctly laid out the situation (i.e. change the I/O pin's I-or-O status), but he wants a "lib".
  • FranklinFranklin Posts: 4,747
    edited 2011-04-26 08:18
    PJ, I agree if the OP wants help with a lib he should be asking on the arduino forums.
    As to libraries being "Black holes" the source code is part of the library and can be modified at will. (like an object)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-26 11:49
    I agree, intuitively, that the "libs" must be alterable, but the arduina kultur, such as I've observed, is: to copy & paste "libs" and black-box it, accepting that stuff "works" and one needn't trouble himself to know why as it's all been done for you.

    Ergo, the process of changing an I/O pin from an input to an output, or vice versa, necesssary knowledge, is a concept unfamiliar.

    Frickaduina-this "shield" and Frackaduina-that "lib" and buy (buy into) the arduina doin'-mille-nothing.
  • FranklinFranklin Posts: 4,747
    edited 2011-04-26 19:15
    Since we are in the general discussion forum I will continue.
    Ergo, the process of changing an I/O pin from an input to an output, or vice versa, necesssary knowledge, is a concept unfamiliar.
    Not so, that is a top level function and requires no libraries. I remember a joke, A man gets stopped at the airport gate for carrying a chainsaw through the screening. There are two ways for him to respond,
    1) I made a mistake, my wife told me not to bring it.
    2) I'm never flying Delta again!!
    Arduinos are just another type of hardware and can do different things than stamps and propellers in different ways.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-26 19:45
    Franklin, top-level, "lib" level..., who cares?
    Why is an elementary exercise, changing the status of an I/O pin, alien to the OP and, since, a few others who have started subjects hinging on this very "dilemma"?
    It's not me. It's the world of arduina and the sum of the doin'-mille-nada: it "works" cuz, uh, someone else did the work.
    Hey, gotta spare "lib", man?
    :tongue:
  • gelfling6gelfling6 Posts: 60
    edited 2011-04-26 19:47
    I'm also looking for the same info.. The problem with the Arduino platform, is the libraries are still in development, as time goes on.. the Arduino still relies on libraries, not direct code. (I.E. controlling constant rotation servos, instead of pulse-out, sending the code write.servo(#, degrees).. (send a number from 0 to 180, 90 being center) which is computed from degrees to milisecond pulse width sent to the servo.)

    I see a simple method, too, IF the top-level code can be devised, to react on the RSSI to prepare to go into receive mode, then using the RX/TX before going into send mode.
    But..... as of yet, no-one has devised the idea of single-line RX/TX serial, which even the BS1 was capable was able to to assign any pin to digital input, digital output, PWM, serial data (at TTL level) and analog I/O. The Arduino code (so-far,) has specific lines from the ATmel chip, assigned as either digital, analog, or serial Input, and Serial Output. This doesn't mean the code cannot be devised. At the risk of insulting Parallax, even the Basic Stamp's PBasic is NOT the chip's native language. PBASIC is a front-end, which converts the program written into PBASIC to machine code.. Same as the Arduino's AVR front-end, converts the 'C++' derivative into native machine code for the ATmel chips. Welcome to the world of Libraries, Compilers, and development packages. (Am I still on here?)


    No reason to insult one platform, or another.. Granted the Propeller, Basic Stamps, PIC, Arduino are all competing, But they CAN share code & knowledge! Let's not lock things down to MicroChip's level, with the PIC and companies like Innovation-First did with the VEX platform. Let's get a little open source in here.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-26 19:51
    "Open Source" -- can't help you. Someone will develop a "lib" for you, whump you a "shield", or whatever the arduina trip is. Go for it.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-26 22:17
    gelfling6 and UMLstudent,
    The issue is that you're looking for Arduino code to handle the half-duplex serial I/O on a single I/O pin. This is a Parallax forum and is intended for support of Parallax products. We can provide examples for the Parallax microcontrollers and we can explain how the various products work in generic terms, but you, the user, has to take responsibility for the actual coding for the microcontroller you want to use like the Arduino. We can't support this and that microcontroller, each of which does things in a different way. There's neither enough people here on the forums nor is there enough time to become competent or even conversant on all the different microcontrollers. For help with the Arduino coding, you're really dependent on the Arduino forums and their on-line libraries. Sorry.

    gelfling6,
    The Stamps don't compile to PIC or SX instructions. The Stamp Editor compiles into PBasic interpretive code (byte codes). The PIC or SX that's on the Stamp module has an interpreter pre-programmed into the microcontroller chip. Similarly, the Propeller Tool compiles into Spin interpretive code and the Propeller chip has a ROM which contains the Spin interpreter which gets automatically loaded into a cog to start things off once the compiled Spin program is loaded from the EEPROM or attached PC.

    You can't program a Stamp using native PIC or SX instructions. With the Propeller, you can combine Spin with native instructions in a program although the native code has to be loaded into its own cog to execute. Spin code doesn't call assembly code and assembly code can't call Spin code although they can talk to each other through shared (hub) memory.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-28 15:52
    I've attached the schematic for an interface circuit for anyone who's stuck on separate data output and input pins.
    (I don't know why you cannot access your direction register and change it on the fly, please don't explain.)
    It requires, nonetheless, an output pin to control the T/R SEL.
    Maybe somebody will come along with some "new school" IC, something more "elegant" (ralf!), or somesuch, that matters not, but I worked this out on the bench with what I have on hand. I can vouch for it.
    522 x 416 - 83K
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-04-28 18:11
    Ok, I'm confused. From the arduino.cc page:

    pinMode()

    Description

    Configures the specified pin to behave either as an input or an output. See the description of digital pins for details.
    Syntax

    pinMode(pin, mode)
    Parameters

    pin: the number of the pin whose mode you wish to set
    mode: either INPUT or OUTPUT

    This would indicate to me you can change pin directions.......on the fly. It did take about a minute to find this and then I had to read it......difficult concepts.

    {I confess, I've spent time in the House of Arduino by choice.)

    Rick
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-28 19:44
    Nobody else has managed that, fascinating.
    Well, I guess you'll have to re-write the "virtual wire" for this specific case before any of your fellows catch on. But, please, post that in the arduina forum.

    PE - Do them up a "lib", or whatever. Hey, I don't own this joint, make an attachment, it's support for a Parallax product, I shouldn't care.
  • leothornleothorn Posts: 8
    edited 2013-05-31 07:02
    Hi,
    Hate grave digging posts but im desperate. I am using the BOE edcational shield for arduino and the 27982. I need a pair of these to communicate. Now even the shield has port 0 for rx and port 1 for tx . I dont want to damage my rf module so I ask if i still need to add the additional circuitry you guys suggested above ?

    Or will just the software part of shifting ping mode between rx and tx work ?


    /leo
  • Mike GreenMike Green Posts: 23,101
    edited 2013-05-31 07:26
    @leothorn - Your choice. You can add hardware that converts a Tx/Rx and direction line to a Tx/Rx pair or you can manage the Arduino I/O pins with software. If you do it in software, put a 4.7K or 10K resistor in series between the 27982 lines and the Arduino I/O pins. This will protect both against mistakes where both are working as outputs, but with opposite polarities (one high and one low).

    Again, we cannot help you with the Arduino programming or interpreting the many I/O libraries for the Arduino. The 27982 works with the Stamps and with the Propeller and there is sample code available for the Stamps.
  • leothornleothorn Posts: 8
    edited 2013-05-31 07:33
    @ Mike :- Any specific reason why The ports 0 is designated Rx and 1 is designated Tx on Boe Shield >>>and the arduino uno . Cant I use the other ports ? if im doing software switching between input output mode ?

    ( And thanks for the prompt reply)
  • Mike GreenMike Green Posts: 23,101
    edited 2013-05-31 07:54
    If you look at the schematic for the Arduino boards, pins 0 and 1 are connected to the built-in USB to serial adapter (and hence to the PC). There are 1K series resistors in these leads, so you can probably use them for some other purpose. I'd suggest using some other I/O pins for connecting to the 27982. Note that the serial library routines might override the I/O pin direction set by the pinMode library routine. You'd have to look at the source code of the serial library.
  • leothornleothorn Posts: 8
    edited 2013-06-12 02:00
    @ Mike : thanks mike a need a little more guidance from you. I am putting up this photos i took of the schematic. I just want to be sure I am doing the right thing ( scared of frying it).
    12062013245.jpg
    schematic_arduino_parallax.jpg


    I had a few follow up questions :

    1) I used 4.7k resistors wouldnt going any higher risk introducing noise to the signal between arduino and parallax due to low signal strength ? I not should i use higher resistances ?
    2) I dont intend to use any arduino libraries as there are none for 27982. I prefer converting the BS2 code as i was working on it initially. Any tips on where i should start going about this. As in creating a 1:1 translation of bs2 code to arduino code . for starters the pulsout command. Searching for coe examples im lost . any single post u suggest i start from
    3) When would i want to start bothering with RSSi and PDN pins ?
    320 x 240 - 28K
    640 x 410 - 13K
  • leothornleothorn Posts: 8
    edited 2013-06-12 04:13
    bump for help
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-12 06:28
    DO NOT "BUMP"! It's against forum guidelines (posted under Announcements forum) and strongly "frowned upon".

    1) Your choice. CMOS is voltage-sensitive, not current sensitive, so the main concern is RC delays due to having to charge the capacitances involved (wiring and gates). For short runs (a few inches), 10K or even higher is not unreasonable.
    2) Start with the Basic Stamp Syntax and Reference Manual for definitions of what the various Stamp statements and operators do. For the most part, they're pretty straightforward. You could also look at the BS2_Functions object in the Propeller Object Exchange. This is a library for the Propeller, written in Spin, that implements most of the Basic Stamp statements as subroutine calls. You could use it as a model.
    3) Don't bother unless you're just curious about what they do.
  • leothornleothorn Posts: 8
    edited 2013-06-12 07:18
    @ Mike : Sorry for that
    While i was waiting for your reply , I proceeded to hunt for some help on my own.
    This is my current setup
    12062013246.jpg


    I hope the schematic i attached in the previous post is correct and not faulty!!!
    Now though these forums are for parallax products only ..but you are the only one even bothering to reply to my questions hence i ask it here.

    I came ac-cross this tutorial http://arduino.cc/en/Tutorial/SoftwareSerial which is to see if the RF modules are even communicating.
    Now i adapted this code slightly. Here it is ( i split between transmitter and receiver for a start)

    For Transmitter
    #include <ctype.h>
    #define bit9600Delay 84
    #define halfBit9600Delay 42
    #define bit4800Delay 188
    #define halfBit4800Delay 94
    byte rtselect = 9;
    byte datapin = 8;
    byte SWval;
    void setup() {
    pinMode(rtselect,OUTPUT);
    digitalWrite(rtselect,HIGH); // When rtselect is 0 module is in receive mode . When rtselect is 1 module is in transmit mode.
    digitalWrite(13,HIGH); //turn on debugging LED
    if (rtselect==HIGH)
    {pinMode(datapin,OUTPUT);}
    if(rtselect==LOW)
    {pinMode(datapin,INPUT);}

    SWprint('h'); //debugging hello
    SWprint('i');
    SWprint(10); //carriage return
    }
    void SWprint(int data)
    {
    byte mask;
    //startbit
    digitalWrite(datapin,HIGH);
    delayMicroseconds(bit9600Delay);
    for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
    digitalWrite(datapin,HIGH); // send 1
    }
    else{
    digitalWrite(datapin,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
    }
    //stop bit
    digitalWrite(datapin, HIGH);
    delayMicroseconds(bit9600Delay);
    }
    void loop()
    {

    SWprint(toupper(SWval));
    }

    FOR RECEIVER

    #include <ctype.h>
    #define bit9600Delay 84
    #define halfBit9600Delay 42
    #define bit4800Delay 188
    #define halfBit4800Delay 94
    byte rtselect = 9;
    byte datapin = 8;
    byte SWval;
    void setup() {
    pinMode(rtselect,OUTPUT);
    digitalWrite(rtselect,HIGH); // When rtselect is 0 module is in receive mode . When rtselect is 1 module is in transmit mode.
    digitalWrite(13,HIGH); //turn on debugging LED
    if (rtselect==HIGH)
    {pinMode(datapin,OUTPUT);}
    if(rtselect==LOW)
    {pinMode(datapin,INPUT);}

    SWprint('h'); //debugging hello
    SWprint('i');
    SWprint(10); //carriage return
    }
    void SWprint(int data)
    {
    byte mask;
    //startbit
    digitalWrite(datapin,HIGH);
    delayMicroseconds(bit9600Delay);
    for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
    digitalWrite(datapin,HIGH); // send 1
    }
    else{
    digitalWrite(datapin,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
    }
    //stop bit
    digitalWrite(datapin, HIGH);
    delayMicroseconds(bit9600Delay);
    }
    void loop()
    {

    SWprint(toupper(SWval));
    }

    Observation 1 ) Based on what I read for the parallax datasheet : A constant HIGH is used to synchronize,two RF modules which I changed ( in the tutorial if was Low)

    Observation 2 ) I made it difficult to alter between transmit and receive the module as a safety precaution.

    Ideally I should be getting an output on my computer console as the receiving boebot is connected to my system . I know its too much to hope , but well it didnt .
    Could you tell me where I could be going wrong ?

    Thank you : I will be sure to acknowledge you in my maters thesis :)
    640 x 480 - 65K
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-12 07:35
    A brief HIGH is indeed used to synchronize the two modules. HIGH turns on the transmitter and this pulse allows the AGC (automatic gain control) in the receiver to adjust to the level of the received signal so that it can tell better what's LOW and what's HIGH.

    I can't help you with the debugging of your Arduino code. Sorry.

    The schematic looks ok.
  • leothornleothorn Posts: 8
    edited 2013-06-12 07:49
    Is there an extended datasheet for to know the length of the pulses i have to give in order to bring the module to life ( Does it have some kind of led like the ping sensor does ?)

    Or do i need to refer directly to TRM 433LT datasheets for that info. If so will it be directly applicable to our module.
    As for the code im not asking for debug . Im just asking if i am going on the right path in terms of choosing the library.
    Tyvm.
    /leo
Sign In or Register to comment.