First project ever. Where do i begin?
annonymous
Posts: 14
Hey y'all i am new to micro controller programming. I have been programming in C for a few years and just recently started to program in 32 bit Linux Nasm. So I just went to radio shack and bought a bunch of goodies! A spdt(Single Pole Double Throw) relay, 22g wire, a general purpose micro controller, and a 5 button keypad. I am going to hook up the 5 button keypad to the micro controller. the MC to the relay and the spdt relay to my ignition switch. So if i enter the correct code, the relay will close the circuit and enable the ignition. Without the code the car will not start. Where do i start? Where can i get diagrams or turorials, or what ports are for what? Do i need to write a serial server first? I just downloaded the BST IDE.I run Ubuntu as an OS and gcc for my compiler.
what i would like to know is where do i start with the micro controller programming?
The development board i have is the Propeller P8X32A QuickStart # 4000-RT
what i would like to know is where do i start with the micro controller programming?
The development board i have is the Propeller P8X32A QuickStart # 4000-RT
Comments
Welcome to the forum.
The best place to start is at the beginning - this link should get you started Propeller General Information
The Propeller can be programmed in various languages but a beginner my want to start with SPIN, the language Parallax developed for the Propeller - and then maybe PASM.
Propeller Manual v1.1
Actually it is quite complex. If you intend to learn how to program a Propeller, you need to understand the basics of how the microcontroller works. There are eight processing "cogs" and it takes time to learn the hardware and programming tools.
There are many links and tons of information available to you on the QuickStart product page
There are easier to learn microcontrollers and all have pluses and minuses. The Propeller's multiple cogs give it advantages but with added complexity.
Ultimately it depends on your goals. If you are looking for a quick and dirty one-time microcontroller project, the prop is probably not the best fit.
If you plan on many more MCU projects and are looking for a powerful platform, the propeller offers a lot.
Good luck.
You will run into similar issues no matter what microcontroller you start with. As a C programmer, you will likely find the Arduino more familiar. On the other hand, you will run into the same issues with the Arduino and the push buttons and the relay and it's these issues that are unfamiliar and daunting. Parallax has a lot of educational material (manuals, tutorials, etc.) for its Basic Stamps and most of it is directly applicable to the Propeller (and the Arduino for that matter). Look at the "What's a Microcontroller?" tutorial for examples of interfacing pushbuttons. The Nuts and Volts Columns have similar examples. There are C compilers available for the Propeller. Catalina is free, stable, and quite good. There's a GCC C compiler in alpha testing that will be directly supported by Parallax. You still have to learn how the microcontroller works.
So start there.
Wire up the LED and resistor and type in you code.
Then play with it to make it do other stuff.
Be advised that Spin uses indentation to control the structure of the program.
Also, sometimes it's a PITA to get code to show properly here.
Hence the dots in the example below. The indentation is that important.
I've tried to fix it a few times but gave up in frustration and added the dots.
Edit them back to spaces...
An example really ought to be pinned to a Newbie thread.
Just so guys can easily find it and get started.
There are just too many variables trying to do it from a book!
Anyway: See if this might get ya going...
code
{{ Jan 30, 2011
Blinky51.spin
}}
CON
_CLKMODE=XTAL1+PLL2X
_XINFREQ =5_000_000
HI = 1
LO = 0
SlowWait = 5_000_000
FastWait = 1_000_000
PinOut = 07 ' has an LED
PinIn = 06 ' has a switch wit a 10K pull up resistor
PUB MAIN
dira [PinOut] := 1 'output bit for LED
outa [PinOut] := 0
dira [PinIn] := 0 'input bit for button
repeat
if ina[PinIn] == 1 ' if button IS NOT pressed
..repeat 1 'blink it fast
....outa[PinOut] := HI
....waitCNT (FastWait+cnt)
.... outa[PinOut] := LO
.... waitCNT (FastWait+cnt)
..else ' button IS pressed
.... repeat 2 'blink it slow
.... outa[PinOut] := HI
.... waitCNT (SlowWait+cnt)
.... outa[PinOut] := LO
.... waitCNT (SlowWait+cnt)
/code
Learn Spin.
Then learn Assembly.
Once you learn Assembly on ANY processor, it's easy to learn Assembly on any other processor.
Remember, you'll still have to learn about the Propeller's hardware and how it works since, even with Catalina, you have to manipulate the hardware with library routines. The Arduino programming environment does the same sort of thing and does it differently.
http://code.google.com/p/propgcc/
There are hundreds of pre-written modules available at the obex.parallax.com page. This only simplifies your work.
Steve
Welcome to the forum, whoever you are:)
I'm very surprised that you are having BST crashing on you. I have been using
it exclusively for Spin/PASM development on Debian for ages with no such issues
and no one else has popped up here with BST problems.
BradC the author of BST also created command line versions of the compiler and
loader, BSTC and BSTL, perhaps they work well for you. If so then you could try
the PZST graphical IDE which makes use of those programs.
http://code.google.com/p/pzst/
If that does not work out there is also the HomeSpun compiler/loader
http://propeller.wikispaces.com/Homespun+Spin+Compiler. HomeSpun is
command line only. It is written in C# and runs very well under mono on Linux.
As a C programmer you might like to try the new prop-gcc. Despite being in alpha
test state it has been working very well for me.
@Ron Czapala
Are there, which ones? Having been through a bunch of MCU since the 80's from
8051 through to PIC's AVR's and ARM's I would say the Prop and Spin is one of
the easiest to get started with.
Can do, but when starting out you hardly have to worry about the parallel
processing. Just drop your serial, video, whatever ready made drivers you need
in to your program and away you go. With the bonus that there are no interrupts
to worry about.
As you see, I totally disagree:)
You think the Prop and Spin are easier than a Basic Stamp? I think most people would disagree.
For someone with no previous microcontroller experience, the BS2 is much simpler.
Continuing with your premise that you don't have to "worry about parallel processing" with the Propeller,
you don't have to worry about interrupts with the Arduino initially - you can do many projects without interrupts.
With a BS2 you don't have to worry with either one.
I have never used or seen a Basic Stamp. Probably because I have been avoiding BASIC since tech school back in 1974 and would never have imagined it being useful on a micro-controller.
I always thought that firing up a Prop Tool and getting ones first few lines of Spin running was about as easy as it gets. If the Basic Stamp is even easier, well, jolly good.
I like the PICAXE "Simulate" debugging capability where you can set break points and single step through your code. It doesn't work well with all scenarios but it can really be helpful.
The "Getting Started with Parallax" web page does a good job comparing the Basic Stamp and Propeller.
You'd be surprised how many large companies employ VBScript in web development when using Microsoft' IIS platform (Internet Information Server).
It is often used in the server-side components while javascript is used on the client-side components.
You might try a progression something like this:
1. Blinky light (side note: on ARM7 I have invested several weeks, still nothing; all other MCUs, 10 minutes)
2. Turn blinky light on/off with a single button input
3. Hello world over serial
4. two blinky lights; each with a cog
etc...
Definitely helps to start very very simple and slowly work your way up. I personally prefer to learn programming languages with the "how do I..." approach -- by working projects and learning instructions/syntax/expressions as needed.
You can break down your project into steps. Start with #1 blinky light (pin output and some basic syntax) move on to pin input #2 ... Look up debouncing and implement. Now you have the fundamental basis for your project.
The rest you add on as you go. Next perhaps learn serial so you can debug. Then work on decoding a numeric keypad. Then you're very close. Work out how to check the entered code against the password. Use # to terminate input to keep it simple. Add a status LEDs: green solid for "OK" and red (that you blink) after wrong code entered.
Now all that's left is to figure out how to drive a relay. That requires some electronics. Best bet is to look around the internet for examples and try them and ask questions on forums. You may need to find an automotive forum or two for help as well. You'll probably want to think about an opto-isolator to prevent damage to the Prop and you'll also need to start thinking about a really good power supply as the vehicle power is rather hostile, ranging in voltage and with spikes and noise and whatnot from what I understand.
Best of luck.
Questions; What size resistor do i but at the base of the transistor? I laid down a 1k ohm 1/4watt 5% tolerance. Should i have laid down the 220?
heres is a schematic i laid out on fritzing for linux --->
Arduino could be either 3.3v or 5v. Prop is 3.3v. Base-Emitter drop of a transistor is 0.7v
3.3-0.7 = 2.6v
Transistor current gain (hFE) is at least 100. Base current should be ~1.5mA.
2.6v / 1.5mA = 1.73 kOhms
That circuit is seriously wrong. Can you see the problem?