Which type of logic? - Page 1
Forum section: electronics / projects

author: Randy222
author_rank: Frequent Contributor
timestamp: September 03, 2024, 08:24:37 pm
content: I making a basic dusk-dawn / dawn-dusk power switch. I have some things outside that should run only at night, while other things only run during the day.I can make the logic two ways, just not sure what the best choice is.120VAC rms input and output. I was thinking using an MC (cktPython code) for the logic because I can use a jumper between logic and SSR to select dusk-dawn or dawn-dusk mode. I just not sure if a tiny MC is better than simple 8dip comparator config.It's for outdoor use, environmentals can be 120F to 25F, and exposed to water. I would probably pot the whole thing.What would you choose for logic?

author: shabaz
author_rank: Frequent Contributor
timestamp: September 03, 2024, 09:18:37 pm
content: If your requirements are not fully defined, or if you think you may need to tweak things, then a microcontroller is likely a good option, even if your current needs are met by a comparator.But, I would not use circuitPython. That's good for a concept but generally not for production. MicroPython seems more reliable. But I would most likely use C code.Case in point: I discovered a bug in CircuitPython a while back where if power is removed or if there is a brownout that occurs within a window after a certain number of seconds after power-on, then your Python code is erased from Flash. The Adafruit fix reduced the window for this to occur but (I believe) didn't eliminate it.

author: Randy222
author_rank: Frequent Contributor
timestamp: September 03, 2024, 09:33:44 pm
content: I mentioned cktPython because I have a whole set of MC's that will run it.I could switch to a microPY MC, but I don't think it's needed.Would basically be using the MC as a type of "comparator" with code for the hysteresis. One big benefit I see with an MC is using two outputs for the SSR control, but one output is inverse of the other, essentially a jumper to select mode of operation.I am thinking any code would be super simple for this application. If I left the programming port accessible I would need to think about how to protect it when the whole thing is outside being used, so maybe a sealed access door or something. I would prefer to just pot everything leaving nothing exposed at all.

author: Andy Chee
author_rank: Super Contributor
timestamp: September 03, 2024, 09:40:52 pm
content: I can imagine an implementation using a PIC 12F675, using the ADC peripheral to read the analog light values, and implementing the hysteresis in code.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 04, 2024, 12:31:57 am
content: Quote from: Randy222 on September 03, 2024, 08:24:37 pmDo both designs in parallel ?If you can manage it with simpler logic, that will be lower power and more stable.There are simple low power timers that can give you some delay or ON time limits.Once the parts count goes above some limit, you can look to flip to a small MCU.Something with few pins that can run a 32kHz xtal could give you more options ?If this is always mains connected (likely dropper powered?) you could also count mains cycles for timing.What power is available ?

author: Randy222
author_rank: Frequent Contributor
timestamp: September 04, 2024, 04:58:02 pm
content: It's 120VAC rms (mains) for source.The PSU can be any size, but it will be made just big enough to power the logic. A 5v USB phone charging block could work, but I would build a tiny linear PSU section.I think I can do the logic with just 7 "discrete" parts; 5 resistors, 1 LDR, 1 MC. Using comparator dip would be about same amount of parts.