Shop OBEX P1 Docs P2 Docs Learn Events
Voltage Comparitor — Parallax Forums

Voltage Comparitor

John WhitfieldJohn Whitfield Posts: 42
edited 2005-09-19 16:24 in General Discussion
I am designing a lightmeter using the comparitor on rb and since I'm using rb as my com port already since I am using the core of my old multimeter program. I'm not sure if the com port and comparitor and confusing things and that's why it doesn't appear to be·working or if there's something I'm missing in the set up. Anyway here's the code I have now.

Thanks,
-John Whitfield

Comments

  • PJMontyPJMonty Posts: 983
    edited 2005-09-19 16:24
    John,

    Without spending too much time with your code, there's always a chance that you are stomping on a seting or an input or output value by using a single port for more than one function. There's nothing wrong with using a port for more than one functin, it's just that you run the risk of making a mistake. In your case, since you have for more port pins than you are using, just separate things. This is the whole point of using named constants in your code (which you do already) instead of hard coding things in the source body.

    In your case I would just make a small change, so this:

    ComPort           = rb
    lightread      = Comport.0
    photores      = Comport.1
    setvolt          = Comport.2
    TxPin2            = ComPort.3 ; ----------------------+|||  Input to speakjet
    



    ...becomes...

    ComPort           = ra
    LightPort        = rb
    lightread      = Lightport.0
    photores      = Lightport.1
    setvolt          = Lightport.2
    TxPin2            = ComPort.3 ; ----------------------+|||  Input to speakjet
    



    And, voila', you have now moved the serial communications from port b to port a, and you have separated the two functions onto different ports.
      Thanks, PeterM
Sign In or Register to comment.