looking for method
HI Everybody,
I'm trying to measure how long a capacitor take to get charged to a certain amount (10V - 60 V)
while supplying to another pin a PWM signal from 5% to 50% at roughly 30Khz.
I was thinking to use the comparator to sense when the voltage has reach a ref voltage.
the trouble is this is the first time i have to cope with exact timing readings.
How can i count the time from a given istant to the comparator firing?
and also should be done toghether with the PWM coming out during that time
thanks
Stefano
I'm trying to measure how long a capacitor take to get charged to a certain amount (10V - 60 V)
while supplying to another pin a PWM signal from 5% to 50% at roughly 30Khz.
I was thinking to use the comparator to sense when the voltage has reach a ref voltage.
the trouble is this is the first time i have to cope with exact timing readings.
How can i count the time from a given istant to the comparator firing?
and also should be done toghether with the PWM coming out during that time
thanks
Stefano
Comments
Then just use RCTime to measure the charge time of the cap (you'll need a resistor divider to get levels down).
More details needed: Which SX, What clock speed ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
my intention was to use sx28, the clock speed 10 to 20 mhz.
Stefano
P.S. the real thing is a boost PS that charge a large capacitor,
the time to charge to a certain level is proportional to the power i can draw from that PS.
so i should be able to decide wich load is better suited
Post Edited (ellizard) : 2/8/2007 6:54:10 PM GMT
It would be cake with the SX48. If possible I would use that. You can use one timer to generate the PWM and the other to measure the time for the cap to charge.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
thanks for the advice
I'll steer for the sx48
regards
Stefano
Sorry for stealing your time
BUT !
For wath i read about multifunction timers on SX48
I could not understand much....
how i connect the pins for: start the timer with a software start, at a stop signal from a comparison vs a ref voltage, store somewhere the elapsed time.
do some other computing, start again the process.........................
I'm confused by the description of software timer mode, capture/compare mode, it seem to me that there are described only the minimum information,
Gunther's book reports roughly the same as the sx48 datasheet reports, the same in the sx-key manual and in Al Williams's book.
No example schematic, to start with..
Searching in the forum lead me to very high topics on the subject, too high for me?
As you could understand I'm not exactly a guru in programming (probably the opposite).
Give me a startup
Saluti
Stefano
The easiest way would be to use one timer to generate the "TIMER1 PWM" command (see the help file):
TIMER1 PWM, duty, 1667 ' Generate 30KHz PWM with 50MHz clock; duty=0 to 1667
Then measure the cap with a traditional RCTIME or PULSIN command.
If you want to use the hardware timer you would use the TIMER2 CAPTURE mode.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Post Edited (Bean (Hitt Consulting)) : 2/10/2007 3:22:00 PM GMT
if i read correctly the data sheet, duty is Register 1 and 1667 is Register 2
thus to obtain a fixed frequency I should increase duty while decreasing 1667 ?
What's bringing me into confusion is the
It asserts that TIMER1 PWM, 52, 105 ' modulate at 38 kHz, 50%
How the values 52 and 105 relates to 38Khz and 50% duty?
let me know
Saluti
Stefano
Post Edited (ellizard) : 2/10/2007 4:55:44 PM GMT
As usual after answering for other informations,
I started to think in front of a spreadsheet with the real figures on it..........
And Bang it come to eyes that:
@50Mhz 1667 represents 1667 * 20ns = 29.994 Khz
and 834 (say 50% duty) is 834 * 20 ns = 59.988 Khz
All is clear now for the PWm
Still with doubts and grey areas on the capture mode.
how should do a command for starting timer, stopping for an external event (a voltage more than Vref) and storing that elapsed time in a variable?
Regards
Stefano
I am struggling with the SX48 hardware Timers.
I used for testing the simple program in the HELP FILE
With this arrangement I had a signal of 11,2 us period with a fast spike of roughly 2us measured with an analog 60 Mhz scope.
I got confused when changed the parameters to see the variations in frequency.
Changed the prescale to 5 same R1 and R2 figures, still the same 11,2 us <> 2us signal.
prescale at 5, R1 to 1000 and R2 to 1000 as well, same 11,2 <> 2us signal.
Where I am wrong?
Regards
Stefano
· You have 1600 for the duty and 1600 for the maximum. That would be 100% duty(on all the time except for one very quick spike).
· "TIMER1 PWM, 800, 1600" would be a 50% duty cycle square wave.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
·
But in the Help file;
From that reading it seems to me that to maintain the same frequency, I should increase the R1 register while decreasing the R2 register,
for shure I'm dumb (for what relates programming) but I understood that the R2 register indicated the OffCycles
and the overall frequency was given by the sum of the two registers.
I'm trying to learn by error and correction.
And also I do that in my spare time......
(this is a problem because there is no time to accomplish a finite experiment and so it's difficult to keep in my brain the correct solution)
Anyway
Thanks for your time
Stefano
Yes R1 is the on cycles, and R2 is the off cycles, but as the help file says R2 will be loaded with (PeriodCycles - OnCycles), which would be zero if both parameters are 1600.
I think what is confusing you is that SX/B does the calculation for you. You only need to specify what duty-cycle you want, and R2 will get set automatically to what it needs. In other words when you do "TIMER1 PWM, 800, 1600" SX/B will set R1 to 800 and R2 to 800.
I hope I explained that okay.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
·
So the relative values for R1 and R2 must be calculated only when programming in ASM.
I think I have understood correctly now..............
THANKS TO YOU
Regards
Stefano