Randomland - The Forum

Technology => Hardware and Software => Topic started by: Nick on Feb 12, 2010, 08:26 PM

Title: I made an LED blink!
Post by: Nick on Feb 12, 2010, 08:26 PM
So, in my quest to find myself a constructive project I bounced around some ideas. One of them was that media database program (that still will get written!) Another was to make something using the limited knowledge of electronics I gained in high-school.  So after looking online a bit I found a WIFI driven RC car. I decided that it ooked like a good project to start with and down the road I went to learn about microcontrollers.

Using a PIC16F628A  (http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010210) I have made an LED blink programmatically. Using C code even as I cant stand assembly. Forgive me if I sound a little worked up over so little, but I find all this rather exciting. Loading code onto a tinny little chip to accomplish some task in the real world, even if its just blinking an LED is kinda cool.
(http://randomland.net/sites/default/files/imagecache/Thumbnail/nick/images/LEDblink.jpg) (http://randomland.net/node/1235)

Super crappy video :)


My next order of business was to get the computer talking to the controller via serial ports. Finding a few good tutorials that used a different compiler then the one I had, and as such presented me with incompatible code. I used the free Hi-Tech C lite compiler. Its ok. But their demonstration code is confusing and documentation is atrocious.  Anyway, I took a serial communication demo they had written for another chip and did some slight modifications to make it work for the 16F628A. Very little needed changing. Just removed a line that stopped the compiler if the wrong chip was being compiled for and some useless EEPROM stuff and BAM. It's ALIVE. It was easier then I was expecting to get it working. But only because of the demo code. I could find no good tutorial for learning anything basic about the language anywhere. I think they want to sell classes so they have poor documentation.  Seems dumb.  So after a few tests in the microchip simulator, cleaning up the code some to remove strangeness that made no sense and seemed to break things and burning the code to the chip it worked!
Next is to write code to control a motor using PWM  (http://en.wikipedia.org/wiki/Pulse-width_modulation), and then build the associated hardware to be controlled. I have all the parts.... now to put them together. H-bridges (http://en.wikipedia.org/wiki/H-bridge) and logic gates (http://en.wikipedia.org/wiki/Logic_gate)!
(http://randomland.net/sites/default/files/imagecache/Thumbnail/nick/images/RS232PIC_0.jpg) (http://randomland.net/node/1236)

The output to the serial port. It also echos any characters you send.
(http://randomland.net/sites/default/files/imagecache/600px_wide/nick/images/ItsAlive.jpg)
In case you are the kind to wonder. Its alive.

 
Title: Re: I made an LED blink!
Post by: Brad on Feb 13, 2010, 11:12 AM
Awesome! I've always wanted to get into that stuff. Good luck on your RC car project, I'm interested to see your results.
Title: Re: I made an LED blink!
Post by: zourtney on Feb 13, 2010, 03:40 PM
Dude, dude, check one dude!

That's pretty sweet. I'd like to see that blinking action in person. I took a class or two in college where I did similar stuff. Just making music with assembly was very, very exciting!
Title: Re: I made an LED blink!
Post by: Nick on Feb 13, 2010, 04:24 PM
Cool. What did you use for that? And you should come have a look sometime if you want.
Title: Re: I made an LED blink!
Post by: zourtney on Feb 13, 2010, 05:57 PM
It was a microcontrollers class. I actually liked the lab portion of that class a lot. And there were certainly other classes like it in the "hardware" vein of education. But the frustrations of electrical theory made me focus on software instead.

And yeah, we should do stuff. And I'll peak at your breadboard!
Title: Re: I made an LED blink!
Post by: zourtney on May 15, 2010, 09:07 PM
Last week, I attempted failed to repair an Xbox cord that a naughty kitty got ahold of. I failed, but there is plenty of more wire to try with :) My soldering skills leave much to be desired. Got any cool project ideas? Have you played with your breadboard any more? I'd like to be a little more knowledgeable about these things. Just like most things.
Title: Re: I made an LED blink!
Post by: Nick on May 15, 2010, 10:17 PM
 I got employed and then the sun came out, so I have shelved the breadboard for a while. I still want to make  something with it though. Wifi robot seems where I was heading before. And I think I have all the parts. Just need to assemble them and write some code. And then figure out what I did wrong and why its not working.
Title: Re: I made an LED blink!
Post by: zourtney on May 16, 2010, 08:20 PM
That sounds cool. I have many projects, but this sounds like another fun one.
Title: Re: I made an LED blink!
Post by: zourtney on Aug 13, 2010, 11:40 AM
So, not that I don't have other projects, but I'm interested in seeing this in actionsome time. And "the codes" (as the internets say). I'm always interested in knowing new ways to use hardware and software :) It can inspire!
Title: Re: I made an LED blink!
Post by: Nick on Aug 13, 2010, 12:52 PM
Its fun and interesting. Like I think i said before, its using computers to interact with the 'real world.' My ultimate goal is something romotly/semi autonomously controlled with lots of cameras mounted on it. Then we can take it up to some abandoned mines and make it go exploring (or something like that.)
Title: Re: I made an LED blink!
Post by: zourtney on Aug 13, 2010, 02:20 PM
Doing stuff with cameras would always be cool. I've been working with a C-based computer vision library (OpenCV). It can be used to do template matching and all kinds of cool stuff. I'm sure it'd be a bit too processor and memor intensive for your hardware, but I like the sounds of building image recognition software into something. Though I do t know what. I should finish the projects I have already started, I suppose.
Title: Re: I made an LED blink!
Post by: Nick on Aug 14, 2010, 11:29 AM
Its a little more then what my hardware can handle, but I started cheap. You could easily get something that runs a basic linux kernel at a few hundred (or even thousand) mega hertz. The router I bought can probably handle some of it, unless it needs lots of ram (relatively speaking of course. My idea of lots of ram in 6 gigabytes, though embedded systems think that 128m is lots of ram.)
Title: Re: I made an LED blink!
Post by: zourtney on Aug 15, 2010, 08:50 PM
I wonder if there are any projects out there which run custom Linux kernels on old mobile device hardware. We're kind of at the point now where many people have two or three retired ones lying around the house. Sure, most aren't too powerful, but it's got everything you need...other than a simple way to connect it to your computer, of course  :-\
Title: Re: I made an LED blink!
Post by: Nick on Aug 15, 2010, 09:52 PM
Some old phones have linux (http://tuxmobil.org/) for them :) Easiest to get get an older (strange to say older as they have barely been out more then a year or two) android phone.  Linux to the core and easy to program for (relatively easy anyway.) You could build a whole flight computer out of one. With GPS built in you would just have to make a custom altimeter for it (thats easier then it sounds if the phone has a USB host controller built in) Then you could use the camera for horizon detection and have a FULL autopilot setup. :) Sounds fun.
Title: Re: I made an LED blink!
Post by: zourtney on Aug 17, 2010, 07:25 AM
That's cool. Too many projects, so little time :(
Title: Re: I made an LED blink!
Post by: Nick on Sep 15, 2010, 10:36 AM
This project is collecting too much dust. I think I should do something with it again. Any suggestions for small targets? Otherwise I will continue alone my (rather daunting) path to my goal of a semi-autonomous camera-carrying car. 
Title: Re: I made an LED blink!
Post by: zourtney on Sep 22, 2010, 08:21 AM
How much memory and how much processing power do you have? A less-daunting task might be good, but I too am having trouble coming up with one. You don't have Bluetooth or a USB port onboard, do you?
Title: Re: I made an LED blink!
Post by: Nick on Sep 22, 2010, 10:01 AM
Getting USB would take another board. And then it would be super slow. Serial is better. I can do serial out the wazoo. I think each chip has two or three serial ports (maybe four?.) Plus I have a WRT linksys router with 8mb flash and linux! It'll run any c++ program you throw at it (provided it will run in 16mb of memory) and it has duel serial ports to control the two chips I have.

There are tones of things you can do. Controlling flash cards over serial is relatively simple (or so I hear) People usually use that for storing route info or data logging. Video processing is kinda out of the question. Takes lots more CPU and ram then I have. And the boards to do the processing cost more. But getting a GPS chip could cost as little as about $30, or as much as several hundred. Those can be got in a serial variety so the chips can have access to the location information. If we need more memory, there are other chips that could provide a couple of megs (running at fast serial speeds, but memory all the same.)  But it would be better to get faster, bigger chips then to do all that complicated work. ATmega makes some that look pretty cool. They have a rather big chip (cost the outrageous price of $7!) that will do everything one could want. And MicroChip has some 32bit chips with built in USB host controllers. Oh the possibilities. Currently I only have a programmer for a range of MicroChip chips.

I also have everything thing I need to make a pair of motor controllers. And some motors. And a WIFI linux router box. And a strange obsession with putting cameras on things. And an age old desire to make a mars rover-type thing.

I have been thinking about starting up the soldering iron and stripping some wire again with my free afternoons. I will post something if I don anything noteworthy. Or maybe just post if I do anything at all. :)
Title: Re: I made an LED blink!
Post by: zourtney on Sep 22, 2010, 04:32 PM
I keep thinking it'd be cool to do something with the (Bluetooth) Wiimote. But it sounds like you're ill-equipped for such an adventure. I also keep thinking of making light control systems...hmm, projects, projects.
Title: Re: I made an LED blink!
Post by: Nick on Sep 22, 2010, 07:15 PM
A light control system would be fairly simple. And there are dozens of tutorials out there for it.
Title: Re: I made an LED blink!
Post by: zourtney on Sep 23, 2010, 09:05 AM
I've kind of taken a liking to those LED lighting systems I've seen behind TVs and under cabinets. That by itself, of course, has no need for a fancy logic board. Hmmm...(I guess I'm not helping)
Title: Re: I made an LED blink!
Post by: Nick on Sep 23, 2010, 03:06 PM
But you could hook it up to a light sensor and have it change colors and intensity to match the rooms lighting! Just think of something useless and your on the right track@!
Title: Re: I made an LED blink!
Post by: zourtney on Sep 23, 2010, 06:23 PM
Or signal processing on my audio channels! That could look so loud, yo.
Title: Re: I made an LED blink!
Post by: Nick on Sep 23, 2010, 06:38 PM
Now your thinking! The lights can flash with the base! Another color for the mids and treble!
Title: Re: I made an LED blink!
Post by: zourtney on Sep 23, 2010, 07:26 PM
Do you know how cool* it would be to put little lighting modules on each channel of a 7.1 surround sound system? Each speaker with its own little piece of illuminative mastery. Just think of the light show that would occur! A car wizzing by would be like a flashbang!

Which makes me think that "Flashbang Theater" would be a pretty cool band name.

* not very
Title: Re: I made an LED blink!
Post by: Nick on Sep 23, 2010, 09:29 PM
Yes it would. Or a production company. Did you just think up a name to go with all the videos you make?

But yeah, each channel? :)
Title: Re: I made an LED blink!
Post by: zourtney on Sep 23, 2010, 10:18 PM
Wait, what? I'm confused. And surely not really helping you figure out what to make! :)
Title: Re: I made an LED blink!
Post by: Nick on Sep 24, 2010, 12:35 PM
Flashbang Theater
Title: Re: I made an LED blink!
Post by: zourtney on Sep 24, 2010, 09:36 PM
I guess that would explain the confusion. On the bright side, my eyesight seems to be coming back.
Title: Re: I made an LED blink!
Post by: Nick on Sep 24, 2010, 10:24 PM
Thats puntastic.
Title: Re: I made an LED blink!
Post by: zourtney on Sep 24, 2010, 10:50 PM
Only half of it was intentional. But yeah. So what are you going to make?
Title: Re: I made an LED blink!
Post by: Nick on Sep 24, 2010, 11:15 PM
Space robots. Or maybe just a RC car with too much logic on board for its own good. Then start adding telemetry until you can navigate it from your phone.
Title: Re: I made an LED blink!
Post by: zourtney on Sep 25, 2010, 09:58 AM
Space Robot 5
Is he alive?
So very alone
So far from home


I couldn't resist.

Have any old junk laying around that needs automated? I keep trying to think of useful things, but I am not coming up with much (except super high-level stuff I have no hopes of being capable of building myself).
Title: Re: I made an LED blink!
Post by: Nick on Sep 26, 2010, 05:48 PM
Using servos and stepper motors, making complex things are easier then you might think.
Title: Re: I made an LED blink!
Post by: zourtney on Sep 26, 2010, 09:55 PM
I know. School has tainted me into thinking I am unable to do something which I am actually capable of doing. Much like the much-unused Calculus classes can halt a programmer's schooling, electrical theory halted my interest in hardware. Or perhaps it merely suspended my interest.

It's a skill I'd like to have, but and not sure I want to go through all the schooling :(
Title: Re: I made an LED blink!
Post by: Nick on Sep 27, 2010, 08:29 AM
You can do allot with only a superficial knowledge of whats actually going on. Some of the servos and what not have a kinda complicated interface, but nothing more complicated then making the LED change brightness like I did. Its all done using pulses of different widths. Or with stepper motors, pulses at different intervals (I think) Just keep count and you know (roughly) what position the motor is in. The servo will always be where you tell it to be. And they have motors that will 'tell' you what position they are in. So much cool stuff. All I can think of though is ways to make it pan/tilt cameras. :) 
Title: Re: I made an LED blink!
Post by: zourtney on Jan 27, 2011, 09:37 AM
Apparently this topic died. Maybe we were posting about random electronics projects elsewhere...anyway, sometimes I want to play with some lower level stuff.

Do any of those boards come with USB controllers? Or built in Bluetooth? I think I'd be "fun" to make a Wiimote controlled something. I keep thinking about picking up one of these, a Bluetooth dongle (http://www.newegg.com/Product/Product.aspx?Item=N82E16833242001). Not that I'll have time to play with it...
Title: Re: I made an LED blink!
Post by: Nick on Jan 27, 2011, 10:27 AM
The project is not dead! I just got the last few little resistors and such that I was missing and have been assembling a few things on beadboards. I just have little time that I am not at work, not busy and not wanting to sleep.

If you want a USB host controller then it gets a little more costly. Same with bluetooth. You need a bit of processing power to start controlling any USB devices it seems.... BUT, it has been done. (http://courses.cit.cornell.edu/ee476/FinalProjects/s2007/blh36_cdl28_dct23/blh36_cdl28_dct23/index.html) You can make things as USB/bluetooth guest devices easily enough. The USB route is easiest and many of the development boards come with a USB port on them.

The usb port is just a serial port as far as the MC is concerned, and you can use it to send it commands. Same with bluetooth, its just a serial port. But there is allot of potential for sending commands to the controller this way.

Also, it is relatively easy to get a micro-controller onto Ethernet. But WiFi is a little more costly. Unless you go the used WiFi router option.

Annnnnd, there is now a board (a slightly beefy one in terms of these things) that you can program with C#. But its all run time interpreted. And the parts are a little more complex then the others. Making it difficult to build a finished project that does not include the $30 dev board.

Part of why I have been looking at the mini x86 and arm things is because of their USB host powers. Cameras, Bluetooth, WiFi, GPS, temp sensors and so much more can easily be attached to then, for little cost, if you have that nice little universal serial bus.  But the simple (and crazy cheap ones) cant interface with any of that. The more complex (and still very reasonably priced) ones that can interface with those get rather out of my league fairly quickly.

So for simple devices that need to act upon the input from a sensor or serial commands, AtMel and PIC have got you covered. For more complex devices that you want to attach inexspensive USB devices to, you have to go with more costly boards (talking $100 rather then $25 -$30.)

But... there is always the post-consumer waste method of doing things. Using mildly dated WiFi routers that happen to posses USB host ports (think wireless printer sharing and network storage.) These are built to be as slim on the components as possible, but can be had for cheap. People have compiled drivers for webcams, printers, usb mass storage and other things. A small amount of research had told me that a USB GPS should be doable as its just a USB to serial device anyway. And if your USB device had drivers for the 2.4 kernel then you should be able to get it to work on any router that is supported by DD-WRT and has USB host ports on it (not the USB guest ports that allow it to act as a modem.)

To long? Didn't read? Want a summary?
Title: Re: I made an LED blink!
Post by: zourtney on Jan 28, 2011, 10:31 AM
Overwhelmingly awesome! What should we make?
Title: Re: I made an LED blink!
Post by: Nick on Jan 28, 2011, 12:33 PM
Something with cameras and motors. Solar charging camera rover with some kind of WiFi? Either need an ethernet camera for that, specialized video processing cips or a heavier duty system with some real memory to handle the imaging. With real CPU and memory we could even try some computer vision/navigation as opposed to just a remote controlled unit. Not that there is anything wrong with a remote controlled unit. After all, the Mars rovers were mostly remote controlled (for movement.) I have a pile of small solar cells!

Or something that does a simple task in an overly complex manner! A good example of that is the Ethernet attached hydration monitor for house plants :)

Fighting robots made of old printer parts?

Table top version of Snake made with an LED matrix?

Super universal remote? Control your TV from your computer? 

Here are a bunch. (http://hackaday.com/category/arduino-hacks/)

My problem is finding applications for things. Like, it would be easy to build a simple little unit to launch a bunch of rockets all at once, but I have no use for that after making it. Unless I have an aircraft to launch them off.....
Title: Re: I made an LED blink!
Post by: zourtney on Jan 28, 2011, 06:20 PM
I think we should all spend the weekend watching 80s movies for inspiration! :)

Yeah, I keep trying to think of useful things I could create, but don't come up with much. I still like the idea of camera-driven tone generation though...I don't know why!
Title: Re: I made an LED blink!
Post by: Nick on Feb 03, 2011, 07:53 PM
http://www.youtube.com/watch?v=8IqMbgHpAv4&NR=1

Bullet counter! That is one useful project that would use micro controllers.
Title: Re: I made an LED blink!
Post by: zourtney on Feb 04, 2011, 08:32 AM
Is that the accelerometer-based one I saw a link to on the gawkers the other day? I'm not exactly in the best video watching place. It's an interesting idea, though not very necessary. Which reminds me, we still haven't laid the smackdown on those targets, like we were talking about a few months ago. We should!
Title: Re: I made an LED blink!
Post by: Nick on Feb 04, 2011, 09:43 AM
Defiantly should!

I don't know if it was a Gawker or not, I saw it on Reddit. It looks simple enough to construct, just a (very small) micro controller and some sensors/buttons.
Title: Re: I made an LED blink!
Post by: zourtney on Feb 04, 2011, 11:13 AM
Could double as a pedometer, now that I think of it. Which would be interesting...if I walked more than 100 paces a day :P

Eve and I are going to try and sight in her scope this afternoon, if the weather holds out. Come along! (if you're not working)
Title: Re: I made an LED blink!
Post by: Nick on Feb 04, 2011, 03:17 PM
Not working, still sick. And I have plans tonight. Dinner with family.

Still going bowling tomorrow? I promise not to sneeze on anyone!
Title: Re: I made an LED blink!
Post by: zourtney on Feb 04, 2011, 10:59 PM
yep yep
Title: Re: I made an LED blink!
Post by: zourtney on Feb 07, 2011, 08:22 AM
Saw this (http://www.engadget.com/2011/02/07/pyxis-operating-environment-hits-net-leaves-no-embedded-chip) this morning. It looks like a .NET-based application environment for Arduino systems. Not that I have anything against C :)
Title: Re: I made an LED blink!
Post by: Nick on Feb 07, 2011, 11:52 AM
That sounds rather cool. But that's allot of overhead for some of those chips (they don't have much memory to spare) But cool all the same.
Title: Re: I made an LED blink!
Post by: zourtney on Feb 07, 2011, 07:28 PM
Yeah, my thoughts exactly.

I'm thinking a cool project would be a 8-bit tone generator. Seems like a pretty simple task. I don't know what you'd want for inputs and outputs, but it sounds fun. Because I like sounds. :)