Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

pic16f887 adc compare problem

Status
Not open for further replies.

wizardgrt

Junior Member level 1
Joined
Jun 16, 2008
Messages
19
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
Serbia
Activity points
1,433
pic16f887

I'm almost as new in programming pic microcontrollers in assembly language.
What i tried to do in program, is to compare two results of AD conversion, by subtracting previous, from the current result of conversion. If the previous result is greater then the current, diode should be turned off and the program stops, otherwise it's turned on. Measured (input) voltage is from potentiometer 10k. Frequency is at 8 MHz. Problem is that diode is turned off, with no matter if the previous voltage is grater or not. On reset the situation is like it should be before reset, until the resistance is changed. It seems that the CARRY flag is cleared whenever input voltage is beeing changed. Help me please!!!!:cry::|
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
pic 16f887

Hi,

If you have a Pickit or ICD programmer can you run your code on debugger ?

Cannot immediately see an obvious error but btfsc /ss are so easy to mix up.
Note also that the Carry flag is set to 1 if the Sub result is Pos or Zero.

To make things more clear for yourself add in a 1 second delay between each adc call, this little site make delays easy http://www.piclist.com/cgi-bin/delay.exe

For small code examples just post the code with your text, just enclosing it with the 'Code' tags
 

    wizardgrt

    points: 2
    Helpful Answer Positive Rating

wizardgrt

Junior Member level 1
Joined
Jun 16, 2008
Messages
19
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
Serbia
Activity points
1,433
pic16f887 adc

I do have a mikroICD, but it's not supported in MPLAB, and i wrote a program in assembler, since the lack of expirience in programming in higher languages. When i took a closer look, on some segments of potentiometer the diodes just flashed, very shortly... even after reset
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
adin 1pic16f887problem

Hi,

Just might be worth posting your circuit diagram - you might have something set up incorrectly.

Are you running the circuit in a mikroe easypic board or a separate breadboard etc ?
 

    wizardgrt

    points: 2
    Helpful Answer Positive Rating

wizardgrt

Junior Member level 1
Joined
Jun 16, 2008
Messages
19
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
Serbia
Activity points
1,433
16f887 adc problem

I'm running the circuit in mikroe easypic board, but it seems that cheap chineese potentiometer is in pretty bad shape. I did generated a time delay, just as you said, about 0.4sec, and everything works fine, until bad segment of potentiometer comes up. Didn't expect something like that... Thanks a lot!!!! CHEERS!!!
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
adc pic16f887

Hi,

Just a follow up to some other points - nothing wrong in doing Assembler first - many folk recommend doing it before trying the higher languages as it gives you a better understanding if the pic chip.

It is possible to run MPlab Debugger with Microchip Assembler or C from the Easypic boards. A friend has an EP4 and he uses a Pickit2 unit, just connects its 5 leads onto the EP4. You can buy a Pickit2 or build your own cut down version.
 

wizardgrt

Junior Member level 1
Joined
Jun 16, 2008
Messages
19
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
Serbia
Activity points
1,433
1 sec delay in pic assembly pic 16f887

I'm trying to connect opamp and inamp like on schematic attached, but the gain of the instrum. amplifier falls down. When a source of stabilized voltage is connected with instr. amp. instead of LEM transducer, everything works fine. What's the problem?
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top