This is an ethernet cable, it's how devices can communicate to the ethernet and internet
sending packets to and from each other in order to accomplish tasks.
Ordinarily you'd have to plug this into magnetics, a PHY, and a MAC before you'd be able to send
or receive any packets.
Except for me, in which case you just cut a bunch of the wires off and you wire two
of them into this little ATTiny85 here.
They're actually the RX wires on the switch end, so they're TX from the AVR.
As you can probably guess that means this is simplex, you can only send packets.
I have here a simplified diagram where you can see the wires coming into the AVR, there
are absolutely no passives and two switches on these two pins right here in order to be
able to detect when a pin is clicked or not.
So, let's go plug this in right now.
Uum.
Just plug it in that port there.
And you can see it started linking at ten megabits per second.
It's currently sending packets over to my computer right here, so, the packets are coming
in.
Each packet is a dot.
And, if I click the switch, right here, it starts sending a different kind of packet.
I can actually detect when this switch is clicked or this switch is clicked by sending
a different value.
So, let's get a little bit more into how this works.
When you are running off of a power supply, I'm running at 4.6 volts, it actually uses
less than 10 mA.
So, I dare say this might be simplest and lowest power ethernet enabled device I'm aware
of.
10-BaseT is particularly convenient for this because it operates at - you guessed it - 10
MHz - and it's a very simple encoding scheme.
So, the first part that I have to worry about is the media detection, and that's very simple.
All we have to do is send one of these ticks every 16 ms and the switch will recognize
us as an ethernet enabled switch.
The next one is send the packet, this would be particularly difficult if we were trying
to do something clever, but you'll see later on, we're not.
Really all it is is a series of highs and lows, it has to be differential signaling
that's why we need to have two wires, so whenever one is high the other is low and vice versa.
And we send a sequence if the signal goes from a high to a low, then we're sending a
1.
If it goes from a low to a high then we're sending a zero.
And so the beginning of the message is called a preamble.
We send a series of 1's and 0's and 1's and 0's and it's a fairly low frequency wave,
it works out to about 5 MHz.
When we're ready to actually go send the message, we switch around to having a series of zeros
and then the message.
So it goes from hi lo lo hi hi lo lo hi to hi low low hi low hi lo hi then whatever rest
of the ethernet message we want to send.
Since we're not actually doing anything clever here.
Really all we're doing is pre-writing all of the the packets.
There's only three packets so they can conveniently fit inside the flash, then I go and convert
this packet into raw assembly code where it goes and sets up some stuff and then it proceeds
to, one byte after the next, flip the output pins backward and forward so all I'm doing
here is one instruction after another, each being issued at one clock cycle at 20 MHz,
switching the two pins, differential output pins on port B, backwards and forwards.
So, this right here is what it takes in order to even be able to send three packets.
It uses about 7 kB.
For the actual code, all I do is I set up the clock, set to 20MHz, this is different
on each AVR, probably temperature unstable, and it makes it completely unsuitable for
any kind of practical real world application.
Really, don't use this project.
And then down here, set up the outputs, look at the switches and every so often, send A
packet if the switch is down or B packet if the other switch is down, or C packet all
the time no matter what.
All of the source code is available on github, but really I do want to urge that you should
never ever use this, and this project should probably go die in a fire.
OK!Have fun!