darb1972
Senior Member
Hi All
Is there such a thing as software block? Something a bit like writer's block?
I have a project that feels like it might never start unless I can decide on the best way to monitor a pulse.
Here's the summary of the project (I hope this makes sense):
I want to monitor 2 different mains (power) lines for activity. I have a device (one for each mains line) that acts as an opto-coupler and wave shaper (it is designed to take the mains, in my case 240V AC, reduce amplitude (via resistors) and produce a nice and relatively clean 5V logic level pulse equivalent to the frequency and duty cycle (50Hz 50% duty cycle). The devices will feed into an 08M2 as I then only need two outputs to drive some further logic. Only one input at any one time will be active. The active (mains) input will remain active until such time as it switches over to the opposite mains input. In other words, only one mains voltage will be present at any one time. Once an input is detected, the 08M2 will drive an output (high logic level only) for a brief period and then ignore that input and wait for the inputs to change state. Basically it toggles from monitoring one input to the other.
The hardware side of things isn't an issue. What I would like some advice about is code (not my strong point). At switch on (for the very first time), the 08M2 will have NO idea whether input one or input two will have a mains drive pulse on it. Should I use PulseIn or Count to monitor both pins? I think the Count command is somewhat blocking until it times out. Is that correct? I'm not sure how to monitor both inputs (initially). Should I use PulseIn to monitor both pins instead? Need some pointers here.
I also wanted to try and incorporate the Count command to count the pulses for a brief period to ensure that I'm getting a mains driven signal and not just a bit of noisy rubbish (particularly from the initial switching process). Will the 08M2 happily count pulses as slow as 50Hz??? It doesn't have to be super accurate, I just want to confirm I have received a 50Hz signal before the 08M2 outputs the applicable logic level.
Any initial advice to get me started would be appreciated.
I'm not expecting anyone to write code for me (actually, it's probably good if you don't as I'll learn more doing it myself). I'm just looking for some general advice on the commands above (or maybe some bright spark can suggest something else).
Thanks in advance.
Is there such a thing as software block? Something a bit like writer's block?
I have a project that feels like it might never start unless I can decide on the best way to monitor a pulse.
Here's the summary of the project (I hope this makes sense):
I want to monitor 2 different mains (power) lines for activity. I have a device (one for each mains line) that acts as an opto-coupler and wave shaper (it is designed to take the mains, in my case 240V AC, reduce amplitude (via resistors) and produce a nice and relatively clean 5V logic level pulse equivalent to the frequency and duty cycle (50Hz 50% duty cycle). The devices will feed into an 08M2 as I then only need two outputs to drive some further logic. Only one input at any one time will be active. The active (mains) input will remain active until such time as it switches over to the opposite mains input. In other words, only one mains voltage will be present at any one time. Once an input is detected, the 08M2 will drive an output (high logic level only) for a brief period and then ignore that input and wait for the inputs to change state. Basically it toggles from monitoring one input to the other.
The hardware side of things isn't an issue. What I would like some advice about is code (not my strong point). At switch on (for the very first time), the 08M2 will have NO idea whether input one or input two will have a mains drive pulse on it. Should I use PulseIn or Count to monitor both pins? I think the Count command is somewhat blocking until it times out. Is that correct? I'm not sure how to monitor both inputs (initially). Should I use PulseIn to monitor both pins instead? Need some pointers here.
I also wanted to try and incorporate the Count command to count the pulses for a brief period to ensure that I'm getting a mains driven signal and not just a bit of noisy rubbish (particularly from the initial switching process). Will the 08M2 happily count pulses as slow as 50Hz??? It doesn't have to be super accurate, I just want to confirm I have received a 50Hz signal before the 08M2 outputs the applicable logic level.
Any initial advice to get me started would be appreciated.
I'm not expecting anyone to write code for me (actually, it's probably good if you don't as I'll learn more doing it myself). I'm just looking for some general advice on the commands above (or maybe some bright spark can suggest something else).
Thanks in advance.