Shop OBEX P1 Docs P2 Docs Learn Events
problem getting value from INA — Parallax Forums

problem getting value from INA

tholbertontholberton Posts: 41
edited 2012-07-25 18:00 in Propeller 1
I wrote this routine, the serial portion works just fine. I'm having problems getting a value from an input pin. I don't think the problem is in the code, but I'll paste it below anyway. On the propeller board I have an input pin connected to ground with a 200 ohm resistor and a another 200 ohm resistor connected to 3.3V that I use to 'turn on' the input pin. On the serial monitor I keep getting 0's. And it's quite annoying.
CON
  _clkmode = xtal1 + pll4x
  _xinfreq = 6_000_000
  
PUB Main
  cognew(@IR,0)
  
Dat
org 0
IR


:initialization
              or        dira,tx
              or        outa,tx
:receive
              waitpne   rx,rx
              mov       time,delay
              add       time,cnt
              waitcnt   time,delay
:getData
              test      ina,dIn wc
        if_c  mov       data,#49
        if_nc mov       data,#48
:readyData                     
              mov       tx_dat,data            'sample first byte of data
              or        tx_dat,#$100           'attach stop bit
              shl       tx_dat,#$1              'shift left to assign start bit
              
              mov       nBits,#10              'total number of bits for serial byte is equal to 10 - send that many
:txLoop           
              ror       tx_dat,#1 wc
              muxc      outa,tx
              djnz      nBits,#:txLoop
              
              jmp       #:getData


dIn           long $0000_8000
tx            long $4000_0000
rx            long $8000_0000
delay         long 120


time          res 1
data          res 1
tx_dat        res 1
nBits         res 1

(edit) -I have tried using smaller resistors on one or the other side, I know 200 across 200 ohms is going to give 1.15V

Comments

  • brianm734brianm734 Posts: 29
    edited 2012-07-25 17:37
    200 Ohms is too low. You will always pull the input to ground. Try a 2000 ohm resistor to ground, and no resistor to 3.3V if your button connects the input pin to 3.3V. The resistor to ground could be anywhere from 2K Ohm to 20K Ohm and it should still work. If the ina pin is set as an input it will have very high input impedance and you don't need to worry about current limiting between your 3.3V connection and the pin on the Propeller.
  • tholbertontholberton Posts: 41
    edited 2012-07-25 17:47
    I've tried 2.7k, still not responding :/
  • brianm734brianm734 Posts: 29
    edited 2012-07-25 17:51
    I'm not a PASM expert, but you are sure your program is expecting a low-to-high transistion on the input pin? Phil Pilgrim would be the guy to ask.
  • tholbertontholberton Posts: 41
    edited 2012-07-25 17:54
    Oh, I didn't know the propeller has input impedance. Do you know what value it is?
  • kuronekokuroneko Posts: 3,623
    edited 2012-07-25 17:58
    @tholberton: FWIW, test ina,dIn wc doesn't do what you think it does. Using ina in the destination slot will access its shadow copy. You want the real input part which means using test dln,ina wc. HTH
  • tholbertontholberton Posts: 41
    edited 2012-07-25 17:59
    OKAY, IT WORKS NOW. Thanks Brian. It worked with 2.7K, I'm not sure why it didn't the first time but it does now. Many thanks!
  • tholbertontholberton Posts: 41
    edited 2012-07-25 18:00
    OHH, that was it. thank you kuroneko, I swear that's like the eighth time you've helped me with a pasm problem. haha
Sign In or Register to comment.