# Timer Circuits or PIC

Discussion in 'Electronic Basics' started by Rob Convery, Sep 13, 2005.

1. ### Rob ConveryGuest

I am working on a project where I am going to be controlling a number of
rams. These are triggered using solenoids. I am trying to work out the best
method of controlling these. The whole setup will have 5 instances of the
setup described below (this may effect how you suggest doing this). I am
working in a environment with a supply voltage of +12v.

I have a single pulse trigger which I need to subsequently operate 2 outputs
using delays using a 2nd input to decided what to trigger. In Summary.

Trigger input pulses High
If Input Z if ground Then
Output A must go high for X (approx 5-10) seconds
&
Output C must delay for X (probably 2), then high for X seconds
(probably 2)
else
Output B must go high for X (approx 5-10) seconds
&
Output C must delay for X (probably 2), then high for X seconds
(probably 2)
end else

or pictorally

Trigger ___|-|_______________________
InZ _____________________________
A ____|-------------------|____
B _____________________________
C __________|--|_______________

OR

Trigger ___|-|_______________________
InZ -----------------------------
A _____________________________
B ____|-------------------|____
C __________|--|_______________

(Copy above to notepad if it displays incorrectly)

So what is the best way of implementing this. Should I use a combination of
timer circuits to do this but with having 5 of these it would become a mass
of timer circuits. Alternatively I could program a PIC or PICs do to this (I
have never done PIC programming - well other than some traffic light thing
during electronics at Uni, but should be able to pick it up as I am a
programmer/tester by day)

Rob

2. ### John FieldsGuest

---

If this is what you mean:

t0-->|_ t0-->|_
Trigger ___| |_________________..._____| |_____________________
____ __________________________
InZ ____|______________________...__|
_______________
A _________| |___..._____________________________
|<--- 5-10s --->|
_______________
B _____________________________..._____| |_______
|<--- 5-10s --->|
___ ___
C _____________| |___________...________| |________________
2s-->| |<-- 2s-->| |<--
-->| |<--2s -->| |<--2s

---
---
If you build it out of glue logic then you'll need a timer for A,
one for B, one for C, and one for the delay before C. You'll also
need an inverter to select between A and B, so if the timers are
dual one-shots like 4538's or HC123's it'll cost you 4 chips per
channel plus four timing caps, four timing resistors (probably pots
if you're not sure what you timing requirements will be). Also, for
the board, one hex inverter and one RC for the power-on reset.

That's 11 chips and 42 discretes total, versus a single
microcontroller and a ceramic resonator if you need better accuracy
than you can get with the µC's internal clock oscillator.

If you write code for the µC, the choice of which way to go is
pretty much a no-brainer, huh?

BTW, you could use a single timer for A and B, but then you'd have
to steer its output, which would cost you three quad 2-input ANDs.
So your savings in one-shots(2 chips) would be offset by the need
for the three quad 2-input ANDs, so that would cost you an extra
chip. You'd save ten discretes, though...

Still a no-brainer, I think.

3. ### ehsjrGuest

I agree strongly with John. Even if the hardware did not present
such a compelling case, I still think a micro-controller would be
better in this case, based on your requirements. They included the
terms "approx" and "probably" 6 times, indicating there is some
possible variability in what you need to do.

Ed

4. ### petrus bitbyterGuest

___
Trigger ______| |___________________________

InZ _______________________________________

______________________
A _______| |________

B ________________________________________

______
C __________________| |______________

__________
Chelp ________| |_____________________

Redraw (part of) your pulse diagrams to make sure I understand what you want
to achieve. A circuit that behaves like this can be build using two dual
monostable ICs like the old CD4098B or the CD4538B along with four Rs and
four Cs for the timing and one inverter. One IC should be used to make the
A- and the B-pulse. Connect the TR+ inputs to the Trigger, one TR- input to
InZ and the other TR- input to the inverted InZ. The second IC can make the
C-pulse. One monostable (making Chelp) is triggered by the raising edge
Trigger, the second is triggered by the falling edge of the first. If the
circuit is one of a kind *and* you have plenty of space for the components
*and* you have neither the skills nor the equipment to program PICs this is
the way to go. But in all other cases I'd prefer an eight pins PIC (or a
collegue, a tiny AVR) to do the job. Keep in mind that a PIC requires 5V
(common types) power. Which means an 7805 and two caps. PICs also do not
like pulse >5V on their inputs so you may need a voltage divider for both
inputs. You will also need output transistors as neither the monostables nor
the micros are able te drive a solenoid.

petrus bitbyter

5. ### mikeGuest

Your use of the word "ram" conjures visions of maiming
or other destruction when things go horribly wrong.
Might want to invest in some position sensors, watchdog
timers and maybe even external solenoid drive gates in case
the processor goes horribly wrong. A cap on the gate function
of a solenoid driver kicked by a watchdog timer gives you two
levels of protection.
PIC lends itself well to including these safety featurs
at virtually no extra cost or complexity. Writing the code
forces you to think about what might go wrong and what
might be done to minimize the destruction.
mike

--
Return address is VALID but some sites block emails
..
Wanted, PCMCIA SCSI Card for HP m820 CDRW.
FS 500MHz Tek DSOscilloscope TDS540 Make Offer
Wanted 12" LCD for Compaq Armada 7770MT.
Bunch of stuff For Sale and Wanted at the link below.
MAKE THE OBVIOUS CHANGES TO THE LINK
ht<removethis>tp://www.geocities.com/SiliconValley/Monitor/4710/

6. ### Rob ConveryGuest

Thanks - I suspected so. Now the nest question. As I have not done PIC
progamming since uni what is the easiest way to get into this? Is there a
decent kit out there etc? Also any specif place for support i.e.
newgroups/forums?

Cheers

Rob

7. ### John FieldsGuest

---
I don't do PICs because I like Motorola (Freescale) better, but this
will get you going if you want to use Microchip's stuff...

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=64

Also, some of the other guys around here and on sed use PIC's so
maybe you'll get some info from them.

Then there are also the comp.arch.embedded newsgroups.

8. ### Rich GriseGuest

John gave you the link to the microchip site, but here's a sample of
what's out there:

too heavily into it yet.

Have Fun!
Rich

9. ### mikeGuest

If you're comfortable with assembly language programming, maplab will do
what you need for free. There are also several other free or cheap
programming environments. But if this is your job and your boss cares
situations into simple statements and can dramatically reduce your
error rate.

Once you get the serial port hooked up, you'll be able to modify the
program and be back testing it in seconds. The serial port connection
comes in very handy to report real-time status of your system. You only
need the PIC programmer to install the bootloader the first time.
After you get it all debugged, you can think about switching to a
smaller part, but it's probably not worth the effort unless you wanna
make thousands...or the big chip won't fit in the box. There are newer
parts, but then you gotta go find newer tools...

recommendations on what I KNOW works. You'll get lots of arguments
over individual pieces, but you need a system that works. YMMV

Email me if you wanna discuss further.
mike

--
Return address is VALID but some sites block emails
..
Wanted, PCMCIA SCSI Card for HP m820 CDRW.
FS 500MHz Tek DSOscilloscope TDS540 Make Offer
Wanted 12" LCD for Compaq Armada 7770MT.
Bunch of stuff For Sale and Wanted at the link below.
MAKE THE OBVIOUS CHANGES TO THE LINK
ht<removethis>tp://www.geocities.com/SiliconValley/Monitor/4710/

10. ### David L. JonesGuest

A PIC-AXE (Google it) is by far the easiest way to program a micro. No
harwdare needed and it uses simple commands in BASIC.
A PIC-AXE is a regular PIC chip with a BASIC interpreter pre-programmed
into it. So you don't need to know anything about the PIC architecture
in order to program it. They are CHEAP too.
A PIC-BASIC Pro compiler with the PIC hardware programmer is more
complicated than a PIC-AXE.

BASIC-Stamps are similar but are a more expensive "module" solution.
PIC-AXE kills it for an apllication like this.

Dave

11. ### Jasen BettsGuest

use a PLC
if you know PIC assembler (or programming and any assember) it shouldn't be
a tough task to implement each on a separate microcontroller

if you want to make it a tougher task implement all 5 on a single chip

Bye.
Jasen

12. ### Jasen BettsGuest

There's comp.sys.embedded but I stopped reading that as *.electronics.* is
keeping me busy enough.

as for hardware any serious electronics store (amy many hobbiest electronics
stores) will have development kits of some kind. there's plenty of software
out there on the internet.

Bye.
Jasen

13. ### quietguyGuest

I would suggest using a PICAXE rather than a PIC - they are just as cheap, but
the mfg provides a free programmer which allows you to program in BASIC on a
Windows box, and you only need a simple Serial port lead and two resistors to
web to get you started

They also have a number of development boards, kits etc

As a starting point have a look at http://www.picaxe.com.au/ - you will
find other links there as well

David

14. ### Rich GriseGuest

Oh, yeah, sounds great, except for the "step-by-step" instructions:
http://www.rev-ed.co.uk/picaxe/stepbystep.htm

Step 1, select a chip,
Step 2, write the program,
Step 3, connect the cable directly to the project board...

Wait a minute? Where did this "project board" come from????

Thanks,
Rich

15. ### Jonathan KirwanGuest

It appears as soon as the right amount of money disappears?

Jon

16. ### quietguyGuest

The project board can be one they sell, or you just use some veroboard etc or
any project type board you may have. Depending on the PICAXE you buy - eg 8
pin, 18 pin etc, the board needs to have a socket for the PICAXE, 2 resistors
(serial input for programming) , and the usual provision for connecting a 5volt
supply. Plus of course you might want some leds etc to play with. You also
need to make up or buy a lead - serial (RS232) plug one end, perhaps a 3.5mm
stereo plug the other end - so you can program the PICAXE

I gather you thought it was some expensive rip off thing, but that isn't the
case. I did buy a (18X) project board, but am also making another one from a
small piece of veroboard for the 08M PICAXE (A\$4.95) to make a musical toy for
my grandson.

David

17. ### Rich GriseGuest

I've got the serial cable, a protoboard (The white rectangular one
with the strips of plug-in contacts), and a supply - are you saying
that I can plug in the chip, power it, two resistors, and plug in the
serial port, and I'm ready to go? That'd be kewl. Where's the schematic
for this arrangement?

Thanks,
Rich