EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

connecting 8 nos of weigand reader to lpc2294

Started by jssaggu September 14, 2007
Good morning veryone,
i want to interface weigand reader to the lpc , since the reader works
on serial protocol and any reader could send data at any time , the
data could be lost , can any help me in this regards.

Thanks

Jitender Singh

An Engineer's Guide to the LPC2100 Series

jssaggu wrote:
>
> Good morning veryone,
> i want to interface weigand reader to the lpc , since the reader works
> on serial protocol and any reader could send data at any time , the
> data could be lost , can any help me in this regards.
>
As far as I recall, weigands do not work on a serial protocol, they
merely emit data in a serial fashion. They are very simple devices
using a hall-effect and a magnet to sense embedded iron wires in a
plastic card. With the ones we worked with, we had a single output (data
+ ground). The idea was to collect the pulse train, then do a
post-analysis on it. This was due to the fact that the data pulse rate
was governed by how fast or slowly you swiped the card.

Pretty simple stuff actually.
TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net http://cyberiansoftware.com http://openzipit.org
"Windows? No thanks, I have work to do..."
----------------
--- In l..., Tom Walsh wrote:
>
> jssaggu wrote:
> >
> > Good morning veryone,
> > i want to interface weigand reader to the lpc , since the reader
works
> > on serial protocol and any reader could send data at any time ,
the
> > data could be lost , can any help me in this regards.
> >
> As far as I recall, weigands do not work on a serial protocol,
they
> merely emit data in a serial fashion. They are very simple
devices
> using a hall-effect and a magnet to sense embedded iron wires in a
> plastic card. With the ones we worked with, we had a single output
(data
> + ground). The idea was to collect the pulse train, then do a
> post-analysis on it. This was due to the fact that the data pulse
rate
> was governed by how fast or slowly you swiped the card.
>
> Pretty simple stuff actually.
> TomW
> --
> Tom Walsh - WN3L - Embedded Systems Consultant
> http://openhardware.net http://cyberiansoftware.com
http://openzipit.org
> "Windows? No thanks, I have work to do..."
> ----------------
>
Thanks TomW
what the problem i am actually facing is i have made weigand serial
protocol reader with pic 16f676 becos i want to connect 8 nos of
reader to lpc i tried the master slave connection to 8 nos of 16f676
but in order to get the data from the 676 they must become master
and lpc 2294 to slave which i was not able to design becos how the 8
master will be driving the lpc. Then i decided to connect through a
parallel bus and using 74ls138 selecting the each 676 by rotation.
but now the problem is driving fanout of the 676. now i am looking
for the i2c connection but i donot know will it be successful.
can u suggest ?

Thanks

jitender Singh saggu
--- In l..., "jssaggu" wrote:
>
> --- In l..., Tom Walsh wrote:
> >
> > jssaggu wrote:
> > >
> > > Good morning veryone,
> > > i want to interface weigand reader to the lpc , since the reader
> works
> > > on serial protocol and any reader could send data at any time ,
> the
> > > data could be lost , can any help me in this regards.
> > >
> > As far as I recall, weigands do not work on a serial protocol,
> they
> > merely emit data in a serial fashion. They are very simple
> devices
> > using a hall-effect and a magnet to sense embedded iron wires in a
> > plastic card. With the ones we worked with, we had a single output
> (data
> > + ground). The idea was to collect the pulse train, then do a
> > post-analysis on it. This was due to the fact that the data pulse
> rate
> > was governed by how fast or slowly you swiped the card.
> >
> > Pretty simple stuff actually.
> >
> >
> > TomW
> >
> >
> > --
> > Tom Walsh - WN3L - Embedded Systems Consultant
> > http://openhardware.net http://cyberiansoftware.com
> http://openzipit.org
> > "Windows? No thanks, I have work to do..."
> > ----------------
> >
> Thanks TomW
> what the problem i am actually facing is i have made weigand serial
> protocol reader with pic 16f676 becos i want to connect 8 nos of
> reader to lpc i tried the master slave connection to 8 nos of 16f676
> but in order to get the data from the 676 they must become master
> and lpc 2294 to slave which i was not able to design becos how the 8
> master will be driving the lpc. Then i decided to connect through a
> parallel bus and using 74ls138 selecting the each 676 by rotation.
> but now the problem is driving fanout of the 676. now i am looking
> for the i2c connection but i donot know will it be successful.
> can u suggest ?
>
> Thanks
>
> jitender Singh saggu
>

I2C will work fine but there is a lot of code to write just to service
the state machines. That's not necessarily a bad thing because for
the PICs, the code will be identical. I2C is nice because it contains
an address for selecting a specific PIC. I2C is a PITA to debug
unless you have a logic analyzer.

However, SPI should work just as well. There is no need for the PIC
to become a master. The LPC does have to do something for the SS'
input of each PIC.

You need to have some protocol between the master and the slaves to
determine whether data is present (return 0x0 if not?) and how much
data to transmit. I don't know anything about the Weigand end of this
so I don't know how long a message might be.

You will also need to pause the SPI between bytes to give the
addresses slave time to retrieve the information. The slave should
probably get ready to send the first byte as soon as it is selected.
You would usually clock a byte of 0xFF to the slave and then on the
next byte clocked to the slave, the slave would begin delivering data.

Something like that...

Now, if these gadgets are located a long distance apart, I would just
implement an RS485 network and call it a day:
http://www.bdmicro.com/code/robin/

Richard
--- In l..., "jssaggu" wrote:
>
> Good morning veryone,
> i want to interface weigand reader to the lpc , since the reader works
> on serial protocol and any reader could send data at any time , the
> data could be lost , can any help me in this regards.
>
> Thanks
>
> Jitender Singh
>

If these devices just emit serial data at a variable rate, as
suggested by others, could you not just use the 8 capture interrupts?
I ask because one of my projects has a similar requirement: 8 flow
meters that issue serial data at a variable rate. If there is some
problem with this approach, could yourself or one of the other more
experienced developers help me and explain it before I head down a
black hole?

I am a Windows developer now struggling with these little chips, and I
need all the help/hints/advice I can get
Rgds,
Martin
--- In l..., "mjames_doveridge"
wrote:
>
> --- In l..., "jssaggu" wrote:
> >
> > Good morning veryone,
> > i want to interface weigand reader to the lpc , since the reader
works
> > on serial protocol and any reader could send data at any time ,
the
> > data could be lost , can any help me in this regards.
> >
> > Thanks
> >
> > Jitender Singh
> > If these devices just emit serial data at a variable rate, as
> suggested by others, could you not just use the 8 capture
interrupts?
> I ask because one of my projects has a similar requirement: 8 flow
> meters that issue serial data at a variable rate. If there is some
> problem with this approach, could yourself or one of the other more
> experienced developers help me and explain it before I head down a
> black hole?
>
> I am a Windows developer now struggling with these little chips,
and I
> need all the help/hints/advice I can get
> Rgds,
> Martin
>
Thanks martin,
Actually weigand sensor transmit data on 2 line data1 and data0 so i
actually need 16 line for the sensors and the data on any of the
sensor can come at any time in the worst case all sensors
transmitting data to lpc simultaneously.
that is why i am using indepent pic to control each weigand and then
depending on protocol they will be transmitting to lpc.

Thanks
jitender Singh saggu
--- In l..., "rtstofer" wrote:
>
> --- In l..., "jssaggu" wrote:
> >
> > --- In l..., Tom Walsh wrote:
> > >
> > > jssaggu wrote:
> > > >
> > > > Good morning veryone,
> > > > i want to interface weigand reader to the lpc , since the
reader
> > works
> > > > on serial protocol and any reader could send data at any
time ,
> > the
> > > > data could be lost , can any help me in this regards.
> > > >
> > > As far as I recall, weigands do not work on a serial protocol,
> > they
> > > merely emit data in a serial fashion. They are very simple
> > devices
> > > using a hall-effect and a magnet to sense embedded iron wires
in a
> > > plastic card. With the ones we worked with, we had a single
output
> > (data
> > > + ground). The idea was to collect the pulse train, then do a
> > > post-analysis on it. This was due to the fact that the data
pulse
> > rate
> > > was governed by how fast or slowly you swiped the card.
> > >
> > > Pretty simple stuff actually.
> > >
> > >
> > > TomW
> > >
> > >
> > > --
> > > Tom Walsh - WN3L - Embedded Systems Consultant
> > > http://openhardware.net http://cyberiansoftware.com
> > http://openzipit.org
> > > "Windows? No thanks, I have work to do..."
> > > ----------------
> > >
> > Thanks TomW
> > what the problem i am actually facing is i have made weigand
serial
> > protocol reader with pic 16f676 becos i want to connect 8 nos of
> > reader to lpc i tried the master slave connection to 8 nos of
16f676
> > but in order to get the data from the 676 they must become
master
> > and lpc 2294 to slave which i was not able to design becos how
the 8
> > master will be driving the lpc. Then i decided to connect
through a
> > parallel bus and using 74ls138 selecting the each 676 by
rotation.
> > but now the problem is driving fanout of the 676. now i am
looking
> > for the i2c connection but i donot know will it be successful.
> > can u suggest ?
> >
> > Thanks
> >
> > jitender Singh saggu
> > I2C will work fine but there is a lot of code to write just to
service
> the state machines. That's not necessarily a bad thing because for
> the PICs, the code will be identical. I2C is nice because it
contains
> an address for selecting a specific PIC. I2C is a PITA to debug
> unless you have a logic analyzer.
>
> However, SPI should work just as well. There is no need for the
PIC
> to become a master. The LPC does have to do something for the SS'
> input of each PIC.
>
> You need to have some protocol between the master and the slaves to
> determine whether data is present (return 0x0 if not?) and how much
> data to transmit. I don't know anything about the Weigand end of
this
> so I don't know how long a message might be.
>
> You will also need to pause the SPI between bytes to give the
> addresses slave time to retrieve the information. The slave should
> probably get ready to send the first byte as soon as it is
selected.
> You would usually clock a byte of 0xFF to the slave and then on the
> next byte clocked to the slave, the slave would begin delivering
data.
>
> Something like that...
>
> Now, if these gadgets are located a long distance apart, I would
just
> implement an RS485 network and call it a day:
> http://www.bdmicro.com/code/robin/
>
> Richard
>
Thanks Richard,

i will be using all these on single board. I have actually tried the
spi master slave between 2 pic but i when i selected the 676 as
slave and the 16f72 as master the first time i got the garbage value
from the 676 and the next time what ever i was send to the slave was
got back. so the problem was that in this process i could not send
the code which was there in the 676 ram one by one.i think becos in
the slave spi mode you can put some data in the send register of the
slave. i donot know there could be an error on my part . this is the
reason i was looking to the i2c . does any have any code on i2c on
lpc2294 which could save me some hours.

Thanks

jitender singh saggu
--- In l..., "jssaggu" wrote:
> Thanks martin,
> Actually weigand sensor transmit data on 2 line data1 and data0 so
i
> actually need 16 line for the sensors and the data on any of the
> sensor can come at any time in the worst case all sensors
> transmitting data to lpc simultaneously.
> that is why i am using indepent pic to control each weigand and
then
> depending on protocol they will be transmitting to lpc.
>
> Thanks
> jitender Singh saggu
>

Just as a matter of intrest, what is the highest equivalent bit rate
that you'd be likely to see from one of the sensors?

You might actually be able to do everything with an LPC2xxx and
forget about the PICs.....

Brendan
> Thanks Richard,
>
> i will be using all these on single board. I have actually tried the
> spi master slave between 2 pic but i when i selected the 676 as
> slave and the 16f72 as master the first time i got the garbage value
> from the 676 and the next time what ever i was send to the slave was
> got back. so the problem was that in this process i could not send
> the code which was there in the 676 ram one by one.i think becos in
> the slave spi mode you can put some data in the send register of the
> slave. i donot know there could be an error on my part . this is the
> reason i was looking to the i2c . does any have any code on i2c on
> lpc2294 which could save me some hours.
>
> Thanks
>
> jitender singh saggu
>

NXP has posted some example code to the Files section here. It isn't
targeted for the 2294 but it would be a good place to start.

For SPI, it is common for the first byte clocked out of the master to
receive either 0xFF or 0x00 from the slave. The real data from the
slave comes on the second byte sent from the master.

You might try having the SPI output register at the slave prepared to
send 0x00 when it is first clocked. Then on the SSPIF interrupt, grab
the real data byte and put it in the output register for the next byte
clocking. There is some useful information in the PICmicro Mid-Range
MCU Family Reference Manual.

There are a lot of options when setting up SPI concerning polarity,
edge and sample point. Getting this straight may take a little work.

Still, SPI is going to be a lot easier to implement. Getting slave
I2C to work on the PICs will take a lot of effort.

You really need a logic analyzer to view the clock and data lines.
You can save days of troubleshooting with a simple picture. It is
absolutely required if you try to implement I2C! I have never gotten
I2C to work without one.

You may find this useful: http://www.piclist.com/techref/microchip/spi.htm

Richard
Brendan Murphy wrote:
>
> --- In lpc2000@yahoogroups .com ,
> "jssaggu" wrote:
> > Thanks martin,
> > Actually weigand sensor transmit data on 2 line data1 and data0 so
> i
> > actually need 16 line for the sensors and the data on any of the
> > sensor can come at any time in the worst case all sensors
> > transmitting data to lpc simultaneously.
> > that is why i am using indepent pic to control each weigand and
> then
> > depending on protocol they will be transmitting to lpc.
> >
> > Thanks
> > jitender Singh saggu
> > Just as a matter of intrest, what is the highest equivalent bit rate
> that you'd be likely to see from one of the sensors?
>
> You might actually be able to do everything with an LPC2xxx and
> forget about the PICs.....
>

Heheh, not that fast, Brendan. A Wiegand reader is nothing more than a
magnet and a Hall Effect sensor positioned opposite each other with a
card slot in between. Think of the arrangement as a credit card reader
swipe. The plastic cards used in a Wiegand setup have are encoded via
iron wires sandwiched inside the card (plastic-wire-plastic). When you
swipe the card, the pickups read the presence of the wires as they pass
between the magnet(s) and Hall Effect sensor(s)

How fast can you swipe the card?

TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net http://cyberiansoftware.com http://openzipit.org
"Windows? No thanks, I have work to do..."
----------------

The 2024 Embedded Online Conference