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.

Novice looking for help

Status
Not open for further replies.

StGeorge

New Member
Hi all, I'm looking for some advice here. I used to be an electronic engineer but left the industry in 1992 to take up a career in IT so I have forgotten most of what I used to know. And anything I do remember is obsolete :)

A colleague of mine has a requirement for some electronic expertise and as I am the only 'technical' person he knows, he's turned to me.

The requirement is to control a number (up to 20ish) of small LEDs and program them to flash at varying intervals (each LED needs to flash with a different interval). He has a circuit which someone made for him a few years ago (the creator has sadly passed on) and it consists of 2 PIC16LF84A controllers.

I know nothing of these controllers and am wondering if:
a) Can I reverse engineer the programs on these controllers to get an idea of what is required
b) What tools do I need for the above and also to program new controllers
c) Are these controllers still available
d) Am I going about this the wrong way and is there an easier way to do this nowadays

Sorry for the long post but hopefully it all makes sense.

Any and all information/advice will be gratefully received.
 
Look at Talking Electronics website under: Elektor,EPE,Silicon Chip and it will show you programs to help you with what you are wanting to do.
 
What do the LEDs do? What are the intervals, and are the LEDs on 50:50 duty or a small ON period and long OFF period?

If you provide more information its much easier for people to help you. :)
 
What do the LEDs do? What are the intervals, and are the LEDs on 50:50 duty or a small ON period and long OFF period?

If you provide more information its much easier for people to help you. :)

Sorry, I'm new to this :)

The LEDs will be used at wildly varying intervals. For instance if I have a circuit with 10 LEDs 2 may be flashing at 1s on, 3s off. Another may be 250ms on, 250ms off. Some others could be 2s on, 500ms off.

They will vary that much and more but within each circuit a specific LED will always flash with the same interval.

I assumed that if I can write a program to control 10 (or more) LEDs then I can have standard routines for the on and off cycles and just insert them where necessary. However, I do know assumption is a dangerous thing :D
 
IMHO the easiest programming language to learn for a beginner is BASIC, and an excellent free student edition for the 18F series PICs is Swordfish BASIC SE.
Blinking LEDs would only take a few lines of code.
 
You will most probably be dealing with a timer interupt, and a bunch of counters.

Supposing each led has a static behaviour
You shall finish with something like (in mostly correct C99)


#define NUM_LED 10
#define DELAY_TYPE unsigned char
const DELAY_TYPE tOn[NUM_LED]{...values...};
const DELAY_TYPE tOff[NUM_LED]{...values...};
DELAY_TYPE counter[NUM_LED];
bool status[NUM_LED];

timerISR()
{
//deal with the interupt stuff
//insert a sub counter here if you need longer ticks than the one your mcu can provide
//as in
if(counter--)
return;
else
counter = divider;

for(int i=0; i < NUM_LED; i++)
{
if(status)
counter--;
else
{
counter=(status?tOff:tOn);
status = !status;
}
}
// deal some more with some interrupt related stuff here if needed
}

Plenty of optimisation to be done in there, but the question in the end is always, can you really be bothered if it works. In real life, the status array would most likely be the output buffer registers for your mv ports, and hence would be bit packed.

I could see how you would get more generic, but you would waste an awful lot of ressources to do so.
 
Last edited:
Thanks for the info Jim, much appreciated.

If I get this is it the same product with the board you indicated included with it?

Yep, thats the one:)
Its a cheap solution to get going with. If you order some 2.54mm header strip too, you can knock up any project you like on a breadboard, and use the header strip to program the PIC in circuit

Jim
 
OK, I've got the basic programming (that's a small 'b', I've done it in assembly :)) worked out and have ordered some bits to build a more complete prototype of what I want, with extra LEDs.

Jim, you suggested that I can program the PIC in circuit using the PICKit 2 programmer. Looking at the way it's connected on the demo board I just need to connect Vss, Vdd, RA0, RA1 and RA3. Will it be OK if I have things connected to these pins or do I need to isolate them in order to program the chip properly?

TIA...
 
Last edited:
do I need to isolate the programming lines in order to program the chip properly?

The programming lines need to be "lightly loaded" so that the programming can produce a "HIGH." If you have a LED connected to any of the outputs, you will see it flash during programming.
It is especially important to keep the Vpp line lightly loaded so that the full 13.5v will be detected by the chip.
This is all covered on the link I gave previously, so it is plainly obvious that you have not taken the trouble to do any reading yourself.
 
Last edited:
Try to read the program off the chip first. If these were hand programmed, they might not have the CodeProtect bit enabled. It'll be all assembly, but you should be able to decern something from the code.
 
Thanks for the info smanches but I don't think the PICKit 2 has the ability to prorgam/read the PIC16LF84A. And I think I have the software cracked now, I just need to get the hardware sorted out.

Colin, thank you for your reply but you seem to have misquoted me. However, thank you for your information on the loading of the programming lines.

This is all covered on the link I gave previously, so it is plainly obvious that you have not taken the trouble to do any reading yourself.

I can assure you that I have been doing little else but reading for the last week but your 'link' (not precisely a **broken link removed**, but hey ho) was one of the first things I looked at so it was also the first thing I forgot. I probably could have delved deeper into that site but I just wanted a quick answer to a simple question so I thought I would ask it here as everyone had seemed so friendly.

I have no wish to disturb the amity of this forum so I will seek the knowledge I require elsewhere. Thanks to everyone else for being so helpful.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top