Shop OBEX P1 Docs P2 Docs Learn Events
QTI problem — Parallax Forums

QTI problem

HoffaHoffa Posts: 46
edited 2008-01-09 07:02 in Propeller 1
Hi

I´m trying to translate my bs2 QTI program to Propeller, but it won´t work. Someone have any idea what I´m doing wrong?

BS2:
qtiLeft VAR Bit
qtiCenter VAR Bit
qtiRight VAR Bit
DO
HIGH 5: PAUSE 1: qtiRight = IN3: INPUT 5
HIGH 6: PAUSE 1: qtiCenter = IN3: INPUT 6
HIGH 7: PAUSE 1: qtiLeft = IN3: INPUT 7
DEBUG HOME, BIN1 qtiLeft, BIN1 qtiCenter, BIN1 qtiRight
PAUSE 100
LOOP




Propeller:
CON
    _clkmode = xtal1 + pll16x                           
    _xinfreq = 5_000_000                              

    inPin = 18
    firstPin = 19
    numPin = 5

OBJ
  clock : "Clock"
  text : "VGA_TextOut" 

PUB start | i, ans
  text.start
  init
  repeat
    repeat i from 1 to numPin  
      outa[noparse][[/noparse]firstPin+i]~~
      clock.PauseMSec(1)
      ans := ina[noparse][[/noparse]firstPin]
      outa[noparse][[/noparse]firstPin+i]~
      text.printNum(ans)
    clock.pausesec(1)
    text.CLS
      
    
PUB init | i
  dira[noparse][[/noparse]firstPin]~ 
  repeat i from 1 to numPin
    dira[noparse][[/noparse]firstPin+i]~~




/Hoffa

Post Edited (Hoffa) : 1/7/2008 10:30:31 AM GMT

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-01-07 20:47
    (a) You INA firstPin.. shouldn't that be rather "inPin"?
    (b) You outenable pins "FirstPin" plus 5 further.. Shouldn't that be 4 further only? Your loop in "init" looks awkward.. You know you can start it with zero, don't you?
    (c) I do not know what BASIC INPUT 5 does... Can it be it sets the port to TriState? If yes, you should modify DIRA rather than OUTA for that...

    Post Edited (deSilva) : 1/7/2008 8:55:31 PM GMT
  • HoffaHoffa Posts: 46
    edited 2008-01-08 18:51
    Now I have rewrited my code a bit. Now I´ll try to connect just 2 QTI:s the same way as in the QTI manual: http://www.parallax.com/Portals/0/Downloads/docs/prod/robo/QTILineFollow.pdf page 4.

    I use this code:
    [b]CON[/b]
        [b]_clkmode[/b] = [b]xtal[/b]1 + [b]pll[/b]16x                           
        [b]_xinfreq[/b] = 5_000_000
    
        inPin = 13
        firstPin = 11
        numPin = 2
    
    [b]OBJ[/b]
      clock : "Clock"
      text : "VGA_TextOut" 
    
    
    [b]PUB[/b] start | ans, i, testPin
      text.start
      [b]dira[/b][noparse][[/noparse]inPin]~
      [b]repeat[/b]
        [b]repeat[/b] i [b]from[/b] 0 to numPin-1
          testPin := firstPin+i
          ans := checkPin (testPin)
          text.printNum(testPin)
          text.printStr([b]string[/b](" : "))
          text.printNumln(ans)
        clock.pauseMsec(200)
        text.CLS
    
    [b]PRI[/b] checkPin (pin) : ans
      [b]dira[/b][noparse][[/noparse]pin]~~
      [b]outa[/b][noparse][[/noparse]pin]~~
      clock.PauseMSec(1)
      ans := [b]ina[/b][noparse][[/noparse]inPin] 
      [b]outa[/b][noparse][[/noparse]pin]~
      [b]dira[/b][noparse][[/noparse]pin]~
      [b]return[/b] ans
    
    
    



    If I try this code but with just one QTI it works fine. But when I use two they interact with each other. When one (or both) sees white both indicates 0, if both sees black both indicates 1.
  • HoffaHoffa Posts: 46
    edited 2008-01-09 07:02
    Is there any other way to connect the QTI:s so they work with propeller?
Sign In or Register to comment.