- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I read in the IDAC document. It says IDAC can be used to measure resistance. How do you do that with IDAC? Wouldn't you need ADC too?
I want to read the resistance from a pot. Don't need to know the exact resistance, basically just want to know the position of the pot i.e. low to high. Is there any way to do this with a PSOC 4000 (no analog)?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
I wouldn't use precious resources just to read a trimpot. Add a capacitor to trimpot, so it becomes a RC and connect to a digital pin. Connect capacitor to a second digital pin tied to interrupt. Set first pin HIGH and measure time for interrupt to fire. Use SysTick timer or WDT timer for that.
With some effort a single pin may work (set both to input and output). First charge capacitor (thru R) HIGH, then set it to LOW and wait for interrupt on falling edge to occur. Resistor value can be found from the discharge equation V(t)/Vo = exp(-t/RC). For CMOS, the interrupt should fire at ~0.5Vo, so exp(-t/RC)=0.5.
If you are looking for simple input control, then Rotary Encoder is the simplest way to provide feedback to PSoC. See custom component library for that:
Quad Decoder with Button Switch component for rotary shaft encoders
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may try to give us your test target framework model.
The theory about the resistance test theory is that:
Rx=Vtest/Idac.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know Omh's law. The question is, how do you read Vtest from a PSOC 4000 family MCU, since it doesn't have ADC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
Attach resistor to a comparator (1.024V) and rise IDAC current. When comparator flips, I_idac * R = 1.024V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The previous response is a good idea, depending on the comparator(1.24v) idea, you may try to connect the Pin_1 and Pin_3 together. You can refer to the below schematic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone for your suggestions. Since I'm just trying to read a trimpot, Sounds like all I need is a Comparator.
However, when I look for Comparator for my CY8C4013SXI-410 MCU, all I see is an external Comparator. From the spec, I thought this chip has 1 DAC and 1 Comparator. What am I missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
I wouldn't use precious resources just to read a trimpot. Add a capacitor to trimpot, so it becomes a RC and connect to a digital pin. Connect capacitor to a second digital pin tied to interrupt. Set first pin HIGH and measure time for interrupt to fire. Use SysTick timer or WDT timer for that.
With some effort a single pin may work (set both to input and output). First charge capacitor (thru R) HIGH, then set it to LOW and wait for interrupt on falling edge to occur. Resistor value can be found from the discharge equation V(t)/Vo = exp(-t/RC). For CMOS, the interrupt should fire at ~0.5Vo, so exp(-t/RC)=0.5.
If you are looking for simple input control, then Rotary Encoder is the simplest way to provide feedback to PSoC. See custom component library for that:
Quad Decoder with Button Switch component for rotary shaft encoders
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My precious resource is my pin. I only have 2 left. but if the RC works, I can possibly use the barebone CY8C4013SXI-400 instead! Will give it a shot. Thnx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using 2 pins + 1 pot + 1 cap works fairly well and consistent. Tried 1 pin, but no luck. I tried setting the pin to both input & output, bidirectional but it doesn't seem to work. I wish PSoC has a function that can set a pin to input or output like other mcu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
I got it running with single pin (input+output: (a) resistive pull down, falling edge isr, or (b) resistive pull up, rising edge isr. R=10k, C=0.150u) on PSoC5. Needs some testing. Will research over weekends unless you in a hurry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tried all settings with 1 port. Some settings do result in a number, but it's the same number, no matter where the pot is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim,
On PSoC5 I am getting tunable range (bus clocks) from approx. 50 to (10-20)k depending on settings. There could be some difference with PSoC4. Will work out some PSoC4 demo on weekends. Do you have P4200 or P4100 MCU?
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm working on a P4100: CY8C4013SXI-400
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
Attached is demo project for measuring RC-time on a single pin. It utilizes the system timer (SysTick) to measure elapsed time between pin set and interrupt events. Tested on KIT-044 (PSoC4200M) but should work on P4100 as well. RC-time was measured for both falling and rising edges (see separate project pages). Enable only one project page at a time to avoid error messages. WDT timer is used to poll the pin at about 4Hz (WDT divider 16384), to observe/capture signal on the scope increase polling frequency to ~125Hz (WDT divider ~256). Values of R=10k and C=0.15u used are probably not optimal, but rather what was at hands. I believe that 100k x 0.01u may be better. Terminal output is elapsed time (system cycles and microsecond) in the range from approx 5us to 740us, with resolution of approx. 8-bit. Linearity is not great but usable. Some noise filtering and linearization routine may be needed.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
Attached is another demo project for sampling RC-time on a single pin, which uses different approach. It requires extra resistor (R2), and RC connection now is in parallel. As in previous examples, it utilizes the system timer (SysTick) to measure elapsed time between pin set and falling edge interrupt events. Interrupt threshold of 1.8V gives about 4 times less jitter than CMOS. WDT timer used for polling the pin periodically. Elapsed time varies in range from 3us to 1640us for R1=100k, C1=0.01u and R2=470 ohm, with resolution of approx. 8-bit. Resistor R2 serves as current limiter when pot goes to zero.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow. That's a lot of solutions. I don't really need it to be precise, so I'll try the simplest one. Thanks very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dzuy,
The complexity of all three projects is the same. I would recommend the last one, as it seems to provide better linearity and resolution, and low current draw.
/odissey1