The Let's Play Archive

SHENZHEN I/O

by Quackles

Part 57: Assignment #27: Ocean Monitoring System

Ocean Monitoring System



I think I have a guess...



Called it. Right on time, too, with Tilly checking in. Stay tuned for a speculations at the end of this post.






This project effectively has two parts: one that records the data in a memory chip (very, very simple), and another that sits on the radio, waits for a call, and replays the memory chip's data (not as simple). I'll start by making a fairly modular solution, and (as before) seeing how I can improve it.

Fortunately, some things work in my favor: the memory chip holds exactly 14 items (so the last 7 readings for each sensor). We need to disburse 6 of the 7 when called on. Once said disbursing is done, that'll leave the memory chip's address pointer exactly in place to write the next set of items, so there's no need for any fancy address math to get the MC ready to write again.

One more thing before I start work: I guess this is what Sun needed the ID chips to be extra-durable for: abyssal depths! It's cold down there...

[ ~ ]



   

Here's the first version. It's modular as promised.

The leftmost MC reads in sensor data and stores it to the memory chip - values are interleaved, so the order goes sonar - magnetic - sonar - magnetic ... and so on.

The upper right MC is responsible for listening to the radio and setting up playback. It waits for a notification that matches the ID chip, then gets the address of the oldest requested data (because the address get happens as the left MC is writing the data, the upper right MC goes 3-4 cells ahead of the current position). It sends that address to the lower right MC, which reads every other value, until it's read 6 values, and sends it all out the radio.

This version costs ¥11, and uses 604 average power per run. Now that it's done, I can see some avenues for optimization - most notably, the left and upper right MCs have space on them. I'll try combining the two and see how far it takes me.

[ ~ ~ ]

Thinking about the design a little, I get the feeling that optimizing for power is more important than optimizing for cost here. Sun Haotian has always been after quality work, but these are specifically going to be at the bottom of the ocean. Not an easy task to change the batteries (and there will be batteries - if they had a power cable, they could just attach a data cable to that and they wouldn't need a radio).

Anyway, I was able to combine the two MCs I picked successfully.



 

The new design is ¥10, and I got the power down to 536 units on average. (I've noticed that having fewer MCs usually results in a small power savings because each only sleeps and does common functions once.)

The big MC on the left responds to the radio - but instead of getting the address and advancing it, it uses 'mov x2 null' instructions to advance the memory chip to the right location. (This is mostly because I ran out of pins on the big MC to attach to the memory chip's address line - the big MC can't send the correct address to the little MC, and there's not enough free lines on the small MC to have it update the address on its own, so the simplest way for the big MC to advance the address is to ask for values from the memory and throw them out.)

Anyway, the small MC just loops and sends six values to the radio, like before. If it was a sonar reading, the big MC will use the '+ mov x2 null' line up near the top to move the memory chip's address pointer one more cell forward, so it's in the right place before it starts writing again.

This looks pretty close to perfect. I'll try polishing it a little more before I finalize it, though - that blank space on the first chip is calling to me.

[ ~ ~ ~ ]

I tried to improve the design further - to get it down to one MC. And for a bit, I thought I had it!
The only problem is, to do it, I ended up taking the top '+ mov x2 null' out from the big MC's code. This led to the chip passing the test cases, but miswriting data after any sonar-reading request (the miswriting corrected itself by the time the simulator checked again). Once again, test cases turn out not to be everything.

Here's the busted version. (¥7, 510 power... and it works, just not in real life if you ask for data too soon after the last time.)





To be perfectly clear: I am not shipping this design. Sun Haotian is getting the ¥10 / 536 power version (the one I showed before this one) - for one thing, it works properly. And for another, even if Sun Haotian was OK with the drawback of this version (which I don't think he is), 510 average power vs 536 is probably not that big in the grand scheme of things. (I'm hoping.)

The important part is I've done what I could, and I delivered something that fits the intentions of the spec, not just the test cases. I still don't know what Sun Haotian's building - not completely - but I get the feeling that if I deliver shoddy workmanship to whatever-it-is, I'm really going to regret it when I find out what it's all for.



And on that note...

So let's say Sun Haotian needs this for his (hypothetical) city. It'd have to be a city on the coast, next to deep ocean waters, for him to want this; he's probably worried about the risk of earthquake, volcanic activity, tsunami, etc. I'm surprised there's no seismometer in there, though.

There's only one problem with the above idea: I took a look at a nice map of the world's oceans, and the entire coastline of China is surrounded by continental shelf. I’m not sure if that counts as deep sea at all.

So what if it's not being founded in China? What if it's, say, on the west coast of Africa someplace? If we're assuming this is to measure tectonic activity, it doesn't hold up (Africa's plate extends far to the west of its landmass), but it might be a possible location. Or could it be... on the coast of California?! It'd be a nice bit of urban (re)development, especially after the 2024 quake.

We'll have to see.


P.S: REPRESENT!

P.P.S: I know there's been a lot of discussion of Lamia episodes recently, but I've fallen a bit behind and haven't had time to watch the season finale. I ask that people not post spoilers in the comments until I mention otherwise, as this one's promising to be big (not least in determining if the second season is gonna be Lamia— or Succubus...).
Anyway. No spoilers, lest dozens of tissue paper hamsters animated by succubus magic eat the contents of your sock drawer. (No, I couldn't believe it when she animated them either.)