Shop OBEX P1 Docs P2 Docs Learn Events
Reading voltage and using it to answer IF/THEN statments — Parallax Forums

Reading voltage and using it to answer IF/THEN statments

JPHJPH Posts: 13
edited 2009-05-17 04:48 in General Discussion
Ok first off I would like to thank everyone in advance for their time and help. Novice doesn’t even start to explain my level of understanding and knowledge of microcontrollers….

I have a relatively simple problem I need to overcome. Below I will outline a basic idea of what I need to have happen and an idea of how I think I can make it happen.

What I am requesting help on is what components do I need and how can they be combined to solve this problem. Also if there is an easier way to go about this I am open to any and all ideas.

Lastly I did some basic searching on the forum but I really don’t have the vocabulary to do a proper search, there very well may be an answer to my questions on here and if so please point me in the right direction…

Thank-you,
James


Problem:

Input 01: IF voltage is greater than 0.5vdc then make output pin HIGH (5vdc)
Input 02: IF voltage is greater than 1.0vdc then make output pin HIGH (5vdc)
Input 03: IF voltage is greater than 1.5vdc then make output pin HIGH (5vdc)
(The following inputs have the same IF/THEN question so I will only list the cutoff voltage)
Input 04: 2.0
Input 05: 2.5
Input 06: 3.0
Input 07: 3.5
Input 08: 4.0
Input 09: 4.5
Input 10: 5.0
Input 11: 9.0
Input 12: 12.0
Input 13: 24.0

The output pin (in the case of the SX28AC/DP-G I/O #20) will be connected to a relay I also have some very basic statements using some of the other I/Os to control some LEDs so if any solution you offer use a large number of I/Os this my or may not be a problem…



My first thought:
My first thought is that the key to this is interfacing between an ADC0831 8-bit A/D converter DIP and an SX28AC/DP-G…

Like I said before I have only worked a bit with the BS2 so I really don’t know where to start, if it wasn’t for the fact that I will have to make a run of 20 of these right off the bat and possibly hundreds latter down the line I would just building it on the more expensive BS2.

Any and all help will be appreciated,
James

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2009-04-30 23:10
    JPH

    A V.C.O. might be a better approach for Your 0 - 24 volt reading. Buy reading just Freq. from the VFO it would use only one I/O pin as well.

    You'll have to find a VCO with a TTL level output of coarse.

    With a 0 volt "VCO" freq set at 1kHz and a 24 volt "VCO" Freq set at 5kHz, This would mimic the industry standard "1 to 5 volt"

    I don't recommend using 0 volts with a 0 kHz out for this setup because it lacks "Loop" verification. Its nice to know that the field loop is intact. since anything less then 1kHz would generate an error

    Thier are other was to do this voltage read. I like the simple ways


    _________________$WMc%_________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA

    Post Edited ($WMc%) : 5/10/2009 10:08:47 PM GMT
  • JPHJPH Posts: 13
    edited 2009-04-30 23:19
    This brings up a good point that I failed to point out… On the enclosure there will be a headphone jack style connection for each of the voltage options so that the user can connect this system to anyone of the other interfaces… so unless I get in to displays and user interfaces having a single I/O doesn’t seam like it would work…. But maybe I am thinking inside a box..
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-01 01:39
    JHP

    I thought You were looking for voltage readings. This is what I got from Your first post. I see now that Your trying a form of MULTIPLEXING with the SX28. Since Your using only one headphone jack,I don't see the need to tie up 13 I/O pins.But its Your project, So 13 window comparators, each set a volt higher then the previous, should work.

    I personally would do this with software, But maybe You have found a new way to do this.

    If You could add some code/hardware info, this would help Your post.


    _________________$WMc%________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • JPHJPH Posts: 13
    edited 2009-05-01 15:36
    I will start with a better end application example....

    The user will have a pigtailed line that can be placed on one of 4 different systems (but we see the need to have growth room for other control voltages that is why I have 13 different comparisons) when these systems send a voltage higher than the control or base voltage then we need a relay to trip and activate another system...

    I really hope this helps clear things up. NOTE: End user will not have a technical mind so it needs to be a simple "ok due when you plug it in to the red box set the switch to the red dot, when using the blue system set the switch to the blue dot...."
    ________________________________________________________________________________________________________________________________________

    Ok what if I did this...

    Headphone jack
    > ADC0831 8-bit A/D converter
    > 13 or more position switch
    > I/O pin 1-13 on SX28AC/DP-G

    I may still be thinking inside the box, but to be truthful I don't fully understand your suggestions so I am doing a little Google research today to better understand them...

    Code: I don't know the code yet, I will have to learn the SX assembly language or use a compiler but the logic would look like this....

    Each pin would then have the question

    If (the 8-bit reading converted to a numeric value) is greater than (the control voltage) THEN send OUTPUT pin HIGH

    __________________________________________________________________________________________________________________________________________

    I don't know what a window comparator is so I may change my thinking once I do my homework. Without a doubt I want the easiest and cleanest way to do this, so I am open to all ideas I don't have "a way I want to do this" you will never suggest something that I will argue with based on pride or and existing plan....

    and lastly I can't thank you enough for taking the time to help me.

    James
  • JPHJPH Posts: 13
    edited 2009-05-01 17:58
    AM I MAKING THIS TO HARD???

    Copied from http://www.parallax.com/Store/Microcontrollers/SXChips/tabid/138/ProductID/355/List/1/Default.aspx?SortField=ProductName,ProductName

    "The on-chip functions of the SX28AC/DP-G include a general-purpose 8-bit timer, an analog comparator, watchdog timer, a power-save mode with wakeup capability, a configurable internal oscillator and high-current outputs."

    The key question being the "analog comparator" can I use this organic ability of the chip to do this with nothing but a switch and software?

    Headphone jack
    > 13 or more position switch
    > I/O pin 1-13 on SX28AC/DP-G

    Or in reality because of the 12vdc and 24vdc needs this...

    Headphone jack
    > 13 or more position switch
    > 1-11 to I/O pins 1-11 on SX28AC/DP-G and 12-13 both going to 12vdc and 24vdc relays that will then send I/O pins on the SX28AC/DP-G to 5vdc when selected?
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-02 00:42
    JHP

    The SX28 does have a comparator. But only one, and its limited to 5.25volts MAX input!, This is pins RB0,RB1, and RB2.

    You have Me confused with the 13 pos. switch and 1-11 I/O pins?

    Can You draw out Your schematic in windows "Paint" and then save it as a JPEG and attach it to a post reply?
    This will help Me and others to see what Your after.

    You also spoke of having to write in ASM., Have You tried the·SX-Key v3.23 editor?· It lets You write in SX/B "BASIC"?

    ______P.S._I still think a V.C.O. would work better._____________$WMc%________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA

    Post Edited ($WMc%) : 5/2/2009 6:18:12 PM GMT
  • JPHJPH Posts: 13
    edited 2009-05-02 19:21
    Ok will do, i just got back to the house about an hour ago. Again thanks for the help
  • JPHJPH Posts: 13
    edited 2009-05-02 19:38
    Ok here is my latest idea bases on my limited understanding of the capabilities of these components.

    A little disclaimer my ideas seams like the worse idea i have ever had. My problem is that I just don't know what tools I should use solve this problem... Therefore I am trying to make round things fit in square holes...

    Nonetheless here it is:
    700 x 525 - 36K
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-05 00:30
    JHP

    I kinda see what your after and I have a few ideas. I'll have to think about this a Bit, and see which idea uses the least components.

    ___________$WMc%_________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • JPHJPH Posts: 13
    edited 2009-05-05 01:16
    Thanks
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-05-06 00:06
    Maybe I'm missing something but it seems to me that if you want to detect the incoming voltage reliably you should run it through a divider to limit it to a safe level and then read the voltage with an ADC.
    572 x 282 - 37K
  • JPHJPH Posts: 13
    edited 2009-05-07 15:14
    As I said in my first post that was my first thought, but I am learning different ways to do this everyday...
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-08 02:26
    JPH

    Hang in there.

    I'm really tied up now, But I'll get some free time soon.

    Keep searching these threads and You might find what You need.


    ____I'll be Back___________$WMc%_______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • JPHJPH Posts: 13
    edited 2009-05-08 03:40
    Thank-you so much, no rush, I am just thankful for the help, I have e-mail alerts set up so when you get time to post your ideas I will get a heads up....

    As for the rest of this forum I am looking but haven't found anything yet.... I will keep at it.
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-15 00:40
    JPH

    Did You get Your project going?
    Or do You still need some with it?

    _______$WMc%___

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • JPHJPH Posts: 13
    edited 2009-05-15 17:04
    Yea I still need some help, I haven't found anything worth mentioning. So any ideas you have would be welcome.
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-17 01:24
    JPH

    I think Your Idea of using the ADC0831 is the way to go. Like JonnyMac suggested, A simple voltage divider in front of the input to
    the ADC0831 would do the trick.( reduce 12volts down to 5volt TTL)

    The ADC0831 has some really good resolution, So scaling 12volts down to 5volts shouldn't be a problem.

    A simple 10kpot with a current limiting resister will divide the 12volts down to 5 volts (by adjusting the pot) in Your test setup to the ADC. This could be replaced with simple fixed resisters after You have tweaked the circuit, for a production run.

    I would use another voltage divider for the 24volt signal and use the comparator pins on the SX28.( pins RB.0,RB.1 and RB.2 )

    I would also make sure that all voltage dividers DO NOT exceed 5volts on their outputs before I hooked them to any component!, along with
    5 volt zener diodes in My test bed to help insure I don't ZAP anything.

    I know this might sound complex but its just for the test and setup mode.Once a setup has been debugged the components can greatly be reduced.
    The specs for the ADC0831 can be found on the Parallax home page/store. its a PDF.

    _____________$WMc%__________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • JPHJPH Posts: 13
    edited 2009-05-17 01:34
    Ok things are getting crazy at work and it may be 2-3 weeks before I sit down and start bread-boarding this. If I PM you and post any question I have would that be considered a good way to get in touch with you?
  • $WMc%$WMc% Posts: 1,884
    edited 2009-05-17 02:22
    JHP

    I know the crazy thing at work, just about to start up a 4th boiler, with its own Turbine-Gen. set.

    I know I didn't cover any software in My last post reply, But feel free to PM me.

    I have an old tractor that I'm working on, And charging voltage is something I need to monitor using the SX28.
    I'll use a ADC0831 to read this voltage along with a voltage divider in front of the ADC.

    ____Feel free to PM me_______$WMc%_____

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • pjvpjv Posts: 1,903
    edited 2009-05-17 04:48
    Hi All;

    But why would you use an external A/D when the SX can do this all internally so easily..... that is if I understand the problem correctly..... I think this can all be easily done with some push buttons and a handful of resistors.

    JPH, I think you are making this WAY too hard. But please, to be sure, can you explain in different words exactly what you are trying to accomplish... there is still some guessing going on here on the readers' parts.

    Think outside the box; don't presume certain implementations such as multiple input phone jacks, particular relays etc., unless such are a specific requirement, and then explain why so we can get a better understanding. Describe what needs to be achieved, but not how to implement it.

    I suspect what is required here is bordering on trivial, but we need a better desciption.

    Cheers,

    Peter (pjv)
Sign In or Register to comment.