Reading Resistance....

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Reading Resistance....

Post by Sparkoids »

I want to read the resistance of an three (analogue) potentiometers with a PIC then using a Digital Potentiometers controlled by the SPI bus on that PIC recreate that resistance (doesn't have to be particularly accurate) but done digitally.

Before I go ploughing in does anyone have any code for this type of thing already or any ideas of the best way to proceed please?

Thanks in advance....


James :-}

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times

Re: Reading Resistance....

Post by petesmart »

Hi James,

I have been playing around with digital potentiometers. They are really cool :mrgreen: – microchip sell them.

They can be driven via SPI what I2C, and you can cascade quite a number of them. They come complete with 3 terminals just like a normal potentiometer, I have used values of 5K, 10 K and 100 K

You could use an ADC on the micro to read the voltage on the wiper of your input potentiometer – convert that to a byte - then send that byte value to the (output) digital potentiometer.

Attached is the data sheet url - come back to me if you have any questions

http://www.microchip.com/wwwproducts/De ... e=en010497

http://ww1.microchip.com/downloads/en/d ... 11195c.pdf

good luck

best regards,

Pete
sorry about that Chief!

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times

Re: Reading Resistance....

Post by petesmart »

Hi James,

further to my post (a few minutes ago) I have found a code example for you.

It is a 2 channel ADC to dualchannel Digi pot. I have not used this for a while, not sure if it works on the hardware still, however it simulates okay in V5. Note I originally created this in V4.

Have a play and see how you go.. I think this is possibly what you are after albeit only 2 channels. Adding another channel is relatively simple, have a go yourself, I'm sure you can do it. :wink:

All the best,

Pete
Attachments
dual channel actuator driver.fcf
(21.82 KiB) Downloaded 369 times
sorry about that Chief!

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Reading Resistance....

Post by Sparkoids »

Hi Pete,

Thanks for that fella!

Are the Microchip ones easily cascadable?

The only thing that puts me off is that Analogue Devices make one unit that can be a Log or Lin pot but the Microchip is either or...

Thanks again...


James :-}

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times

Re: Reading Resistance....

Post by petesmart »

Yes they are easily cascadable

On the microchip site there is an application note, which describes in detail how to address multiple devices...

I have not had any experience with AD ... Looked at them briefly, then chose microchip...I can recommend the MCP solution.


Best

Pete
sorry about that Chief!

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Reading Resistance....

Post by Sparkoids »

Hi Pete,

Well your code seems to be exactly what I'm looking for on the channels.

All I need to do it appears is set up two outputs to those digipots and it should be it...

Thank you again - if I have something to start with I find it easy to mess about and hack something together. And then people on this board who are very helpful clean it up for me!

Thanks again....


James :-}

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times

Re: Reading Resistance....

Post by petesmart »

Hi James,

Thanks for the feedback....I used this code to drive a large industrial machine....please be aware that the code needs the appropriate level of error checking if you are going to use it in mission critical situation.

Can you post back your final result/outcome of you project...I am very interested in the end result.

All the best,

Pete
sorry about that Chief!

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Reading Resistance....

Post by Sparkoids »

Hi Pete,

Nothing industrial here!

Thanks for the info - I will let you know how I get on....


Best regards,


James :-}

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: Reading Resistance....

Post by Spanish_dude »

Best way I can think of is using a constant current and measure the voltage with an ADC.

Nicolas

Post Reply