May 18, 2024, 03:21:06 AM

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.


Two HC-8's and ten inputs

Started by JoshHHA2014, October 13, 2014, 11:20:03 AM

Previous topic - Next topic

JoshHHA2014

Okay, so I have been programming interactive room that have had 8 inputs and 8 outputs on a "Hacked" HC-8, and a "non-hacked" HC-8 controller taking care of 8 other outputs dealing with prop movements and routines.

Is there a way or how would I go about adding some inputs on the "non-hacked" controller that my program will be able to read in order to activate a routine in the room?

Right now all I have been doing with the non-hacked controller is using "hc8_set_digital(addr, ch, state)" and "hc8_digital_select(addr, states,    mask   )" commands to turn outputs on/off.

JonnyMac

Are you connecting to the non-hacked board via the SERIAL link? If yes, then yes. In EFX-TEK mode (SM switch off) and using the SERIAL connection (not DMX), you can requiest the state of the TTL pins on the remote board.
Jon McPhalen
EFX-TEK Hollywood Office

JoshHHA2014

October 13, 2014, 12:26:23 PM #2 Last Edit: October 13, 2014, 12:30:04 PM by JoshHHA2014
What command do I use to request them?

Because its easy requesting the state on the "hacked" controller by using "ttl_bit(Exit_Byp_PB) == 1" commands but how would requesting the non-hacked inputs via ser look like?

Configuration swtich settings
  -- BR = on (38400 baud for HC-8+)
  -- A1 = off high bit of address
  -- A0 = off low bit of address
  -- SM = off (for EFX-TEK serial mode)

JonnyMac

I'm building a new template that will include remote HC-8+ control, remote AP-16+ control (both through the SERIAL header), and allow SD access.

Note that on the master controller (hacked side), the OPTION switches are not used; that only matters when the device is a slave.
Jon McPhalen
EFX-TEK Hollywood Office

JoshHHA2014

Quote from: JonnyMac on October 13, 2014, 12:32:11 PM
I'm building a new template that will include remote HC-8+ control, remote AP-16+ control (both through the SERIAL header), and allow SD access.

Note that on the master controller (hacked side), the OPTION switches are not used; that only matters when the device is a slave.

Yes true, that is the sittings on the slave HC-8 controller

JoshHHA2014

I already have the program template that works with the master and slave HC-8 controllers, just need to know what program command will make a program check state of an input on the slave HC-8.
Once I know that command it should be rather simple for me to get this interactive room I'm working on running and ready to have interactions.

JonnyMac

I don't know that your original template included the "I" command for reading remote inputs from another HC-8+ -- this is what I would suggest for that.

pub hc8_inputs(addr)

'' Read ttl inputs from remote HC-8+ at address

  efx.str(string("!HC8"))
  efx.tx(addr)
  efx.tx("I")
  efx.rxflush

  return (efx.rxtime(25) #> 0)



Please keep in mind that the official documentation for the HC-8+ should be printed and on your desk when you're writing custom code.  Here's the link:

-- http://www.efx-tek.com/downloads/hc-8_docs.pdf

See the section on serial protocol. The examples are for the Prop-1, but detailed enough to allow programmers to port to other languages.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

October 13, 2014, 07:53:55 PM #7 Last Edit: October 14, 2014, 02:21:48 AM by bsnut
Jon,

When I wrote the base program for Josh, it was based from this one hc-8_auto_digins - Archive [Date 2012.04.01 Time 11.25].zip  from this topic http://www.efx-tek.com/php/smf/index.php?topic=1859.msg11019#msg11019. But, the file is called hc-8_adv_template.spin

Josh,

I will send you a updated version of your program later on tonight/early morning with what Jon did for me in this topic http://www.efx-tek.com/php/smf/index.php?topic=2013.msg12119#msg12119 using this hc-8+_sio_template - Archive [Date 2013.01.30 Time 08.48].zip   
William Stefan
The Basic Stamp Nut

bsnut

Quote from: JonnyMac on October 13, 2014, 12:32:11 PM
I'm building a new template that will include remote HC-8+ control, remote AP-16+ control (both through the SERIAL header), and allow SD access.

Note that on the master controller (hacked side), the OPTION switches are not used; that only matters when the device is a slave.

Will this template have the auto scanned TTL inputs?
William Stefan
The Basic Stamp Nut

JoshHHA2014

Okay, so I added this "I" command for reading inputs from the "Non Hacked" HC-8


Quote from: JonnyMac on October 13, 2014, 05:02:55 PM
pub hc8_inputs(addr)

'' Read ttl inputs from remote HC-8+ at address

  efx.str(string("!HC8"))
  efx.tx(addr)
  efx.tx("I")
  efx.rxflush

  return (efx.rxtime(25) #> 0)


Using this command to read input 0 which is trap button 5 input to set off its show.

'     TRAP 5     

      if hc8_inputs(%00000001) == 1 and outb[t5pb] == 1
        outb[t5pb] := 0
        low(Trap_LEDs)
        hc8_set_digital(%00,  4,    1)
        pause(1000)
        high(Trap_LEDs)
        hc8_set_digital(%00,  4,    0)


Quote from: JonnyMac on October 13, 2014, 05:02:55 PM
Please keep in mind that the official documentation for the HC-8+ should be printed and on your desk when you're writing custom code.  Here's the link:

-- http://www.efx-tek.com/downloads/hc-8_docs.pdf

See the section on serial protocol. The examples are for the Prop-1, but detailed enough to allow programmers to port to other languages.

I have the pdf printed in front of me always when creating new events and shows plus using references in help tab of propeller tool. But, this command address isn't working and would like to know propper format to use when reading status of input on other controller.

JonnyMac

I know you're in a hurry, so I'll tell you about a little plaque my grandmother used to have in her kitchen:

The hurrier I go, the behinder I get!

There's an important message in that down-home, Southern humor: take your time.

Did you write a test program to verify that method works? If not, why not? As I told you, all of my HC-8s are on loan save one, so I cannot, at the moment, do any HC-8 to HC-8 testing.

I suggest you setup a little test loop polls and and displays the remote TTL inputs. Once you have that working, only then should you deploy the code in an operational program.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Josh,

I have saw your email and noticed that you are not calling this method correctly.


pub hc8_inputs(addr)

'' Read ttl inputs from remote HC-8+ at address

  efx.str(string("!HC8"))
  efx.tx(addr)
  efx.tx("I")
  efx.rxflush

  return (efx.rxtime(25) #> 0)

This "addr" means the address of the slave HC-8+. So you're code needs to look like this.

'     TRAP 5     

      if hc8_inputs(%00) == %00000001 and outb[t5pb] == 1
        outb[t5pb] := 0
        low(Trap_LEDs)
        pause(100)          'give the slave hc-8 receive the command from host hc-8
        hc8_set_digital(%00,  4,    1)
        pause(1000)
        high(Trap_LEDs)
        hc8_set_digital(%00,  4,    0)

As, Jon stated test it to see if it works. I will test it my end later on.   
William Stefan
The Basic Stamp Nut

bsnut

October 23, 2014, 01:10:18 AM #12 Last Edit: October 26, 2014, 01:55:03 AM by bsnut
Josh,

I tested this method a few minutes ago

pub hc8_inputs(addr)

'' Read ttl inputs from remote HC-8+ at address

  efx.str(string("!HC8"))
  efx.tx(addr)
  efx.tx("I")
  efx.rxflush

  return (efx.rxtime(25) #> 0)

using this test code and it works (Test code is attached). In the test code, the hacked HC-8+ is looking at TTL input 0 and the non-hacked HC-8+ (remote) is reading TTL input 0. 

  repeat
    if ttl_bit(0) == 1      '   
      hc8_set_digital(%00, 4, 1)
    else
      hc8_set_digital(%00, 4, 0)

    if hc8_inputs(%00) == %00000001   
      high(OUT3)
    else
      low(OUT3) 

    pause(100)                        ' run loop every 100ms

The I/O matches an older setup that you provided me and you will need to make it match the current I/O that you have.

One thing that you need to remember is, when you are wanting the remote HC-8+ outputs to do something you can't have the hacked HC-8+ reading the remote TTL inputs. And the same goes for the other way around. This is do due the bi-directional coms that is being used between the hacked HC-8+ and the non-hacked "remote"
William Stefan
The Basic Stamp Nut

bsnut

I also came up with this method

pub hc8_inputs_bit(addr, bit) | remotettlbit

'' Returns 1 or 0 status of the remote HC-8 TTL bits
'' "addr" is the address of the remote HC-8 
'' "bit" is the remote TTL bit. Valid bits are 0 to 7


  com1.str(string("!HC8"))
  com1.tx(addr)
  com1.tx("I")
  com1.rxflush
  remotettlbit := com1.rxtime(25)

  if ((bit => 0) and (bit =< 7))                             ' valid bit?
    return (remotettlbit & (1 << bit)) >> bit                ' extract bit
  else
    return 0

for looking at a single TTL input pin on the remote HC-8+, which saves you from typing this out like this

if hc8_inputs(%00) == %00000001

to look at TTL input 0. When you can do this instead to look at remote TTL input 0

if hc8_inputs_bit(%00, 1)

William Stefan
The Basic Stamp Nut

JonnyMac

William,

You can simplify this line:

  return (remotettlbit & (1 << bit)) >> bit

to:

  return (remotettlbit >> bit) & 1

Jon McPhalen
EFX-TEK Hollywood Office