LC-3 Assembly interpreter for the Parallax Propeller

As part of a future project to build a portable LC-3 simulator, I have written an almost complete LC-3 interpreter for the Parallax Propeller. LC-3 is a 16-bit word-addressable assembly language designed for the LC-3 micro computing system. The LC-3 system was designed for educational purposes and is designed so that it can conceivably be manually written as binary machine code. Wikipedia has a good description of the history of the system and the general purpose of it. In addition, there is a complete ISA available for download for LC-3. The object I’ve written has a few minor exceptions to the ISA which are described in the comments of the object.

The code is written in PASM and runs in a single cog. This was to allow you to write the LC-3 program over the HUB RAM without fear of overwriting existing SPIN code. This was my first “serious” coding project in PASM, so it took a bit longer than it should have taken getting around the learning curve of PASM. The finished source code can be DOWNLOADED HERE.

Thanks for reading!

Posted in Objects and source code, Propeller | Leave a comment

Building Radio Transmitter/Receiver circuits: Tips and tricks

Normally this is a project blog, but I’m going to “break the mold” today and share some of the things I wish I had known about radio circuits. I attempted to build radio transmitter circuits for years and always ran into unexplainable problems. Most of the time, I would a schematic off of the internet and attempt to recreate it, rather than writing my own, because I had no idea whatsoever about what actually made them work. I would build it to the minute specifications (more on that later) and would still end up with a completely non-functioning circuit. The few times I did end up with a working circuit would be after I unplugged a few components that I had previously assumed were vital to operation, thus causing more confusion. One particular circuit I attempted again and again was this one. Once I was finally able to obtain all the odd parts required for this project (and for such a small circuit, there are quite a few of them) I tried to actually build the circuit but to no avail, I simply couldn’t get it working. I tried looking around on the internet for information, but found surprisingly little that was actually helpful, which is why I am writing this now. Here is what I have found about radio transmitting/receiving circuits:

1. The Capacitor
90% of schematics that you will find for radio circuits involve a 4-40pf variable (“trimmer”) capacitor. This simple part is almost IMPOSSIBLE to find. Unless you have a RadioShack near you that sells 20 year-old RadioShack components OR you have access to an old transistor radio, you will likely never have access to this part. The good news? You don’t need it. The purpose of the variable capacitor is to tune the frequency, allowing you to select the exact frequency on which the device transmits. However, you can just use a 22pf capacitor and tune the frequency using the coil, as I will explain below. (If someone does, in fact, know a good source for these capacitors, shoot me an email at info@microcontrolled.com, and I’ll credit you in this blog post.)

2. The Coil
Every single radio circuit you could ever build will require one of these, a hand wound coil. Instructions in schematics can range anywhere from “5 – 8 turns of 22-24 gauge magnet wire over a straw” to “5 13/23 turns of 24 gauge enamel coated wire over a 0.847 inch air core”. Neither of these are correct. The performance of your coil depends heavily on many parameters that simply cannot be monitored. When winding a coil, standard 22 gauge enamel coated copper wire (“magnet wire”) is preferred, though with tuning, you could probably get away with using insulated 24 gauge wire. The main point here is TUNING. Yes, one thing that schematics often leave out is that you will need to TUNE your coil if you expect it to work. The preferred method of tuning is to use a ferrite bead, but a screw will also work. Let’s first discuss how to actually wind the coil. If you are transmitting or receiving on the standard AM/FM band, wind anywhere from 7-12 times around a screw. That’s it. Regardless of how many times it says to wind it, you can get away with just about anything here. Leave the screw in the circuit while you solder it together, and apply power to your circuit. Insure that everything is working right, then proceed to tune your coil. Turn on a radio and find an empty frequency to work with, then SLOWLY unscrew the bolt from your coil. It will make your life easier if you use a plastic screwdriver, as a metal screwdriver (or your hand) is conductive and will mess with the frequency tuning, causing you more trouble than it’s worth. Even a scrap of plastic that you can twist the screw with will work better. Anyway, twist the screw out until you hear something on the radio. If you DON’T hear something on the radio, try adding more turns on your coil. (and make sure that you are actually transmitting something) Once you get it tuned, glue the whole thing down and don’t move it until the glue drys. One little movement could mess up the coil.

3. The Antenna
Though this can technically be a simple strip of wire, a good antenna will save you a lot of trouble in the end. Like the coil, movement of the antenna can highly affect the functionality of the device. Even the antenna touching metal could mess up the transmission, even if the wire is insulated, so I would suggest you spend $5-$20 on a good antenna if you want no trouble with it. If you can’t, bend a wire antenna around the frame of your circuit board and glue it down. You will need to tune the coil accordingly, but it works. I have made several transmitters that work like this.

4. The Construction
This can really cause frustration if you don’t know about it: DO NOT BUILD RADIO CIRCUITS ON A BREADBOARD! It will not work once you transfer it to a protoboard and solder it down, or even if you build another circuit on the breadboard. Each metal strip in the breadboard causes electrical “noise” that interferes with the radio transmission, so you should just avoid it entirely.

I think that this is conclusive, if you need help assembling your own radio circuits, contact me at info@microcontrolled.com and I will help you out. If you have your own contribution to make, I will post it here and credit you with the idea.

Thank you for reading!

Posted in Analog, General | Leave a comment

Light up your hallway!

Do you live in an apartment, condominium, or dormitory? Do you want all your neighbors and friends to know how ridiculously geeky you are? Than this project is for you! Basically, this circuit waits for a knock at the door, then turns on an LED in the peephole that lights up the hallway outside. It uses a Parallax Sound Impact Sensor to detect the door knock and a simple analog circuit to hold the LED on for a few seconds after the signal is received from the sound impact sensor. Here’s the schematic:

“Port 4″ is replaced by the sound impact sensor, which can be wired up to it’s respective pins. I used a bright blue LED for mine, and it’s quite effective in getting attention. You will need a simple power converter of your choice to power this circuit, I would suggest a PowerTwig , but you can use just about anything. A resistor could probably suffice. One thing: If you plan to use this project, I strongly recommend powering it either from wall power (if there is an outlet close by) or a rechargable 9V battery. I’ve found that a standard 9V battery only lasts 3 days if continuously powered.

I hope you found this mini-project interesting, I’m working on some bigger things that I’ll post about soon.

Thanks for reading, and thank you to all my readers! This site is starting to get 350-650 views PER DAY, and is now paying for itself! (to cover hosting/domain fees) You guys made this possible, thank you so much!

Posted in Analog, Completed Projects | Leave a comment

Stingray Robot – Update 3

All new robot circuitry and weaponry! This is the first modification to the actual robot itself, as all other updates have to do with the remote. This update re-writes all the code and re-builds all the circuitry. The default Robot driver board has been replaced with a Propeller BOE and duel HB-25 motor controllers. This mean that the Xbee and the SD card are now integrated into the board, eliminating the connectivity issues that was had with the old setup. In addition there is a full audio setup on the Prop BOE, so the WAV player is more effective than before. Due to the fact that the HB-25′s are controlled differently than a simple H-bridge, the steering code had to be entirely re-written, which is why this update has been so long in coming. That, and the fact that I’m lazy and don’t update my blog much. This project was actually finalized mid June.

Oh, and did I mention that in addition to all this, the robot has been outfitted with a 10 shot Nerf gun? No more reloading between shots!

Here’s a picture, click it to see it larger:

Here’s the Pros and Cons list I attach to each Robot update I do:

PROS:
- More reliable system
- SD card actually works more than half the time
- Xbee errors are almost completely gone
- No longer hard to duplicate the project (The robot control board was obsolete)
- Rechargeable battery system built in
- Robot is faster due to the elimination of the PMW system
- New nerf gun means you can launch a full assult from up to 100 ft. away
- Easily Detachable Nerf gun

CONS
- Steering is a little bit harder
- Power draw is more (due to the HB-25)
- Nerf gun will fall off if you hit it on something. (disadvantage of it being detachable)

Anyway, hope you liked this project! If you have any questions, feel free to contact me at info@microcontrolled.com
Thanks for reading!

Posted in General | Leave a comment

Hacking, Modding, Programming……

I’ve been doing things a little out of the norm lately. Specifically, as the title suggests, hacking, modding, and programming. Not the physical hacking and modding that most of you are used to seeing on this blog, but code-only modding with the popular Java game Minecraft. I wanted a way to learn Java coding, but most outlets for coding in Java involved assuming that you already knew some of the basics of coding in Java, which I hadn’t. That is, until I found out about Minecraft modding. It had hundreds of tutorials out there for people that didn’t have any experience at all coding, and it was quite easy to pick up. I had downloaded eclipse so I thought I would give it a shot, and I made a few mods. The first one was a waste of time, getting about 350 downloads (more than I could dream of getting on Propeller code, but a low count for a Minecraft mod) however I gained a valuable experience in what to do and what not to do when modding. The second one had some time put into it, and it became mildly successful, getting over 3,500 downloads in a month and still counting. I won’t post the details of the mod here, as I know most of my followers are technical readers who couldn’t care less, but if you want to know about it you can see the link in the Minecraft forum here: http://www.minecraftforum.net/topic/1095388-125ssp-mo-splosions-v12-the-ultimate-explosives-mod/

(keep in mind, I only linked to the good one) :)

Though electronics is my preferred outlet of interest, it has one caveat: Expense. Programming does away with this, which is why I have been working with it for the time being. I will post with some more electronics-fun soon, and finally get that stingray update working properly. :)

Thanks for reading!

 

Posted in General | Leave a comment

ALICE Artificial Intelligence on the Propeller! (AIML Interpreter)

NOTE: THIS PROJECT IS STILL IN PROGRESS. CHECK BACK FOR UPDATES.

UPDATED TO VERSION 0.7 ON 1/20/12

My project over winter break has been to successfully port the ALICE AI onto the Propeller chip. After 1.5 weeks, I’ve finally finished what I set out to create, a working ALICE interpreter for the Parallax Propeller. I’m releasing it now even though it is not entirely done, for 2 reasons. (1. Classes start back on Monday, and I want to get this out before I have other things to worry about. (2. The sooner I get this out, the quicker I’ll be able to get support and help with it.
This interpreter has a lot of data to chew through, and for added speed it is really deserving of a multipropeller system, but I have designed it for use with a single Propeller so that anyone can download a try it. The download link is at the bottom of this article

Here are the pros and cons of the current system (v.1.7)

PROS:
- You can carry on a simple conversation with it without too much error.
- It is very versatile code and can be easily adapted to many projects.
- You can easily add your own data due to the easy editing of AIML.
- It’s AI!!

CONS:
- EXCRUCIATINGLY slow!! Sometimes you’ll get an answer in a few seconds, other times several minutes. It’s like talking over email or text. This is why it needs a multipropeller system!
UPDATED: Now only certain questions are slow! Anything NOT starting with WH, IS, DO, I, AR, YO, or CA are answered in a couple of seconds! Optimization for these starting letters is in the works for version 0.8
- Still displays some of the lesser used tags like HTML tags, ul, random, set, bot, and think.
- Takes up over half of the memory. This can be adjusted though.
- Does not capture the text AFTER a wildcard (“*”). This will sometimes give you interesting responses, especially if you type “what is a [blank]“. I’m working on this and should fix it soon.
- Does not filter out punctuation and white space.

If you want, you can download and try this out now!
You will need:
- Demoboard or similar configuration
- SD card and holder/breakout board
- VGA monitor
- Keyboard
- The source code! Download it here!
- The ALICE brain file. This goes on the SD card. Download it here!

Directions:
On a demoboard, connect the SD card to pins 0 through 3 in the standard configuration. Connect the card to a computer and unzip the BRAIN.zip file to the card. Program the EEPROM on the Propeller with the linked ALICE file. Plug in a VGA monitor and a keyboard. That’s it!
Make sure you DON’T use ANY punctuation when you type, as it doesn’t filter this out yet.

Thanks! I’ll post with updates soon! If you want to ask a question, contact me at info@microcontrolled.com

Posted in General | Leave a comment

Stingray Robot – Update 2

Picture of the new Stingray remote
Ever since winning my Stingray, it has been the one “ongoing project” that is continually being updated in little ways. The pictures I have for this second update don’t even have some of the most recent upgrades, as they were taken about a month ago. Speaking of which, you may have wondered why have haven’t posted in so long! Let’s just say I’ve had a large (paid!) job that has consumed much of my free time over the past few months, and that’s all I’ll say on the matter. Now! No time to waste, here’s the list of most recent updates, along with some pictures!

I have COMPLETELY rebuilt the remote, so that is mostly what the updates are for.

New Stingray improvements:
- Now armed with a Nerf gun
- Features a backlit LCD for readout of data like speed control
- Plugs directly into the wall for charging
- Has a frontal collision plate to avoid gearbox damage
- Features a full speaker system and is capable of playing WAV files read from the external SD card.

New remote improvements (that’s what has changed the most, after all):
- More simple, clean, and accessible
- More accurate control with a triple axis hall effect joystick
- Easy speed readout
- 2 steering options: Preset and Scaled. Preset is the simple Up, down, left, right control whereas scaled takes advantage of the accurate joystick and uses a software algorithm to control the robot based on the joystick location.
- Easy speed select with the third axis on the joystick, so speed can be adjusted while the robot is moving
- Dart launch button (Duh!) with indicator light
- Wav file playing/stopping button.
- NEW Speed lock switch – this switch lets you lock the speed controls so that you don’t accidentally change it while navigating the robot

And of course, it is much nicer and more practical than the previous remote. The only disadvantage to this one over the previous model is the lack of a touchscreen. The touchscreen on the other model was simple impractical – it was only used for 3 functions, ones that simple buttons could replace. Personally, I am a fan of analog interfaces.

However, if you still want to see the old one, you can see it in an old forum thread here: http://forums.parallax.com/showthread.php?130414-The-Coolest-Stingray-Robot-Remote….-EVER!!&highlight=Coolest+stingray+remote

I’ve been told that the mass amount of images on my blog slows down the connection in other countries, so I will be posting links rather than having them inline. Also, the setup is so large that it didn’t fit on the nice white background that I usually use. Here’s the links:
Picture 1
Picture 2
Picture 3
Picture 4
Picture 5
Picture 6

Thanks for reading, I hope to post new updates soon!

Posted in Ongoing Projects, Propeller, Updates | Leave a comment

Learning iPhone programming – Update 1

Where have I been? What have I been doing? iPhone programming! My previous update on Android programming, from which I only toyed around with, is a lot different than this. Rather than just evaluate the software and programming experience, I have taken the full plunge into iPhone programming. I got a shiny new 21.5″ iMac, a book on Objective-C, and (of course) Xcode! The iMac isn’t just for me, nor was it bought primarily for iPhone programming. It is the new family computer, and I just had some persuasion on getting an iMac instead of a Windows machine. You will notice that this is “Update 1″, assuming that there is going to be more. This is because I plan to post more updates once I subscribe to the Apple developer program, and when I release some apps. Considering that the Apple developer fees ($100 a year!!) are coming out of my personal budget, I want to actually get an app made before I go and buy into the program. Until then, I can’t put apps on my device or submit them to the app store.

I wanted to do a review on the iMac, but I’ll save that for another post as it’s a little off topic now. This review is about Xcode and Objective-C. Lets get into it now! Objective-C is one of the strangest languages I’ve ever programmed in. Aside from objects, it uses a total of 4 programs, 2 of which have to be manually edited every time you add a user interface. It has a Delegate header file, a Delegate implementation file, a Controller header file, and a Controller implementation file. The Controller implementation file is the one where most of the main code takes place, as it provides access to methods that are related to the user interface. However, you have to take care of the UI also in the Controller header file, by declaring and setting the variables as properties that are passed on from the Interface Builder. Lost me? The Interface Builder is a completely separate program that edits the .xml file that the user interacts with. It’s the most user-friendly part of the whole setup, but is still complicated in contrast with the interface builder in Visual Basic 2010. After placing your buttons, labels, or anything else you want to interact with in some way, you have to connect it to the main file by holding “Control” and dragging a line from the item to the File Builder logo in one of the 4 windows the program uses. You then select a variable to connect to, and presto! You have a linked UI! At first I found this exceptionally complicated, but after a week of working with it (for that is how long I have had the computer to this date) I have grown to appreciate it.

To give you an accurate example of iPhone programming (of what I’ve learned so far, anyway) here is a little walkthrough of how to make a program that let’s you push a button to make it tell you “Hello”.

Open a new project in Xcode, select “View-Based Template” and give it a name.

First, update the Controller header file (.h) with the following code in the implementation loop:
IBOutlet UILabel *outputLabel;
Then this outside of the loop before the “@end” statement.

@property (retain, nonatomic) UILabel *outputLabel;

-(IBAction)activateHello:(id)sender;

Now, save your files and open up Interface Builder by double clicking the “ Interface.xml” file and add a new button and Label. Link them to the “outputLabel” and “activateHello” controllers (a.k.a variables) that we defined earlier by Control-dragging lines from the File Owners icon to the item. Select the appropriate controller when prompted, then save and close interface builder. Go back to Xcode, edit the Controller Implementation file with the following code under the header-code right before the first comment:

@synthesize outputLabel;

-(IBAction)activateHello:(id)sender {
NSString *helloString;

helloString = [[NSString alloc] initWithString:
@"Hello there"];
[outputLabel.text = helloString.text];
}

That’s it.
————————————
There you go, a quick little runthrough on iPhone programming. The text beneath the little dashed line was written 31 days after the original article. Why? Upon visiting my site I realized I had forgotten to push the “Publish” button so this draft had been sitting in my browser the whole time. Nice.
Well at least you will get another article soon.

Hope you enjoyed it!

Posted in Experiments, Observations, Updates, Works in Progress | Leave a comment

Writing a Nuts and Volts article


To all you who have been wondering why I haven’t been posting new articles on my blog: I have been working on writing an article for a magazine. As some of you may have known, I have written for the electronics magazine Nuts and Volts in the past. Writing for them is both a challenge and a great experience, and I have been waiting some time before I had an opportunity to do it again. In order to write an article for Nuts and Volts, you have to have the perfect project to fit the role. It has to be unique, fun, and altogether interesting; even if it isn’t economical. The last project I did was a box that would only unlock if you waved an RFID card over it (the cover for the issue I was published in is the header image) , this time I’m entering the FlipClock.

I have spent the last several weeks writing the article, assembling the BOM and getting the pictures ready. The article has not yet been accepted by Nuts and Volts, which means that I can post it here free for your viewing until it gets accepted, in which it would then be the property of Nuts and Volts. You can download the viewer-friendly article including photos, BOM, and a full How-To guide from the link below. Keep in mind, this is a rough draft only.

Click here to download the PDF version of the Article

UPDATE: My article was dejected because the project was “too complicated”. Sigh. I’ll try again soon.

Posted in General | 3 Comments

The FlipClock – An accelerometer controlled Digital Clock

One of those things you dread about morning is waking up to a blaring alarm, and fumbling sleepily around for the off switch. Don’t you wish your clock would get the hint when you’re knocking it on the floor trying to press that blasted button? Well, no more of that! This clock doesn’t have an off button at all! In fact, it doesn’t have any buttons! The only thing you need to do to turn it off is knock it over!
Introducing the FlipClock!!




The FlipClock is controlled by a Propeller Chip and uses a GPS module for timekeeping and a 3AD module by Rayslogic.com as the accelerometer. When building this project, the biggest concern was the power and sound, which should have been the least of my worries. I ended up using a power source ripped off of a Propeller protoboard, however, I originally used a PowerTwig. The problem with the PowerTwig was the low current handling, which although good for the Propeller setup, couldn’t drive the speaker circuit without resetting the Propeller Chip. I experimented with different setups, including attaching a heatsink, using an external 5V regulator, and using a potentiometer to lower the speaker input current. The external regulator was temporarily successful, but when I added the accelerometer it stopped working correctly and the Propeller started resetting again. Eventually I ended up replacing the PowerTwig with the salvaged power source. The speaker is the only disappointing part of this system, as it is as audible as a watch alarm, which is OK, unless you are trying to wake someone up, which is the whole purpose of an alarm! Lucky for me I’m a light sleeper and it does work.

Operation is very simple. To disable the alarm, simply flip the clock over. The digits automatically invert and the indicator light shows the status of the alarm. As previously stated, to turn off the alarm when it is going off, just knock it over. This clock is so simple to use I don’t really need to explain how to operate it. The time is taken from the GPS so it never needs set, and the alarm is at an unchangeable time (still working on this, but I promise I won’t add any buttons to set the alarm, I’ll just have to think of something creative).

And now for the most important part: Even upon close inspection, this looks like something you would buy! I’ve learned that a project that looks good is usually more accepted by those who are not into electronics, even if it is not as functional as others that look like a mess of wires [this is]. Another very important feature: This project is salvage-proof! I know that in a few months I’ll be wanting that GPS module back for another project, so I’ve built in a DS1302 RTC (Real Time Clock) that will take over as soon as the GPS module is removed. I guess the thing this project needed protected most from was myself.

Click here to download the Propeller Source Code

Thanks for reading! Please subscribe to my RSS and my YouTube channel, and don’t forget to like this article on Facebook!

Posted in Completed Projects, Propeller | 2 Comments