View previous topic :: View next topic |
Author |
Message |
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sat Feb 20, 2010 6:59 pm Post subject: ADC with Pulseout and wait |
|
|
Hi
I m using pulseout 25ms to drive a selonoid but at the same time I want to measure the opening time of selonoid with simple opto coupling interface. My worry here is, Will AVR be able to carry out pulsein measurements and adc conversion while generating pulseout.
A prompt reply will save my day and money. |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Sun Feb 21, 2010 12:19 am Post subject: |
|
|
easy,but what adc for optocoupler?what are u measuring?if time of opening,then just use int0/1 for the optocoupler in isr mode like this
start tmr
give 25ms pulse
in the isr:stop timer&u got the opening time |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sun Feb 21, 2010 7:37 am Post subject: |
|
|
Hi
Thanks
Actually adc will measure the current drawn by the selonoid while optocoupler is used to measure the selonoid opening time as when the selonoid is fired it will disrupt the light falling on the base of phototransistor thus making a logic low on a pin of AVR. The problem which I m anticipating is the measurement of the current ( I m using ACS714) and the pulsein function because the pulse out or wait uses software timers making Avr busy for the specified time leaving no resources to carryout other tasks.
Thanks again. |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Sun Feb 21, 2010 8:13 am Post subject: |
|
|
ok,same thing:first measure opening time then measure adc value inside the isr
just use pulseout with no dedicated timer to save resource |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Thu Feb 25, 2010 7:11 am Post subject: |
|
|
Thanks
What if I use timer for the pulse and use pulsein to measure the time.
The question here is how to generate 25ms pulse using 8 bit or 16 bit timer using simple math. remember this pulse generation will not occur in the main loop but in sub and the measurement will also be done in that sub. this sub is being called from a while wend loop inside the main do loop.
thanks again |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Thu Feb 25, 2010 7:26 am Post subject: |
|
|
ok, like this :
- pulse=hi
- delay 25ms using timer1
- pulse low
- start timer1 as timer
- wait until opto low
- stop timer, record the counter
- measure the adc
- done ( go see my wife at bed,hehehehe ) |
|
Back to top |
|
|
|