Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Electronics - introduction to PICAXE - 08M

"So what so exciting about a programmable microchip?" I hear you ask.

"Lots.", I hear me reply. And I've just had a tiny glimpse of what they can do.

This is a rough outline of how they do what the do so well.

You buy this little bit of plastic with some pins sticking out of it. This one costs around $2. It's a little computer that can read stuff connected to it, and respond to the outside world by manipulating stuff connected to it. Inputs and outputs.

It's surprisingly powerful. In fact is has the same processing speed as my first computer.

I never looked in side my first computer, but I doubt that this was all there was inside.



My little chip has 8 pins.

Each of them does interesting stuff.











The top two pins are to connect your power lines.

One + 4.5 volts, and one - 0 volts.











Useful force can be applied to a problem, because of the difference in these two voltages. A rock sitting on top of a hill is stored force, because there is a downhill. If there were only uphill, or only downhill, you'd just have regular powerless rocks. But combine an uphill with a rock on it, with a down hill, and we have some potential energy.

So useful force exists because we can tap into the difference between these two voltages.

The next two pins are so your chip can chat with a computer like the one you are sitting in front of now.

I dont know how that stuff works except to say a cable goes from these pins to a computer, and as a result you can successfully store instructions on the little chip.

You can also see some stuff on your computer screen so you can tell what's going on in there.

But more about that later.

The bottom four pins are the interesting bit. They allow inputs and outputs.

Within this chip they can be referred to by your instructions as C.1, C.2, C.3, and C.4.









What this allows you to do is write a program that controls the temperature in a grow house with  something like this...

Start
Check the temperature from a thermometer connected to pin C.1
         if its too hot, turn on a switch (connected to a vent fan) connected to pin C.2          otherwise don't worry about it
         wait a few minutes and count sheep for a bit
go back to the start and recheck over and over again for ever, in case the weather has changed


That's not a real program or anything, that's just the kind of thing you might ask of one.

I wish that was real programming. Then I'd be an expert, because that's just my thoughts on any regular day.

I count a lot of sheep.

But you can also do a lot more than that. For instance just on the subject of keeping your grow house temperature sane, you could take a temperature inside and out, compare them, decide which is the better temperature, and run the fan only if its an advantage to do so. After all, if it was hotter outside than in, and you blew your too hot air out, it would be replaced with even hotter air from outside. Perhaps you could choose to draw in air from somewhere cooler.

I can think of a dozen different things I could control in the grow house alone.

The really cool thing, is there are a stack of incredibly inexpensive components that you can buy, that are light sensitive, sound sensitive, distance, moisture, GPS, touch, vibration....everything you can think of. And they can all be attached to a pin, have some decisions made, then those decisions can control things like lights, motors, switches, locks, pumps, robot arms, clocks, electric toothbrushes, toys, lawn mowers, and everything else you didn't think of in that first bit, where I got you to think of everything.

Electronics - PICAXE 08M Proto board additions

I'm not really sure the level of detail I should go to with this electronics thing.

For instance, the PICAXE system uses a form of a programming language called BASIC, and I think I should at least discuss it a little, but I don't want to bang on about it too much.

What I think I'll do is promise to only put up two posts with computer programming examples.

I think I'll describe the reuse of bits of programs and why its a really efficient thing to do, and I think I'll also describe "If Then"" statements, because conditional branching of program flow is really the way computers do what they do. And maybe variables.

But that's it. Three posts.

And they wont all be in a row.

I'll explain those things later.

But in the mean time I've been learning an amazing amount of stuff and reading everything I can lay my hands on. In fact I've been reading so much that I've forgotten to write about it.

I've also been working on my mini computer.

I removed some bits of my little kit and added a few things to make it a bit more useful to me.

It now looks like this...

I realise you don't know what it looked like before, so you will just have to trust me that this is much better now.

Actually, the previous post has an image of the back of it, but that also fails to incite the excitement in the viewer that I feel, having put the thing together.

Instead of making a torch, I can now make a digital, computerised torch. It works the same, but is much more high tech, and costs a bit more.



The main thing I did was to put a row of contacts on the bottom so I could plug it into a breadboard and play around a bit without the need to solder things.

The breadboard is the white thing, and allows you to poke bits of wire in where clips hold them in place. You can also add electronic components the same way.

This way you can build a fully functional project without committing to soldering it before you have tested it, so you can have everything working the way you want it.

It's amazing to think that in a few months I'll have a new skill. It will be one that I'll spend the rest of my life learning, but I'll be able to do useful stuff with my new electronics skills soon.

I cant wait.

Doing 120 Things in 20 years has turned out to be a very worthwhile thing to do. It takes almost all my time, but I get to learn so much amazing stuff.

It turns out if you stop watching TV, you free up a stack of hours in your life.

Popular Posts