Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Ibblebibble
Nov 12, 2013

I'll be honest, I've been speaking Mandarin for ages and I've always pronounced it like somewhere between 'ts' and 'jj' in Korean. Might just be a Southeast Asia variant.

Adbot
ADBOT LOVES YOU

Quackles
Aug 11, 2018

Pixels of Light.


Self-Driving Car Stuck In a Loop? You May Be Entitled to a Settlement



Before I moved to China, I was never really in a position to afford a self-driving car. I guess it's a bit of a blessing in disguise, with this sort of thing going on.

I'd joke that bicycles are the way of the future, but the air quality readout on my tablet menu is telling me that that's a really bad idea, at least in Shenzhen.

The_White_Crane posted:

The best advice I heard for an English speaker emulating a Chinese "zh" was to use the sound that is in the middle of "pleasure" or "leisure". Though I expect that depends on what your particular dialect of English is.

Ibblebibble posted:

I'll be honest, I've been speaking Mandarin for ages and I've always pronounced it like somewhere between 'ts' and 'jj' in Korean. Might just be a Southeast Asia variant.

I've mostly been pronouncing it... OK, so you know how there's a 'juh' sound if you say 'Japan'? Or there can be. I've been pronouncing the 'zh' like that, maybe a little more blended with the 'en' at the end. So it's more of a... "Shen-j'h-eh-n".

I'm not exactly a linguist or anything, but so far so good.

Quackles
Aug 11, 2018

Pixels of Light.


Infrared Sensor - IMPORTANT








These 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...! :D

Quackles fucked around with this message at 00:19 on Aug 28, 2018

Pierzak
Oct 30, 2010
Next stop: design a murderbot.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Pierzak posted:

Next stop: design a murderbot.

acquired is a simple input that indicates the presence of a target.
scream is a standard input that measures volume of screaming detected.
stab is a standard output that controls stabbing depth of an attached knife.

Carbon dioxide
Oct 9, 2012

TooMuchAbstraction posted:

acquired is a simple input that indicates the presence of a target.
scream is a standard input that measures volume of screaming detected.
stab is a standard output that controls stabbing depth of an attached knife.

Do you have stairs in your house?

Quackles
Aug 11, 2018

Pixels of Light.


Working Remotely





I do hope her car's not in a Rogue Loop or anything.

Pierzak posted:

Next stop: design a murderbot.

I know you're joking about this, but if they do actually ask me to design one, I'm quitting on the spot.

Carbon dioxide posted:

Do you have stairs in your house?

I am protected. Guess how you get to my (21st floor) apartment?
Yes, there's also an elevator.

Quackles
Aug 11, 2018

Pixels of Light.


Virtual Reality Buzzer





Ooh, this seems like a cool idea. And— man, I gotta congratulate David in person when I next see him!
Now, let's see what the specs are for this thing.







Uh-oh.
The bit with the radio seems straightforward. That's not the problem. As the datasheet says...

quote:

Reading from the C2S-RF901 when no data is available will yield a value of -999 instead of blocking until data arrives (which is typical XBus behavior). With the C2S-RF901, you can keep working while you wait for data to arrive!

What the problem is is that the buzzer isn't a straight on-off output like I expected. You have to pulse it. And 'off' packets can come in at the end of a pulse or right before the beginning of the next one, so it looks like ignoring input until the start of a new pulse is right out.

I think the best way to do this might be to join two MCs together (I knew this'd be the case sooner or later). MC #1 samples info from the radio, and sets its output pin to on or off depending on whether the buzzer is supposed to run. MC #2 pulses the buzzer whenever its input pin is on.

Seems pretty simple, when broken down. What could go wrong?

[ ~ ]



 

This is the first prototype. It behaves exactly like I described above (the tcp in the first MC lets it check for 0, 1, and -999 without having to store the value from the radio), but you might notice something strange about the second MC.
It turns out there's something I didn't know, or didn't realize, about chip timing:

Suppose you have two MCs connected two each other, by simple I/O ports. Chip #1 sends a value to Chip #2 midway through its script.
Chip #2's script is still running while Chip #1 gets its value ready to send.

Let's say Chip #2 is supposed to read the value that Chip #1 sends. If the "read data" instruction is earlier in Chip #2's script than the "write data" instruction is in Chip #1's, the write will happen after the read and the read will get the old value from the pin.

This is what happened to me while I was building the prototype. The effect was to make the buzzer start pulsing late.

 

This is what the 'nop' instructions are for in MC #2. 'nop' stands for "no operation" - literally, "do nothing". They're just there to make MC #2 wait for MC #1 to tell it what to do.
There's an unfortunate side effect of 'nop'. Unlike 'slp' instructions, 'nop' instructions do consume power at the usual rate. I'm paying electricity to have the chip stand around idle, and it shows. The simulator says the design has an average power usage of 348 units, which feels kind of high for this application.

There has to be a better design out there - but what? I'm going start by going back to the drawing board and trying to do it all with just one MC, maybe a MC6000. The script'll be a bit more complex, but it'll almost certainly be more efficient.

[ ~ ~ ]





Here's what I came up with. It's 10 lines of code, so it does need the MC6000, but the simulator says it's more efficient (284 average power - about a 20% savings over the original). Slightly cheaper, too, so that helps it as an impulse buy.

The first few lines are like MC #1 from the original prototype - testing the radio input, then setting dat to indicate whether the buzzer's on or off. acc is used to store the current state of the buzzer - it's set to 100 when the buzzer's switched on, set to 0 when it's turned off, and pulsed with the not / moved to the output the rest of the time.
I'm still not that satisfied with this design, though I can't see a good way to improve it. It looks like you do have to check the radio every cycle to be able to stop the pulses on time, and that's the real stumbling block here... right?

Let's send it out and see what response I get.



Just a note: that's David's first response, and it does work great for him 'cause he's got a quality headset. Regarding selling it to act as an accessory, David did note that some of the lower-powered VR headsets on the market might not quite be able to drive the current version's power requirements - the device needs to use at least 30% less power* to be compatible with everything. It feels like a better-optimized version is out there somewhere... but how?

*About 200 units or less, on average.

Readers, can I ask for your help with this?
(I'll post a Engineer's Corner about the ways you can wire MCs together once we get this sorted out.)

Quackles fucked around with this message at 00:19 on Aug 28, 2018

pumpinglemma
Apr 28, 2009

DD: Fondly regard abomination.

I see a way to cut the cost and maybe the power - you could replace dat's role by p0, throw in an AND gate between p0 and p1, and switch out the MC6000 for the cheaper model. The code would look something like this:

tcp x1 0
-jmp pulse
+mov 100 p0
+mov 100 acc
mov 0 p0
pulse: mov acc p1
not
slp 1


But I certainly don't think that would give a 30% reduction.

RichardA
Sep 1, 2006
.
Dinosaur Gum

Quackles posted:

Readers, can I ask for your help with this?
Hint1: In this design you never receive two signals in one time-step
Hint2: The radio has an internal buffer.
Hint3: Consider the possible timing for the off signal in a pulse.
Solution: A pulse is mov 100 p1, slp 1, mov 0 p1, slp 1. You don't need to check between the two sleeps - if the off occurs during the gap it would result in a output of 0 anyway.

Also in the Infrared Sensor it might be possible to fit in a slp acc with acc being the time until the sensor is armed instead of looping and checking each time-step.

Sydin
Oct 29, 2011

Another spring commute
I managed to get a design down to 180 power. Code is at the bottom but if you just want a hint: No signal (-999) is your downtime and you want as little as possible happening when receiving it to conserve power. In particular, you shouldn't need to do any mov operations unless the buzzer is on.


mov x0 acc
tgt acc -1
+ mov acc dat
teq dat 1
+ mov 100 p1
+ slp 1
+ mov 0 p1
slp 1

Sydin fucked around with this message at 15:51 on Aug 24, 2018

pumpinglemma
Apr 28, 2009

DD: Fondly regard abomination.

Hold on, something weird is going on here. If you miss the "off" input on x0 before outputting 0 on p1, you'll be doing the right thing for that time step, but won't you then continue pulsing when you should have stopped?

Sydin
Oct 29, 2011

Another spring commute
I realize I said You shouldn't have to do any mov operations, when the very first instruction in my setup that always runs is a mov operation. Nothing like trying to explain code in cryptic hints at 7AM :downs:

That said I messed around with it a bit more and managed to get power all the way down to 146. I even managed to shrink the code down to 7 lines and remove the need for dat so it can use an MC4000 and save two bucks:


tgt x0 -1
+ not
teq acc 100
+ mov 100 p1
+ slp 1
+ mov 0 p1
slp 1

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
It bugs me that you can use nops to precisely align instruction execution timing across two different chips. That doesn't feel very realistic to me.

Carbon dioxide
Oct 9, 2012

I think a much more sensible way to do this than using nops is by using the X-bus because an X-bus connection between two chips will block the reading chip until the writing chip is ready to send something. I wonder how much power it would save to take the prototype and change nothing other than making the inter-chip connection using the X-bus and removing the nops.

Grayshift
May 31, 2013
Power usage down to 146. Still not lowest bar on the histogram though.

Strat: Uses/abuses the fact that all non -999 inputs can be considered toggles rather than sets in the test data. 0 = 1!

tgt x0 -999
+ not
teq acc 100
+ mov 100 p1
+ slp 1
+ mov 0 p1
slp 1


This kind of solution has always made me feel there's a missed element that would introduce even more replayability to Zachtronic game levels - a "quality" ranking based on whether your solution passes just the bare minimum test cases, and higher quality grades being granted on optionally passing increasingly more rigorous test cases. Whether your design is cheap Chinesium crap or precision German engineering. Like in the Baron von Schnapps puzzle, my solution falls apart if there's ever a test case where both the Point and Foul buttons are pressed on the same cycle. But there isn't, so I get away with it!

Edit: Thinking about the quality grading more, I can sort of see why it might not be a great idea. As the stringency of the requirements increases solutions would tend to converge and those clever hacks around recognizing patterns in the input data would disappear. Having the most freedom in the bargain-bin quality grade means it would always be the most interesting category. I don't think it would be a bad idea, the higher quality grades would always just be optional.

Grayshift fucked around with this message at 20:04 on Aug 24, 2018

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
You can optimize for different things. A category that's all about minimizing power requirements, one that's about passing more complex test scenarios, one that's for minimizing component counts, etc.

EponymousMrYar
Jan 4, 2015

The enemy of my enemy is my enemy.
Infinifactory, the only Zachtronic game I own and kinda enjoy does that. There's separate achievements for each optimization in a level, considering that it's outright impossible to fully optimize some things at the same time.

IE: when optimizing a factory for time you'll need to use more blocks so you can do multiple things at once, which is the exact opposite of optimizing the footprint (minimizing the amount of blocks in your solution.)

mercenarynuker
Sep 10, 2008

I don't understand a dang thing in this LP because I'm not a programmer, but I'll be damned if I can't look away. I know everyone is posting streamlined elegant solution ideas, but could we see some kind of burly, over-engineered, trashy solution to one of these as well?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

mercenarynuker posted:

I know everyone is posting streamlined elegant solution ideas, but could we see some kind of burly, over-engineered, trashy solution to one of these as well?

That's pretty much what the first solutions in each update have been. Maybe not as wasteful as I think you're imagining, but a straightforward, unoptimized approach to the problem.

GuavaMoment
Aug 13, 2006

YouTube dude

Grayshift posted:

Edit: Thinking about the quality grading more, I can sort of see why it might not be a great idea. As the stringency of the requirements increases solutions would tend to converge and those clever hacks around recognizing patterns in the input data would disappear. Having the most freedom in the bargain-bin quality grade means it would always be the most interesting category. I don't think it would be a bad idea, the higher quality grades would always just be optional.

I remember a post from the games thread. Every person has 3 solutions to every level in this game - what the customer wants; ehhh this assumption makes my life easier; and gently caress IT, IT PASSES CERTIFICATION, SHIP IT.

Sometimes the first one isn't possible...

Sydin
Oct 29, 2011

Another spring commute

TooMuchAbstraction posted:

That's pretty much what the first solutions in each update have been. Maybe not as wasteful as I think you're imagining, but a straightforward, unoptimized approach to the problem.

Yeah I've liked the LP direction so far of "show off a rudimentary design that fulfills the specs but nothing more, then a second round of refining the solution and explaining it. It's pretty much how I approached the game back when I was obsessed with it: first you solve the problem, then you solve it elegantly.

klafbang
Nov 18, 2009
Clapping Larry

Sydin posted:

Yeah I've liked the LP direction so far of "show off a rudimentary design that fulfills the specs but nothing more, then a second round of refining the solution and explaining it. It's pretty much how I approached the game back when I was obsessed with it: first you solve the problem, then you solve it elegantly.

I agree with this, and add that I also like that the “best” solution isn’t shown but left as an exercise to the thread.

Carbon dioxide
Oct 9, 2012

Note that none of the "requirements" our engineer posts like minimum power or whatever are actually necessary to beat a level. All you need to do is have your design pass a bunch of test runs.

But that highscore histogram that shows up after you first solve a puzzle, man. If you see a lot of people did better than you you want to improve as well.

whitehelm
Apr 20, 2008

Grayshift posted:

Power usage down to 146. Still not lowest bar on the histogram though.

You're not going to be able to get the lowest bar necessarily because there are things in the game that haven't been "unlocked" yet in the LP (you can go back to earlier problems using new stuff). Also it's usually not possible to get all lowest bars at the same time.

Quackles
Aug 11, 2018

Pixels of Light.


Building a Better Buzzer

Wow, thanks for your outpouring of support! It looks like there were, in all, three different 'camps' of solutions. I'll discuss each in no particular order.

And Gate Version

pumpinglemma posted:

I see a way to cut the cost and maybe the power - you could replace dat's role by p0, throw in an AND gate between p0 and p1, and switch out the MC6000 for the cheaper model.

But I certainly don't think that would give a 30% reduction.





This was a clever idea - abstracting the "pulse AND on" logic to a logic gate. It's certainly cheaper than my final solution (₯5 / 284 pwr), at ₯4 / 238 pwr (16% reduction). The fact that it still pulses every time unit is probably what keeps the MC from saving too much power, but it's pretty smart. Thanks @pumpinglemma!


The next two versions both rely on a fact I'd missed about the radio:

RichardA posted:

Hint2: The radio has an internal buffer.

Meaning, that when data comes in to the radio, you don't need to read it on the same time unit as when it shows up. The radio will hold the data in its buffer until you're ready.
I'm at least half tempted to blame the datasheet for being unclear, even though I did quote the relevant line (ft "buffer") right in my post.

With this in mind, you don't have to check the radio when a pulse is being made - just when you'd be about to make a pulse.


Buffered Radio - The Hacky Solution

I call this version The Hacky Solution because, at a certain level, it's a hack, relying on the fact that the doorbell (transmitter) always sends a 1 followed by a 0 later. This is exploited because it toggles on or off whenever any data is received, not bothering to check the packet's actual value.





While this solution is certainly efficient in both cost and power (₯3 / 146 pwr - 49% reduction), it does have the pitfall of potentially getting stuck so that the buzzer is on when the button is not being pushed (perhaps if the 'off' data packet is lost due to signal interference) with no way to get it back to normal (pressing and releasing the button won't reset it).

I don't normally make hacky solutions on the job out of respect for the intention of the specifications, but it's a cool optimization! Thanks, @Sydin and @Grayshift!


Buffered Radio - The Clean Solution





This solution is basically the same as the Hacky Solution, except it stores the data packet in acc and checks the value before pulsing (or not). This is what @RichardA was hinting at - thanks Richard! - with his hints.
The solution uses ₯3 and 176 power (38% reduction) - David is happy to hear about the improvement, and it looks like this is how it's going to go out on the market!


Reader Comments and So On

Carbon dioxide posted:

I think a much more sensible way to do this than using nops is by using the X-bus because an X-bus connection between two chips will block the reading chip until the writing chip is ready to send something. I wonder how much power it would save to take the prototype and change nothing other than making the inter-chip connection using the X-bus and removing the nops.

It's a good idea, but there's a fly in the ointment. XBus doesn't really work like simple I/O, where the data is always available after it's been written. For each XBus read, there has to be exactly associated XBus write - you can't read the same packet twice after writing it once*. And if you write a packet, there had better be someone to read it in the same time unit or the writing MC blocks and it's an error.**

So, even if you have MC #2 wait for XBus to turn on, you either have to keep sending XBus packets every time you want MC #2 to pulse - and if you send a packet during the pulse while MC #2 isn't listening, error.

*I/O Expanders don't work like this, because they don't have code and so always respond to every XBus read/write as it comes in.
**I'll explain more about this in my upcoming post.


I did think of a hybrid approach where MC #1 signals MC #2 to turn on with XBus, and then sets a simple I/O pin to tell MC #2 to stay on (or not). Of course, then, you're back to needing at least one nop to adjust the timing...



 

(In case you're wondering: ₯6, 279 avg power.)


mercenarynuker posted:

I know everyone is posting streamlined elegant solution ideas, but could we see some kind of burly, over-engineered, trashy solution to one of these as well?

Believe me, just hang around me long enough and I'll post a few of those. :P


klafbang posted:

I agree with this, and add that I also like that the "best" solution isn't shown but left as an exercise to the thread.

I'm not gonna do this every time, but the more a problem bothers me, the more likely I am to ask for help.


TooMuchAbstraction posted:

It bugs me that you can use nops to precisely align instruction execution timing across two different chips. That doesn't feel very realistic to me.

This only works 'cause they're both 诚尚Micro MCs, the chips have the same effective clock speed, and every instruction (not counting slp or XBus-I/O instructions, which we're deliberately not using) takes the same amount of time to run. I don't think I'd be able to pull it off, otherwise.

RichardA posted:

Also in the Infrared Sensor it might be possible to fit in a slp acc, with acc being the time until the sensor is armed instead of looping and checking each time-step.

I'm going to work on this and get back to you, actually. That's a good idea - the only issue is that the calculation of how long to wait vs run only needs to be done once - but there's also the consideration of how long to wait or run the first time when the device is started in the middle of an off (or on) period.

Carbon dioxide posted:

All you need to do is have your design pass a bunch of test runs.

In the words of Jie (I may be paraphrasing a bit): "There is a difference between finishing a design and finishing a design well."


BTW, here's the radio's full datasheet.



Anyone want to take any guesses on how you're supposed to pronounce "C2S-RF901", exactly?

Quackles
Aug 11, 2018

Pixels of Light.


Engineer's Corner #4: Putting It All Together

"It is a truth universally acknowledged that a MC in possession of output pins must be in want of being connected to a second."
—Pride and Prejudice and Microcontrollers, revised edition (2022)

OK, I made that quote up. But sooner or later you will have to connect two MCs together. And there's two ways to do it. Both have benefits and drawbacks.

1. Simple I/O

Simple I/O pins can take values from 0 to 100 (the exact voltages vary depending on whatever variant of MCX000 you're using - my simulator abstracts away the details). Once you push a value out to a simple I/O pin, that pin stays set to that value until you reset it to something else. You can read it at your leisure. Simple, right?

There's a catch, of course, and it's got to do with timing when you push a value out to a pin. The time a chip has run after it wakes up at the start of a time step can be measured in single instructions (I'll call them "ticks"). With the exception of instructions dealing with XBus I/O, which can run long waiting for data, every instruction takes one tick to run.

So, here's the problem - this came up in the virtual reality buzzer job. If you have two chips, and Chip #2 reads from Chip #1... but Chip #2 reads at 2 ticks after wake, and Chip #1 writes at 4 ticks after wake, Chip #2 will read old data unless you make it wait for Chip #1 by padding its script with 'nop' or other instructions.

The rule is that Chip #1 writes and Chip #2 reads, Chip #2 must read after the tick where Chip #1 writes the value, or it won't work.



If you're not clear what's going on in this example, note that last tick, MC #1 wrote a new value and MC #2 read (the old) value, on the same tick. Next tick, MC #2 will read the new value successfully.


2. XBus

XBus: The industry standard for digital I/O. Sends values from -999 to 999, and can send multiple values per time unit in a handy 'packet' form. There's even a special instruction - slx - that will cause a MC to wait for I/O from an XBus port, as many time units as necessary*.

Like you'd expect, there's a catch or two to this, too. XBus is a synchronized I/O protocol, meaning: If you send a value over XBus, there must be someone on the other end to receive it, and during the same time unit, too. If there isn't, the sending MC will block and that's an error. In the same vein, if you try to read a value over XBus, and there's no one on the other end to send it during the same time unit - yep. The receiving MC will block, and that's an error too.
(Though if your reading MC is ready before your writing MC, you can just use slx to make it wait*.)





On top of that, any value can only be read once - if you read from an XBus pin twice, the MC'll assume you're getting a two-value data packet and wait to receive two separate values. This can trip you up with parts like the radio, which will only send each value in a data packet once, and then report -999 (no more data).

One more thing: If you send a value over XBus and there's more than one MC connected that can receive the value, only one of them will get it. Whoever reads first wins. (If they both read at the same time, it's anyone's guess.)

*You only need to use slx if you expect the MC to receive XBus input in a later time unit. If you're, for example, sending something out with XBus and getting a reply in the same time unit, no slx is necessary - the read will wait properly, without drawing extra power or erroring out.


In Summary:

1. Simple I/O

Perks:
• Write once, read more than once (value stays stable once you set it)
• Write and read in different time units if you want
• Multiple readers from one source is fine!

Perils:
• 0-100 ONLY!
• Must time reads to run after writes, if they happen in the same time unit.
• Because of timing issues, reading more than one value in the same time unit isn't recommended

2. XBus

Perks:
• Any value, from -999 to 999
• Wait until you receive input with slx
• Multiple values in one time unit

Perils:
• Can only read a value once - this is what lets you read multiple values in one time unit!
• If there's no one at the other end of the line (now), your circuit breaks
• There can be only one! (reader for each writer, and vice versa)
• If using slx to wake a MC, you have to do something with the value being sent or it's an error

RichardA
Sep 1, 2006
.
Dinosaur Gum
My current best, which doesn't need the acc register, is
code:
- slp 1
  teq x0 1
buzz:
+ mov 100 p1
+ slp 1
+ mov 0 p1 
+ slp 1
+ teq x0 -999
+ jmp buzz
at 125 power. It is essentially a two state machine. The default waiting state sleeps until it receives a on signal, and then transitions to the buzz state. In the buzz state it outputs a pulse until it receives a signal, assumes it is an off signal, and transitions back to the default state. If that assumption bothers you it can be removed by an extra test at a cost of 11 more power.

AceOfFlames
Oct 9, 2012

mercenarynuker posted:

I don't understand a dang thing in this LP because I'm not a programmer, but I'll be damned if I can't look away. I know everyone is posting streamlined elegant solution ideas, but could we see some kind of burly, over-engineered, trashy solution to one of these as well?

If you want that I guess I could LP this game...

idhrendur
Aug 20, 2016

GuavaMoment posted:

I remember a post from the games thread. Every person has 3 solutions to every level in this game - what the customer wants; ehhh this assumption makes my life easier; and gently caress IT, IT PASSES CERTIFICATION, SHIP IT.

Sometimes the first one isn't possible...

So, another area where it matches real-life engineering.

Of course, in real life it's the managers and company culture determining which kind of solution you do, not the actual engineers. Most times.

Sillyman
Jul 21, 2008

Quackles posted:

Anyone want to take any guesses on how you're supposed to pronounce "C2S-RF901", exactly?

Judging by the rhyme structure, "Cee Two Ess Arr Eff Nine Oh One".

Quackles
Aug 11, 2018

Pixels of Light.


Prototyping New Ideas




Looks like there's a generic prototyping area in the simulator! It's got access to a bunch of parts that I haven't run into in projects yet:

• Bigger memory chips - 33-item variants of the 100P and 200P.
• Basic I/O - Switches, buttons, dials, and LEDs.
• Cool Parts! - A few extra parts that I haven't seen before: Keypads, LCD screens, and a math co-processor! (datasheets below)











I might make something with these...

VERY IMPORTANT: I'll take suggestions, but there's no guarantee I'll do any or all of 'em. My actual job comes first!

Quackles
Aug 11, 2018

Pixels of Light.


Shenzhen Days: Things Visitors Say



The word 'Communist' in 'Communist Party of China' is basically a historical artifact nowadays.


Sillyman posted:

"Cee Two Ess Arr Eff Nine Oh One".

Congratulations! I have successfully annoyed David by chanting the rhyme from the datasheet at him.

Quackles
Aug 11, 2018

Pixels of Light.


Little Help?



Ooh, this sounds like a fun project. A game controller! A low-end game controller, if Carl is to be believed, but who cares I'm finally working in the games biz

Er. (ahem) Anyway. On to the spec.






From the looks of this, this probably isn't doable with one MC alone (not enough simple I/O ports). Which is good! It'll give me a chance to practice my XBus chip-coordinating skills.

[ ~ ]



 

Not bad for a first try! As usual, cost is a priority (it seems to be that way with a lot of clients...), and all that empty space in the first MC is really making me wish that I could just use a MC4000. Sadly, I can't see any obvious way to save a pin from the first MC as long as it's responsible for getting the X and Y values. (I did try connecting both the radio's pins to the same XBus pin on the MC, but that gave me an error.)



What the design's actually doing is pretty straightforward for the 'get and send the x/y' values bit. For the next part, the MC6000 pings the small MC by the buttons, which does the calculation for the third item in the data packet and returns that on the same wire (where it gets promptly sent up the chain).

Looking at this, the ping-response architecture I've just set up... I'm inspired. I could extend this! Be right back.

[ ~ ~ ]



   

Here's the modular version. Both of its stats are worse than the original (₯8 / 262 avg power VS ₯9 / 333 avg power), but it's built so cleanly! Everything is nice, commented, discrete. The dispatcher MC4000X at the top pings the other two and gets back the X/Y values and the A/B button calculation, and sends them... and I even managed to use every port on the top MC!
(This is my first time using a MC4000X, by the way.)

This is almost certainly not going to be the version I submit to the client. But making it was refreshing; a balm for my soul.
[sigh] Anyway, back to work.

I've started to notice that, in general, the more chips I add, the greater the power usage is likely to be. I'm reconsidering my initial assessment that this job couldn't be done with just one MC - as long as the buttons (which are on/off inputs) get turned into values with an expander, I no longer have the port shortage that got me to split the design off into two MCs in the first place. I'll try making that design and see how it stacks up.

[ ~ ~ ~ ]





The masked avenger single MC6000 strikes again. The pattern I had previously noticed continues to hold true, as this version is cheaper than my original, and about as power-efficient (₯6, 264 avg power). The only downside comes to readability in the A/B calculation section, where I'm exploiting the full power of the MC's conditional flags to get the job done properly.



And that, as they say, is a wrap.



You know, there have been a lot of jobs lately where it's looked like two full MCs were the way to go - but a single MC6000 and attendants proved to be the most efficient solution. I wonder when I'm going to stop being able to use this design pattern?

By the way, David introduced me to Xiaomei. She seems really nice, kind of nerdy in her interests - when we weren't talking (when I got up to order, etc) she was chatting to David about what David says are various popular TV shows. (I have to take it on David's say-so, 'cause they were talking in Chinese.)

whitehelm
Apr 20, 2008
You can get the correct outputs by sending 0 and 1 straight through, and subtracting 8 from 10 and 11, so the #button values section can be changed to
tgt x2 9
- mov x2 x1
+ mov x2 acc
+ sub 8
+ mov acc x1
which gets you down to 238 power.

whitehelm fucked around with this message at 02:21 on Aug 29, 2018

NGDBSS
Dec 30, 2009






I'm guessing as before that you can't get too complicated with the arithmetic tester? I was most surprised to see it use regular Polish notation (with prefixed operators) rather than reverse Polish notation (with suffixed operators), but apparently that shows up in Lisp.

sincx
Jul 13, 2012

furiously masturbating to anime titties
I really wish I had the foresight to turn my Digital Systems I and II labs into a video game.

Xerophyte
Mar 17, 2008

This space intentionally left blank

NGDBSS posted:

I'm guessing as before that you can't get too complicated with the arithmetic tester? I was most surprised to see it use regular Polish notation (with prefixed operators) rather than reverse Polish notation (with suffixed operators), but apparently that shows up in Lisp.

It's the natural formulation in almost any functional language, since using prefix notation exclusively means your functional language can treat arithmetic operators like any other function. Lambda Calculus only has unary functions*. In a simple functional language an expression + 2 3 is really interpreted as + 2 first constructing a single-argument "add-two" function, which is then applied to 3 to produce 5.

Reverse Polish Notation is (or, well, was) more popular because it's very simple to implement on actual (non-lisp machine) hardware. You don't even need a parser or any memory storing what the user has previously entered as with regular polish notation. Your implementation can just be a stack of numbers, and you can parse input tokens immediately and without context. If the user enters a number, you push that number on the stack. If the user enters an operand, apply the operation to the top elements and push the result. Entering 3 2 + on an RPN calculator is just treated as 3 sequential instructions of "push 3 -> push 2 -> add top two stack elements and push the result".

I realize you knew that but for the thread, the simplicity of implementation is why RPN is probably more expected as something a piece of hardware might just do. As for why Shenzhen went with the regular notation here, I'm guessing Zach just thought people would be less familiar with it so it would be more of a fun challenge to work around. Zachlikes usually do a good job of making programming weird but internally consistent, so it feels like you're exploring something fun and challenging.

* Lambda calculus doesn't really have functions, it just has lambda. Lambda is kinda-sorta a unary null function and numbers, and addition and so on are defined in terms of that kinda-sorta function. Anyhow, not super relevant.

Carbon dioxide
Oct 9, 2012

For the modular design, would it matter at all to use parallel processing? That is, to have the radio listener first ping both other chips and then wait for both to return, instead of pinging one, waiting for that, pinging the other, waiting for that?

I don't think the stats tracked by the game care about this at all but in real life I'd certainly do that with that kind of design.

Adbot
ADBOT LOVES YOU

Quackles
Aug 11, 2018

Pixels of Light.


Feel the Connection and Get Ahead!



Honestly, I'm glad I have people in my life. Otherwise, I'd end up having to— I don't know— join a bunch of internet forums to meet people or something.


whitehelm posted:

You can get the correct outputs by sending 0 and 1 straight through, and subtracting 8 from 10 and 11, so the #button values section can be changed to...
[...]
which gets you down to 238 power.

Oh, that's clever! Thank you!


NGDBSS posted:

I'm guessing as before that you can't get too complicated with the arithmetic tester? I was most surprised to see it use regular Polish notation (with prefixed operators) rather than reverse Polish notation (with suffixed operators), but apparently that shows up in Lisp.

It doesn't look like you can chain operators, no. So you have to fish the result out of the MathMC if you want to use it in a second calculation.


Carbon dioxide posted:

For the modular design, would it matter at all to use parallel processing? That is, to have the radio listener first ping both other chips and then wait for both to return, instead of pinging one, waiting for that, pinging the other, waiting for that?

诚尚Micro MCs don't consume additional power while they're reading XBus data but haven't gotten a value yet. I think it's a sort of mini-slx. It doesn't matter for my simulator's metrics, but for a case like this (had I sent the modular design off to SleepCUBES) it probably would have been better to parallelize the design as much as possible, to speed the time between ping and data return - it might matter for a game console! 30 FPS = 33.3 ms, and I'm not sure what options 诚尚Micro offers for clock speeds in the MC4000/6000 lines (I just know there's more than one).

While we're on the subject of time, longtime readers might have noticed that the definition of a 'time unit' is a bit flexible to the simulator. To give an example from past jobs, the infrared sensor only wakes up once every 15 minutes or so! On the actual factory floor, "slp 1" gets translated into "slp amount_of_time". MCs are pretty customizable!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply