Continue to Site

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.

  • 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.

Measuring negative voltages with a PIC

Status
Not open for further replies.
hi Al,
No problem.

You say at 15V at 400mA you get this.

pin 5 = 4.91v
pin 6 = 4.91v
pin 7 = 0.01v
pin 8 = 4.85v

Pins 5 and 6 should be close to 15V , they are connected to the Rsense resistor.??

Eric
 
Sorry Eric,

Forgot I changed the OPA around to be sure it worked.

Sould be pin1 to 3. Its as follows.

1 = 0.5v at 5v and .48v at 15v
2 = 3.51 to 14.09 as var goes up
3 = 3.51 to 14.09 as var goes up
4 = 0v
8 = 17.85v

Al
 
Last edited:
hi Al,

Adjust R28 the 15Kpot , to 6K, then at 400mA [ set at 15Vout] the readings should be as I show on this image.

Pin 8 =2.6V
AN3 [ 2N3904] emitter close to 1.95V [ equals 400mA]

Eric
 
Hi Eric,

Are we using the same OPA? Pin 4 gnd and pin 8 is +supply.

output from my var is pin1. and has about 0.48 regardless of var or load

Al

BTW my resistors are not as your latest schematic. I have 4k7 fixed and 10k pot.
 
Last edited:
hi Al,

Woops

AN3 [ 2N3904] emitter close to 1.95V [ equals 400mA]

Should be Pin 1 at 2.6V [ cant tell my 8 from my elbow!, sorry about that]

I know that you have a 4k7 and 10Kpot in series, just adjust the pot so the 'total' resistance is 6k [ that would make the pot its self 1.3k]

Eric

EDIT:

I have tried various simulations and the only way I can make pin 1, 0.48V is if the emitter of the 2N904 is connected to 0V.

Can you use an ohmmeter and measure the resistance from the 2N3904 emitter to 0V, [ with the power Off].?

Eric
 
Last edited:
Whoooooooooopeeeeeeeeee

Found out what was wrong all along Eric, had a cap across the sense resistor! Doh!

The path for the output is very circuitous and I had cut where I though was the output but it splits from the actual pin and goes to a cap which I didn't notice when I did the wiring.

Sorry mate to give you all this grief! Wish I'de spotted this during the hundred times or so that I have had the board upside down.

Anyway that settled I think I can finally say once the adjustments are made it will be done and finally can be put to use.

Thanks again for all the help and don't go far mate. I am certain the next project will go just as smoothly as this did ;)


Happy regards,
Al
 
hi Al,
Thats good news.

If you want the LCD display program tweaking, let me know what and I will post a new hex file.

Eric
 
Hi Eric,

One thing I still need to do is stabilise the readings. Even the voltage ones tend to fluctuate in the end digits and if there was a way of slowing the changes down? Maybe I am talking about buffering which I asked about in another thread and almost started a war. Sad thing is that they were already beyond me when the thread started. I have never done any buffering and don't know how to start.

If you can explain it in simple terms or know somewhere that does I will give it a go.

Thanks again mate, Al
 
hi Al,
I will ponder and let you know,via an EDIT.
E

Hi Al,
I have rearranged the LCD layout in order to improve its appearance.
On:
Sw1 position you have the +V15var, the -15var and the +V15var milliamp

Sw2 position is the Vsum [Vs] of the +15var and -15var and the +V15var milliamp

Sw3 position is the Temperature of the Thermistor and the state of the Fan ie: On or Off.

Sw4, unused [future development]

If this acceptable, let me jnow and will program a PIC and hardware test it.

The adc takes the average of 60 samples for each adc channel

Another point you should consider is the Fan control, at the moment the Thermistor temperature and Fan on/off is only active when Sw3 position is selected.

The Therm/Fan should be sampled at regular intervals, I would suggest at the end of select sequence.
It would not be displayed, it would only control the Fan
Eric

EDIT:
Added the hex and OSH Basic files, give the hex a try.
The program checks the Thermistor/Fan at the end of each sequence.
Works fine in a PIC.;)
 
Last edited:
Hi Eric,

Its fine mate, I dont mind what you do so long as I can see the basic, then I can learn with it.

Remember I am using a DS18B20 sensor now for the temperature. Its much more accurate being digital and also easier to see the result without fluctuations.

Do you want my code for reading it? I am reading to portC.7 and didn't bother reading the sign since if the temperature in my PSU is less than 0 I sure won't be in the shed to see it! ;)

As to the spare display, I was considering at one time using a display to show the actual current limiting beig used but I couldn't come up with a way of doing it without more ADC channels. Remember I was using 12 way rotary switches to set the LM317s output. I cant think of a way of reading it at all that does not need extra ADC so I was just going with putting the values around the knobs.

I am open to any ideas about the PSU and extra gadgets that would be handy.

BTW I was also wondering about how to get some hysteresis on the fan so it is not just going on and off all the time. I have never studied how they do that but I am sure you will have some ideas mate.

Thanks, Al
 
Hi Al,
Try that hex file, ignore the Tempr.

Check out the sampling,,, also use your scope to check for noise and ripple on the outputs.

Eric

Al,
DS1820
According to the device datasheet the conversion will be completed in at most 750ms.
After that period the measured value can be read


This could slow the temp reading updates
 
Last edited:
please ignore

Edit,

Hi Eric,

Just tried the code and it seems to be ok.

NB I am using a DS18B20 not the 1820, they are very different as I know to my grief whe I first used one!

I will post the snippet of my code for the 18B20. It is very small and does not seem to slow anything down. Have a look. I have used it before.
Al

Code:
TEMPINREAD:
        OWOUT TEMPIN,1,[$CC,$44]
        HIGH TEMPIN
        PAUSE 10
        OWOUT TEMPIN,1,[$CC,$BE]
        OWIN TEMPIN,0,[TEMPDATA.LowByte,TEMPDATA.HighByte,SKIP 7]
        tSign = SIGN ' save sign bin
        IF TSIGN=1 THEN
        TEMPDATA = $FFFF-TEMPDATA
        TEMPDATA = TEMPDATA + 1
        ENDIF
        TEMPDATA = TEMPDATA/16
        RETURN
 
Last edited:
hi Al,
By looking at the adc sampling and the sums in the OSH Basic program are you now able to convert the program to PBP Basic.??

If you can do that it will be possible to make any changes you need, if not I will get a 18B20 IC and write the routine in OSH Basic.

The problem is I do not have an external module for a DS18B20 in OSH.

Eric
 
hi Al,
Have added a DS18B20 routine to this HEX file, the other functions are the same.

The DS18B20 is on position 4 of your select switch.

Try it, see what get, you should get a range of 0C thru 125.00"C

Eric
 
Hi Eric,

I get :-

"DS18S20 Testing"
"DS=+ 25.50 C' "

Warm in my shed eh!

So is that running in the background? i Noticed you are reading on B0, had me puzzled for a while. ;)

I assume you are planning on using RB1 for the fan power? I was thinking a darlington npn as the fan is about 300mA at 5v. I did have a thought about PWM linked to the temperature but it does seem a bit of a job just to cool the unit.

Al
 
Last edited:
Hi Eric,

I get :-

"DS18S20 Testing"
"DS=+ 25.50 C' "

Warm in my shed eh!

So is that running in the background? i Noticed you are reading on B0, had me puzzled for a while. ;)

I assume you are planning on using RB1 for the fan power? I was thinking a darlington npn as the fan is about 300mA at 5v. I did have a thought about PWM linked to the temperature but it does seem a bit of a job just to cool the unit.

Al

hi Al,
It works, thats good news.;) [ I assume the reading changes OK as the DS tempr changes.???]

I should have pointed out the pin number , duh.
Define 1WIRE_REG = PORTB
Define 1WIRE_BIT = 0


PortC.4 was set for the Fan control.

The program you are now running does not control the Fan, it was created just to test the DS18B20 operation.

Now that the DS18B20 can be accessed OK, let me know which temperatures you want the Fan to operate at also which PIC pin number for the Fan. [and the tempr hysteresis]

I have also added the minus tempr range to the DS18B20 program down to -55C, so you could check your deep freezer tempr.!

Eric
 
Morning Eric,

Yes mate the temp changes just fine.

As to the temperature for fan turn on. Now that is a puzzler!

I have used temp reading before but never had to control anything with it so I don't have the first clue as to what to expect or plan for. The only reason I wanted to implement this is that it would be belt and braces.

I have never abused the PSU in the past in that when I was testing loads that were on or just above the ratings I always made sure to minimise the time loaded. So I don't really know what to expect.

I would probably need to test the PSU and keep reading the temp before I could make a decision on when to use the cooling. Also sensor placement would be a consideration. Will the transformer be the thing that heats up first or will it be the heatsinks on the regs?

I think I need further testing. But some of that testing will need to be done under load with the box closed so I would need the temp just to be read for now I think.

You probably have much experience of cooling and if you know a rough guide that would be "good enough" I will be more than happy to go along with that.

What do you think mate?

Al
 
hi Al,
Let me know your tempr readings and I will modify the program.

On the existing program , the thermistor ADC part is on Sw pos 3, I will drop that routine off in future programs. Do you want the DS18B20 moving to Sw pos 3.??

What have you planned for the ADC input pin that was used for the Thermistor.?

Eric

EDIT:
Have you considered using a small 3 pin connector on the PSU and the DS18B20.
Put the sensor on a short lead say 1 mtr, in that way you could use the thermometer to check other items of equipment.
 
Last edited:
Hi Eric,

Thats just the problem. I don't know what the PSU would be happy running at?

I don't mind at all where the sensor is mate and that is a good idea about a mobile temp sensor, but how about taking it a step furhter and having a small socket on the rear of the PSU (or the front if there is room) and having the sensor inside disconnected by plugging in the external one? A stereo 3.5mm jack could be used as they have switched sockets, then the sensors could be exchanged at will.

As to the spare ADC input? Any ideas for a useful gadget? The possibilities are endless but something useful is harder to think of. I had thought of having an external voltage probe? It could be handy for debugging voltages on boards that I'm powering from the PSU.

Back to the Temp, I did think that maybe it would be prudent to have a set level of heat where a small warning piezo buzzer would tell of impending doom but then again I will have to do some testing to see what the PSU runs at normally and under certain loads.

Anyway I will begin testing it now and let you know what the readings are, today is ideal as it is about 30c in my shed! ;)

Al
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top