thunderer
Junior Member
Offline
Posts: 61
Thank You
-Given: 19
-Receive: 69
I try to be patient
|
|
« on: April 14, 2013, 10:21:45 22:21 » |
|
I decided to make myself a symetrical PSU with LM317 and 337, control by dual taper pots (coarse and fine). The intent was to have a PSU for small audio power amps and pre-amps, correctors, etc. Nothing fancy, the datasheet schematic. Works flawlessly. The part I added was a LCD showing the voltage and current on each branch. Remember, there are 3 output terminals (V+, 0V, and V-). So I chose to use some resistive dividers and shunts (0.1ohm, 3W, 1%). See the attched DSN file for connections outside the PSU (I do not show the 317 and 337, as there is no issue with them). I chose to display the positive current as the voltage drop on RSH1 (later to divide by 0.1 to get the current) to avoid putting another OPAMP, as I could not find how to reference it to the V- (being the GND of the PIC). The issue I have is that the difference is not consistant. See the pictures for 1A and 0.5A. The voltage drop on RSH1 (shown on LCD) at 0.5A (0.12V - on 7.45V shown on LCD) is bigger than at 1A (0.1V = which is 1A on 0.1ohm = coincidence? - on 13.3V shown on LCD). How come?! Note I used a 13ohm load (so 1A at 13V) The code for the 16F88 I used is: ' VI_LCD_for_differential_PS ' * Copyright: ' (c) Thunderer (2o12) ' * Revision History: ' 0 - 1st issue ' * Description: ' DC voltage and current are measured and displayed on a 16x2 LCD. ' Data: 20Vdc max, 1.5Adc max for a symetrical power supply. Common GND. ' S -------------------- +V ' S -------------------- GND (0V) ' S -------------------- -V ' Example: ' ------------------ ' |S+: 12.34V 1.23A | ' |S-: 12.34V 1.23A | ' ------------------ ' * Test configuration: ' MCU: PIC16F88 ' Oscillator: INTOSC 4 MHz ' Ext. Modules: - ' *
program Measurement ' Declarations section dim U1mes, U1m, U1 as float ' U1 U2mes, U2m, U2 as float ' U2 U3mes, U3m, U3 as float ' I1 U4mes, U4m, U4 as float ' I2 i as byte
' Lcd module connections dim LCD_RS as sbit at RB7_bit LCD_EN as sbit at RB6_bit LCD_D4 as sbit at RB5_bit LCD_D5 as sbit at RB4_bit LCD_D6 as sbit at RB3_bit LCD_D7 as sbit at RB2_bit
LCD_RS_Direction as sbit at TRISB7_bit LCD_EN_Direction as sbit at TRISB6_bit LCD_D4_Direction as sbit at TRISB5_bit LCD_D5_Direction as sbit at TRISB4_bit LCD_D6_Direction as sbit at TRISB3_bit LCD_D7_Direction as sbit at TRISB2_bit ' End Lcd module connections
dim txtU1 as char[5] txtI1 as char[4] txtU2 as char[5] txtI2 as char[4]
' Set-up the PIC sub procedure InitMain() OSCCON = 0x7E ' 8MHz clock OPTION_REG = 0x80 ' Pull-up disabled PORTB INTCON = 0x00 ' No INT CMCON = 0x00 ' No COMP ANSEL = 0x0F ' PORTB Digital I/Os, PORTA AIs ' on RA0 to RA3, RA4 to RA7 are DIs CCP1CON = 0x00 ' CCP disabled
TRISA = 0xFF ' All inputs TRISB = 0x00 ' All outputs
PORTA = 0x00 ' Clear PORTA PORTB = 0x00 ' Clear PORTB end sub
' Main program Main: InitMain()
Lcd_Init() ' Initialize Lcd Lcd_Cmd(_LCD_CLEAR) ' Clear display Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off Lcd_Out(1,2,"Symmetrical PS") ' Write text in first row Lcd_Out(2,3,"2x20V/1.5Adc") ' Write text in second row Delay_ms(1000) Lcd_Cmd(_LCD_CLEAR) ' Clear display ADC_Init() ' Initialize ADC module
' The VI measurement Measure: while (TRUE) ' Display static text Lcd_Out(1,1,"S+: ") ' Write in 1st row 1st position Lcd_Out(2,1,"S-: ") ' Write in 2nd row 1st position Delay_ms(100)
' Voltage positive ' Measure U1mes = 0 for i = 1 to 200 U1mes = U1mes + ADC_Read(0) next i ' Calculate U1m = U1mes/200 - U2m U1 = U1m*25*5/1023 FloatToStr(U1, txtU1) ' txtU1 = U1 ' Display Lcd_Out(1,5,txtU1) ' Write textU in 1st row 5th position Lcd_Out(1,10,"V") ' Write V in 1st row 10th position Lcd_Out(1,11," ") ' Write "space" in 1st row 11th position
Delay_ms(100) ' Current positive ' Measure U3mes = 0 for i = 1 to 200 U3mes = U3mes + ADC_Read(1) next i ' Calculate U3m = U3mes/200 - U2m U3 = U3m*25*5/1023 FloatToStr(U3, txtI1) ' txtI1 = U3 ' Display Lcd_Out(1,12,txtI1) ' Write textI in 1st row 12th position Lcd_Out(1,16,"A") ' Write A in 1st row 16th position
Delay_ms(100)
' Voltage negative ' Measure U2mes = 0 for i = 1 to 200 U2mes = U2mes + ADC_Read(2) next i ' Calculate U2m = U2mes/200 U2 = U2m*25*5/1023 FloatToStr(U2, txtU2) ' txtU2 = U2 ' Display Lcd_Out(2,5,txtU2) ' Write textU in 2nd row 5th position Lcd_Out(2,10,"V") ' Write V in 2nd row 10th position Lcd_Out(2,11," ") ' Write "space" in 2nd row 11th position Delay_ms(100) ' Current negative ' Measure U4mes = 0 for i = 1 to 200 U4mes = U4mes + ADC_Read(3) next i ' Calculate U4m = U4mes/200 U4 = U4m*0.936*5/1023 ' 5 * 9.36 = 4.68 correction FloatToStr(U4, txtI2) ' txtI2 = U4 ' Display Lcd_Out(2,12,txtI2) ' Write textI in 2nd row 12th position Lcd_Out(2,16,"A") ' Write A in 2nd row 16th position Delay_ms(100)
wend end.
|
|
« Last Edit: April 14, 2013, 11:03:40 23:03 by thunderer »
|
Logged
|
Interested and hopefully helpful in: DC brushed motor control (mainly R/C - PPM/PWM), analog audio, PIC (mikrobasic PRO). Feel free to ask, and if I can, I will help. But only on forum topics, any started private conversation will continue in a public topic.
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4671
Thank You
-Given: 836
-Receive: 4331
There is no evidence that I muted SoNsIvRi
|
|
« Reply #1 on: April 15, 2013, 01:29:22 01:29 » |
|
some users don't have proteus installed, why not post a *.pdf first thought why use LM317 & LM337 ripple would be a problem.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
kentar
Newbie
Offline
Posts: 23
Thank You
-Given: 44
-Receive: 29
|
|
« Reply #2 on: April 15, 2013, 05:11:08 05:11 » |
|
Shunt resistor is in series with load resistor. When the load is very small (very small voltage drop) on shunt resistor rsh resistor is load . So in low voltages you must use offset in your code or use very small shunt resistor. (2 x 0.1 ohm in parallel) or typical shunt resistor (75 mV max voltage drop).
|
|
« Last Edit: April 15, 2013, 05:26:59 05:26 by kentar »
|
Logged
|
Warned
|
|
|
PaulC
Active Member
Offline
Posts: 170
Thank You
-Given: 3935
-Receive: 133
information is free and should be shared for free
|
|
« Reply #3 on: April 15, 2013, 12:25:40 12:25 » |
|
|
|
|
Logged
|
find it , read it , share it .
|
|
|
thunderer
Junior Member
Offline
Posts: 61
Thank You
-Given: 19
-Receive: 69
I try to be patient
|
|
« Reply #4 on: April 16, 2013, 12:17:39 00:17 » |
|
@pickit2 - I attached the PDF. I agree 317-337 is such noisy. Can we believe 317 turned 40 years? ...rsh resistor is load . So in low voltages you must use offset in your code or use very small shunt resistor. I do not follow you. A shunt is not more of a load on a small load than on a big one. And the 0.1R has a drop of 150mV at 1.5A. More, I measure the voltage after the shunt (on the positive branch), so I know how much voltage I have at the load terminals. Funny is that we complain about 0.1R but we do not care about more than 3-4 times resistance in cables to the load . I am interested about the use of offset. Do you mean deducting the voltage drop on the negative branch - that is a flaw of my software in both positive and negative? This is easy to fix. Can you give me some hints? @PaulC - I will read it, thx! Guys, FYI the negative branch works OK, I mean the GND to V- works perfectly, the current is perfectly measured with such simple scheme. Only the positive branch refused to "behave".
|
|
« Last Edit: April 16, 2013, 12:56:51 00:56 by thunderer »
|
Logged
|
Interested and hopefully helpful in: DC brushed motor control (mainly R/C - PPM/PWM), analog audio, PIC (mikrobasic PRO). Feel free to ask, and if I can, I will help. But only on forum topics, any started private conversation will continue in a public topic.
|
|
|
Catcatcat
Senior Member
Offline
Posts: 433
Thank You
-Given: 285
-Receive: 1672
|
|
« Reply #5 on: April 16, 2013, 06:36:57 06:36 » |
|
I think the problem is that you have a common wire is taken not tire COMMON PSU, and - FROM PSU
|
|
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4671
Thank You
-Given: 836
-Receive: 4331
There is no evidence that I muted SoNsIvRi
|
|
« Reply #6 on: April 16, 2013, 07:59:43 07:59 » |
|
Why not use the voltage value at Ajust of voltage regs.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
DreamCat
Senior Member
Offline
Posts: 283
Thank You
-Given: 223
-Receive: 116
|
|
« Reply #7 on: April 16, 2013, 08:11:09 08:11 » |
|
@thunderer, as you said, the 0.1R shunt resistor has a voltage drop of 150mV at 1.5A, but it really too small respect to the reference voltage of your MCU, it can't get a enough resolution. So, I think you should better use a current monitor IC, or a op amp to get some gain. of course, a current mirror also can be used for this.
|
|
|
Logged
|
May be I expressed the wrong meaning, sorry for my bad english. Please correct it for me if you can.
|
|
|
thunderer
Junior Member
Offline
Posts: 61
Thank You
-Given: 19
-Receive: 69
I try to be patient
|
|
« Reply #8 on: April 16, 2013, 10:49:29 22:49 » |
|
@ Dreamcat: Are you proposing a differential amplifier on the RSH1? My issue with this is that I will have an opamp powered at 5V, and its inputs will see maybe 40V with respect to the "- of the PSU" (which is the GND of the OPAMP and the PIC). Will this be acceptable? Maybe I will keep the resistive dividers and then input them in the OPAMP I purchased to re-do this project (a rail-to-rail FAN4174 http://www.fairchildsemi.com/ds/FA/FAN4274.pdf). Then the output of the OPAMP sent to the PIC. I will have to try this configuration. Looks like a plan, thx!
|
|
« Last Edit: April 16, 2013, 11:02:03 23:02 by thunderer »
|
Logged
|
Interested and hopefully helpful in: DC brushed motor control (mainly R/C - PPM/PWM), analog audio, PIC (mikrobasic PRO). Feel free to ask, and if I can, I will help. But only on forum topics, any started private conversation will continue in a public topic.
|
|
|
Catcatcat
Senior Member
Offline
Posts: 433
Thank You
-Given: 285
-Receive: 1672
|
|
« Reply #9 on: April 17, 2013, 06:42:16 06:42 » |
|
maybe you should pay attention to such converters TSC101
|
|
|
Logged
|
|
|
|
PaulC
Active Member
Offline
Posts: 170
Thank You
-Given: 3935
-Receive: 133
information is free and should be shared for free
|
|
« Reply #10 on: April 17, 2013, 06:25:07 18:25 » |
|
ICL71363 1/2 Digit LCD/LED, Low Power Display, A/D Converters with Overrange Recovery w?w www.intersil.com/data/fn/fn3086.pdfICL71063 1/2 Digit, LCD/LED Display, A/D Converters h??p http://www.intersil.com/content/dam/Intersil/documents/fn30/fn3082.pdfICL71073 1/2 Digit, LCD/LED Display, A/D Converters h??p http://www.intersil.com/content/dam/Intersil/documents/fn30/fn3082.pdfICL71263 1/2 Digit, Low Power, Single-Chip A/D Converter h??p htty://www.intersil.com/content/dam/Intersil/documents/fn30/fn3084.pdf Key Features First Reading Overrange Recovery in One Conversion Period Guaranteed Zero Reading for 0V Input on All Scales True Polarity at Zero for Precise Null Detection 1pA Typical Input Current True Differential Input and Reference, Direct Display Drive LCD ICL7136 Low Noise - Less Than 15µVP-P On Chip Clock and Reference No Additional Active Circuits Required Low Power - Less Than 1mW Surface Mount Package Available Drop-In Replacement for ICL7126, No Changes Needed Pb-Free Plus Anneal Available (RoHS Compliant) Description The Intersil ICL7136 is a high performance, low power 31/2 digit, A/D converter. Included are seven segment decoders, display drivers, a reference, and a clock. The ICL7136 is designed to interface with a liquid crystal display (LCD) and includes a multiplexed backplane drive. The ICL7136 brings together a combination of high accuracy, versatility, and true economy. It features auto-zero to less than 10µV, zero drift of less than 1µV/oC, input bias current of 10pA (Max), and rollover error of less than one count. True differential inputs and reference are useful in all systems, but give the designer an uncommon advantage when measuring load cells, strain gauges and other bridge type transducers. Finally, the true economy of single power supply operation, enables a high performance panel meter to be built with the addition of only 10 passive components and a display. The ICL7136 is an improved version of the ICL7126, eliminating the overrange hangover and hysteresis effects, and should be used in its place in all applications. It can also be used as a plug-in replacement for the ICL7106 in a wide variety of applications, changing only the passive components. may be worth a look.. EDIT: Do not code links
|
|
« Last Edit: April 18, 2013, 07:56:44 07:56 by pickit2 »
|
Logged
|
find it , read it , share it .
|
|
|
thunderer
Junior Member
Offline
Posts: 61
Thank You
-Given: 19
-Receive: 69
I try to be patient
|
|
« Reply #11 on: April 18, 2013, 03:08:28 03:08 » |
|
Hi guys, I re-wrote the program, saved some "space" on the PIC, and got it more stable (I still have to improve it). I mean, using this erroneous way of voltage drop I managed to have a consistent difference Vsupply-Vload. Anyway, it will not stop here as I will try (first) an opamp to differentially amplify the difference and get better us of PIC ADC resolution. If not happy, I have sourced some current monitor IC (ZXCT1009) that I may use having them in my comps box. I will be travelling these days, so news come in the weekend. Below the new code: program Measurement ' Declarations section dim adc_rd0, adc_rd1, adc_rd2, adc_rd3 as integer dim tlong0,tlong00,tlong1,tlong11,tlong2,tlong22,tlong3 as longint dim ch0, ch1, ch2, ch3 as word
' Lcd module connections dim LCD_RS as sbit at RB7_bit LCD_EN as sbit at RB6_bit LCD_D4 as sbit at RB5_bit LCD_D5 as sbit at RB4_bit LCD_D6 as sbit at RB3_bit LCD_D7 as sbit at RB2_bit
LCD_RS_Direction as sbit at TRISB7_bit LCD_EN_Direction as sbit at TRISB6_bit LCD_D4_Direction as sbit at TRISB5_bit LCD_D5_Direction as sbit at TRISB4_bit LCD_D6_Direction as sbit at TRISB3_bit LCD_D7_Direction as sbit at TRISB2_bit ' End Lcd module connections
' Set-up the PIC sub procedure InitMain() OSCCON = 0x7E ' 8MHz clock OPTION_REG = 0x80 ' Pull-up disabled PORTB INTCON = 0x00 ' No INT CMCON = 0x00 ' No COMP ANSEL = 0x0F ' PORTB Digital I/Os, PORTA AIs ' on RA0 to RA3, RA4 to RA7 are DIs CCP1CON = 0x00 ' CCP disabled
TRISA = 0xFF ' All inputs TRISB = 0x00 ' All outputs
PORTA = 0x00 ' Clear PORTA PORTB = 0x00 ' Clear PORTB end sub
' Main program Main: InitMain()
Lcd_Init() ' Initialize Lcd Lcd_Cmd(_LCD_CLEAR) ' Clear display Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off Lcd_Out(1,2,"Symmetrical PS") ' Write text in first row Lcd_Out(2,3,"2x20V/1.5Adc") ' Write text in second row Delay_ms(1000) Lcd_Cmd(_LCD_CLEAR) ' Clear display ADC_Init() ' Initialize ADC module ' Display static text Lcd_Out(1,1,"S+:") ' Write in 1st row 1st position Lcd_Out(2,1,"S-:") ' Write in 2nd row 1st position
' The VI measurement Measure: while (TRUE) ' Voltage positive ' Measure adc_rd0 = ADC_read(0) tlong0 = adc_rd0 * 5000/0.122725 tlong00 = tlong0 - tlong22 tlong0 = tlong00 >> 10 adc_rd0 = integer(tlong0) ch0 = adc_rd0 div 10000 if ch0 = 0 then Lcd_Out(1, 4," ") else Lcd_Chr(1, 4, 48+ch0) end if ch0 = (adc_rd0 div 1000) mod 10 Lcd_Chr(1, 5, 48+ch0) Lcd_Chr(1, 6, ".") ch0 = (adc_rd0 div 100) mod 10 Lcd_Chr(1, 7, 48+ch0) ch0 = (adc_rd0 div 10) mod 10 Lcd_Chr(1, 8, 48+ch0) Lcd_Out(1, 9,"V") Delay_ms(100)
' Current positive ' Measure adc_rd1 = ADC_read(1) tlong1 = adc_rd1 * 5000/0.122725 tlong11 = tlong1 - tlong22 tlong1 = tlong11 >> 10 adc_rd1 = integer(tlong1) ch1 = adc_rd1 div 10000 if ch1 = 0 then Lcd_Out(1, 11," ") else Lcd_Chr(1, 11, 48+ch1) end if ch1 = (adc_rd1 div 1000) mod 10 Lcd_Chr(1, 12, 48+ch1) Lcd_Chr(1, 13, ".") ch1 = (adc_rd1 div 100) mod 10 Lcd_Chr(1, 14, 48+ch1) ch1 = (adc_rd1 div 10) mod 10 Lcd_Chr(1, 15, 48+ch1) Lcd_Out(1, 16,"A") Delay_ms(100)
' Voltage negative ' Measure adc_rd2 = ADC_read(2) tlong2 = adc_rd2 * 5000/0.122725 tlong22 = tlong2 tlong2 = tlong2 >> 10 adc_rd2 = integer(tlong2) ch2 = adc_rd2 div 10000 if ch2 = 0 then Lcd_Out(2, 4," ") else Lcd_Chr(2, 4, 48+ch2) end if ch2 = (adc_rd2 div 1000) mod 10 Lcd_Chr(2, 5, 48+ch2) Lcd_Chr(2, 6, ".") ch2 = (adc_rd2 div 100) mod 10 Lcd_Chr(2, 7, 48+ch2) ch2 = (adc_rd2 div 10) mod 10 Lcd_Chr(2, 8, 48+ch2) Lcd_Out(2, 9,"V") Delay_ms(100) ' Current negative ' Measure adc_rd3 = ADC_read(3) tlong3 = adc_rd3 * 5000 tlong3 = tlong3 >> 10 adc_rd3 = integer(tlong3) ch3 = adc_rd3 div 10000 if ch3 = 0 then Lcd_Out(2, 11," ") else Lcd_Chr(2, 11, 48+ch3) end if ch3 = (adc_rd3 div 1000) mod 10 Lcd_Chr(2, 12, 48+ch3) Lcd_Chr(2, 13, ".") ch3 = (adc_rd3 div 100) mod 10 Lcd_Chr(2, 14, 48+ch3) ch3 = (adc_rd3 div 10) mod 10 Lcd_Chr(2, 15, 48+ch3) Lcd_Out(2, 16,"A") Delay_ms(100)
wend end.
Posted on: April 18, 2013, 04:01:26 04:01 - Automerged
Paul, I do not ignore you, but I do not want the ICL chips. I have some 7107, but not yet decided what to do with them. Anyway, your very first post I found it useless (at the first sight - sorry for that!!!), but you have to know that the program changes I made (see above) are due to your suggestion to take a look at the link you gave. Thanks!
|
|
|
Logged
|
Interested and hopefully helpful in: DC brushed motor control (mainly R/C - PPM/PWM), analog audio, PIC (mikrobasic PRO). Feel free to ask, and if I can, I will help. But only on forum topics, any started private conversation will continue in a public topic.
|
|
|
max
Senior Member
Offline
Posts: 322
Thank You
-Given: 1676
-Receive: 52
|
|
« Reply #12 on: April 19, 2013, 11:08:40 23:08 » |
|
See the attached file for the high side current shunt amp.
|
|
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
kentar
Newbie
Offline
Posts: 23
Thank You
-Given: 44
-Receive: 29
|
|
« Reply #13 on: April 20, 2013, 01:37:08 13:37 » |
|
For better results , you can use a vref ic like mcp1525 or 1541 as vref instead of vcc In this case you can increase the resolution of your measurement Get more counts (50) at adc and use the average value .
|
|
|
Logged
|
Warned
|
|
|
thunderer
Junior Member
Offline
Posts: 61
Thank You
-Given: 19
-Receive: 69
I try to be patient
|
|
« Reply #14 on: April 21, 2013, 02:43:51 02:43 » |
|
See the attached file for the high side current shunt amp.
I used a differential opamp just like the one you proposed. I changed my reference to 0V (GND of the PSU) - and now have 2 differential opamps for both high and low sides. And supplied it +5/-5V. I need to do some touch-ups and move it from air-wired to final position in the PSU.
|
|
|
Logged
|
Interested and hopefully helpful in: DC brushed motor control (mainly R/C - PPM/PWM), analog audio, PIC (mikrobasic PRO). Feel free to ask, and if I can, I will help. But only on forum topics, any started private conversation will continue in a public topic.
|
|
|
|