Part 13: Assignment #4: Light-Up Signs
Light-Up SignsLooks like Joe's come up with something! I hadn't heard of the Solid Steel Gamer before today, but she seems pretty cool from her bio. Can you imagine at some live event with however many hundred of her fans holding up animated signs? That'd be pretty freakin' intimidating!
This is also notable as the first time I've had to optimize my designs for anything in particular. In this case, per Joe's hint, I'm going to try to make the signs as cheaply as possible.
Well, this is an interesting design problem. Up until now, I'd had one, or two, outputs to work with. Now I have five - and each MC only has two simple I/O pins.
Now, I could just brute-force this by throwing 3 MC4000s in there, wiring it up, and calling it a day, but the total cost would be ¥9 (or, as Carl might put it, "bloody expensive").
So: There's gotta be a cheaper way to do this.
[ ~ ]
This is my first shot at it. I noticed some interesting patterns in the output signal patterns for the sign: click-0 and click-1 are the reverse of each other, and only one of drink-0 through drink-2 are on at any given time.
Meaning: this is the perfect time to try out some of those logic gates I got access to the other day.
The left MC just drives the click outputs. It creates a simple pulse for click-0, and then the NOT gate below it reverses it to send to click-1.
The right MC is in charge of all the drink outputs. The secret here is that drink-1, arguably the most complex output of the three, is only on when drink-0 and drink-2 are off. So, the MC pushes the right output to drink-0 and drink-2 and lets an OR gate sort out the rest: normally, the OR gate would be on when either of drink-0 or drink-2 are on - but I'm using the reversed output (with the dot), so instead the OR gate is off when drink-0 or drink-2 are on, and on when they're both off.
The thing is, all those logic gates still cost money. So instead of a third MC (¥3), I've got two logic gates (¥2), for a total cost of ¥8.
I think I might be able to get it down to ¥7 if I make the left MC drive click-0 and click-1 from different output pins, and lose the NOT gate entirely. I'll have to check if the code'll fit, though.
When I mentioned this to Joe, he said, "Bet you can't get it down to ¥6!"
This is why Joe's in Sales.
[ ~ ~ ]
¥7 came pretty easily - the code on the left MC does indeed fit. However, I was talking about other potential optimizations, and someone in the ChipOverflow chat room said they thought they could actually get the design down to ¥6. For real.
Of course, they went AFK without saying how to do it, and then someone else on ChipOverflow gave me an earful because I called the wires on the board wires. (Apparently they are ~🎉 traces" 🎉~. Sigh )
I'm going to try to take a decent shot at getting the sign to ¥6, now that I know that it's (probably) possible. And I'll keep the chat open. Whoever it was said they were gonna be back soon...
[ ~ ~ ~ ]
It's been three hours. They haven't been back. The ¥6 version really really hasn't worked out.
Here's what I figured out when trying to make the ¥6 version:
Using two MC4000s is out, because that's ¥6 already and I have 4 pins and 5 nonidentical outputs.
Therefore: Use a MC6000 (¥5), and one of those Digital I/O Expander things (¥1) to push output to all three drink pins from one XBus pin.
I can't toggle the click wires on and off more than once in the MC's script or I'll eat up all my code space, so I'm gonna have to have a loop of some sort to tell how far into the cycle we are. The accumulator will be a counter for this.
The script pulses p0 once, and pulses p1 once. Each of these times uses 3 lines each (mov 100 p#, slp 1, mov 0 p#).
The script has four places where it tests to see if the counter is at the right value, then updates the drink pins. This uses 2 lines each time (teq acc #, + mov ### x3).
The script also needs a line that increments acc so it works as a counter (add 1), and two lines that roll it back to 0 when it's at the maximum value (teq acc #, + mov 0 acc). That's 3 more lines.
We have 14 lines to work with, and we've used 2 x 3 + 4 x 2 + 3 = 17.
I cannot think of any way to cut out 3 lines of code in this. Barring some sort of conditional logic epiphany, or chat guy coming back and explaining themselves, I'm calling this project done. Finished. Finito. ¥7 version it is.
For all that I spent spinning my wheels at the end there, the finished product looks pretty cool.
Anyway, MC assembly sucks and I have a headache. I'm gonna ask David what the popular drinks are in this part of China (and invite him to go get one.)