| Author |
Message |
Bob Monsen
Guest
|
Posted:
Wed Sep 21, 2005 12:35 am Post subject:
Re: newbie:Simple LED sequence? |
|
|
On Tue, 20 Sep 2005 17:15:02 +0000, Terry Pinnell wrote:
| Quote: | ehsjr <ehsjr@bellatlantic.net> wrote:
It was another damn "use a PIC" post. Some of these posters drive
me crazy. Never a "Wow John, you sure put a lot of work into that,
nice job!" Never a complete project, with a schematic and source
code. Just "you could use a PIC". Hell, if you did what those
pic-ophiles do, your posts would say "use a soldering iron."
One thing's for sure - we can't criticize the PIC designs posted as
solutions to requests from posters. I'll tell you this, I'll put
any one of the solutions you've offered in the newsgroup against
all of the posted "PIC solutions", combined. Your solutions are
always great. Theirs are non-existant.
Agreed. I could probably have made a movie of it in the time it would
take a PIC-er to just get started! Here it is:
http://www.terrypin.dial.pipex.com/Images/LED-Sequencer4MB.wmv
|
This took 5 minutes to code (adapted another project). 15 if you include
the setup, programming, testing, and bugfix (I inadvertently forgot to
call init(), and it didn't work the first time). Only one chip, a pot, 5
resistors, and 4 leds. Sadly, I don't have a movie camera, or I would
record it. This is compiled with the free 'hitech lite' C compiler, and is
downloaded to a pickit 1 using lawlor's usb_pickit for linux.
The PIC12F675 is an 8 pin uC, which supports ADC, timer interrupts, and
such. Pin 7 is used as the ADC input, so changing the voltage changes the
rate of change of the display, from once every 2 seconds to as fast as it
can go. The period is about Vin/Vcc * 2048 for Vin > 0.
Pin 6, 5, 3, and 2 are A, B, C, and D. Pin 4 is the reset, pin 1 is Vcc,
and pin 8 is GND. A-D can source up to 20mA, so a 1k resistor between it
and the LED limits current to about 3.5mA.
(for the curious, it uses a 1ms interrupt to do delays. The result of
the high byte of the AD is between 0 and 255. Thus 8 * AD is from 0 to
2040, and just delaying that number of ms interrupts provides the ability
to change the period from fast to slow)
BTW, I'm sure we all appreciate JF's and Terry's efforts to help people
out. I wish everybody's posted circuits were as well thought out, tested,
and nicely presented as the ones they post.
Regards
---------------------------------------------------------------------------
#include <pic.h>
__CONFIG(UNPROTECT & BORDIS & MCLREN & PWRTDIS & WDTDIS & INTIO);
unsigned int g_ticks; /* Ticks since startup */
#define TICKS_PER_SECOND 1000
#define LED_A GPIO1
#define LED_B GPIO2
#define LED_C GPIO4
#define LED_D GPIO5
void init_gpio(void)
{
GPIO = 0;
}
void init_tmr0(void)
{
/* prescaler is 1:4, GPIO pullups are disabled */
OPTION = 0x81;
}
void init_tmr1(void)
{
T1CON = 0; /* Disabled */
}
void init_comparator(void)
{
CMCON = 0x7; /* Turn off the comparator */
VRCON = 0x0;
}
void init_a2d(void)
{
ANSEL = 0x11; /* Fosc/8 and RA0 is analog */
ADCON0=0x00; // Left justify output
ADON=1; // turn on the A2D conversion module
}
void init_ee()
{
}
void init_interrupts(void)
{
INTCON = 0xA0;
}
void init(void)
{
OSCCAL = _READ_OSCCAL_DATA();
TRISIO = 0x01; /* RA0 is ad input, rest are outputs */
init_gpio();
init_tmr0();
init_tmr1();
init_comparator();
init_a2d();
init_interrupts();
}
unsigned int get_voltage (void)
{
GODONE=1; /* initiate conversion */
while(GODONE) /* wait for result */
{
continue;
}
return ADRESH;
}
void wait_ms(unsigned int x)
{
unsigned int temp = g_ticks + x;
while (temp != g_ticks);
}
void main(void)
{
int state = 0;
init();
LED_A = 1;
LED_B = 1;
LED_C = 0;
LED_D = 0;
for (;;)
{
unsigned int ms_to_wait = get_voltage() * 8;
wait_ms(ms_to_wait);
switch(state)
{
case 0:
LED_A = 0;
LED_C = 1;
state++;
break;
case 1:
LED_B = 0;
LED_D = 1;
state++;
break;
case 2:
LED_C = 0;
LED_A = 1;
state++;
break;
case 3:
LED_D = 0;
LED_B = 1;
state = 0;
break;
}
}
}
static void interrupt isr(void)
{
T0IF = 0;
TMR0 = 6;
g_ticks++;
}
|
|
| Back to top |
|
 |
eric
Guest
|
Posted:
Sat Sep 24, 2005 4:35 pm Post subject:
Re: newbie:Simple LED sequence? |
|
|
"Bob Monsen" <rcsurname@comcast.net> wrote in message
news:pan.2005.09.20.22.58.43.448485@comcast.net...
| Quote: | On Tue, 20 Sep 2005 17:15:02 +0000, Terry Pinnell wrote:
ehsjr <ehsjr@bellatlantic.net> wrote:
It was another damn "use a PIC" post. Some of these posters drive
me crazy. Never a "Wow John, you sure put a lot of work into that,
nice job!" Never a complete project, with a schematic and source
code. Just "you could use a PIC". Hell, if you did what those
pic-ophiles do, your posts would say "use a soldering iron."
One thing's for sure - we can't criticize the PIC designs posted as
solutions to requests from posters. I'll tell you this, I'll put
any one of the solutions you've offered in the newsgroup against
all of the posted "PIC solutions", combined. Your solutions are
always great. Theirs are non-existant.
Agreed. I could probably have made a movie of it in the time it would
take a PIC-er to just get started! Here it is:
http://www.terrypin.dial.pipex.com/Images/LED-Sequencer4MB.wmv
This took 5 minutes to code (adapted another project). 15 if you include
the setup, programming, testing, and bugfix (I inadvertently forgot to
call init(), and it didn't work the first time). Only one chip, a pot, 5
resistors, and 4 leds. Sadly, I don't have a movie camera, or I would
record it. This is compiled with the free 'hitech lite' C compiler, and is
downloaded to a pickit 1 using lawlor's usb_pickit for linux.
The PIC12F675 is an 8 pin uC, which supports ADC, timer interrupts, and
such. Pin 7 is used as the ADC input, so changing the voltage changes the
rate of change of the display, from once every 2 seconds to as fast as it
can go. The period is about Vin/Vcc * 2048 for Vin > 0.
Pin 6, 5, 3, and 2 are A, B, C, and D. Pin 4 is the reset, pin 1 is Vcc,
and pin 8 is GND. A-D can source up to 20mA, so a 1k resistor between it
and the LED limits current to about 3.5mA.
(for the curious, it uses a 1ms interrupt to do delays. The result of
the high byte of the AD is between 0 and 255. Thus 8 * AD is from 0 to
2040, and just delaying that number of ms interrupts provides the ability
to change the period from fast to slow)
BTW, I'm sure we all appreciate JF's and Terry's efforts to help people
out. I wish everybody's posted circuits were as well thought out, tested,
and nicely presented as the ones they post.
Regards
---------------------------------------------------------------------------
#include <pic.h
__CONFIG(UNPROTECT & BORDIS & MCLREN & PWRTDIS & WDTDIS & INTIO);
unsigned int g_ticks; /* Ticks since startup */
#define TICKS_PER_SECOND 1000
#define LED_A GPIO1
#define LED_B GPIO2
#define LED_C GPIO4
#define LED_D GPIO5
void init_gpio(void)
{
GPIO = 0;
}
void init_tmr0(void)
{
/* prescaler is 1:4, GPIO pullups are disabled */
OPTION = 0x81;
}
void init_tmr1(void)
{
T1CON = 0; /* Disabled */
}
void init_comparator(void)
{
CMCON = 0x7; /* Turn off the comparator */
VRCON = 0x0;
}
void init_a2d(void)
{
ANSEL = 0x11; /* Fosc/8 and RA0 is analog */
ADCON0=0x00; // Left justify output
ADON=1; // turn on the A2D conversion module
}
void init_ee()
{
}
void init_interrupts(void)
{
INTCON = 0xA0;
}
void init(void)
{
OSCCAL = _READ_OSCCAL_DATA();
TRISIO = 0x01; /* RA0 is ad input, rest are outputs */
init_gpio();
init_tmr0();
init_tmr1();
init_comparator();
init_a2d();
init_interrupts();
}
unsigned int get_voltage (void)
{
GODONE=1; /* initiate conversion */
while(GODONE) /* wait for result */
{
continue;
}
return ADRESH;
}
void wait_ms(unsigned int x)
{
unsigned int temp = g_ticks + x;
while (temp != g_ticks);
}
void main(void)
{
int state = 0;
init();
LED_A = 1;
LED_B = 1;
LED_C = 0;
LED_D = 0;
for (;;)
{
unsigned int ms_to_wait = get_voltage() * 8;
wait_ms(ms_to_wait);
switch(state)
{
case 0:
LED_A = 0;
LED_C = 1;
state++;
break;
case 1:
LED_B = 0;
LED_D = 1;
state++;
break;
case 2:
LED_C = 0;
LED_A = 1;
state++;
break;
case 3:
LED_D = 0;
LED_B = 1;
state = 0;
break;
}
}
}
static void interrupt isr(void)
{
T0IF = 0;
TMR0 = 6;
g_ticks++;
}
|
What program lang did you use It looks like C to me or is it Basic?
Eric |
|
| Back to top |
|
 |
Bob Monsen
Guest
|
Posted:
Sun Sep 25, 2005 12:30 am Post subject:
Re: newbie:Simple LED sequence? |
|
|
On Sat, 24 Sep 2005 13:27:44 +0000, eric wrote:
| Quote: |
What program lang did you use It looks like C to me or is it Basic?
Eric
|
It is C. There is a free compiler available from http://www.htsoft.com/
which works for pic 12 and 16 series chips.
|
|
| Back to top |
|
 |
Jasen Betts
Guest
|
Posted:
Sun Sep 25, 2005 1:34 pm Post subject:
Re: newbie:Simple LED sequence? |
|
|
On 2005-09-24, eric <ericgundersen1@mchsi.com> wrote:
| Quote: |
"Bob Monsen" <rcsurname@comcast.net> wrote in message
news:pan.2005.09.20.22.58.43.448485@comcast.net...
On Tue, 20 Sep 2005 17:15:02 +0000, Terry Pinnell wrote:
ehsjr <ehsjr@bellatlantic.net> wrote:
It was another damn "use a PIC" post. Some of these posters drive
me crazy. Never a "Wow John, you sure put a lot of work into that,
nice job!" Never a complete project, with a schematic and source
code. Just "you could use a PIC". Hell, if you did what those
pic-ophiles do, your posts would say "use a soldering iron."
One thing's for sure - we can't criticize the PIC designs posted as
solutions to requests from posters. I'll tell you this, I'll put
any one of the solutions you've offered in the newsgroup against
all of the posted "PIC solutions", combined. Your solutions are
always great. Theirs are non-existant.
Agreed. I could probably have made a movie of it in the time it would
take a PIC-er to just get started! Here it is:
http://www.terrypin.dial.pipex.com/Images/LED-Sequencer4MB.wmv
This took 5 minutes to code (adapted another project). 15 if you include
the setup, programming, testing, and bugfix (I inadvertently forgot to
call init(), and it didn't work the first time). Only one chip, a pot, 5
resistors, and 4 leds. Sadly, I don't have a movie camera, or I would
record it. This is compiled with the free 'hitech lite' C compiler, and is
downloaded to a pickit 1 using lawlor's usb_pickit for linux.
The PIC12F675 is an 8 pin uC, which supports ADC, timer interrupts, and
such. Pin 7 is used as the ADC input, so changing the voltage changes the
rate of change of the display, from once every 2 seconds to as fast as it
can go. The period is about Vin/Vcc * 2048 for Vin > 0.
Pin 6, 5, 3, and 2 are A, B, C, and D. Pin 4 is the reset, pin 1 is Vcc,
and pin 8 is GND. A-D can source up to 20mA, so a 1k resistor between it
and the LED limits current to about 3.5mA.
(for the curious, it uses a 1ms interrupt to do delays. The result of
the high byte of the AD is between 0 and 255. Thus 8 * AD is from 0 to
2040, and just delaying that number of ms interrupts provides the ability
to change the period from fast to slow)
BTW, I'm sure we all appreciate JF's and Terry's efforts to help people
out. I wish everybody's posted circuits were as well thought out, tested,
and nicely presented as the ones they post.
Regards
---------------------------------------------------------------------------
#include <pic.h
__CONFIG(UNPROTECT & BORDIS & MCLREN & PWRTDIS & WDTDIS & INTIO);
unsigned int g_ticks; /* Ticks since startup */
#define TICKS_PER_SECOND 1000
#define LED_A GPIO1
#define LED_B GPIO2
#define LED_C GPIO4
#define LED_D GPIO5
void init_gpio(void)
{
GPIO = 0;
}
void init_tmr0(void)
{
/* prescaler is 1:4, GPIO pullups are disabled */
OPTION = 0x81;
}
void init_tmr1(void)
{
T1CON = 0; /* Disabled */
}
void init_comparator(void)
{
CMCON = 0x7; /* Turn off the comparator */
VRCON = 0x0;
}
void init_a2d(void)
{
ANSEL = 0x11; /* Fosc/8 and RA0 is analog */
ADCON0=0x00; // Left justify output
ADON=1; // turn on the A2D conversion module
}
void init_ee()
{
}
void init_interrupts(void)
{
INTCON = 0xA0;
}
void init(void)
{
OSCCAL = _READ_OSCCAL_DATA();
TRISIO = 0x01; /* RA0 is ad input, rest are outputs */
init_gpio();
init_tmr0();
init_tmr1();
init_comparator();
init_a2d();
init_interrupts();
}
unsigned int get_voltage (void)
{
GODONE=1; /* initiate conversion */
while(GODONE) /* wait for result */
{
continue;
}
return ADRESH;
}
void wait_ms(unsigned int x)
{
unsigned int temp = g_ticks + x;
while (temp != g_ticks);
}
void main(void)
{
int state = 0;
init();
LED_A = 1;
LED_B = 1;
LED_C = 0;
LED_D = 0;
for (;;)
{
unsigned int ms_to_wait = get_voltage() * 8;
wait_ms(ms_to_wait);
switch(state)
{
case 0:
LED_A = 0;
LED_C = 1;
state++;
break;
case 1:
LED_B = 0;
LED_D = 1;
state++;
break;
case 2:
LED_C = 0;
LED_A = 1;
state++;
break;
case 3:
LED_D = 0;
LED_B = 1;
state = 0;
break;
}
}
}
static void interrupt isr(void)
{
T0IF = 0;
TMR0 = 6;
g_ticks++;
}
What program lang did you use It looks like C to me or is it Basic?
Eric
|
--
Bye.
Jasen |
|
| Back to top |
|
 |
Cliff
Guest
|
Posted:
Tue Nov 29, 2005 5:35 pm Post subject:
Re: Can twisted wire replace shielded wire? |
|
|
On Mon, 28 Nov 2005 14:51:55 -0600, John Field
<jfields@austininstruments.com> wrote
| Quote: | On Mon, 28 Nov 2005 13:32:27 -0500, Cliff <Clhuprich@aol.com
wrote
On Mon, 28 Nov 2005 00:56:50 GMT, David <rickets@knac.com
wrote
Characteristic impedance is purely a function of th
capacitance and inductance distributed along the line's length, an
would exist even if the dielectric were perfect (infinite paralle
resistance) and the wires superconducting (zero series resistance)
Velocity factor is a fractional value relating a transmission line'
propagation speed to the speed of light in a vacuum. Values rang
between 0.66 and 0.80 for typical two-wire lines and coaxial cables
For any cable type, it is equal to the reciprocal (1/x) of th
squar
root of the relative permittivity of the cable's insulation.'
How odd then that the speed of propagation in conductor
varies
Not at all. Since resistivity varies between conductors because o
the materials of which they're composed and inductance varie
because of their diameters, why would one _not_ expect c to vary
You think that resistivity controls the speed of light |
I think I heard that a good vacuum has a lot of resistanc
but a fairly high speed of light
The speed of light goes down as things become more
conductive
--
Clif |
|
| Back to top |
|
 |
Fred Abse
Guest
|
Posted:
Thu Dec 01, 2005 12:34 am Post subject:
Re: Can twisted wire replace shielded wire? |
|
|
On Tue, 29 Nov 2005 07:31:11 +0000, Jasen Betts wrote
| Quote: | On 2005-11-27, Fred Abse <excretatauris@cerebrumconfus.it
wrote
On Sun, 27 Nov 2005 17:14:25 -0330, Gary wrote
David wrote
sni
Characteristic impedance and DC resistance are the same if the lin
i
infinitely long and unterminated
Bullshit
If you mean by "DC resistance", the impedance you would see at th
inpu
of an infinitely long line, it's not bullshit, it's perfectly true
eve
if the line is made of zero-resistance conductors. You'll just se
th
line's characteristic impedance
what about lines made of copper and plastic
Most are :- |
| Quote: |
ISTM that a few hundered kilometers if RG59 is going to measure mor
than 75 ohms even with far end is shorted
There's no way an infinite length will have a lower resistance
Run the LTSpice simulation below, three cases of 1000 miles of RG59-U |
terminated. shorted, and open at 1 MHz. You'll find all 3 cases loo
lik
75 ohms. Constants are per Belden data
LTSpice is free, if you didn't already know that, and runs under WINE
(well at least here it does.
RG59-U.as
Version
SHEET 1 880 68
WIRE -128 144 -128 3
WIRE -128 160 -128 14
WIRE -128 320 -128 24
WIRE 48 320 -128 32
WIRE 48 320 48 6
WIRE 80 320 48 32
WIRE 80 320 80 17
WIRE 112 32 -128 3
WIRE 112 64 48 6
WIRE 112 144 -128 14
WIRE 112 176 80 17
WIRE 128 320 80 32
WIRE 128 352 128 32
WIRE 240 176 208 17
WIRE 240 320 128 32
WIRE 240 320 240 17
WIRE 288 64 208 6
WIRE 288 320 240 32
WIRE 288 320 288 6
WIRE 384 32 208 3
WIRE 384 144 208 14
WIRE 384 320 288 32
WIRE 384 320 384 22
FLAG 128 352
SYMBOL ltline 160 160 R
SYMATTR InstName O
SYMATTR Value RG59
SYMBOL voltage -128 144 R
WINDOW 123 0 0 Left
WINDOW 39 0 0 Left
SYMATTR InstName V
SYMATTR Value SINE(0 1 1e6
SYMBOL res 368 240 M18
WINDOW 0 36 76 Left
WINDOW 3 36 40 Left
SYMATTR InstName R
SYMATTR Value 7
SYMBOL ltline 160 48 R
SYMATTR InstName O
SYMATTR Value RG59
TEXT -152 456 Left 0 !.model RG59U LTRA(len=5.28e6 R=51.6e-3 L=0.115
C=20.5p
TEXT -162 506 Left 0 !.tran 0 1m 0 1
TEXT 496 456 Left 0 ;(Belden 8263
RG59U.pl
[Transient Analysis
Npanes:
Active Pane:
traces: 1 {524290,0,"v(n001)/Ia(O1)"
X: ('u',0,0,8e-005,0.0008
Y[0]: (' ',0,0,10,100
Y[1]: ('_',0,1e+308,0,-1e+308
Units: "Ohm" (' ',0,0,0,0,10,100
Log: 0 0
GridStyle:
}
traces: 1 {524291,0,"v(n001)/Ia(O2)"
X: ('u',0,0,8e-005,0.0008
Y[0]: (' ',0,0,10,100
Y[1]: ('_',0,1e+308,0,-1e+308
Units: "Ohm" (' ',0,0,0,0,10,100
Log: 0 0
GridStyle:
}
traces: 1 {524292,0,"v(n001)/Ia(O3)"
X: ('u',0,0,8e-005,0.0008
Y[0]: (' ',0,0,10,100
Y[1]: ('_',0,1e+308,0,-1e+308
Units: "Ohm" (' ',0,0,0,0,10,100
Log: 0 0
GridStyle:
--
"Electricity is of two kinds, positive and negative. The differenc
is, I presume, that one comes a little more expensive, but is mor
durable; the other is a cheaper thing, but the moths get into it.
(Stephen Leacock |
|
| Back to top |
|
 |
Terry Given
Guest
|
Posted:
Thu Dec 01, 2005 5:35 pm Post subject:
Re: Can twisted wire replace shielded wire? |
|
|
NunYa Bidness wrote
| Quote: | On 27 Nov 2005 18:27:46 -0800, "Kevin White
kevinjwhite@comcast.ne
Gave us
Winfield Hill wrote
Since the electrons travel on the surface and multi-strand wir
has more surface area it should be better
Only if the strands are insulated from one another
-
Thanks
- Wi
And also woven as in Litz wire. Otherwise the magnetic field wil
force the current to the outside of the bundle
It comes down to individual strands. If they are separated fro
each other electrically, the configuration of "the bundle" matter
not. The skin effect is exhibited in each strand, not in the bundl
as a group
thats not correct. case in point, it is quite feasible to analyze a |
conductor as comprising an n-tuple of (very thin) strands, completely
ignoring strand-to-strand conduction (if the strands are thin enough)
I
once hacked up a Mathcad worksheet that did exactly that, and i
agreed
well with messrs Vandelac & Ziogas. slow though :
if your argument were correct, multiple parallel strands of magne
wire
in a xfmr would behave just like litz, and it doesnt
A friend also had a problem a few years back with a litz cable, abou
1"
OD, with many thousands of strands. the strands were woven int
smaller
bundles, IIRC about 5mm OD, and these were then woven into the larger
cable. A screw-up by the manufacturer meant the centre two bundle
were
not woven at all, but ran down the center of the cable. When they
started pumping a few hundred kW into the cable, losses were extremel
high. Close inspection of a cable segment showed why, and severing th
central bundles solved the problem
| Quote: |
Conductors that are in intimate electrical contact with each othe
along their length operate as a single strand and THAT bundle woul
"push" electron flow toward the outside of the bundle as
increases
the bundle doesnt do the pushing, its the H field |
Cheer
Terr |
|
| Back to top |
|
 |
|
|
|
|