Reading voltage and using it to answer IF/THEN statments
JPH
Posts: 13
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
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
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
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
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
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?
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
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:
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
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
As for the rest of this forum I am looking but haven't found anything yet.... I will keep at it.
Did You get Your project going?
Or do You still need some with it?
_______$WMc%___
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
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
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
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)