Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21

Thread: Everything I ever wanted to know about microcontrollers but was afraid to ask

  1. #1

    Default Everything I ever wanted to know about microcontrollers but was afraid to ask

    The fourth in a series of n00b question threads.

    So this guy wants me to do a 3-Watt LED conversion of his Force FX Darth Vader (haven't asked which model yet), but he wants it to be able to switch between three modes:

    • Red blade
    • Blue blade
    • Blade blinking back and forth between red and blue

    I have never done "blinking" of any kind yet, and I'm assuming there are several ways to achieve it (and I would love to hear about those options), but I'm thinking this is a good opportunity for me to expand my horizons and dip my toes into the waters of the microcontroller. (Pardon the mixed metaphors.)

    I have been exploring "The Google", and am more confused now than ever. It seems that "low-level" microcontrollers (e.g., PIC?) are not as beginner friendly as mid-level ones (e.g., NetMedia's BX-24...?), but it also seems the low-level chips are a lot more compact.

    I would prefer to have something not much bigger than a Scrabble chip and that uses a programming language not much more difficult than BASIC. Oh, and I use a Mac (OS 10.5.7). Oh, and I don't want to dish out a lot of money each time I do a new project. And hold the ketchup.

    Suggestions? Advice? Warnings?

    Thanks in advance!
    There's always a bigger fish.

  2. #2

    Lightbulb

    fair enough
    ok, that's not that easy but I'll do my best to make a long story short.

    As a matter of fact, using a bear microcontroller isn't easy since you have to deal and understand its architecture. Then you have the programming language, either assembly or evoluated language now that
    - C compilers for microcontrollers are good
    - microcontrollers have a hardware stack for function calls
    - microcontrollers have a reasonnable amount of memory

    however, the time and effort needed to learn that isn't worth if your application doesn't need huge performance. Like audio playback or sensor realtime analysis for instance.
    My day job deals with electronic systems and computers music applied to live performance, so I know this problem pretty well. Certain people from the arts side with average to good skills for computer music & programming would like to experiment with interactive arts and sensors. But they have no skills for hardware.
    Several things have been proposed like paralax basic stamps, pic basic, this sort of things. Those "mono chips" are a normal microcontroller with a simplified programming language, BASIC most of the time. Access to the peripherals are then as simple as a function call like START_TIMER1, and no more register access.

    Due to the simplification of the complexity, those chips are however damn slow. In general the program is interpreted, ie the basic program is stored, then read in real time and "converted on the fly" by the interpreter. No compiling => weak performance.

    However, if you don't need performance but just blink some accent LEDs, that's a pretty neat solution.

    The current and actual answer for artist was born a while ago in Italy, and it's called arduino. Released with a Creative Commons licence, it uses the Wiring language, and from what I remember, wiring lib warps the code to "translate" processing to C, then compiles the whole thing using GCC for Atmel microcontroller and get a executable code. Since it's compiled, performances are better than the picbasic thing.

    http://en.wikipedia.org/wiki/Arduino
    http://www.arduino.cc/

    you have many implementations of arduino, some of them are extremely minimalists with part spider soldered on the DIP package of the chip itself. Loads of tutorials, loads of youtube videos, huge community with ready made projects, code sharing and... inexpensive hardware.
    Creative commons allows people to reproduce / adapt / customize the schematic to their own needs. That's why you can find some custom arduinos at sparkfun for instance.

    I ate with one of the developpers during a workshop in Amsterdam in 2006 or 2007. Great compagny, great product, great guys. And some personnal little pride this phenomenom was born in europe

    Hope this helps,

    Happy hunting
    Erv'
    Props Electronics
    http://www.plecterlabs.com

  3. #3

    Default

    Hi there,

    Seems to me there is a bit of a difference of scope in this thread. Matt Thorn is asking a fairly simple test the waters type of question, and Erv' (being the generous and very literal person he is) gave a very detailed answer. I think we should back up a bit though and look at scope of the question here. Main question re-stated below...
    Quote Originally Posted by "Matt Thorn"
    So this guy wants me to do a 3-Watt LED conversion of his Force FX Darth Vader (haven't asked which model yet), but he wants it to be able to switch between three modes:
    Red blade
    Blue blade
    Blade blinking back and forth between red and blue
    Let's rephrase this a bit to have it make more sense. Matt, you walked into a custom motorcycle shop with a simple purpose. A motorcycle with a fat rear wheel and a blue seat. Erv' is replying by telling you where to get started on designing a motorcycle from scratch. I'm not convinced that's the path you really want to go down... Perhaps you have over simplified the design, program, and debug on a small electronic board? Have you ever done one before? It's NOT a simple project. wiring up an LED to a buckpuck is a simple project. Custom designing and programming an electronic saber driver board is a pretty serious undertaking.

    If you have never designed a single board computer or microcontroller system from scratch, don't start like this. Plan on spending a solid year doing the design if that's your goal. If you just want to get a simple board and do some programming, I reccomend buying some type of MAKE controller or something along those lines (pre-made electronic board with all the circuits needed.. you just program.) But even just that might take you 6-9 months to come up with a decent program worthy of being in a saber and working better then an MR.

    Now, assuming that you don't want a MASSIVE electronic undertaking like that (please... tell me if I'm assuming wrong and you really do...) I think your best bet is a very simple solution. Here's your original question again.

    Quote Originally Posted by "Matt Thorn"
    So this guy wants me to do a 3-Watt LED conversion of his Force FX Darth Vader (haven't asked which model yet), but he wants it to be able to switch between three modes:
    Red blade
    Blue blade
    Blade blinking back and forth between red and blue
    Get yourself a tri-color Seoul LED, Wire up the output of the MR driver board to a circuit that will simply line-switch your output. Close the loop on the blue LED, then the red LED. Either through a hilt switch or some type of blinker unit (I would have to think about what type is best.)

    That's your simple answer which can be done in 1 week... which is again what I'm assuming you are really going for. Not a 1 year long intense project.
    Edwin Tracy (Eandori)

    - Official Plecter Labs USA station for repairs and firmware upgrades, Ultrasound soon!
    - Occasional completed Lightsabers for sale there!

  4. #4

    Default

    I think I answered pretty much on the subject line, reading again the title of the topic, and matt questions. From what I read, he seems to have a interest for the microcontroller / electronic question.
    Not that he's against a simple and effective solution to his problem, but I though he was looking for gathering some knowledge to do something himself.
    while for sure he will now dive in the full custom electronic circuit board, I think that arduino or parallax BASIC chips are worth to be mentionned.

    http://www.parallax.com/

    For instance, an arduino board to prototype your ideas costs $20. The make controller is also known to be an excellent board but it quite "overkill" for the task you mentionned.
    Now, about doability, sure you'll have to learn about programming a "controller board" but it's definitly nothing compared to design a board from scratch.

    Another topic to be discussed : once prototype, what sort of experience or ressource do you target to fit the whole thing in a hilt, cause this ask the question of adapt the controller board to a new formfactor.
    PIC BASIC chip could be a good candidate since they embed the language interpreter and are small enough to fit-in-a-hilt.

    http://www.parallax.com/tabid/295/Default.aspx

    Matt, you might now clarify your needs Let us know if like eandori said you target this as a 1 year project or if it was supposed to be finished yesterday

    Erv'
    Props Electronics
    http://www.plecterlabs.com

  5. #5

    Default

    Quote Originally Posted by erv View Post
    I think I answered pretty much on the subject line, reading again the title of the topic, and matt questions. From what I read, he seems to have a interest for the microcontroller / electronic question.
    Not that he's against a simple and effective solution to his problem, but I though he was looking for gathering some knowledge to do something himself.
    while for sure he will now dive in the full custom electronic circuit board, I think that arduino or parallax BASIC chips are worth to be mentionned.

    http://www.parallax.com/

    For instance, an arduino board to prototype your ideas costs $20. The make controller is also known to be an excellent board but it quite "overkill" for the task you mentionned.
    Now, about doability, sure you'll have to learn about programming a "controller board" but it's definitly nothing compared to design a board from scratch.

    Another topic to be discussed : once prototype, what sort of experience or ressource do you target to fit the whole thing in a hilt, cause this ask the question of adapt the controller board to a new formfactor.
    PIC BASIC chip could be a good candidate since they embed the language interpreter and are small enough to fit-in-a-hilt.

    http://www.parallax.com/tabid/295/Default.aspx

    Matt, you might now clarify your needs Let us know if like eandori said you target this as a 1 year project or if it was supposed to be finished yesterday

    Erv'
    I have experience with Parallax boards, I found them quite straightforward to use. The programming language is not hard to learn either. I could always give you a hand if you decided to go that route.

  6. #6

    Default

    Erv, Eandori, Thaxos, many thanks. This is exactly the kind of information I was looking for. And Erv and Eandori were both right: I do want a simple solution to the problem at hand (getting an RGB LED to automatically toggle between red and blue at a fixed interval), but I do want to get started in microcontrollers as well. (When my post drew no responses, I actually sent a P.M. to Erv asking if he could help--Thanks, Erv!)

    Quote Originally Posted by erv View Post
    The current and actual answer for artist was born a while ago in Italy, and it's called arduino.
    That's funny, because after I sent my P.M. to you, I did a lot more digging, and I came to the same conclusion. For someone like me, Arduino seems like a great place to start with microcontrollers. I found ladyada's tutorials, and thought, "Wow. Can it really be this simple!?"

    However, I couldn't find a board that seems small enough (and simple enough) for the problem at hand: getting an FX Vader to do the three modes I described. Maybe I just need to look harder. I still don't know what those cute Lilypads are.
    Quote Originally Posted by Eandori View Post
    If you just want to get a simple board and do some programming, I reccomend buying some type of MAKE controller or something along those lines (pre-made electronic board with all the circuits needed.. you just program.)
    I came across MAKE in my Googling, but haven't really looked into it. I will do some more studying on my own before coming back with more questions.
    Quote Originally Posted by Eandori View Post
    Now, assuming that you don't want a MASSIVE electronic undertaking like that (please... tell me if I'm assuming wrong and you really do...) I think your best bet is a very simple solution. <snip> Get yourself a tri-color Seoul LED, Wire up the output of the MR driver board to a circuit that will simply line-switch your output. Close the loop on the blue LED, then the red LED. Either through a hilt switch or some type of blinker unit (I would have to think about what type is best.)
    Great advice. The first part I've already got nailed down (though I'm using a LedEngin RGBA--I haven't seen the Seoul LED yet). It's the blinking thing that has me stumped. I know I could use a 555 and a resistor to make a single color blink off and on, but I don't know of a similarly simple device that will toggle between two LEDs (and also let me adjust the time interval the way a 555 does). Do you know of something that would work?
    Quote Originally Posted by Eandori View Post
    That's your simple answer which can be done in 1 week... which is again what I'm assuming you are really going for. Not a 1 year long intense project.
    I am going for all of the above. I'm now sure I want to get into microcontrollers, despite the daunting learning curve, if only because it sounds like fun and will broaden my sabersmithing horizons. But, yeah, I'd like to take care of the problem at hand as quickly and easily as possible. So I'd like to keep this thread going as a place to talk about microcontrollers, but, as a practical matter, I am also soliciting info on simple, off-the-shelf alternatives to tasks that would otherwise require a microcontroller.

    I hope that makes sense.

    Quote Originally Posted by erv View Post
    I think that arduino or parallax BASIC chips are worth to be mentionned.
    Parallax did not even register on my radar as I was Googling. This is great information.
    Quote Originally Posted by Thaxos View Post
    I have experience with Parallax boards, I found them quite straightforward to use. The programming language is not hard to learn either. I could always give you a hand if you decided to go that route.
    Cool. Thanks for the offer, Thaxos. I hope you don't regret making it.

    Thanks again for this wealth of information. (And if you can suggest a blinker unit, Eandori, that would be great.)
    There's always a bigger fish.

  7. #7

    Default

    Im not 'up' on the Arduino at all.. but maybe the Arduino Nano or the Arduino Mini..might be suited for your size requirements..

    Im not sure of the shortcomings or differences in these units though.. voltage requirements? memory/space issues perhaps?


    anyways..

    I have some general questions if I can piggy back here..

    Where would onw go if they 'did' in fact want to start programming there own microcontrollers from scratch? or using a sub-language derived off BASIC or C?

    I will compare these to the ReplicantFX project.. where it is basically a PIC24 microcontroller... that comes pre-flashed with an "API". (so to speak) that the end user can use to make their own config/module.txt files and write a program to do whatever it is they need done.

    Whiel I have flashed chips before..and written several small programs using 'that' particular API.. where would one start (web sites/forums prefered but a nice/easy book is also welcomed) to learn about doing this from scratch? Making your 'own' API/firmware to be flashed to a chip?

    I supposed you would start learning abotu the actual microcontrollers themselves? limitations of each chip and pick one that is the most friendly to your end goal?

    this is something I wouldnt mind learning..Im in no rush..and have time of course.. (Im just a geek like that..LOL)

    something that can use FAT32..and have enough space for an API and end user code..

    anyways.. links/tips helpful..

  8. #8

    Default

    Great thread so far. Definitely moving forward with purpose now.

    You actually already nailed the first blink-unit that I was thinking of... a 555 timer circuit set up with very low speed intervals. Keep in mind though, with a 555 your digital switching output will be very low power. You'll need to go through 1 to 2 stages of amplification and/or relay to drive the full 1000mA your LED will probably be using.

    The second thing I thought of for a blinker unit is funny... I thought of an old-school blinker unit same as what old cars use in their turn-signal circuit. Simply put, an old cars blinker unit runs lots of current through a piece of metal which heats it up. When it heats up it bends away from the contact pad and the current flow stops. Then it cools down and bends back making contact again. That's how old cars actually blink their signals. Seems kind of barbaric really. It's a waste of power and not very reliable as well. So... don't do that method. I'm really just typing it out to show where my crazy mind was going.

    Another possibility could be a low frequency, low voltage clock (like 1 KHz) hooked up to a counter chip of some type. Tie the 2 relays to the highest order bit on the output of the counter and Viola! A fairly slow toggling blinker unit.

    As for turning on just one of the LED colors at a time with 1 digital input... make each relay circuit opposite polarity. One closes with active low input, the other closes with active high. Like one FET that closes when the Gate is at VDD, and the other that closes when the gate is at ground. Etc.

    I am going for all of the above. I'm now sure I want to get into microcontrollers, despite the daunting learning curve, if only because it sounds like fun and will broaden my sabersmithing horizons. But, yeah, I'd like to take care of the problem at hand as quickly and easily as possible. So I'd like to keep this thread going as a place to talk about microcontrollers, but, as a practical matter, I am also soliciting info on simple, off-the-shelf alternatives to tasks that would otherwise require a microcontroller.
    This is really where the meat of this subject is. If I was going to stick a raw number to complexity of the subject, figuring out how to switch blade colors is 1% and learning to REALLY use microcontrollers is like the other 99%. Please don't let this push you away, just be clear you are stepping into something MUCH bigger then lightsabers.

    The single best advice I can give you for learning microcontrollers is to find somebody in your local area that uses them and knows them well. You will have a lot of questions and I find they are best answered from a person and not an online post or book. If you are like me, when you read through a very complex user specification (usually written by some Engineer and not a trained writer...) you end up having tons of questions as you go. A person will let you stop and clarify something as you learn. A book, or an online post just lays it out at the author's speed.

    The first microcontrollers I used were PIC microcontrollers. They were great for my first projects. I went in steps at a time. First learning how to wire them into a breadboard, then learning how to read and write from ports and verify it with DIP switches & LED bars. Then I started doing interrupt routines. Then I started writing main programs witih many different interrupt routines based on timers and external input. It just kept adding on from there. I got a very solid understanding of the microcontroller itself before ever moving onto an actual C-compiler which really removes you from the nuts and bolts of the microcontroller.

    I'm personally very familiar with controlling hardware and interfacing microcontrollers to main computers or other devices. But I'm not very experienced with the processing and driving of sound files via a microcontroller. Erv' knows a ton about that though. In short I think Erv's reccomendations for what controllers to start with are really good. He would know much better then I for lightsaber-type uses.

    Cheers,
    Edwin Tracy (Eandori)

    - Official Plecter Labs USA station for repairs and firmware upgrades, Ultrasound soon!
    - Occasional completed Lightsabers for sale there!

  9. #9

    Default

    Thanks for another info-packed response, Eandori. Naturally, I now have a dozen or so questions.

    Quote Originally Posted by Eandori View Post
    You actually already nailed the first blink-unit that I was thinking of... a 555 timer circuit set up with very low speed intervals. Keep in mind though, with a 555 your digital switching output will be very low power. You'll need to go through 1 to 2 stages of amplification and/or relay to drive the full 1000mA your LED will probably be using.
    Okay, you lost me on "1 to 2 stages of amplification." What exactly would that entail? I'm pretty sure I understand what you mean by relays, though: using the 555 to trigger the relay, which would send power directly from the MR board to the LED, rather than having it go through the 555, right? But doesn't a 555 just do on/off? Can it do red-on/blue-on? Would I use 2 units, and somehow have them alternate?

    Quote Originally Posted by Eandori View Post
    The second thing I thought of for a blinker unit is funny... I thought of an old-school blinker unit same as what old cars use in their turn-signal circuit. <snip> I'm really just typing it out to show where my crazy mind was going.
    Actually, that was the first thing that popped to mind when this guy asked me if I could do this.

    Quote Originally Posted by Eandori View Post
    Another possibility could be a low frequency, low voltage clock (like 1 KHz) hooked up to a counter chip of some type. Tie the 2 relays to the highest order bit on the output of the counter and Viola! A fairly slow toggling blinker unit.

    As for turning on just one of the LED colors at a time with 1 digital input... make each relay circuit opposite polarity. One closes with active low input, the other closes with active high. Like one FET that closes when the Gate is at VDD, and the other that closes when the gate is at ground. Etc.
    Okay, that was all Greek to me.
    Quote Originally Posted by Eandori View Post
    This is really where the meat of this subject is. If I was going to stick a raw number to complexity of the subject, figuring out how to switch blade colors is 1% and learning to REALLY use microcontrollers is like the other 99%. Please don't let this push you away, just be clear you are stepping into something MUCH bigger then lightsabers.
    I got that impression very early on, when I first searched the forums here and came across this old thread. I also figured that the complexity was the reason there has been almost no discussion of microcontrollers here.
    Quote Originally Posted by Eandori View Post
    The single best advice I can give you for learning microcontrollers is to find somebody in your local area that uses them and knows them well. You will have a lot of questions and I find they are best answered from a person and not an online post or book.
    Since I live in Japan, Google gives priority to "jp" domain pages, and I was surprised (though I don't know why I should be) to find how much stuff there is in Japanese on the subject. I'll take a look through the Japanese forums and see if there's a friendly and knowledgeable person who lives in Kyoto. Somehow I doubt that person would be an attractive female, but one can always hope.

    It sounds like you've been doing this stuff for years. That would explain why I'm always wowed by the effects in your sabers.
    Quote Originally Posted by Eandori View Post
    I'm personally very familiar with controlling hardware and interfacing microcontrollers to main computers or other devices. But I'm not very experienced with the processing and driving of sound files via a microcontroller. Erv' knows a ton about that though. In short I think Erv's reccomendations for what controllers to start with are really good. He would know much better then I for lightsaber-type uses.
    At this point, I'm not even contemplating sound. I will leave that to people like Erv and Airsoftmode/Saberforge. I just want to have more control over LEDs, both the main blade LEDs and accent LEDs. One thing I'm daydreaming about is a blade that gradually shifts through a range of colors. But right now I just want red-blue-red-blue-red-blue...
    There's always a bigger fish.

  10. #10

    Default

    Sorry for going a bit deep on my last replies. I'm trying to gauge where your experience in electronics and programming currently is... so I can write up responses that will make sense. I undershot on my first response, and overshot on that last one. Aiming more in the middle this time

    When I was typing up electronic solutions to the red/blue switching saber, I'm making the assumption of a single digital output line going high to low voltage to control the red to blue switching. For example, a single pin going from 5v "red on" to 0v "blue on". On the 555 timer, and also the countdown-timer examples I gave, they both assume you are switching based on that one pin going high-->low-->high-->low voltage.

    Now... since red LED's turn on with + voltage, and Blue LED's turn on with + voltage, you have a problem. You need one at a time to turn on, but a single output will go high, then low. That's different then 2 inputs going high then low opposite to each other.

    That's where the other part I mentioned comes into play. Use a FET transistor to drive both red LED, and another FET to drive the blue LED. FET's exist that "turn on" with different voltages at the gate. Some turn on with high voltage at the gate, some turn on with low voltage at the gate. I was suggesting an easy fix to the polarity problem would be one of each FET type.

    If you follow me... the digital input goes high (+5v) and say the FET connected to the red LED turns on because that FET is made to "turn on" with high gate voltage. The gate voltage IS the digital output of your 555 timer. Later, the digital output (connected to both FET's) goes low, which turns off the "active high" FET connected to red, and turns on the "active low" FET connected to blue.

    So one digital output, running into 2 different FET's, each tied to a different LED. That gives you switching colors. Here's a very rough mock up of what I'm talking about.


    It sounds like you've been doing this stuff for years. That would explain why I'm always wowed by the effects in your sabers.
    Electronics? Yes, for decades, at least in some form. Sabers? Well for like... 3 years now?

    As for the effects in my sabers, probably most of that credit is for Erv's board. And Novastars sound font, but I've had a few custom things in there. Thanks for the kind words.
    Edwin Tracy (Eandori)

    - Official Plecter Labs USA station for repairs and firmware upgrades, Ultrasound soon!
    - Occasional completed Lightsabers for sale there!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •