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!!!!:|
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
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
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!!!
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.
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?