Voltage divider i merenje napona na PIC-u

Rasprava o PIC mikrokontrolerima, PIC projekti i drugo vezano za PIC-eve...

Moderators: pedja089, stojke369, [eDo], trax

Post Reply
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Voltage divider i merenje napona na PIC-u

Post by electron »

Pozdrav društvo. Treba mi šema za merenje napona na ADC PIC reda veličina 0-300v DC. Radi se o merenju napona izlaza sa plazma aparata za sečenje. Trebao bi neki voltage divider, koje vrednosti otpornika najbolje izabrati? Izlazi sa plazme se kreću do 300V DC. Da li treba jos nesto, sta vi predlažete?
Attachments
VoltageDevider_copy_400x228.png
VoltageDevider_copy_400x228.png (28.61 KiB) Viewed 9099 times
20210430_071910_copy_400x316.jpg
20210430_071910_copy_400x316.jpg (36.04 KiB) Viewed 9100 times
Voltage_divider.png
Voltage_divider.png (21.2 KiB) Viewed 9101 times
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

10K i 660K. To ti daje 5V na izlazu za ulaz od 335V.
660K napravis od 2 otpornika 330R, i to 1 ili 2W. Ova snaga nije potrebna zbog disipacije, nego je potrebna zbog napona na otporniku. Da nozice otpornika fizicki budu dalje jedna od druge.
Mogao bi i 680K, recimo 5W. Ali ja sam uvek za varijantu od 2 komada da sastavis.
Zener bi ti trebala verovatno 5V7, da smanjis curenje kroz nju. Ne znam da li je na plazmi AC ili DC, pa mozda ce ti trebati jedna dioda na ulazu. Taj pad napona od 0.7V slobodno mozes zanemariti.
Kondezatori 100nF i 10nF obavezno. U zavisnosti od potrebne brzine odziva, ako ima mesta mozda i neki tantal 1uF ili tako nesto. I ne bi bilo lose staviti koju feritnu perlicu izmedju kondezatora i razdelnika.

I ono sta ostaje kao potencijalni problem i to moras proveriti je napon za start plazme. Koliko znam(a ne znam) plazme imaju visoki napon za start. Tipa par impulsa od 5KV.
Ako je ovo slucaj ti bi napon morao da pokupis pre tog transformatora.
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Plazma nema HF start, nego novija tehnologija tzv.kapacitivno praznjenje unutar primarnog kola, DC napon je u pitanju, operativno radi na 120-160v, napon otvorenog kola je 300-315v po specifikacijama....
Znaci 2x 330k 1-2w i 10k isto 1-2w za razdelnik napona. Koji tip z diode da ubacim od 5.7v, kao i koju,feritnu perlicu i gde tačno ubaciti?
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Ferit koji god da nadjes, ide ti izmedju razdelnika(spoj 10K i 330K) i ovih kondezatora do pica.
U sustini nece mnogo da promeni stvar, a nije na odmet da bude tu.
A ovo nisam skontao za tip zenerke. Ako mislis dal obicna zener, ili TVS, il sta vec. Ne igra neku veliku ulogu. Vidi da joj je struja curenja mala. Da ti ne kvari merenje.

Naravno opet moras dobro paznju obratiti na izvodjenje mase, da ne pravis one petlje, da ti ne resetuju pic, itd...
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

E da, da li je bolje 7 segmentni display ili lcd. Da mi plazma ne resetuje jos i LCD
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Sam si dao odgovor...
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Kako bi ovo izgledalo u PicBasicu? Da li neko zna? Na sajtu je u MPAB XC8 Code i u MikroC Code

Code: Select all

#include <xc.h>
#define _XTAL_FREQ 20000000 //define crystal frequency to 20MHz
#define digit1 PORTBbits.RB0
#define digit2 PORTBbits.RB1
#define digit3 PORTBbits.RB2
#define digit4 PORTBbits.RB3
// This array stores binary bit pattern that will be send to PORTD
unsigned char binary_pattern[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char display1[10]= {0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xE7};    // with dp turn on
unsigned int a1,a2,a3,a4;
unsigned int counter = 0;
int adc_value; //store output value from Analog Read functoion
unsigned int number;
long tlong;
unsigned int voltage;
void Analog_setting(){
    ADCON0 = 0x81;
    ADCON1 = 0x02;
}

unsigned int Analog_read(unsigned char channel){
    int aadc,bbdc, ccdc;
    if(channel>7)return 0;
    ADCON0 = ADCON0 & 0xC5;
    ADCON0 = ADCON0 | (channel << 3);
    __delay_ms(2);
    ADCON0bits.GO_DONE = 1;
    while(ADCON0bits.GO_DONE);
    aadc = ADRESH;
    aadc = aadc<<2;
    bbdc = ADRESL;
    bbdc = bbdc >>6;
    ccdc = aadc|bbdc;
    return ccdc;

}
void main(void) 
{
    Analog_setting();
    TRISD = 0x00; //define PORTD as a output pin
    PORTD=0X00;   // initialize PORTD pins to active low
    TRISB=0X00;
    digit1 = 1;
    digit2 = 1; 
    digit3 = 1;
    digit4 = 1;
    while(1)
    {
          adc_value = Analog_read(0);  // read data from channel 0
           tlong = (float)adc_value*0.488768555;
           voltage = tlong;
        
           a1 = voltage / 1000;   // holds 1000's digit
           a2 = ((voltage/100)%10); // holds 100's digit
           a3 = ((voltage/10)%10);  // holds 10th digit
           a4 = (voltage%10);  // holds unit digit value
           
        
PORTD=binary_pattern[a2]; // send 1000's place data to fourth digit
digit1=0;   //  turn on forth display unit
__delay_ms(3);
digit1=1;   //  turn off forth display unit
PORTD=display1[a3];  // send 100's place data to 3rd digit
digit2=0;    //  turn on 3rd display unit
__delay_ms(3);
digit2=1;  //  turn off 3rd display unit
PORTD=binary_pattern[a4];  // send 10th place data to 2nd digit
digit3 = 0;  //  turn on 2nd display unit
__delay_ms(3);
 digit3 = 1;   //  turn off 2nd display unit
PORTD=binary_pattern[a1];  // send unit place data to 1st digit
digit4 = 0;  //  turn on 1st display unit
__delay_ms(3);
digit4 = 1;  //  turn off 1st display unit


    }
    return ;
}
https://microcontrollerslab.com/digital ... roller/amp
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Ovaj kod, ali prikaz na 7 segmetnom displeju:

Code: Select all

' Name        : VMETERX.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : 40-pin 16F877 or similar
' Hardware    : LAB-X1 Experimenter Board
' Oscillator  : 4MHz external
' Keywords    : ADCIN, LCDOUT
' Description : PICBASIC PRO program to measure voltage (0-5VDC)
' and display on LCD with 2 decimal places.
'

' This program uses the */ operator to scale the ADC result from 0-1023
' to 0-500. The */ performs a divide by 256 automatically, allowing math
' which would normally exceed the limit of a word variable.

' Connect analog input to channel-0 (RA0)

' Define LOADER_USED to allow use of the boot loader.
' This will not affect normal program operation.
Define LOADER_USED 1

' Define LCD registers and bits
Define LCD_DREG  PORTD
Define LCD_DBIT  4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG  PORTE
Define LCD_EBIT  1

' Define ADCIN parameters
Define ADC_BITS     10 ' Set number of bits in result
Define ADC_CLOCK    3  ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS

adval Var Word         ' Create adval to store result

   TRISA = %11111111   ' Set PORTA to all input
   ADCON1 = %10000010  ' Set PORTA analog and right justify result
   Low PORTE.2         ' LCD R/W line low (W)
   Pause 500           ' Wait .5 second

mainloop:
   Adcin 0, adval      ' Read channel 0 to adval (0-1023)
   adval = (adval */ 500)>>2 ' Equates to: (adval * 500)/1024

   LCDOut $fe, 1       ' Clear LCD
   LCDOut "DC Volts= ",DEC (adval/100),".", DEC2 adval ' Display the decimal value  
   Pause 100           ' Wait .1 second
   Goto mainloop       ' Do it forever

   End
Image
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Treba u prve 2 teme u ovoj sekciji da ima objasnjeni primeri sa 7 seg LCD...
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Za razdelnik napona ulaz 0-10v , izlaz prema Picu 0-5v koje otpornike staviti 100k i 100k 1/4w?
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Ne. Impedansa koju pic "vidi" treba da je ispod 10K. Ako se dobro secam.
Tako da mozes uzeti 2 komada od 10K, pa pic "vidi" 5K, sto je sasvim ok...
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Hvala, ako nesto zapne, javim se
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Kako da mi racuna, tj prikazuje priblizno 0-300V recimo, ili 315v, 350v ...? :?:

Code: Select all

adval Var Word         ' Create adval to store result

   TRISA = %11111111   ' Set PORTA to all input
   Low PORTA.6         ' LCD R/W line low (W)
   Pause 500           ' Wait .5 second

mainloop:
   Adcin 2, adval      ' Read channel 0 to adval (0-1023)
   adval = (adval */ 500)>>2 ' Equates to: (adval * 500)/1024
   Pause 100           ' Wait .1 second
   LCDOut $FE, $80, "DC Volts= ",DEC (adval/100),".", DEC2 adval ' Display the decimal value 
   Goto mainloop       ' Do it forever

   End
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Poigraj se malo sa matematikom...
Npr
adval = adval *10 '0-10240
adval = adval /32 '0-320
Konkretni brojevi zavise od upotrebljenog razdelnika.
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Voltage divider i merenje napona na PIC-u

Post by electron »

Slično sam i uradio, ali mi na displeju ludeo prikaz kada sam simulirao potenciometrom, pogotovo kad brzo menja vrednosti
Rešio sam tako što sam napisao
LCDOut $FE, $80, "DC Volts= ",DEC3... umesto DEC
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: Voltage divider i merenje napona na PIC-u

Post by pedja089 »

Super. Bitno da je reseno.
Post Reply