Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to read OUTA? — Parallax Forums

Is there a way to read OUTA?

TCTC Posts: 1,019
edited 2014-05-16 15:49 in Propeller 1
Hello all,

I am wondering if it is possible to read the state of OUTA of the actual output pin? In the manual it says you can, but that only works if the current COG is controlling the I/O pin. I want to display if a heater is on or not, just an indicator on the display. If the character is on, then the heater is on. If the character is off, then the heater is off.
   IF OUTA[Heater] == 1
     Display.tx($DB)

   ELSE
     Display.tx($20)


Thanks
TC

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-05-16 14:32
    I think you can use ina this way. It should tell you if the pin is high or low. (At least I'm pretty sure almost positive it does.)
  • TCTC Posts: 1,019
    edited 2014-05-16 14:40
    That did it, Thank you so much Duane
  • tonyp12tonyp12 Posts: 1,951
    edited 2014-05-16 14:48
    Only the cog that sets it's own OUTA can read what it have set it to.
    It's not really the actual state of the pin that you read, as DIRA would also have to be set for your cog to affect the pin.

    You can use INA to read the actual electrical pin state, unless there is a short somewhere the state will reflect: if Any Cog have DIRA=1 and OUTA=1 for this pin it will be a 1
    As if any other cog also use the same pin, a high state is ORed
  • TCTC Posts: 1,019
    edited 2014-05-16 14:51
    tonyp12 wrote: »
    Only the cog that sets it's own OUTA can read what it have set it to.
    It's not really the actual state of the pin that you read, as DIRA would also have to be set for your cog to affect the pin.

    You can use INA to read the actual electrical pin state, unless there is a short somewhere the state will reflect: if Any Cog have DIRA=1 and OUTA=1 for this pin it will be a 1
    As if any other cog also use the same pin, a high state is ORed

    The INA works like a charm for what I needed.
        if ina[upper_heater] == 1 AND ina[Lower_Heater] == 1
          Display.tx($CD)
    
        elseif ina[upper_heater] == 1 AND ina[Lower_Heater] == 0
          Display.tx($DF)
    
        elseif ina[Upper_Heater] == 0 AND ina[Lower_Heater] == 1
          Display.tx($DC)
    
        else     
          Display.tx($20)
    

    Thank you
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-05-16 15:07
    Yes, ina[.] always reads the actual state of the pin, whether that be controlled from inside or outside the prop.

    OTOH, X := outa[.] reads the state of the output latch for a particular cog, and that only affects the output if the corresponding dira[.] is set to ouput, and all other output sources (cogs and counters) are permissive.
  • TCTC Posts: 1,019
    edited 2014-05-16 15:49
    Yes, ina[.] always reads the actual state of the pin, whether that be controlled from inside or outside the prop.

    OTOH, X := outa[.] reads the state of the output latch for a particular cog, and that only affects the output if the corresponding dira[.] is set to ouput, and all other output sources (cogs and counters) are permissive.

    That makes sense now, thanks.
Sign In or Register to comment.