Part 19: Assignment #7: Infrared Sensor - IMPORTANT
Infrared Sensor - IMPORTANTThese jobs are getting a bit more complex. Not only do I have the sensor to deal with, there's also three other inputs that are in the form of self-contained parts: two dials and a real-time clock. (I can move the dials and the clock wherever I want on the board, at least.)
The job is complex enough that it almost looks like I'll have to use two MCs directly connected together (something I've been low-key dreading learning to set up). However, while I'm pretty sure I could direct-connect two MCs, one line in the specs means that today is not going to be that day:
"Whenever the device is armed and the sensor reads at or above a value of 20, the alarm output should be active."
And as in... AND gate!
With that in mind, here's my first attempt.
This is pretty straightforward, really. The upper MC turns its output on if the sensor is 20 or over. The lower MC turns its output on when the clock matches the On Time dial, and back off when the clock matches the Off Time dial. The AND gate turns on only if both MCs are on at once - and that's the cue for the alarm.
The spec strikes me as the type of job you could overthink pretty easily - mostly when it comes to the real-time clock. A logical (but painful) approach would be to make the timer MC check if the current time on the clock was between the 'on' and 'off' dials... each cycle. Which would require some extra math in case the Off dial is set to an earlier time than the On dial, like in the image.
I'm not gonna try to implement that here. I'm pretty sure this design is more efficient.
[ ~ ]
I've had another look at the design, and I realized you could probably fit the logic on these two MC4000s into a single MC6000. Let's try it out and see how it compares.
The updated design worked even better than I thought! The top four lines (which keep track of the clock) now set dat on or off instead of an output pin. From there, it's just a matter of testing whether dat is on and then if the sensor is reading heat, and moving the appropriate value to the alarm output (through an output expander, as I'm out of simple I/O ports again).
The simulator reports this version's power usage is about the same as the other (average 358 units - the original averaged 362), and I've saved ¥1.
Wait, we're becoming a defense supplier?
OK, so... I did come to China to make things. And a good number of the things I've helped make so far have been... junk, basically. And I wouldn't mind if I ended up getting jobs at Longteng that are a little less ignoble. It's just... I'm not sure I want it to turn into making just military gear or whatever.
I could have stayed in North America for that.
P.S: Here's the clock's datasheet.
I'm going to start organizing these datasheets into their own post on this blog, so people can refer to them all in one place, if they want to. I've just added the DT2415 (clock) to the list.
While we're talking about the clock, it's nice to see a few chips being made back in NA for once. Maybe I could convince 诚尚Micro to outsource production of their MCs to the USA. They could save a fortune in labor costs...!