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,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,
    Try this test7.hex.

    On Sw3 position, the DS18S20 temperature is displayed,also the Fan State, Ton and Toff temperatures.

    Add a 4k7 pull up resistor on PORTC.7 [ to +5v] , add a n/o push switch from pin PORTC.7 to 0V.

    To Set up your Fan On/Off temperatures, select Sw pos3 and then press and hold the push switch. [the push switch allows you to change the settings, while its pushed]

    Set the Ton using the set +15Vvar pot and the Toff using the -15Vvar pot.
    These are the controls on the front that you use set the V outputs of the variable supplies.

    Once set release the push button.

    The settings are stored in the PIC's EEPROM and recalled at power up.

    Sw4 is still unused.

    Eric

    EDIT:

    Does your PC have a serial RS232 connector.??
     
    Last edited: Jul 25, 2012
  2. bigal_scorpio

    bigal_scorpio Active Member

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

    That looks amazing mate. What would I do without you?

    I have not been able to test any temperatures as I said the other day as just after I posted my parents came and stayed till late. Then today we at last got to have our grandson Sam for the day, after all the trouble and strife his mum causes. Anyhow moan over, well not moaning about seeing grandson.

    The ideas you have come up with for the fan control and setting are amazing! I would never have thought of that at all. If this project gets any more intelligent we may have to be careful of it taking over the world! ;)

    As soon as I have finished this post I will prog a pic and give it a try, can't wait!

    As to a serial port. Not as such but there is a parallel one (25 pin) that I believe carries all the signals. What do you have in mind mate, you have me intrigued.

    Al
     
  3. bigal_scorpio

    bigal_scorpio Active Member

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

    Works beautifully mate! Thats really crafty code. What is the hysteresis of the values? Also I would love to see the code mate, I can certainly learn a lot from it. You are doing things that I had no idea were even possible.

    The part where you use the voltages to set the temp is pure genius!

    Al

    BTW my wife Dawn has a facebook page and seems to think you do too? Shall I tell her to friend you? I never got round to making a facebook.

    Al
     
  4. dave

    Dave New Member

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


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE

    hi Al,
    Pleased to hear its working for you.

    The difference between the Ton and the Toff is the hysteresis, once the fan comes On at the Ton temperature it will not go Off until the temperature falls to Toff

    I will tidy up and comment the basic code and post it here.

    Look forward to seeing your wife on FB.

    Eric
     
  6. bigal_scorpio

    bigal_scorpio Active Member

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

    My wife goes by her married and maiden name on FB as do many married women I believe. So don't be surprised when a strange name adds you.

    Al
     
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,
    As requested the Oshonsoft test7.bas is attached, I have cleaned it up and added comments.

    Note, for some reason the test.7.bas when download becomes test7.bas.txt [just delete the .txt part]

    Eric
     
    Last edited: Jul 26, 2012
  8. bigal_scorpio

    bigal_scorpio Active Member

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

    I have had a quick look at the bas file and I understand some of it. The strangest part is the ASM bit where the numbers get converted to chars. As I have never understood ASM it has me baffled but I can see it works fine.

    Actually having to use locations is strange to me too. Nothing in PBP pro had prepared me for that, the last time I had to do that was back in the days of the Commodore 64 with its peeks and pokes etc. It was all in decimal then though so it was easier to see the relation of one address to another.

    Even if I become fluent in basic of any kind I don't think I will ever have the grasp that you have of the actual ways of doing things. I'm always just glad if something works at all! ;)

    Anyway back to finishing the PSU now and then there will be the usual tweaking of the thing to get spot on results. But to be honest I think that this has been the project that I have learned most from so far and thanks to you it all works!

    Al
     
  9. bigal_scorpio

    bigal_scorpio Active Member

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

    Got everything running! Fan and all. :)

    During the completion I have discovered a small glitch. When I switch on the unit I get -0v showing on the display for +v and -v, no matter how high the volts are actually set to. Obviously the voltage is still there but the PIC isn't seeing it. As a workaround I have discovered that if I turn on and it shows 0 then if I adjust the neg volts to its lowest point then the display shows as it should and the problem is fixed until I power down again.

    Can you think of anything obvious it could be mate? Maybe it will do it in the sim if you turn on with high neg v?

    Al

    PS I will post some pics soon!
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,
    Thats a strange effect, let me look thru the circuits and see what I can find.

    I assume both the +15V and the -15V show 0V.?? or is it just the -15V section.?

    I have the PIC running here with pots for the +15V and -15V etc, never seen that problem.

    Eric
     
  11. bigal_scorpio

    bigal_scorpio Active Member

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

    Its only the neg side that is affected. It does also have a knock on effect that it throws a wobbly if you change to temp view whail the negv is high. This seems to overload the reading for off temp and again the only cure is to turn the neg volts to the lowest setting then start setting the off to the required.

    I seem to think the circuit was doing this at the beggining but the PSU was so rarely together that it was dismissed as a teething problem.

    Al
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,
    I suspect the LM358 is latching up at power on, will look at that first.

    As a check disconnect the 10K from the -15V LM337 output that goes to the LM358 input and connect it to 0V. Its R19 , 10k on the 'full' drawing.


    Eric
     
    Last edited: Jul 27, 2012
  13. bigal_scorpio

    bigal_scorpio Active Member

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

    Done that and the display shows neg volts as 0 and of course nothing adjustment wise as it is disconnected.

    Is that what was expected?

    Al
     
    Last edited: Jul 27, 2012
  14. bigal_scorpio

    bigal_scorpio Active Member

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

    Been testing a while now and found another small problem. Though the fan works fine when the display is set to temp, when the display is showing volts or amps the fan does not cut in.

    I had a look at the code but I don't quite get it all though I seem to think that the fan control routine is only accessed from the temp routine. I am not sure how to alter it without impacting on other things. That said I can't anyway as the Oshonsoft won't run on this machine for some reason. But by monday that should be sorted as I am moving from the stone age computer I now use to my sons old machine.

    Anyway off to bed now. Eyes going anyway.

    Al
     
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,,

    See that, I will post a hex file with a correction for the fan.:eek:

    Did you try the 10K reconnect.?

    Eric
     
  16. bigal_scorpio

    bigal_scorpio Active Member

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

    Yes mate I did tie it to gnd and the display shows 0v on the neg side. Is this as it should be?

    Al
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    Morning Al,
    Thats what I would expect, but does the +15Var and the +5V show a positive voltage and current. at power up OK??

    I am modifying the test7 program to include the repeated sensing of the Fan tempr circuit [ I had a senior moment, duh!]

    Have you decided what you are going to do with the Mode switch Pos 4.??

    Eric.

    OT: Masonry painting outside today, bit like the Fourth bridge.
     
    Last edited: Jul 28, 2012
  18. bigal_scorpio

    bigal_scorpio Active Member

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

    Yes, positive side showing and measuring ok.

    As to position 4. Its a puzzler. I did have various thoughts but all seemed to be pointless. I can't think of anything that is really useful. Any Ideas mate? I don't mind building extra parts or adding to the existing so long as its something interesting or useful.

    As to the painting, if you planned it for the weather well done! If you didn't plan it then go and buy a lottery ticket, cause you must be lucky enough to win mate.

    Al
     
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Al,
    I am temporarily using pos4 for a temperature test subroutine on AN4, in order to check out the 'repeat' fan control as I dont have a 18S20 on the bench.

    Can you measure the 18V zener supply to the LM358 , with the 10K connected back to the -Vvar LM337 output .

    It looks as though the +18V voltage is rising far slower than the +15V and -15V outputs, so I suspect the LM358 is latching up.

    Try this small change, reduce the 470R that feeds the zener to 330R and reduce the 10uF across the zener diode to 100nF [0.1uF]

    I will post a new hex file over the weekend..;) ,lets know what you get with that 18V mod.

    Eric
     
  20. bigal_scorpio

    bigal_scorpio Active Member

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

    The zener part measures 17.87v

    Going to do the mods now and will post results.

    Al

    PS don't let me interrupt your painting mate. With the weather as it is you need to take it while you can! ;)
     
  21. bigal_scorpio

    bigal_scorpio Active Member

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

    That did the trick mate! Providing I don't turn the PSU off and on quickly it performs perfectly.

    Thanks mate.

    BTW would you like an 18B20 sensor? I have half a dozen or so and could send one if you like?

    Al
     

Share This Page