- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know I can do it in software with an ADC, etc. but is there a way to do it that produces hardware outputs?
For example, I tried using the Scanning Comparator, with the input voltage connected to all terminals, using "Internal VDAC" with "per channel" voltage thresholds. Theoretically it would then continually scan the input vs the 3 thresholds and output 3 hardware logic signals, one for each case, updating them automatically in hardware.
But it doesn't seem to be able to route this because of the input MUX. It gives a confusing error message:
Cannot use pin PIN(0) as digital HW output when it is connected to an analog HW mux.
If a GPIO pin is connected to an AMuxHW component, its digital input is expected to be used by the matching digital control signal on the AMuxHW component. So this GPIO pin's digital input signal should be reserved for the matching digital control signal on AMuxHW component only.
Actually the pin is not set to anything other than analog input, but I think it's just because it can't connect a single GPIO to multiple MUX inputs.
Any other solutions? The thresholds in this case are 600, 1380, and 1490 mV, so not something I can just generate with VRef components and use separate comparators. Any way to make the Mux accept the single pin input?
Solved! Go to Solution.
- Labels:
-
PSoC 3
-
PSoC 3 Device Programming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
With Scanning Comparator all 3 pins must be connected externally.
The easiest way would be to use an ADC to read input voltage and make a decision. If you have enough resources left, use 3 comparators and 3 DACS to set Vref.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
like so...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
The Scanning Comparator mux approach should work, but each input must be connected to the individual pin.
What scan rate is acceptable for your application?
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BoTa_264741 wrote:
each input must be connected to the individual pin.
There's only one input.
What scan rate is acceptable for your application?
It's not very important. 1 kHz should be plenty.
Actually... Probably the scan rate doesn't matter too much, but it would matter that all outputs get changed at the same time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
With Scanning Comparator all 3 pins must be connected externally.
The easiest way would be to use an ADC to read input voltage and make a decision. If you have enough resources left, use 3 comparators and 3 DACS to set Vref.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
Only one input that can be wired to three other PSoC pins.
About the error the component throws: I cannot see any reason why the component couldn't allow for internal analog routing. Does anyone monitoring this discussion know of a reason for this restriction?
There is another solution, someone could re-write the component validation logic to allow for internal analog connections.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
Here's a schematic snip of the circuit /odissey1 is recommending.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
The error you are getting is because the ScanComp component requires that all Analog inputs into the AMux be assigned to only one pin each. This is a component requirement. I don't know why the requirement is there, but that's how they wrote the component validation.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rodolfo,
Will the Voltage Fault Detector component allow for internally routed analog connections to anything other than directly to IO?
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure. Internally it uses the AnalogHwMux. So it depends if there is a possible route for that. In the worst case, you could burn a pin and connect the two pins externally. One pin goes to the Voltage Fault Detector, the other one to the desire analog component.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RodolfoG_11 wrote:
We have a component that does just that.
This seems promising. It essentially works as a comparator on multiple inputs, with possibly multiple thresholds for a single input, right?
I still need to learn about the clock source, settings, etc. but it seems like it could work, and it fits in my project's hardware limitations. (I only have one VDAC left.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
I believe that using FaultDetector faces the same problem, that due to using hardware AMux each input must be connected to an individual pin. Another thing is that FaultDetector parses inputs sequentially, so there is some latency. I believe that it also uses DMA to update VDAC setting, so increasing the speed also eats away DMA resources. You also have to handle correctly the sequence of events when Vinp > V1, V2 and V3.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well I have multiple inputs connected to one pin as in my screenshot and it builds, unlike the scanning comparator, so I think that's ok. I'm not sure about sequence of events, I'll have to think about that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JoBr,
Attached is a project using ADC_SAR to continuously sample a single input and indicate status on the output pins 2, 3 and 4.
Project uses custom version of the ADC_SAR modified with hardware bus output. The output value continuously compared against 3 predefined constant values (which should correspond to requested threshold limits). A registered lookup table selects the highest output. All operations are performed in hardware and processor is not involved. As shown, adc scanning rate is 100kHz, but it can be increased to 1MHz if necessary.
Attached are demo project and custom component library, which should be installed using Project->Dependencies->Add..
The project is untested.
/odissey1