Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing a HAC-UM96 RF modem to a BS2P40 — Parallax Forums

Interfacing a HAC-UM96 RF modem to a BS2P40

JaysonJayson Posts: 10
edited 2007-04-07 21:08 in BASIC Stamp
Hello, I'm a newbie in this stuff and I would like to know how I can interface a HAC-UM96 RF modem from SparkFun, [noparse][[/noparse]url http://www.sparkfun.com/commerce/product_info.php?products_id=155] HAC-UM96 to the BS2P40. I bought a pair, one for the PC and the other for the microcontroller. I've read the datasheet provided in the website. How do I use it for remote control applications? Is it possible?

Comments

  • boeboyboeboy Posts: 301
    edited 2007-01-07 14:47
    Yes, you can. You will need two of the HAC-UM96 and you will need two Basic Stamps (any type will work but the BS1)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lets see what this does... KA BOOM (note to self do not cross red and black)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-07 17:17
    Jayson,

    The unit specifies TTL or serial input so you should be set on the PC end. As for the BASIC Stamp 2p40, you can use any set of I/O pins for TX/RX. It says you simply send the serial data out the TX pin and it appears on the other modules RX pin. Where are you having trouble?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • JaysonJayson Posts: 10
    edited 2007-01-08 15:23
    Thanks guys!

    Well, actually I'm planning to build a remote control based on the two RF modem unit using a PC as a transceiver and the BASIC Stamp 2p40 setup for a transceiver. These are actually what's in my head right now. What would be the best method to be used for the BASIC Stamp to process SENT commands from the PC even if it is running, (this is like an interrupt or something) as I see. I will be making a software using Visual Basic to send the commands, the software side will be easy for me, the problem is how do I get the BASIC Stamp to process the commands I SEND it to? Should I create a sub routine to check the I/O pin for RX occasionally or there is a better way?
  • JaysonJayson Posts: 10
    edited 2007-01-12 15:13
    I'm finished wiring my UM96 with the BS2p40 and this is my setup:

    RXD PIN 0 ---> UM96 COM1 (RXD)
    TXD PIN 1 ---> UM96 COM1 (TXD)

    UM96:
    SGND to GND
    SLEEP is floating
    RESET is HIGH +5V

    All other pins of the UM96 is left floating

    This is the simple program I wrote to transmit a character J. I don't know if it works because I don't know how to connect the other UM96 module to the PC.


    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    TXD PIN 1
    RXD PIN 0

    sData VAR Byte

    Init:
    LOW 2
    PAUSE 100
    GOTO Main
    END


    Main:
    SEROUT TXD, 16624, 1000, [noparse][[/noparse]"J", CR]
    GOSUB Indicator
    GOTO Main
    END

    Indicator:
    AUXIO
    TOGGLE 0
    MAINIO
    RETURN
    END


    Does anybody here knows how to wire the HAC-UM96 to a PC? confused.gif

    How will I be able to communicate with it through the PC? confused.gif
  • JaysonJayson Posts: 10
    edited 2007-01-12 15:20
    boeboy said...

    Yes, you can. You will need two of the HAC-UM96 and you will need two Basic Stamps (any type will work but the BS1)

    Does it really have to be another Basic Stamp? Can I just use my PC as the receiving end? If so, please give me details regarding this.

    Thanks.
  • JaysonJayson Posts: 10
    edited 2007-01-16 11:22
    Ok guys, just managed to make the BS2P40 communicate with the HAC-UM96 RF modem module. The boot string I was waiting for came out after I received an e-mail to another person on a different forum. I managed to do everything as he described even though he was using a different MCU. Here's my simple code to receive the boot string from the UM96 module:

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    ' Project: HAC-UM96 Interface to BS2P40

    BAUDMODE CON 240 ' Set BS2P40 Baudrate to 9600,8,N,1 Not Inverted (TRUE)
    RX PIN 14 ' Receive pin
    TX PIN 15 ' Transmit pin
    RST PIN 13 ' Connect PIN 13 of BS2P to RESET PIN of UM96
    ' via a 470R resistor
    rxData VAR Byte(8) ' Data storage "uM96V11"

    rxData(8) = 0 ' Set the last byte to 0, end of string

    Main:
    DO
    LOW RST ' Make RESET pin LOW
    HIGH RST ' Make RESET pin HIGH
    PAUSE 100 ' just a delay
    SERIN RX, BAUDMODE, 550 ,No_Data, [noparse][[/noparse]STR rxData\7]
    DEBUG "rxData: ", STR rxData, CR
    LOOP
    END

    No_Data:
    DEBUG "Garbage: ", STR rxData,CR
    PAUSE 1000
    RETURN
    END


    Notice the LOW to HIGH transition of the RST pin.

    Special Thanks goes to Wim. burger.gif

    Post Edited (Jayson) : 2/4/2007 4:16:54 PM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-16 13:48
    Jayson -

    FWIW, and if you would like to save a couple of otherwise unused bytes, this allocation, based on the operation of your program:

    rxData VAR Byte(8)

    can be changed to

    rxData VAR Byte(7) ' Assign 7 bytes for input data and 1 EOD byte

    The reason why this is possible is because PBASIC begins the array allocation addrressing with element 0, not element 1. Thus, arrray elements 0 through element 6 represents 7 bytes of RAM. You were allocating 9 bytes of memory for the arrray.

    You may also need to change the following statement, although I'm not sure of its purpose in the program:

    rxData(8) = 0 ' Set the last bit to 0, end of string

    to

    rxData(7) = 0 ' Set the last BYTE to 0, end of string

    If you REALLY want to set just the last BIT to one, you will need to do something like this:

    rxData(7) = rxData(7) & $FE ' Set the last bit to 0, end of string

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-16 16:03
    Bruce,

    A minor correction to your statement…While it is true that the elements of the array are addressed starting at zero, the number used in the definition is implicit. Therefore Jayson’s line:

    rxData VAR Byte(8)

    Does in fact define an 8 byte array as evidenced by looking at the memory map. These locations would be addressed from 0 through 7. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-16 17:50
    Chris -

    Ah but it appears to me he's only reading in SEVEN bytes:

    SERIN RX, BAUDMODE, 550 ,No_Data, [noparse][[/noparse]STR rxData\7]

    As far as I'm aware that will be stored as follows:

    rxData(0), rxData(1), rxData(2), rxData(3), rxData(4), rxData(5), rxData(6)

    the way I understand it <shrug>. My explanation may have been confusing as it was before my first cup of coffee <sigh>.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • JaysonJayson Posts: 10
    edited 2007-02-04 16:11
    Guys,

    Thanks for all the help, however, I still have one problem, although I had the BS2P40 communicate with UM96 module, I can't receive the data coming from the MCU side to the PC side. I was so shocked after I have finished the software that I wrote to communicate with the BS2P40 using the two UM96 modules. Is there a reason why this happens?

    By the way, the other UM96 module is connected directly to the PC with no other BS modules in between. Is there a problem with this?

    All connections are correct, this I verified by making sure that the UM96 module connected to the PC can receive its Boot string using the same software I wrote. This goes same with the UM96 module connected to the BS2p40, the boot string is displayed on a 2x16 Parallel LCD.

    Any suggestions?

    I also admit my mistake regarding the comments on the code, It was past 2:30am as far as I can remember when I saw light. But the idea about that is that, We have an array of 8 bytes to store a 7 byte string length which is the boot string size of the UM96 module which is "uM96V11".

    Although it was an 8 byte array, I have stated to read in the 7 bytes (STR rxData\7) knowing that the last byte is empty or 0 [noparse][[/noparse]rxData(8) = 0].


    Warmest regards and many thanks to everyone,

    Jayson

    Post Edited (Jayson) : 2/4/2007 4:17:45 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-02-04 17:33
    Jayson said...
    I can't receive the data coming from the MCU side to the PC side.
    Look at "Table 1", in the datasheet, it's at the bottom of page 3 and the top of page 4.

    There is a pair of pins for TTL signals/levels (pins 3,4)·and another pair for RS232 signals/levels (pins 6,7.)

    The Stamp should be connected using pins 3,4 (of the HAC.)· The PC (its pins 2,3) should be connected·using pins 6,7 (of the HAC.)
  • JaysonJayson Posts: 10
    edited 2007-02-18 08:20
    My latest update,

    Finally, after a very very long time of figuring out how to make my UM96 modules communicate and work here it is.

    HAC-uM96 module version: uM96V11

    BS2P40 side:
    UM96 TX -- to RX PIN on BS2P40
    UM96 RX -- to TX PIN on BS2P40
    UM96 RST -- to +5V
    UM96 SLEEP -- to GND (This solved the problem) Before, I just had it floating (in other UM96 modules they work fine with the SLEEP lines left OPEN)yeah.gif
    UM96 Vcc -- to +5V
    UM96 GND -- to GND
    UM96 SGND -- to GND

    PC Side:
    UM96 ATxD -- to PC RS232 RX PIN
    UM96 BRxD -- to PC RS232 TX PIN
    UM96 RST -- to +5V
    UM96 SLEEP -- to GND (This solved the problem) Before, I just had it floating (in other UM96 modules they work fine with the SLEEP lines left OPEN)yeah.gif
    UM96 Vcc -- to +5V
    UM96 GND -- to GND
    UM96 SGND -- to GND

    That's just about it. I'm off to working on different experiments with this modules.
  • EvgenijEvgenij Posts: 3
    edited 2007-04-07 21:06
    Hello!
    I am a beginner in microelectronics. I have two HAC-UM12 (same as UM96, only other bauderate). Everything, that I could make is to receive a bootstring on BS2p and on PC-side. Please, give me example how to send data between them...
  • EvgenijEvgenij Posts: 3
    edited 2007-04-07 21:08
    PS:
    I one week work above this problem unsuccessfully [noparse]:([/noparse]
Sign In or Register to comment.