Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems with hysteresis as soon the ADC reaches 255

Status
Not open for further replies.

msmax

Full Member level 1
Full Member level 1
Joined
May 6, 2001
Messages
99
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Pays Bas
Visit site
Activity points
919
Need help with PIC asm

Please give your advise on next problem:

I read in an analogue value.
I like to switch 4 outputs on predefined levels.

Problem is that the output is blinking very fast as soon as the ADC reaches the prefined levels before it goes on steady. I think some hysteresis must be added here to solve this problem.

How would you program this in assembler?
 

Re: Need help with PIC asm

My answer to your problem here:
**broken link removed**

should also help you with your new problem which is nearly the same ...

best regards
 

Re: Need help with PIC asm

That looks stupid.

I already asked this question...
Had to ask the next:

It works as you described.
I do get some problems with this hysteresis as soon the ADC reaches 255, then it will go to 0+.

Same happens if the ADC reaches 0 and I do this comparision.

Sorry...
 

Re: Need help with PIC asm

Ok what PIC are you using (8 Bit ADC or 10 Bit ADC)?

Can you post your current code?

best regards
 

Re: Need help with PIC asm

I use a PIC16F628 with ADC0831.

Here is part of my code:

MOVFW Alarm1
ADDLW Hysteresis
SUBWF ADCresult,W
SKPNC
BSF A1_Out

MOVFW ADCresult
ADDLW Hysteresis
SUBWF Alarm1,W
SKPNC
BCF A1_Out

Hysteresis is a constant = 1
Alarm1 is a var
ADCResult is the last read ADC value.

The ADC input value will go from 0-255 or vv.
The output should be ON if ADCresult>Alarm1
It should be OFF if ADCresult<Alarm1

Problem starts if Alarm1 is 255 or ADCresult is 255.
How to handle this?

The full unit should work as following:
We have 4 outputs: OC, BB, A1, A2
We have 5 vars: vOC,vBB,vA1,vA2,vSC

If ADC < vOC then all is off: OC status
If ADC < vBB then BB&OC is ON, others off: BB status
If ADC > vOC and ADC<vSC then OC is ON, all other OFF: Normal status
If ADC > vA1 and ADC<vSC then OC & A1 is ON, others OFF: A1 status
If ADC > A2 and ADC<vSC then OC&A1&A2 is ON, BB is OFF: A2 status
If ADC > vSC then all is OFF: SC status, same as OC status

Hope this makes clear what I like to do with this system.
Thanks for your help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top