CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need help with SPI Digital Pot...
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Tom-H-PIC



Joined: 08 Sep 2003
Posts: 105
Location: New Castle, DE

View user's profile Send private message

I think that you need t rethink this some.
PostPosted: Thu Jan 01, 2004 9:00 am     Reply with quote

Hello Iso9001
First off I think that you’re concept on how the original system works is off some.
There is a resistor in the existing system between the 5V and the ADC and then the wire goes out to the keypad as you have in your drawing.
This resistor will limit the current and be the top resistor of a voltage divider network with the ADC in the middle. Then when a key is pushed it will close the connection to a resistor or resistors in the keypad. With one end of the keypad resistor being grounded and the key pushed current will flow in the two resistors. The first resistor being the one in the processor box of you’re drawing and the second one being at the keypad and to ground. With this you now have a change in voltage at the ADC. (Note ADC will only read voltage)
So your biggest concern is for your system to be able to sink (short to ground) a specific amount of voltage at 2mA.
To do that your going to need some type of current amplifier for your pot.
That current amplifier can be a Op-amp or a transistor (2N2222) of some type.

Tom Very Happy
Ttelmah
Guest







PostPosted: Thu Jan 01, 2004 10:25 am     Reply with quote

iso9001 wrote:
Thelmah,

I tried reading over your thing again. I might (prolly) be mistaken, but I think by hooking the pot upto an op.amp like you said I'de be making a sortof DAC... Which isnt what i want to do.

I thought at first that this thing is sending a 5V siganl into a set of resistors and checking the other (ground) wire to see what value comes back. If this were the case, I could use a DAC and just send the imaginally signal (5V, 3.3, 1.0, etc) right into the wire... Not the case though,

The other wire doesnt even return directly to the processor, its chassis ground. So (and I thought this was clever) they ADC thier own wire to save running on wire back to the controller. So unless I totally missed the point of what you are saying (likely) I'm still thinking about the potentio.

Not quite.
The circuit I visualised, would have something like:
Connection to top of a resistor. Bottom of same resistor, connecting via a PNP transistor to GND. from each side of the resistor there would be a connection to an op-amp, forming a voltage subtractor. The output of the subtractor, would be fed to a second op-amp, operating as a comparator, with it's -ve feedback connection from the subtractor, +ve feedback connection from the wiper of the digital pot, and output connection to the base of the transistor.
What happens then, is that the second op-amp, will adjust the voltage fed to the transistor, till the voltage being developed across the resistor, matches this value. This gives an adjustable current sink at the connection pin, controlled by the digital pot. The value developed, will depend on the voltage from the pot, and the value of the 'sense' resistor.

Best Wishes
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 1:35 am     Reply with quote

You guys confuse me very effectively Smile

Quote:
So your biggest concern is for your system to be able to sink (short to ground) a specific amount of voltage at 2mA.


Right. But... I hooked it up to that I'm disregarding the stupid pot being able to handle only 1.0mA and sending the full 2.0mA in, and IT WORKS. I get a little power light to turn on when I set the pot to simulate the ON resistance of the switch.

So my proof on concept works. But all I need to do now is set it up so that the pot is only getting 1.0mA in.

I understand that my picture was a tad off. There should be a resistor inbetween the 5V and the ADC inside the processor.

I have no idea how a transistor can be used to knock the amperage down. This confusing the crap out of me. I need to re-read the last 5 posts.

I'm really bad w/ op.amps and I dont see how one will work here anyway. I'm not creating a wire with 5V, or sending a signal up this wire, I'm just adding resistance to thier wire. If I add a current limited resistor isnt the ADC going to be off? And if So to restate my problem:

I need to add a variable amount of resistance to my signal wire that sends 5V/2.0mA in, but I my pot can only handel 1.0mA.

I'm almost certain you guys have already posted the answer, I just dont understand it. I'l get to rerereading

By the way Ttelmah: You mentioned that these things become nonlinear when you supply vdd equall to whatever is driving it. Does this mean that the pot w/ 5V vdd is going to be nonlinear when I hook my 5V wire upto B or does it have to do with the 5V pic voltage? I ask because I notice that indeed my pot is acting like its a nonlinear device, the lower resistances are close to what I tell them to be in code, but the higher resistances are VERY off from what I tell them to be in code. How do I fix this and still be able to output resistances on a 5V line? Is it just the vdd I need to knock down? ... I could eventually figure out the nonlinear numbers I need, but linear requires a lot less guess work.
Ttelmah
Guest







PostPosted: Fri Jan 02, 2004 3:10 am     Reply with quote

iso9001 wrote:
You guys confuse me very effectively Smile

Quote:
So your biggest concern is for your system to be able to sink (short to ground) a specific amount of voltage at 2mA.


Right. But... I hooked it up to that I'm disregarding the stupid pot being able to handle only 1.0mA and sending the full 2.0mA in, and IT WORKS. I get a little power light to turn on when I set the pot to simulate the ON resistance of the switch.

So my proof on concept works. But all I need to do now is set it up so that the pot is only getting 1.0mA in.

I understand that my picture was a tad off. There should be a resistor inbetween the 5V and the ADC inside the processor.

I have no idea how a transistor can be used to knock the amperage down. This confusing the crap out of me. I need to re-read the last 5 posts.

I'm really bad w/ op.amps and I dont see how one will work here anyway. I'm not creating a wire with 5V, or sending a signal up this wire, I'm just adding resistance to thier wire. If I add a current limited resistor isnt the ADC going to be off? And if So to restate my problem:

I need to add a variable amount of resistance to my signal wire that sends 5V/2.0mA in, but I my pot can only handel 1.0mA.

I'm almost certain you guys have already posted the answer, I just dont understand it. I'l get to rerereading

By the way Ttelmah: You mentioned that these things become nonlinear when you supply vdd equall to whatever is driving it. Does this mean that the pot w/ 5V vdd is going to be nonlinear when I hook my 5V wire upto B or does it have to do with the 5V pic voltage? I ask because I notice that indeed my pot is acting like its a nonlinear device, the lower resistances are close to what I tell them to be in code, but the higher resistances are VERY off from what I tell them to be in code. How do I fix this and still be able to output resistances on a 5V line? Is it just the vdd I need to knock down? ... I could eventually figure out the nonlinear numbers I need, but linear requires a lot less guess work.

The pot, has a series of built in resistors, and FET switches, that connect the output to these resistors. The resistance of these switches changes according to how far 'away' from the supply voltage the connection is. At very low currents, it doesn't cause much effect, but if you start drawing a current near to the pots rating, the effect of the switch resistance, is to make the pot behave as if it has an extra 'series' resistor on the wiper, whose value gets larger as you get close to the supply rail...
If you post an email address, I'll send you a rough sketch of the adjustable current sink.

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 02, 2004 10:09 am     Reply with quote

It is possible to remove the internal resistor? If so, then your task will be quite easy to accomplish. You should only need the spi pot. All you need to do is measure the voltage when each switch is pressed. Now if you connect the wiper of the pot to the adc without any of the resistors (including the internal one) you will be able to generate the voltage from the pot. To do this, you will need to connect A to 5V and B to Ground. The internal resistor of the ADC is high enough that you do not have to worry about any current limiting resistors. You might need to use a unity gain amplifier (op-amp) as RJ suggested if the ADC requires a lower source impedance.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 12:18 pm     Reply with quote

Ttelmah: I'm still working on getting my brain around your words... Hang in there, I'm slow, but I'll get it eventually.

Mark: Yea, I know, if I could get to the original system this would be easy, problem is, its a sealed system. Just wires going in and wires coming out.

I'm tryin to understand the part about the op amp, but I dont really get what is going on there. I need to take thier signal and apply resistance to it, but isnt hooking an op.amp up to my pot going to 'output' a voltage signal ?

I figured out some numbers and got it working, and thus far my pot has lasted at 2.mA bashing (sometimes upto 2.4)... I just cant understand how to cut amperage out, add a specific resistance but do it at 1.0mA then get that back into 2mA and all add up right as if it was 2mA all along.

Arg... I cant even formulate a question that is correctly good. I figured out that my origianl resistors (switches) were ~ from .4k to 2k, but that was in a 2mA system, so my pot values should be around .8k to 4k at 1mA. If I add a resistor to cut the amperage down I'm looking at a 4.7k value just to do that... that will throw everything off I'm sure.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 2:26 pm     Reply with quote

Is there some device I can send in say 3V and then it will create a draw on the other side of it at that same amount (like -3V?)

Like really what i need is a way to sink a specific amount of power so that I can manipulate the voltage on a line...

I figured a digital pot would be a good way to do this, but maybe no ?
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 2:50 pm     Reply with quote

Hmmmm.. Is that what the - poll of the opamp Ttelmah was talking about is doing ??

OpAmps kind of confuse me, I have some here... looks like i have a LM386 (log), a TL082 (Dual biFet) and a LM324 (Quad high gain opamp).

But I dont understand how to set this up to make it buffer the power coming into the pot... I'm going to read (AGAIN) the posts here...

Thanks to everyone thats been answering my questions, I really appreciate it!

EDIT: I thought of somthing.... It looks as if the wiper is the only thing I need to worry about the 1mA limit.... Well, right now I think I've got the wiper hooked up to the systems ground and B hooked up to my signal wire.

What if instead of grounding W directly, I put a limiting resistor there (i can make a picture if needed). I am pretty sure this will stop 2mA from being drawn (thats a good thing)... But...

1. Would that prevent 1mA from being drawn out of W or just prevent more then 1mA from grounding... oh wait, isnt that the same thing?

2. Would putting a resistor on W mess up the resistance on the signal wire that is connected to B ? (ie: travel back into the pot, up B and add with whatever resistance is already on the circuit)... below is a very poor representation of what i'm thinking of

5V signal wire
|
|
-=B=-
pot (making 5k)
-=W=-
|
4.7k resistor
|
=

ie: Will the signal wire be 5k resistance or 9.7k ?
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 3:09 pm     Reply with quote

Nevermind that....

Any resistance added to W is also added to B. That makes sense really, putting a resistor between W and ground would be the same as adding it between my signal wire and B.

Back to the opamp stuff....

It doesnt make sense that there is no way to add a specific amount of resistance to a 2mA 5V wire.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

Re: I think that you need t rethink this some.
PostPosted: Fri Jan 02, 2004 3:24 pm     Reply with quote

Tom-H-PIC wrote:

So your biggest concern is for your system to be able to sink (short to ground) a specific amount of voltage at 2mA.
To do that your going to need some type of current amplifier for your pot.
That current amplifier can be a Op-amp or a transistor (2N2222) of some type.

Tom Very Happy


Almost... I'm not making a signal and sending it up to the processor. I'm taking a signal they are sending out an adding resistance. So I cant make a signal at 1mA, send it into the pot get the right resistance, amp it up to 2mA and then send that off. I need to get thier 2mA signal into my pot as a 1mA, but not using resistors cause it will mess up the signal the processors ADC reads (i think it will anyway)...
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jan 02, 2004 4:06 pm     Reply with quote

Ok, after my fifth or six read on this thread I think I finally understand whats being suggested... But not really.


Ttelmah Said:
Quote:
Connection to top of a resistor. Bottom of same resistor, connecting via a PNP transistor to GND. from each side of the resistor there would be a connection to an op-amp, forming a voltage subtractor. The output of the subtractor, would be fed to a second op-amp, operating as a comparator, with it's -ve feedback connection from the subtractor, +ve feedback connection from the wiper of the digital pot, and output connection to the base of the transistor.
What happens then, is that the second op-amp, will adjust the voltage fed to the transistor, till the voltage being developed across the resistor, matches this value. This gives an adjustable current sink at the connection pin, controlled by the digital pot. The value developed, will depend on the voltage from the pot, and the value of the 'sense' resistor.


I cant really follow this... I'm still quite new at this stuff but... I like the words "voltage subtractor", "adjustable current sink", and "controlled by the digital pot"... I just dont understand the rest Smile

I'm trying though... I like the idea of a voltage subtractor... That makes sense to me. And if I had one of those the amping the signal back up to 2mA makes sense too. I see how that could work... But not what to do to make that work, since my knowledge of opamps is really limited. I think I need to see a picture...
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 02, 2004 7:31 pm     Reply with quote

I think you are getting hung up on the 2ma thing. What you need to concern youself with is the voltage that the adc will see. Different voltages represent different switches being pressed. The different voltages are created by passing current through the internal resistor. Different currents cause different voltages. The old system accomplished this by connecting different resistor values to ground. These different resistor values caused different currents which generated different voltages. Now you can simulate this by using a current sinker. The voltage at the adc can be feed back to an op amp. The output of an op amp can be used to control the base of a transistor. The reference voltage can be created from the pot. I believe this is what RJ is suggesting to you. We use a similar circuit to control electronic dimming ballasts. Although the transitor is an NPN type. We generate the reference voltage by creating a PWM and passing that through a filter. The pot will make it much simpler. RJ has offered to give you a sketch if you post him an email. I would take him up on the offer if all this sounds Greek to you. You can probably search the net and find some info also.
Ttelmah
Guest







PostPosted: Sat Jan 03, 2004 3:15 am     Reply with quote

iso9001 wrote:
Ok, after my fifth or six read on this thread I think I finally understand whats being suggested... But not really.


Ttelmah Said:
Quote:
Connection to top of a resistor. Bottom of same resistor, connecting via a PNP transistor to GND. from each side of the resistor there would be a connection to an op-amp, forming a voltage subtractor. The output of the subtractor, would be fed to a second op-amp, operating as a comparator, with it's -ve feedback connection from the subtractor, +ve feedback connection from the wiper of the digital pot, and output connection to the base of the transistor.
What happens then, is that the second op-amp, will adjust the voltage fed to the transistor, till the voltage being developed across the resistor, matches this value. This gives an adjustable current sink at the connection pin, controlled by the digital pot. The value developed, will depend on the voltage from the pot, and the value of the 'sense' resistor.


I cant really follow this... I'm still quite new at this stuff but... I like the words "voltage subtractor", "adjustable current sink", and "controlled by the digital pot"... I just dont understand the rest Smile

I'm trying though... I like the idea of a voltage subtractor... That makes sense to me. And if I had one of those the amping the signal back up to 2mA makes sense too. I see how that could work... But not what to do to make that work, since my knowledge of opamps is really limited. I think I need to see a picture...

As I said, give me an email address, and I'll send you a pdf, with a sketch of the circuit.

Best Wishes
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Wed Jan 07, 2004 12:30 am     Reply with quote

Sorry it took me so freakin long!

I've been on the road for a few days.

OK. My email is:

landebu@yahoo.com

I've been thinking about the whole deal and I think my problem is I have no idea what a NPN Transistor is... Whats NPN ?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 07, 2004 6:59 am     Reply with quote

If you have a Radio Shack near you, look at see if they still carry and books by Forrest M. Mims III. He has little circuit diagrams and explains what basic components do. I remember as a kid my mother buying me these and that is what got me started into electronics.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group