1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Measuring negative voltages with a PIC

Discussion in 'Microcontrollers' started by bigal_scorpio, Jul 3, 2012.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    Would you like me to write and post a HEX for a testing program.??

    I will look at your sums.

    E.

    EDIT:

    Program is finished, runs in simulation OK,, will try in a PIC with LCD tomorrow and then post the test1.hex file to the Thread....phew!
     
    Last edited: Jul 17, 2012
  2. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    sounds good mate, nearly there I think. Just a few little problems as usual.

    Al

    But the fluctuating temp is strange!

    Al
     
  3. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Just a bit more info on whats happening at the moment.

    As I said at the moment I can't get the varamp to work. This is definately not software but some fault on the OPA circuit which seems to have developed a new symptom. Now when I read the pos rail ampage, even with the OPA set to 2.44v at 1A it reads way over double of any reading I take, as in 480mA for a 210mA load and it seems to have turned into a sample and hold circuit somehow! Even when the load is removed the display does not change.

    If I change the load to another then the display will change to that but will not return to 0. I have to turn off the PSU and let the caps discharge before I can use it again properly.

    Do you think my OPA circuit has developed a fault maybe? How robust are the OPAs?

    I did solder in the OPA not to save a socket but because I thought that as I was measuring such small differences that the sockets connections may compound any errors. Saying that it would only take me a couple of minutes to swap it if you think it may be faulty. I would also use a socket if you advise me so.

    Al
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. languer

    languer Active Member

    Joined:
    Oct 26, 2010
    Messages:
    193
    Likes:
    25
    Location:
    Arizona
    ONLINE

    Why don't you check in ....? That forum is dedicated just for PBP - you would get the answer to the DEC question in a day probably.

    Anyways; the following is on the manual:
    "A numeric value preceded by DEC will send the ASCII representation of its decimal value. For example, if B0 = 123, then DEC B0 (or DEC 123) will send "123"."
    "BIN, DEC and HEX may be followed by a number. Normally, these modifiers receive as many digits as are in the input. However, if a number follows the modifier, SERIN2 will always receive that number of digits, skipping additional digits as necessary."
     
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    Attached are the Oshonsoft Basic file and the hex file.

    If you program your 16F672 with this hex file it has all the functions and formatting for the LCD.
    [use the IMPORT option on MPLAB for loading the HEX file]

    I have made PORTC.4 the output pin for the FAN driver, high=Fan ON.

    It all works on my project board OK, all the functions. I used your numbers for the Thermistor resistance at Temperatures.

    The OSH basic file will give you guidance on the sums to use.

    Good Luck.:rolleyes:

    Eric
     
    Last edited: Jul 18, 2012
  7. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Just tried the hex and same as mine it ignores the var side. Definately something wrong with the OPA circuit.

    Going to swap it out. Would you recommend a socket or not?

    BTW I notice that the Oshonsoft looks like basic but it is set out so differently than mine, will take some studying to follow properly.


    Al
     
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    For the price of a 8pin DIP socket, I usually fit them.

    You could get the free download from OSH for 28 days or 30 switch On's

    Is the remainder of the circuit working and displaying OK.??

    any chance of a picture of the faulty amp layout.??

    E.
     
  9. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Here are some pics of the circuit.

    OPA on the right is for 5Amp at top and VarAmp at bottom. The other OPA on the left does the neg rail voltage.

    I didn't use a socket because of the tiny measurements involved with the OPA circuit, but I will now anyway as you say its OK.

    I am in the process of swapping computers now too. My son has upgraded so his has moved down the line to me. That used to be the other way round when I was young. ;)

    The Hex you sent shows just the Pos and Neg current. Is that right? I tried the buttons but nothing else.

    If you implemented the display change mode what buttons did you use and did they go to 5 or 0v?

    Al
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,

    I will look over the images, let you know.
    E.
     
    Last edited: Jul 18, 2012
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    On those images I am assuming the LM358 thats only half used, is the Vamp.??

    Can you confirm which circuit diagram you are using.?

    E.
     
  12. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Yes the 1/2 used is the -Volt and the circuit I am using is the one on post 56.

    Apologies for the ciruit not working on LCD display change! Was a "switch glitch", catchy eh!

    Swapping the full OPA now. Done! Still no var mA.

    BTW I don't know if there is some difference between our circuits? My displays with your hex are as follows.

    Al
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    The 'mA' on the third image should not be there, it needs a small change to the program in order to clean it away from a previous display.

    Otherwise all the images are OK, we are making progress!;)

    I will look at post 56.

    E.

    EDIT:
    Al, as you didn't have a 0.01R only a 0.1R we changed the circuit to suit. Post #61
     
    Last edited: Jul 18, 2012
  14. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Could the differences between the 2 circuits account for one side of my OPA not working?

    I was also wondering how the OPA will compensate for the differences in voltage that can occur on the var rail?

    Does the OPA care what voltage is input in relation to 0v? I know we are measuring a PD between the ends of a resistor on both sides but one side is fixed difference from 0v and the other side varies. Does this have any effect? I am asking these questions because I just can't get anything out of the var OPA side.

    I will change the circuits in respect to the correct diagram. Just to clear something up, is R1 really a 10k pot and not a 2k resistor? Or is there actually a 4k7 and a 2k in series Before the 10k pot? BTW when I played with
    LT Spice I could not find anything to use as a Pot. Is that why you do it as in the diagram?

    Al
     
    Last edited: Jul 18, 2012
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    R1 is a 10K pot thats been adjusted to a 2K setting, the series 4k7 is required.

    In your circuit there are tolerances in the components, so the 10K pot allows you to tweak the circuit to set the vadc output to the required value.

    LTS does have pot models, I will zip up my pot models and post them for you.

    The OPA inputs are measuring the voltage drop ACROSS the Rsense resistor, I will look at the effect of the setting of the Var voltage has on the circuit, will let you know.

    If you set the Var to +15V and test the Var OPA, you should get a voltage.

    Can you set the +Var to +15V and say a current of 100mA.

    Then measure the voltages on all the Var OPA pins with respect to 0V and tell me what you see.

    E.

    EDIT
    At the lower voltage settings for +Var, the 2N3904 supply voltage is too low for the transistor to give the required Vadc output over the full current range.
    I will see what I can suggest to correct this.
     
    Last edited: Jul 19, 2012
  16. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Don't worry too much about lower voltages not being enough mate. I don't often use below about 7 or 8v on the var side. But I do wonder what would happen if I measure (if I ever get the var rail working ;) ) a current when I have the load across + and -? Won't that be different with regards to the OPA's 0v? Wish I had learned more about OPA's when I could still learn! Doh!

    As to the measurements, with a load of 150r which I work out at 100mA at 15v the readings from 0v are as follows.

    Pin5=13.73v, pin6=13.73v, pin7=0.01v, pin8(supply)=17.6v

    Still can't see an error in the circuit but there must be surely!

    Al
     
    Last edited: Jul 19, 2012
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    Can I just recap regarding which Var OPA's pins you are measuring.?

    Is it the +1.25V to +15V or the -1.25V to -15V VOLTAGES... OPA 's pins or the

    the +1.25V to +15V CURRENT OPA's pins.?

    E.
     
  18. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    Its the +variable current measure side of the OPA. The other side measures the 5v current and seems to work ok unlike the var side.

    Al
     
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Al,
    OK, had to do a reality check for myself...:rolleyes:

    I assume you have the 2N3904 and all the other circuit components connected to the +Vvar_amp OPA when you measured.. The pin7 looks wrong.?

    Whats the voltage on the 2N3904 pins,, Coll, Base and Emitter.?

    If we get completely stuck, I could build the sensor PCB for you and mail it to you, so don't worry...

    E.

    EDIT:
    This image shows the voltages , when the Vout is 15V at 100mA.
     
    Last edited: Jul 19, 2012
  20. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    I have 13.7v on the collector, 0 on the emitter and base.

    I have rechecked the circuit so many times that I can still see it with my eyes closed.

    The main thing I don't have is the voltage out of the OPA. A supposition. What if my 0.1r is just zero ohms?

    Maybe its unlikely but I just had the thought, then I thought what if?

    Would I still be able to get any voltage on the OPA out pin by adjusting the pot. I'm clutching at straws here mate. BTW have we gone back to 120r on the OPA pin 5 or is it still 220r and just not changed on the schematic?

    Al
     
  21. bigal_scorpio

    bigal_scorpio Active Member

    Joined:
    Oct 6, 2007
    Messages:
    1,072
    Likes:
    4
    Location:
    Rotherham South Yorkshire England
    Hi Eric,

    A further thought occurs. Can I inject a signal into anywhere in the circuit to test things and if so what and where?

    Al
     

Share This Page