Shop OBEX P1 Docs P2 Docs Learn Events
Adc0808 — Parallax Forums

Adc0808

sameiasameia Posts: 7
edited 2010-04-26 17:44 in BASIC Stamp
hi
am programming ADC0808 by basic program and am using ·BS2 chip
I have two analog sensors which give me different voltage 3 and 5
i want to convert·those· sensors to digital
this is my program , i need someone to check and correct the program for me·plzz
>>>>
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM5}
·Addr PIN 5
·SC PIN 3
·ALE PIN 4
·RD PIN 2
·EOC PIN 6

DIRS = %1000000000111111

X VAR Byte
Y VAR Byte

begin:
X =0
Y =0
OUTH =0
DO
LOW Addr
DEBUG "s"

PULSOUT ALE ,5
DEBUG "a"

PULSOUT SC,5
DEBUG "l"

'WAIT FOR END OF Converstion Cycle-Optional
DO
LOOP UNTIL (IN6 = 0)
DO
LOOP UNTIL (IN6 = 1)
·DEBUG "L"
PULSOUT RD,5
X = INH
DEBUG X
SEROUT 0, 84, [noparse][[/noparse]X]
DO
PAUSE 500
X= Y+1
LOOP UNTIL (Y =10)
GOTO begin

DO
SEROUT 0, 84, [noparse][[/noparse]X ]
DEBUG BIN X, CR
X= X+1
PAUSE 500
·LOOP
·' two sensors
· IF ( x>3 ) THEN
· ENDIF
· IF ( y>5 ) THEN
· ENDIF
X =Y+1
LOOP UNTIL (Y= 10)
GOTO Begin
·LOOP
END
in addition am using 555 timer for the clock that is why i didn't included in the program
·

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-04-26 17:04
    It would help if you could tell us why you think this is not working. I'm not where I can run this and I don't have that chip so as much information as you can give helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sameiasameia Posts: 7
    edited 2010-04-26 17:12
    i used debug to know if my program is working until i reach the third step 'WAIT FOR END OF Converstion Cycle-Optional
    it doesnt read the 8 pins, and i dont know how to program the input voltages as you can see my sensors are x and y
  • FranklinFranklin Posts: 4,747
    edited 2010-04-26 17:31
    Try another debug between your two loops testing IN6

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sameiasameia Posts: 7
    edited 2010-04-26 17:44
    I Tried before nothing changed
Sign In or Register to comment.