astrobeed:
Se Cece dice che è tutto corretto stai pur certo che ha fatto qualche casino lui
Speriamo di no
Pighi, Astro si riferisce A Cecé, NON a te, ed io concordo pienamente. Non c'è nulla di più INCERTO delle certezze di Cecé . E comunque è un eccellente TESTER, il giorno in cui il circuito gli funzionerà stai pur certo di aver raggiunto la perfezione
(@ Cecé: si scherza.... un po' .... )
Ma che è quel guazzabuglio di fili ? Non si capisce un antani con cofandina.
Ecco appunto, Cecé è CERTO che le foto siano perfette per capire cosa ha combinato, mentre noi non ci capiamo una mazza
Cecé, il punto è che nessuno dubita che tu abbia fatto le prove, ma tutti pensano che tu abbia commesso qualche errore Domande sparse: ma quelle salsicce celesti sono da 5watt? hai paura che la corrente che possa uscire dal 328P ti mandi a fuoco i componenti da testare ? Quella millefori poggiata al centro serve per coprire il segreto delle tue modifiche ?
No, le "salsiccie" erano le uniche che avevo di quel valore, la misteriosa 1000fori ha saldato delle resistenze smd visto che non avevo le trough hole corrette, copre solo il trimmer dell' LCD
Ciao
C
@Cece
Questa versione è un po' più critica rispetto alla precedente (legge anche la capacità dello stesso circuito). Secondo me (almeno io farei così) ripartirei da zero, magari saldando il tutto su una millefori. Se hai problemi con i componenti leggi il mp.
In allegato la versione stabile. Nell'header ho incluso una TODO e un CHANGELOG.
Oggi mi dedico a tutta la parte di visualizzazione LCD, al selftest e ai menu LCD. (Compresa la gestione pulsanti)
Ho messo un ciclo do while.
Se cycle è vero ripete il ciclo se è falso lo esegue solo una volta.
Il break serve per uscire dal ciclo while interno.
//Read ADC and return voltage in mV
unsigned int ReadU(byte Probe)
{
unsigned int U; //Return value (mV)
byte Counter; //Loop counter
unsigned long Value; //ADC value
Probe |= (1 << REFS0); //Use internal reference anyway
boolean cycle;
do {
cycle = false; // One Time cycle
// sample:
ADMUX = Probe; //Set input channel and U reference
//If voltage reference has changed run a dummy conversion
Counter = Probe & (1 << REFS1); //Get REFS1 bit flag
if (Counter != Config.RefFlag)
{
waitus(100); //Time for voltage stabilization
ADCSRA |= (1 << ADSC); //Start conversion
while (ADCSRA & (1 << ADSC)); //Wait until conversion is done
Config.RefFlag = Counter; //Update flag
}
//Sample ADC readings
Value = 0UL; //Reset sampling variable
Counter = 0; //Reset counter
while (Counter < Config.Samples) //Take samples
{
ADCSRA |= (1 << ADSC); //Start conversion
while (ADCSRA & (1 << ADSC)); //Wait until conversion is done
Value += ADCW; //Add ADC reading
//Auto-switch voltage reference for low readings
if ((Counter == 4) && ((unsigned int)Value < 1024) && !(Probe & (1 << REFS1)) && (Config.AutoScale == 1))
{
Probe |= (1 << REFS1); //Select internal bandgap reference
cycle = true;
break; //Re-run sampling
}
Counter++; //one less to do
}
}
while (cycle);
//Convert ADC reading to voltage
if (Probe & (1 << REFS1)) U = Config.U_Bandgap; //Bandgap reference
else U = UREF_VCC; //Vcc reference
//Convert to voltage
Value *= U; //ADC readings U_ref
//Value += 511 * Config.Samples; //Automagic rounding
Value /= 1024; // / 1024 for 10bit ADC
//De-sample to get average voltage
Value /= Config.Samples;
U = (unsigned int)Value;
return U;
}
Da verificare.
EDIT:
//Measure cap >4.7uF between two probe pins
byte LargeCap(Capacitor_Type *Cap)
{
byte Flag = 3; //Return value
byte TempByte; //Temp. value
byte Mode; //Measurement mode
signed char Scale; //Capacitance scale
unsigned int TempInt; //Temp. value
unsigned int Pulses; //Number of charging pulses
unsigned int U_Zero; //Voltage before charging
unsigned int U_Cap; //Voltage of DUT
unsigned int U_Drop = 0; //Voltage drop
unsigned long Raw; //Raw capacitance value
unsigned long Value; //Corrected capacitance value
//Setup mode
Mode = FLAG_10MS | FLAG_PULLUP; //Start with large caps
boolean rerun;
do {
rerun = false; // One-Time
// large_cap:
//Prepare probes
DischargeProbes(); //Try to discharge probes
if (CompFound == COMP_ERROR) return 0; //Skip on error
//Setup probes: Gnd -- probe 1 / probe 2 -- Rl -- Vcc
ADC_PORT = 0; //Set ADC port to low
ADC_DDR = Probe2_ADC; //Pull-down probe 2 directly
R_PORT = 0; //Set resistor port to low
R_DDR = 0; //Set resistor port to HiZ
U_Zero = ReadU(Probe1_Pin); //Get zero voltage (noise)
//Charge DUT with up to 500 pulses until it reaches 300mV
Pulses = 0;
TempByte = 1;
while (TempByte)
{
Pulses++;
PullProbe(Probe1_Rl, Mode); //Charging pulse
U_Cap = ReadU(Probe1_Pin); //Get voltage
U_Cap -= U_Zero; //Zero offset
//Eend loop if charging is too slow
if ((Pulses == 126) && (U_Cap < 75)) TempByte = 0;
//End loop if 300mV are reached
if (U_Cap >= 300) TempByte = 0;
//End loop if maximum pulses are reached
if (Pulses == 500) TempByte = 0;
wdt_reset(); //Reset watchdog
}
//If 300mV are not reached DUT isn't a cap or much too large (>100mF)we can ignore that for mid-sized caps */
if (U_Cap < 300)
{
Flag = 1;
}
//If 1300mV are reached with one pulse we got a small cap
if ((Pulses == 1) && (U_Cap > 1300))
{
if (Mode & FLAG_10MS) // <47uF
{
Mode = FLAG_1MS | FLAG_PULLUP; //Set mode (1ms charging pulses)
rerun = true;
//goto large_cap; //and re-run
}
else // <4.7uF
{
Flag = 2;
}
}
}
while (rerun);
//Check if DUT sustains the charge and get the voltage drop
if (Flag == 3)
{
//Check self-discharging
TempInt = Pulses;
while (TempInt > 0)
{
TempInt--; //Descrease timeout
U_Drop = ReadU(Probe1_Pin); //Get voltage
U_Drop -= U_Zero; //Zero offset
wdt_reset(); //Reset watchdog
}
//Calculate voltage drop
if (U_Cap > U_Drop) U_Drop = U_Cap - U_Drop;
else U_Drop = 0;
//If voltage drop is too large consider DUT not to be a cap
if (U_Drop > 100) Flag = 0;
}
//Calculate capacitance
if (Flag == 3)
{
Scale = -9; //Factor is scaled to nF
//Get interpolated factor from table
Raw = GetFactor(U_Cap + U_Drop, TABLE_LARGE_CAP);
Raw *= Pulses; //C = pulses * factor
if (Mode & FLAG_10MS) Raw *= 10; // *10 for 10ms charging pulses
if (Raw > UINT32_MAX / 1000) //Scale down if C >4.3mF
{
Raw /= 1000; //Scale down by 10^3
Scale += 3; //Add 3 to the exponent
}
Value = Raw; //Copy raw value
//It seems that we got a systematic error
Value *= 100;
if (Mode & FLAG_10MS) Value /= 109; // -9% for large cap
else Value /= 104; // -4% for mid cap
//Copy data
Cap->A = Probe2_Pin; //Pull-down probe pin
Cap->B = Probe1_Pin; //Pull-up probe pin
Cap->Scale = Scale; // -9 or -6
Cap->Raw = Raw;
Cap->Value = Value; // max. 4.3*10^6nF or 100*10^3uF
}
return Flag;
}
pighixxx: @Cece
Questa versione è un po' più critica rispetto alla precedente (legge anche la capacità dello stesso circuito). Secondo me (almeno io farei così) ripartirei da zero, magari saldando il tutto su una millefori. Se hai problemi con i componenti leggi il mp.