Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting into micros, need a chip to start

Status
Not open for further replies.

originator

Industrial
Dec 12, 2004
71
0
0
US
Hello all.

I am looking to convert a logic system into a micro based board. From what I have learned about the process, I'd like to use C and write some code on Xcode (OS X), then test it with a USB connection to make some leds turn on and off. I am looking to find a simple chip to start on, maybe 12-15 inputs, 10 outs or so. I have someone to help me get going with the language to get my feet wet, but will likely do some consulting to speed up the curve. If you've used a specific chip and have a part number you like that would be great,

I have a PC also, so that is a second choice for interfacing and writing the program.

Functiionally, it needs to see 5 volt inputs from a number of sources and respond with various outputs based on the code. I have heard this should be easy to implement, especially since there is a working logic based board to emulate.

Thanks


Todd Chapman

 
Replies continue below

Recommended for you

I don't know about all that stuff you guys are talking about, but I got these simple Parallax chips in yesterday with a demo board. I have never written any Basic before, but I am almost 80% done with the programing for my project ---minus any serial communication. The stamp I got has 32 i/os.

I wish I had of gotten into this a long time ago. Next I will try out the ethernet add on boards. The chip supposedly has a very quick and easy method for daisy chaining lots of them together, then send serial numbers over a line and wait for a response. Who knows, maybe do both methods at the same time? Poll on a single wire and use wireless ethernet for alarmsa nd polling?

btw How much harder is C+ than this Pbasic? Microchips require a more complicated language right?
 
Hi itsmoked and originator-

Hi itsmoked. No, it was the Carl's Jr. on Homestead in
Sunnyvale, but I know the Jack in the Box on El Camino!

If I remember my computer lore correctly, the guy that
designed the 8080 "jumped ship" and went over to Zilog to
create the Z80 CPU. THAT's very fuzzy in my memory so
that could be an urban legend.

Also, again if memory serves me right, the 8085 extra two
instructions were SID and SOD (serial in and serial out).
Not to a uart, but a pair of pins on the chip. And the
8085 was MUCH different than the 8080 hardware wise. It
used a multiplexed data/address bus. In some ways it
was easier than the 8080 designs.

Originator. Congratulations on the parallax. I went a
slightly different tack on my microchip stuff. I believe
that the "stamps" are PIC based with a little basic
interpreter. I could be wrong and someone please correct
me. However, I looked at the price of the stamps vs. the
cost of a plain pic available from Digikey, Mouser, or
a whole host of mail order catalogs. Microchip at the
time (and still may) gave away 5 PICs for people to play
with (although it took a LONG time to arrive in the mail).
The standard PIC that I use now is a 16F648A. They are
under $2.00 each in quantity 25 (the number that I usually
buy at one shot). I started out with the 16F628 and
home rolled a little programmer for it that uses the
parallel port of the PC to program. Maybe as mentioned,
the microchip assembler and simulator is free from the
microchip site.

The 16F6XX class of PICs are 18 pins, have an internal
clock so no crystal or resonator to mess with. In fact,
other than I/O, all you need is a small cap (0.01 uf)
across the supply pins and optionally a 10K pull up for
the reset line (optional, some programmers use RA5 as
an I/O rather than MCLR, mine doesn't). I use standard
push in proto boards for quickie designs and as a basis
for downloading (programming) the pic's flash memory.
So, with my laptop, a little 5V wall wort, and ICD2
(mentioned later), I can go do a lot of design at a
Starbuck's coffee shop (I've graduated from Carl's, no
power) and have some nice iced tea, have a nice window
to look out of, and people to chat with. Cheaper than
renting an office for sure. Add a logic probe and or
a little USB logic analyzer and I can do hardware debug
there too! Truth to tell, I haven't dragged the logic
analyzer out of the pouch at Starbucks (yet). But it's
there if I need it. Shoot I even do my PCB layouts there
now with the laptop. No more sitting in front of a $25K
workstation using Mentor for me!

Anyway, back to the pics.

For about $2.00 the chip then becomes a logic replacement
element and you can just about use them everywhere. One
wag said:

"Why use a 555 timer when you have a PIC!"

I use the assembler a lot, but I'm a grizzeld old fart when
it comes to programming. I've done Harvard architecture
programming for just about as long as a Von Neumann
architecture machines (that's why the PIC architecture is
so "bad").

However, after learning to use the assembler in little
projects and gaining confidence with the toolchain, you
might want to go to a C compiler for additional ease in
programming. I personally use the cc5x free compiler,
although I've heard good things about the free C compiler
from microchip (the other ones mentioned in the list I
don't have experience with). My choice for the cc5x was
that although they don't have "free" versions that generate
object modules greater than 1K words, they allow one with
a bit of dinking around, to LINK the modules for the full
8K words found in the standard "MAX" 16F series of PICs.

Another very popular PIC is the larger 16F877(A) chips.
These include much more I/O and 8 channels of A/D along
with the aforementioned 8K words of flash program store.
These require a crystal or resonator to operate with.
I typically buy these a couple at a time for about $7.00
each. Most of the time in 40pin DIP. All the pics have
various package designs, with surface mount and lead free
available. For prototype work where space is not an issue,
the DIPs work fine for me.

My final pic that I use is the 12F675. My "little guy".
No UART on them, but 3(4) channels of A/D decent ram and
for me, an 8 pin DIP configuration. Again, no crystal
and use the internal oscillator.

So, I have my 3 models and know them all pretty well. A
mini, midi, and maxie pic to choose from. There are
hundreds of different PICs available. One can go nuts
trying to learn them all. I suggest picking a couple and
learning them. Get to know them well, then if you have
a need for a different one, go to the new one as needed.

I personally "graduated" to an ICD2 debugger/programmer
but you might be just as happy doing the "raw" debug
mode (which you will find out about later). The ICD2 is
about $150 from Microchip (there are, I'm told, cheaper
knockoffs out there). I had to do a design for a
customer who wanted to program his pics and fab his own
boards. No problem. The design however, worked out best
with 2 pics in it, communicating with each other. So,
I got two of the ICD2s, one for myself and one for the
customer. I left one for him to do his programming with.
Saves a BUNCH of time.

There are even more expensive debuggers offered by
microchip, but I tend to only buy the tools that I need.
Again, YMMV.

Finally, there are some very good support groups for the
PICs out there. Two that come to mind and ones that I
monitor are the yahoo pic list:


although, of late, it's been much slower than it used to
be. I read the MIT piclist from gemane reader rather than
having it as a mail group. This is a group with some
real great contributors and although sometimes off topic,
there is good information to snoop through. My link and
reader for it is:


Of course, you can always ask questions here.

We oughta do a FAQ on this subject..... Sigh. Seems
like I remember writing this a time or two.

Best of luck. Keep us informed.

Cheers,

Rich S.
 
Rich; No 18's?? Once I used one of them it was no turning back!

[green] How much harder is C+ than this Pbasic? [/green]

In my opinion a lot harder. I hate C++! I know of no good C++ compilers for small micros. C++ is what brought us the Windoz plague of bloatware.
Now C is another story. If you keep to the simple constructs and pay attention it is not very hard. Probably the hardest thing about C is setting up the tools. That can be a bit of a pain.

[green] Microchips require a more complicated language right? [/green]
Question does not compute.

Microchip is the name of a company with thousands of different parts.

If you mean Microchip's PIC family of microprocessors then um.. the question still doesn't compute.

Any processor can end up with "firmware" in it many, many, different ways.

Your Stamp has a PIC on it that you are programming using a running program already in it called an interpreter. You can use compilers or assemblers or Forth or Java to create programs to run in any microprocessor.

Keith Cress
Flamin Systems, Inc.-
 
I meant Microchip PIC's

Hey many thank for super detailed break down. Since I don't have the time to dive into anything more complicated than basic, BUT, I still want to hack around with prototypes, here is my conclusion:

Build my own prototype projects using Stamps or Stamp OEM parts for production where I don't care about the difference in a part costing 2 or 20, as long as it works. My product will already cost me over 2000 each in low quantities, so $20 is not a big concern in this case. If in the case where I need more whatever -- speed, power, cost reduction, DSP, a/d, then what about I send my working Basic instruction set to someone that can adapt it to a 16 or 18 series PIC? OR, Even build a board to hold either the Stamp or PIC, and interchange or swap out when it as production level with the cheaper PIC?

Ideally keeping things in a rhelm tat I can modify is the best case though for now.
 
Yes, the Stamp is a PIC with a built-in BASIC interpreter. Even the oldest versions will do 2000 instructions/ second, so you don't need to be in a big hurry to use a different language.

Me, I'd use _anything_ but C or its offspring.

I can write modular, object oriented, reliable software, usually bug-free on the second attempt, in assembler or FORTH or BASIC. I'm a little slower in Pascal, because I never remember the right way to hold my tongue, and waste a lot of time fighting with the compiler over syntax.

With C, programming goes fairly fast, but I always manage to run into some archaic bug that 'everybody knows about', except me. I've tried learning it on several occasions. My eyes usually glaze over after the 150th page of '... except when...'.



Mike Halloran
Pembroke Pines, FL, USA
 
Mike I know what you mean. I have the most expensive highest end C compiler for PICs. I use pretty fundamental commands whenever I can and I still find compiler bugs that require the factory compiler writers to figure out.

originator; You have a good pretty good plan there. Get it working pretty much the way you want it. This educates you to the point that you can specify and understand the control aspects. But when you see production coming I strongly,(most strongly), suggest you pull in an experienced designer to roll you a small, inexpensive, control system that has exactly what you need and is commercially tough.

There are a really huge number of pitfalls that await the unwary and inexperienced. These would mean nothing to the hobbyist or the one or two off job but could really hammer you on a production run or worse with a hundred installed units. (The stuff of nightmares.)

Good luck and happy programming.


Keith Cress
Flamin Systems, Inc.-
 
C is a wonderful language; I spent 10 years coding in FORTRAN without needing to look at the assembler the compiler produced.

I do it quite regularly with C to find out if the compiler is producing code that does what I thought I wanted...
 
Hey I got a question now that I am underway programming the thing to replicated the logic stuff. When you are programming, to what extreme do you go towards building the ins and outs to demontrate the real project?

I have maxed out this little built in bread board on the demo kit and am going to make a circuit board with buttons to represent all inputs, and leds or a real motor controller to send the outputs to test. What do you guys do?

I suspect that with enough practice you don't need to see the real world?



Side note: serial vs parallel. If you have a system with 16 or less units you wanted to monitor, and you knew it was not going to go beyond that limit, would you buss 4 sets of wires to all the units off a master, then send out a request to an address, say 0101. and the reply could contain on 2 or 3 very simple one bit responses on seperate lines?

like this maybe:

Master sends out 0001 over 4 wires

Slave has the code built in that says:

REQUEST VAR INA ' inputs 0,1, 2, 3
STATUS1 VAR OUT5 'state of something
STATUS2 VAR OUT6 'state of something else


if REQUEST = %0001 then
output7 = STATUS1 'a buss wire wire to master
output8 = STATUS2 'another buss wire to master
pause 50
output7 = 0
output 8 = 0
endif

Master can then do something with that info, like send it over internet, store it with time stamps, send alarm, etc

Just curious really. Supposedly this stamp does 12,000 lines a second, in that case it could quesry 16 units in real time and never miss a thing, or space the request out a little if needed.








 
Ha! Well It must be the sleep deprivation? A "unit" would consist of one complete door system operated by a microcontroller and touch interface. In the above example of a home or small business concept, 16 or less "units" are connected to one master processor attached to a PC for monitoring, alarm setting, remote control, internet remote access, etc etc. What I was curious about was in such a small scale application, would 4 wires bussed to all the units make sense over a serial implementation even at a production scale?

I am aware of X10 but was leaning against getting involed with that protocol.

More to the point, I really just wanted to experiment with making several door units talk to a master, and start thinking about how to implement a PC based proprietary software to monitor and control them on a small scale.

Sorry for the vagueness

 
The more advanced PICs actually have a master/slave serial setup. It's a 9-bit protocol, if the 9th bit is set (clear?), the remaining 8-bits will be an address. If the address matches what the slave is set for, it enables listening to the remaining bytes until you again disable it. VERY useful little tool, and it's all built in to the hardware, and I love interrupt-driven stuff (polling sucks!)


Dan - Owner
Footwell%20Animation%20Tiny.gif
 
Yeah, you could do a master/slave polling setup, and multiplex sensors, etc. It can get complicated pretty quickly.

Or you could put a PIC at each door, programmed with an identity code, and have them just send status report packets at regular or random intervals, all over the same two wires. The master then just has to listen, and keep a log to detect broken wires or dead PICs. Collisions on the wire can be detected with checksums in the packets; just discard bad packets.

If you don't need a _continuous_ stream of news from each sensor, there are lots of ways to make inexpensive networks.



Mike Halloran
Pembroke Pines, FL, USA
 
Hiya-

O.K. this is the "door" thread. Again, I would vote
for the signals passed on the AC mains. More complex
electronically, but much easier in terms of implementation
without having a second set of control wires. Just pass
the high freqency signal from the "units" master/slave or
collision type (errr, I'd have to think about that a bit),
yeah it should work, to whatever you use to power the doors,
which I would assume to be derived somewhere locally from
110VAC.

This way a "door unit" need only be wired to the nearest
duplex box. No running extra wires.

If this doesn't ring a bell, there was a thread on one
of these sections where someone was interested in doing
a door alarm/web interface for hotels as well as small
businesses. There was a lot of talk about ethernet
and routers. You might reference that for additional
information and some thoughts by me and, more importantly,
by others.

Cheers,

Rich S.
 
The AC convention is interesting, but In the event of power out you are not going to communicate unless AC methods can talk when the AC is down just as well (excepting the case of an AC backup). My system is battery operated and will run for days on its own, so I'd like to consider a system to run own on its own wires, or wireless, to a Master that is battery backed up as well, so that the entire sytstem can be monitored and controlled via internet even in no power. BTW the hotel threads are most likely mine, I like to spread the agitation around as much as possible.

Right now I am looking for a way to network several sizes of systems together, under 10 is the immediate need. The ethernet idea Keith has discussed is my favorite so far: it's wireless and can be battery operated for power out states, and can deal with polling and interrupts easily.

I am really glad to have gotten all the great ideas on methods to do this. We are a small company trying to launch something "hi-techy" on a shoe string. The product is never to be intended as the sole fire and alarm system, but rather an add-on benefit for the gadget minded, not to mention a pretty slick backup plan for the rare cases of fires of alarms. In reality, people are scared of motorized doors in homes, so I have to be way over the top redundant with safety measures to overcome those fears of being "trapped", etc.

The small home installs are right around the corner. I am looking to nail down the final plan for the networking of a small number of units and get going on that design, which will also require a PC based app, or at least an html/ flash/ or java based remote control, monitoring and logging implementation.

The ideal sitution is to use the stamp based control that I am almost done programming, and add on the parts needed for communication, leaving that to someone else. The control is very simple, and the stamp can talk to another processor that is stuck on the board in the cases where networking is required.

You guys have been great, I appreciated it.

 
Status
Not open for further replies.
Back
Top