Maker Pro
Maker Pro

PIC PULSIN statement and pin connection to external V+

J

John Popelish

Jan 1, 1970
0
Rubicon wrote:
(snip)
In addition I wish to replace the tactile switches at some point and
connect the pins to a crossover switch controlling a motor powered by
a 12V (13.8) battery. I read in a previous post reply by John Popelish
to Richard Swinfen.

******************
Richard Swinfen

<snip)

******************
John Popelish
<Snip>
The networked connections can complicate things, since they are all
antennas that can feed spikes to the PIC. I big no-no is having any
connections to the PIC go outside the supply rails, even briefly. The
specs for the PIC are damage specs, not malfunction specs. You might
try adding an additional 1 Mohm resistor between the 10 Mohm resistor
and PIC, with a 4.7 volt zener at the junction of the resistors ot the
0v rail. This will eliminate any positive input voltage above 4.7
volts, and will limit the negative current ot a few tenths of a volt
across 1 Mohm.
<snip>
******************

I take it that something like this circuit would have to be connected
to the PICs input pins. Can anyone advise on the best values for a
13.8 volt battery?

Maybe something like that will work, but that advice was for an input
derived directly from the hot side of the AC power line. And he was
trying to determine the zero crossing time, so he wanted the swing to
take place as soon as possible after the line voltage passed through
zero volts.

You may be able to reduce a logic swing of 13.8 volts to PIC supply
range with a simple voltage divider. I am not clear on what a cross
over switch is. Are you talking about hall effect motor position
switches?
 
R

Rubicon

Jan 1, 1970
0
Hello,

Can anyone help me here with the PULSIN command using PICBASIC PRO on
a 16F84A pic? I'm not asking because I'm too lazy to read and learn
but because I'm getting more and more muddled as each night passes by
and have tried so many different things that I'm getting lost.

I just can't seem to get it working right if at all and it's really
getting me mad now. I want it to count the pulses on two pins via
tactile switches and light or extinguish up to 10 LEDs in 1 second
increments. One TXT file has IF-THEN statements and another has the
IF-THEN statements within a WHILE-WEND for the count up section at
least. Haven't progressed past that as I want to get that part working
first.

W1 VAR WORD '16bit vairable W1
W2 VAR WORD '16bit vairable W2
W3 VAR WORD '16bit vairable W3

DEFINE PULSIN_ MAX 1000

W1 = 0 'Zero W1
PULSIN PORTB.0,1,W1
W3 = W3 + (W1 * 10) 'Multiply W1 increment count by 10uS and add
'W1 to W3

W2 = 0 'Zero w2
PULSIN PORTB.0,1,W2
W3 = W3 - (W2 * 10) 'Multiply W2 increment count by 10uS and
'subtract W2 from W3

IF W3 >= what?? AND W3 < what?? THEN LED1


I read that on a 16F84A with a 4MHz crystal the pulse-width returned
is in 10uS increments so with the 16 bit vairable it's:
65535 * 10uS = 655350uS or a little over 0.65 seconds

1,000,000 uS = 1 second
100,000 increments * 10uS = 1 second

However the statement:
PAUSE (period)

Gives a delay in milliseconds and (period) is also 16 bits so
PAUSE 1000 is a 1 second delay.

This confuses me and I am very confused. If both are 16 bits
then surely PULSIN could count up to a little over a minute like PAUSE
or is PAUSE not dependent on the clock speed like PULSIN is?

Another question is what to do with any unused pins. I read somewhere
but I can't find it again to be sure that it's best to tie each unused
pin through a resistor to V-. Is this correct?

In addition I wish to replace the tactile switches at some point and
connect the pins to a crossover switch controlling a motor powered by
a 12V (13.8) battery. I read in a previous post reply by John Popelish
to Richard Swinfen.

******************
Richard Swinfen
The PIC, 2803 and relays are powered by a 7805 with recommended
caps on both sides (1uf & .33uf) itself powered by a 1.2A 12v regulated
supply. Another possibly relevant point is that the PIC determines
zero-crossing using a dirty-but-working 10MOhm direct live feed to RB0. I'll
check removing this doesn't fix it.
<snip)

******************
John Popelish
<Snip>
The networked connections can complicate things, since they are all
antennas that can feed spikes to the PIC. I big no-no is having any
connections to the PIC go outside the supply rails, even briefly. The
specs for the PIC are damage specs, not malfunction specs. You might
try adding an additional 1 Mohm resistor between the 10 Mohm resistor
and PIC, with a 4.7 volt zener at the junction of the resistors ot the
0v rail. This will eliminate any positive input voltage above 4.7
volts, and will limit the negative current ot a few tenths of a volt
across 1 Mohm.
<snip>
******************

I take it that something like this circuit would have to be connected
to the PICs input pins. Can anyone advise on the best values for a
13.8 volt battery?

Any help greatly appreciated.

Thankyou,

Andrew.
 
R

Rubicon

Jan 1, 1970
0
John,

"Crossover switch" is the term used in some documentation to describe
a DPDT (momentary on, center off, momentary on) switch for controlling
the forward and reverse of the DC motor. The motor has no other
connections apart from the V+/V- so I'm needing to make a rough time
based LED position indicator. This is where the PIC comes in to help
me learn more about them and programming.

Thanks,

Andrew.
 
Top