Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Duty cycle detection

Status
Not open for further replies.
If you were thinking of using a CD4093 (or other Schmitt gate) as a buffer anyway, it would be a simple matter to use another gate in the same package to do the thresholding/comparison function too, like this :-
View attachment 108616
How much hysteresis do you actually need?
Hysteresis: not much, about 5% or so, just to avoid jitter.

Hi guys, thank you so much for all your input, but tomorrow I will be gone for a weeks' holiday, with internet access from time to time, but not means to do any testing; see y'all back then,
Erik
 
Post #50.
If your output is 0V/5V then at 100% the voltage at "RC" will be very close to 5 volts. The voltage comparitors input will be in the 2.5V to 4.8V range. Most voltage comparitors will not work when both inputs are too close to the VCC supply. With a 5V supply the input will only work from -0.4 to + 3.5V. (It is OK to have one input at 3.5V and the other at 5V) Some SPICE components do not work like real parts.
Two fixes:
1) Invert the signal so 100% = 0V and 0%=5V. Then the "RC" voltage be below 2.5V for 100% through 50%.
2) Add a resistor across C2 to pull down the voltage. (voltage divider) Set the max voltage to no more than 3.5V.


The picture is too small to read.
 

Attachments

  • duty cycle schematic and parts list.pdf
    20.5 KB · Views: 110
If you were thinking of using a CD4093 (or other Schmitt gate) as a buffer anyway, it would be a simple matter to use another gate in the same package to do the thresholding/comparison function too, like this :-
(...)
How much hysteresis do you actually need?
About 5%, just enough to avoid jitter.
 
After several weeks of experimentation I must concede that a software solution does give me all the best results:

1. accuracy and repeatability better than 0,001% on a 2.4kHz signal.
2. can be implemented on most Atmega AVR microcontrollers (Arduino, Atmega168, 328,..)
3. output usable for direct further processing in the microcontroller (in my case for an irrigation system)
4. output directly accessible for internet upload or RF transmission

The concept is as follows: I read 4 pulses of the 2.4kHz signal with direct register addressing. This gives me a 0.0625 microsecond resolution (16MHz processor clocking). For a 2.4kHz signal with 45 duty cycle (lowest obtainable value in my case) this gives me about 0.1875 milliseconds to be measured (1/2400*0.45). When my resolution is as above then I get 3000 measurements done per cycle at 45% duty cycle. Only one measurement suffices, so I get 45/3000 = 0.015% resolution.
In practice I notice that the variation in measurements is lower than 0.05% per measurement cycle of 8 measurements.
I do not think I can get that kind of accuracy with an analog system.
Anyway, I got it programmed with lots of sleepless nights, but I now have a system that measures data from a soil moisture detection probe, where I can perform statistical calculations and transmit a measured variable avery hour wirelessly to a remote mastercontroller. My program is capable of being used with a virtually limitless number of remote sensors.

What is included in the software/hardware?

1. sensor probe measurement hardware circuit (see initial post)
2. sensor signal processor using an Atmega AVR controller
3. real-time clock module to command the wake-up routine for the hourly transmissions
4. HC-12 464MHz transceiver
5. optional upload of data to thingspeak (as long as it is in my lab environment: https://thingspeak.com/channels/361794)
5. solar cell powering
6. go-to-sleep routine for the controller, transmitter and sensor hardware circuit (once an hour wake-up, measure, calculate, transmit and go back to sleep)

I just wanted to document this here as a thank you to all who helped me in this thread.
Erik
 

Attachments

  • Arduino_duty_cycle_measurement_v9.ino.with_bootloader.standard.hex
    55.5 KB · Views: 83
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top