Re: One Second Pulse-Width, Once Per Hour

Generally nothing to learn them. Just download a simulator, google for some documentation, and play around.

To actually make the traditional 'blink a LED' project (the embedded versionof 'hello world' :-) you need either a device to program your microcontroller, or a microcontroller that someone else has programmed a bootloader on to. A bootloader is just a program that lets the MCU program itself with your code.

Such questions have started long flamewars :-)

I don't mind PICs or AVRs - my favourite is the PIC18 series. If you choose PICs, don't touch anything that doesn't begin with PIC18 to begin with. They are much nicer to use.

PICs are extrememly simple to use. Here is some PIC code to clear memory

ClrMem ; clears memory in RAM, from 000h to 1FFh

lfsr 0,0 ;load File Select Register 0 with 0 - the start of RAM

ClrMemLoop

clrf POSTINC0 ; clear the byte pointed to by FSR0 ; and automatically increment FSR0 afterwards ifbit FSR0H, 1 ; return if its now pointing to h'200' return ;(bit 10 of FSR0 is set) bra ClrMemLoop ; otherwise loop again

I use the term 'ifbit' instead of btfsc, becasue I find it easier to read.

Al

Reply to
Al Borowski
Loading thread data ...

MPLAB is Microchip's suite of development software. It includes an assembler + simulator.

There are simple programmers, that can be built from almost no parts.

Al

Reply to
Al Borowski

I think the PICs include an internal charge pump for programing; I might be mistaken though. A ton of other MCU's are programmible down to 3.3V IIRC.

Al

Reply to
Al Borowski

I got one as well, I just hope I can get my project presentable before the deadline. Uni is taking up too much time... Gotta love these chips... I thinks it amazing that so much can be crammed into a small black box.

Al

Reply to
Al Borowski

They do indeed have a charge pump for 5v (LV) programming. HV programming is another option; the do-it-yourself NOPPP ("No Parts PIC Programmer") uses HV programming.

Reply to
Michael

Here's a crazy idea for a one-second pulse, once an hour:

Take an ordinary wall clock, the kind with hands. Drill 5 little holes in the face; one that will be blocked once an hour by the hour hand, two that will be blocked by the minute hand one minute apart, and two that will be blocked by the second hand one second apart.

lessee, (I'm inventing as I go along) you'd have the two second-hand photodiodes go to the R and S input of your pulse generator; this is gated by the Q output of another RS FF controlled by the minutes PHDs, and this would all get fired once by the trigger from the hour hand PHD.

The details, of course, are left as an exercise for the reader. ?;->

Cheers! Rich

Reply to
Rich Grise

You should get out more and why do you have to use second hand photo diodes? Will new ones not work in this design?

Reply to
Mjolinor

I'll suggest this once more and see where it goes. What about a digital alarm clock? Each time the hour ticks, run the pulse until the seconds tick. Restart and wait for the hour to tick again. As with other suggestions, the method to accomplish this is up to the reader.

Bill @ GarberStreet Enterprizez };-) Web Site -

formatting link
Email - willy46pa @ comcast DOT net Change DOT to a dot to contact me

--
This email ain't infected, dude!

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.634 / Virus Database: 406 - Release Date: 3/22/04
Reply to
Bill Garber

--- Good thing too, since it seems a few details have escaped you.

First of all, every time the second hand goes around it'll go by the seconds LDRs, bit it'll also go by the minutes and hours LDRs.

Second, when the minute hand goes around it'll go by the minutes LDRs, but it'll also go by the hours LDR (and the seconds LDRs if the minute hand is long enough.

Third, the hour hand would only go by the hours LDR once every 12 hours, but the minute hand would go past it once per hour and the second hand would go by it once a minute, so it seems like your "invention" needs some more work. Not just with the timekeeping either, you need to provide some means for the thing to work in the dark.

Here's how I'd do it for use in total darkness:

  1. Radially drill three small holes in the clock face, (out past the reach of the hour hand) one at precisely 12:00, one at 12:01, and one at 12:02. make sure the diameter of the 12:00 hole is 3° or less.

  1. Glue a betalight with an output around 500nm to the under surface of the minute hand and mask it with a 3° aperture such that the aperture lines up with the 12:00 hole.

  2. Place an LDR behind the 12:00 hole with a spectral sensitivity which matches the output of the betalight.

  1. Behind the 12:01 and 12:02 holes, place a reflective object IR photosensor, and make sure the back of the second hand reflects IR.

Now, when the minute hand goes by 12:00, the betalight will cause the green responding LDR's resistance to drop, which will turn on the reflective sensors' IRLEDS. When the second hand goes by the 12:01 hole the beam from the IRLED will bounce off of it and reflect back to the IR phototransistor, turning on a latch, starting the 1 second pulse. When the second hand goes by the 12:01 hole it'll reset the latch, turning off the pulse and the IRLEDs, since they won't be needed for another hour.

How to do it in daylight is left as an exercise for the student ;)

-- John Fields

Reply to
John Fields

...

Oh, they didn't escape - i was never trying to hold them prisoner. ;-)

Well, there ya go - leaving it open _was_ a good idea then! :-)

Reply to
Rich Grise

Get an ordinary wall clock. Cut off the second hand, and the hour hand. Drill a hole anywhere in the clock where the minute hand passes and not to close to the centre. Use an led/lamp and phototransistor/ldr combination. Place the detection device behind the hole, and the emitting device on the other side of the hole with enough room for the minute hand to pass between. Connect the detector to one of those dreaded 555 in a monostable configuration. Bung the whole lot into a shoe box and whala (or however you spell it) a timer as per spec.

Alternatively (I have read any other posts yet) you could just use a dual dreaded 555.

Reply to
The Real Andy

--
How could you?  You never even caught them!^)
Reply to
John Fields

Real slimy creatures are details, you think you have them all and then realise they were fooling you and some of them sacrifice themself in order that some may escape. Definate hierachy in their behaviour where the most damaging ones are protected by the non fatal / non explosive/ non embarrasing type. They come in all shapes and sizes and as a species are most difficult to recognise.

Reply to
Mjolinor

Decode should be 3599

Reply to
GPG

--
I get 3598, but work out the timing to find out for sure.
Reply to
John Fields

Got a newsreader going. 40tude. allows me to look at your posts on binaries Looked at your diag. Second 4013 section appears to not be required

Reply to
GPG

--
Do the timing.
Reply to
John Fields

How "old-time" are you, old-timer? If you suspect you won't live long enough to make all the mistakes by yourself, perhaps you can learn from my experiences.

My credentials: When I started fixing radios, they glowed in the dark. Had a E.E. degree before the 8051 was ever heard of. Trained for ANALOG circuit design, but . . . worked in broadcasting, microwave comm O&M, second-source manufacturing of military electronics, and a few jobs even less related to electronic design. Last fired in Feb

2003 and still don't have a real job.

My experience: About this time last year, I took on a short-term sub-contract job to design a piece of circuitry for a 3-man shop that developed products for local manufacturers. He wanted to drive a small PM DC motor (think, "slot cars" but the product has nothing to do with toys) from any voltage ever used in an industrial control environment: AC, DC, 12V to 32V, etc. He had some requirements for over- and undervoltage lockout, thermal and locked-rotor protection, shutdown (or reverse, as selected by end user) when the attached mechanism reached end-of-travel, a small heater to repel condensation inside the product package, etc. I started in with H-bridge drivers, switching regulators, analog comparators, and about half a dozen packages of combinational logic.

It was soon obvious that there wasn't enough acreage on my PWB. The guy I was working with suggested I look at the PIC processors as one way to reduce all that logic to a smaller footprint. They're NOT high-powered microprocessors, but they certainly ARE good value: the PIC 16F818 is easily under $2 in 100's, has internal oscillator and reset circuit (no crystal to buy), A/D converters (sense all those voltages and currents, then compare numbers - no more analog comparators), a PWM output (gate the H-bridge to eliminate switching regulator), and 15 pins on the 18-pin package can be used for I/O.

I probably had the same doubts you do: Can gray-haired mere mortals learn to program the thing? What about assemblers & code development tools? How do you burn-in the code? Suppose you screw up the software?

Dan (my client) had used PIC's before (over 5 years ago, I later learned) and had a development-type programmer. He estimated the S/W code effort at 20 to 30 man hours, and said he'd do it. A couple weeks later I had characterized the motor, selected components, documented the hardware design, laid out and ordered the PWB - but Dan was tied up on another project. So I charged ahead and started writing PIC Assembly code. I was unemployed anyway, so I figured I might as well try to learn something rather than paint the house trim. It took me 3 or 4 times the estimated level of effort (which was probably optimistic to start with since the code ran to 800 lines), but in the smoke-test following the first code loading all of the desired functionality was functional! So here it is a year later and I've done half a dozen PIC projects with this same shop. Four different processors from the PIC 16Fxxx series. Probably 5000 executable lines of code.

One disclaimer: I wasn't entirely a stranger to software. Back in High School, I had a basic introduction to "FORTRAN II". Later, after BASIC was invented, I used several dialects of that language. In 1992 I took a grad school class called "Intro to Microprocessor System Design", in which about half the material dealt with Assembly language for the Intel 8086. Shortly after that, I reverse engineered both the hardware and software for a small product based on Motorola's 68HC705. And there's a little MATLAB, EXCEL macros, SPICE decks, etc. To the best of my knowledge, I've never written a line of "C" (but really SHOULD learn it!). I don't claim to be "skilled" in ANY language, though - I'm still at the stage where they all look rather similar, and seem to have the same underlying concepts of variables, loops, structures, procedures, etc.

My Suggestions: As you look down this path, consider that I've recently walked the trail and offer the following observations.

- The free MICROCHIP development software (called "MPLAB") is all I've used, and may be adequate for ANYBODY developing in Assembly language. It includes a Simulator that I've used (on too many occasions) to find, study and squash bugs. Current release (ver 6.5 - minor updates every 6-8 weeks) is a 35 meg download from:

Also grab the tutorial (1 meg) at:

And cruise the company's discussion groups at:

- There are several designs for PIC programmers floating around the web, published in Circuit Cellar magazine (e.g., July 2003, pg 18), and sold by half a dozen small companies either directly or on EBay ("Olimex" looks intersting to me). I built one of the web designs that connect to the Personal Confuser's Parallel port. It worked, but wasn't nearly as convenient as Dan's "PICSTART" (about $200 from MICROCHIP) which is directly supported from within MPLAB. I'd look for a programmer that can be integrated with MPLAB.

- PIC's can be programmed in-circuit. At worst, you might have to add a couple isolation resistors to your circuit. On all of my hardware designs I included a 6 position (2X3) SMT header in 2mm pitch & connected the programming pins to it. For development boards I installed the header and made a short jumper cable to the programmer. When the board went to production, we left the header off and the empty solder pads gave the production test equipment easy access for programming during manufacture.

- Work with the flash-based (16Fxxx series) rather than EPROM (16Cxxx) parts. The uV-erasable 16Cxxx parts are expensive and available for only a few types. The flash parts let you make a LOT more mistakes in a lot less time, and are generally cheaper as well.

- Each part number has it's own "Data Sheet", which you can get in PDF form on the MICROCHIP web site. These are actually books, running 100 to 200 pages. These "Data Sheets" are at least adequate for explaining how to use the various features and peripherals of each part. I don't think they've ever misled me, though sometimes I wish they had warned me about a few things. I get the one for the processor I'm working with and print it 2-sided, 2-up on standard paper. It's still readable (I've been in bifocals for about a dozen years) but saves trees by putting 4 pages on an 8.5x11 sheet. My work style usually has the paper copy of the "Data Sheet" in my left hand, the schematic and PWB layout under my right elbow, and MPLAB full-screen on the PC.

- MICROCHIP is fairly generous with free samples. I think you can get up to 15 parts/month by ordering from their "Samples" page at: . You have to register and answer a few questions about the product you're developing, estimated annual usage, etc. They've never hassled or hounded me after requesting samples. It takes a couple weeks to get them, though, so maybe you'd be better off buying a handful of parts from Digikey.

- There are several beginner's books about PIC's and at least one set of university course-ware (text, lab exercises and breadbord - see: ) One publisher, "Square 1 Electronics"

formatting link
offers a series of beginner's instructional books on PIC microcontrollers. I bought "Microcontrol'n Apps" ($40, as I recall) and found the explanation of both code examples and hardware very thorough and fairly practical. I consulted it a few times, but it mostly confirmed what I'd already figured out so I'm not sure I got my $40 out of it yet.

- I probably made all the "typical" programming mistakes, like SETing a bit that I really should have CLEARed, thinking that the first bit in a byte is "bit 1" rather than "bit 0", etc. Just shows that nothing is fool-proof, since we fools can be pretty ingenious. The most consistent aggravation, however, was already mentioned: page and bank switching in memory. I've learned to be constantly asking myself, "When I ask for {some variable}, will I get the value I want - or something else that lives at the same address but on a different page?" Or (for program memory), "If I jump to {some location} will I actually go there, or land in the corresponding place on some other page?".

- MICROCHIP seems to make a lot of parts that are "the same only different". This probably won't matter to you until you try to use a new part number. Then you'll discover that even though they have the same peripherals (say, an A/D or a UART) the I/O pins are multiplexed just a little bit different . . . or a particular bit is in a different position in the control register . . . or the necessary steps for making the function work are just a little different.

If you have more questions, go ahead and email me direct. I can usually spot the REAL messages among all the "See the naked women add

3 inches to their home mortgage" spam. Besides, we probably went to different schools together,

Dale

Reply to
Dale Chisholm

[snipped excellent information]

Very good! First time I've seen some real nitty gritty info on PICs, with first hand experience from a neophyte. Thanks much.

Reply to
Watson A.Name "Watt Sun - the

Dale, forget the engineering job, start writing humor. Your letter to Jim Thompson was the greatest! BTW just what is an "8051"?

)
Reply to
D. Weatherwax

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.