November 24, 2024, 12:37:53 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Peer to Peer RS485

Started by bsnut, September 05, 2012, 07:57:16 AM

Previous topic - Next topic

bsnut

I was trying to do some RS485 coms with my two HC-8+'s but, with no luck. I know the following spin code under "PUB Main" method is wrong in some way and need to be pointed in the right direction so I can get it to work.

obj

  term  : "fullduplexserial64"
  rs485 : "fullduplexserial64"

var

  long outsval
  long insval
 

pub main | t

  setup_io                                      ' setup HC-8+ IO pins
  term.start(RX1, TX1, %0000, 115_200)          ' start terminal
  rs485.start(RX2, TX2, %0000, 115_200)

  ' start other cogs here
 
  pause(1)                                      ' let all cogs start

  term.tx(CLS)
  term.str(string("EFX-TEK HC-8+ Programming Template", CR, CR))

  t := cnt                                      ' sync loop timer
  repeat
    outsval := rs485rx
    if outsval == 1
      toggle(OUT0)

    if ttl_bit(0) 
      insval := digins
      rs485tx(insval)   

    waitcnt(t += constant(100 * MS_001))        ' run loop every 100ms


pub rs485rx : rxbyte                'receives data through the RS-485 chip

  set_rs485(RX)
  rxbyte := rs485.rx
  rs485.rxtime(200)


pub rs485tx(txbyte)                 'transmits data through the RS-485 chip

  set_rs485(TX)
  rs485.tx(txbyte)
 

I also attached a pic of my setup
William Stefan
The Basic Stamp Nut

JonnyMac

William,

I've been under the weather and am dealing with a friend's wedding, too. Working on a really clean solution for you and all (RS-485 object).  Will post project files ASAP.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

That's OK Jon and understand. I was reading November 1999 Nuts and Volts Column,  by Lon Glazner
Stamp Net Part 1 – A Multi-drop Stamp-based Network to get some ideas on RS485 and be happy to see your RS485 object. 
William Stefan
The Basic Stamp Nut