Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Best code to learn?

Status
Not open for further replies.

Andy1845c

Active Member
I want to use a PIC to flash LEDs. (Yes, still working on my homemade traffic advisor:rolleyes: ) To get several differnt patterns of flashing, I would need quite a bit of analog circuitry. I'd like to keep the control box as small as possible. I've done a little bit of reading on PICs, and it sounds like flashing banks of LEDs with one is a pretty basic function. It looked like the first lesson in Nigel's tutorials is close to what I want.

My questions are:
What programming is used in Nigel's tutorials? Is it C? I really don't know much past HTML:eek:

What would be the best to learn if all i'm looking to do at this point is flash banks on LEDs?

Can one PIC have several flash patterns programmed into it? and if so, how are they selected with a switch?

Mostly i'm looking for some opinions on what I should learn as far as programming goes for a simple task like this.
 
What programming is used in Nigel's tutorials? Is it C? I really don't know much past HTML
Assembler. But don't worry PIC assembler is easy because there are so few instructions. There are only 35 or so. Don't remember the exact number.
What would be the best to learn if all i'm looking to do at this point is flash banks on LEDs?
Assembler is the most common and you'll find more code examples for this than anything else. I've heard that JAL is a pretty easy language to use and is free. This site has lots of JAL coded projects:
**broken link removed**
Can one PIC have several flash patterns programmed into it? and if so, how are they selected with a switch?
The only limit is your imagination! You could use a single pushbutton to cycle through patterns or a BCD coded one, or even a POT connected to the PICs built in ADC (alot of PICs have ADCs), etc
 
Last edited:
kchriste said:
Assembler. But don't worry PIC assembler is easy because there are so few instructions. There are only 35 or so. Don't remember the exact number.

--Yup there are only 35 single word instructions, for the pic 16f84 that is..don't know for the others
 
kchriste said:
The only limit is your imagination!

I like the sound of that! ;)

I know there are many PICs out there, but how much can you fit on one? Is it determined by lines of code or characters or? I know I probably don't need to worry about it for my trivial task, but it seemed like Nigel's example of bouncing an led back and forth takes quite a few lines. Is it concevible to get 5 or 6 semi complex flash patterns on a single PIC?
 
I know there are many PICs out there, but how much can you fit on one? Is it determined by lines of code or characters or?
Most come with 1K (12F675 in a 8pin dip) of flash memory or more (64K for a 18F4620 in a 40pin dip). That's 1024 lines of code or 1024 bytes of raw data in the 12F675. I've got webpages loaded into a 18F4620 :D
Is it concevible to get 5 or 6 semi complex flash patterns on a single PIC?
Definately. Even with the simple table lookup method, it shouldn't tax the PIC too hard. How many LEDs and discrete states do you have in mind?
 
Hey kchriste,
I really appreciate you taking the time to answer my questions. Thanks:)

I want to flash 8 banks of around 40 LEDs. I'm not sure what a discrete state is. If I could get a left to right, and right to left sequence and a few warning patterns i'd be happy. But the more I read about micros, it sounds like any pattern I can dream up won't be a problem once I get to know the coding.

I'll have to invest in the hardware needed to start experimenting and work my way though the stuff on Nigel's site.

At first micros scared me, and I wanted to do this all with analog stuff, but the more I learn, learning to program a micro sounds far easier then figuring out how to do it with shift registers or somthing like that. Not to mention how much easier to assemble and how much smaller the control box will be. :D
 
I want to flash 8 banks of around 40 LEDs.
You'll have to add some shift-registers to your PIC or multiplex the LEDs. I think the largest DIP package is 40 pins, unless you want to go SMD. Multiplexing is your best option as it saves on wiring all those pins and you can use a smaller PIC.
I'm not sure what a discrete state is.
What I meant by that was the number of different LED patterns in each of your semi complex flash patterns. For complex flash patterns, such a Persistance Of Vision display, a lookup table is the most practical method but each group of 8 LEDs would use one word/byte in program memory per discrete state. Nigels back/forth flasher uses an algorithm to generate the display and thus is more compact but less versitile if you wish to change the pattern much. Nothing says you can't use both methods in your design though.
I could get a left to right, and right to left sequence and a few warning patterns i'd be happy.
Left and right scrolling is easy because of the RLF and RRF instructions. :)
I'll have to invest in the hardware needed to start experimenting and work my way though the stuff on Nigel's site.
That is generally the biggest hurdle. Once you get your programmer working and you're flashing your first LED via a PIC, you're past 75% of the most difficult part for new PIC users.
At first micros scared me, and I wanted to do this all with analog stuff, but the more I learn, learning to program a micro sounds far easier
You'll probably never go back to discrete logic once you've learned PIC programming unless you need something really fast like 100Mhz prescaler for a frequency counter etc. The neat thing about PICs is that they can come in really small packages such as the 10F series which is about the size of a SMD transistor!
 
kchriste said:
You'll have to add some shift-registers to your PIC or multiplex the LEDs. I think the largest DIP package is 40 pins, unless you want to go SMD. Multiplexing is your best option as it saves on wiring all those pins and you can use a smaller PIC.
I might have used poor wording about what I want to flash. I don't need to control all 40 seperatly, but rather just each of the 8 groups of 40. I was thinking I could do it with a micro with 8 output pins and drive the 40 LED groups with darlingtons or somthing like that. Is that reasonable, or won't it work that way?

I looked up Persistance Of Vision display, and i'm not looking for anything near that complex for this. What I think of as complex might be pretty simple:eek: I'm looking for like an alternating flash for a a certin number of cycles, then mabey for all 8 groups to strobe a number of cycles and then for mabey 2 or 3 of the 8 to strobe at a differnt rate then for the pattern to start over. This is somthing like what I want: https://youtube.com/watch?v=k4Yjai3w4y0

Can you (or anyone) recommend where to order the hardware from here in the States? I'm excited to start working on this:D
 
I was thinking I could do it with a micro with 8 output pins and drive the 40 LED groups with darlingtons or somthing like that. Is that reasonable, or won't it work that way?
That'll work well. Darlingtons or FETs will work fine. You'll have to series/parallel the LEDs to get the optimum operating voltage for your supply.
This is somthing like what I want: http://youtube.com/watch?v=k4Yjai3w4y0
You should have no problem doing that with a PIC. Something like the 16F628A would fit the bill nicely as it has two 8bit ports.
Can you (or anyone) recommend where to order the hardware from here in the States?
You can get free samples from Microchip at http://sample.microchip.com if you don't feel guilty about pretending to be incorporated.... ;)
I order my stuff from digikey.com but there are others such as mouser.com etc
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top