I use this code :
Code:vmax = 0 for cnt =1 to 70 adcin 3, v_cal vmax =vmax max v_cal pause 100 next cnt v_cal=vmax * 5000 ' I use VDD as Vref v_cal=div32 1023 write 0, v_cal.LowByte pause 10 write 1, v_cal.HighByte pause 10
I use this code :
Code:vmax = 0 for cnt =1 to 70 adcin 3, v_cal vmax =vmax max v_cal pause 100 next cnt v_cal=vmax * 5000 ' I use VDD as Vref v_cal=div32 1023 write 0, v_cal.LowByte pause 10 write 1, v_cal.HighByte pause 10
Then you have saved the value as a Voltage.
And 117 means 117mV.
Since I = E / R ... with a 0.02 ohm resistor ...
0.117 / 0.02 = 5.85 Amps
Dividing by 0.02 is the same as multiplying times 50.
117 * 50 = 5850 or 5.850 Amps.
DT
One truck with e-beer for Mr.Darrel ! With thanks for fratello !
Now another worm walk to my convolutions ! If at start of colecting samples, my motor give me one peek (or "n" peeks) of voltage , but the real v_cal ( from the end of route) it's smaller than peek(s) , it's possible to reject them ? Something like here : http://www.picbasic.co.uk/forum/showthread.php?t=12183
It's possible to use :
Code:AvgCount CON 70 ' Number of samples to average FAspread CON 50 ' Fast Average threshold +/- Reject CON 2 ' Spurious Rejection level ...etc - see post
Last edited by fratello; - 15th November 2010 at 17:07.
Since the whole code don't fit into 12F675, I give up...till hw upgrade...
So, I put in my code one little delay (pause 500) before starting ADC reading...I hope it's enough.
It's ok with "pause'... I have though just one question...
If I use this code:
....Code:DEFINE OSC 4 DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 50
how small can be "pause' for correct reading of ADC ?Code:for cnt = 1 to 3 adcin 3, adval vt=adval * 5000 vt=div32 1023 grup=vt+grup pause 20 next cnt vs=grup / 3
Thanks in advance !
It can be zero.
Dave
Always wear safety glasses while programming.
You will still get correct A/D readings without any pause at all in there.
I guess it depends on how much the signal is changing, as to whether the average will be accurate or not.
DT
Bookmarks