Shop OBEX P1 Docs P2 Docs Learn Events
Sensor magnetico — Parallax Forums

Sensor magnetico

hooktxuhooktxu Posts: 33
edited 2009-06-29 21:15 in Propeller 1
Alguien ha trabajado con algun sensor magnetico o algo parecido junto con el propeller?

Comments

  • hooktxuhooktxu Posts: 33
    edited 2009-06-23 10:33
    I have got this code for a magentic sensor and it doesn´t work.

    CON
    
      _xinfreq = 5_000_000                      
      _clkmode = xtal1 | pll16x
    
    OBJ
    
       serie:"FullDuplexSerialPlus"
       
    PUB inicio
    
      serie.start(-1,30,0,9600)
      
      DirA[noparse][[/noparse]13]:=0 'Patita del sensor magnetico configurada como entrada
      dira[noparse][[/noparse]16]:=1 'LED Verde del sensor magnetico
    
      waitcnt(clkfreq*10 + cnt)
    
      repeat
        if(InA[noparse][[/noparse]13]==0)
          serie.str(String("Entra en IF"))
          waitcnt(12_000_000 + cnt)     
          outa[noparse][[/noparse]16] := 1 ' Enciende el LED (n)
          waitcnt(clkfreq*2 + cnt) 
    
        elseif(InA[noparse][[/noparse]13]==1)
          serie.str(String("Entra en ELSEIF"))
          waitcnt(12_000_000 + cnt) 
          outa[noparse][[/noparse]16] := 0   ' Apaga el LED (n)
          waitcnt(clkfreq*2 + cnt) 
    
      serie.stop 
    
    
    
  • edited 2009-06-23 16:51
    Hooktxu

    The code appears to work correctly (please see attached files code picture).· Even though -1 does work, it's probably better to use serie.start(31, 30, 0, 9600).· That's the only change I made, but it did work either way.· It takes 10 seconds for the serial terminal to start displaying information because of waitcnt(clkfreq*10 + cnt).· Make sure your terminal is set for baud rate = 9600 bps.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • hooktxuhooktxu Posts: 33
    edited 2009-06-25 09:47
    enter the IF condition and elseif without any action. How is it possible?
  • edited 2009-06-29 21:15
    When I started the code, I had P13 connected to 3.3 V. Then, after a few ELSIF messages, I changed the P13 connection to 0 V for the IF messages.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
Sign In or Register to comment.