For an upcoming project,
I'd like to develop a dispensing system that can measure out a desired mass of
material. The idea would be to use a microcontroller, dispensing valve, and
electronic balance to provide feedback. I already have an American Weigh Scales
miniPro-100, and decided to hack it so that my microcontroller can discover how
much mass is on the balance. It can then regulate the dispensing valve
appropriately.
The balance contains a
Cirrus CS5530 24-bit ADC. I tapped the clock and data lines and found bursts of
data that occurred at 7.5Hz. The clock is about 150KHz. I used a Parallax
Propeller running assembly in one of its cores to capture the data stream and
load it into my main program.
hey
everyone for my current project I'd
like to use a
microcontroller to
dispense a material onto a
balance like
this and then have the
microcontroller
stop the dispensing when
it's weighed
out a certain amount of
material so to
do that this this scale
doesn't have any
electronic interface so
today's task was
to crack this thing open
and figure out
a way that I can get a
microcontroller
to read the values from the
balance and
then later I'll do a video
showing how
I'm going to meter out the
material and
turn it off turn off the
dispensing when
we get up to a specified
mass so I
thought I'd just show you
how to take
this thing apart it's
actually built a
little bit differently than
most
consumer electronics that
I've taken
apart most of them you'd
probably start
by cracking the case seen
here that the
plastic shells but this one
actually
doesn't have any clips
around here so I
put a few dents in mind by
trying to
take the plastic shells
apart when that
actually wasn't necessary
so in this
case the platter comes off
just like
that and then there's a
couple more
screws holding down this
stainless plate
and then there's a couple
more screws
here and then the top shell
comes off
and a couple screws to hold
the circuit
board down and then the
circuit board
comes out just like this
now of course I
added these wires here
these these were
not here in the stock
configuration so
let's loop the zoom in on
the circuit
board and I'll show you
what I found
okay I'll just give you a
circuit
overview as near as I can
tell these
wires here are where the
strain gauge
connects to the input of
this thing this
is a weighing device and so
it's its
main piece of sensing tech
here's a
classic strain gauge which
I'll talk
about in a minute and there
really isn't
any analog path to speak of
in fact the
the sense wires from the
Wheatstone
bridge go through a ferrite
you know
bead inductor and then they
go right
into this guy which is a
serious logic
see 5530
24-bit analog to digital
converter so if
I had to guess I would say
that that
chip accounts for most of
the cost of
this
whole project or this whole
item here
maybe besides the strain
gauge there's a
couple of small voltage
regulators one
here and one here and I
think they're
both set to just 5 volts
the input to
this thing is just a typical
unregulated
wall wart type thing so if
the input
voltage is you know 9 volts
unregulated
they put a couple 5 volt
regulators in
there this guy is an LCD
driver and it
has a little bit of RAM
inside of it
it happens to be an HT 1621
and the
microcontroller which is an
ADC 51 part
here drives this whole
thing so the flow
is pretty simple I mean
basically the ad
pumps the data or the
microcontroller
runs the ad and then sends
the data into
the display Ram here and
that's that's
basically it the other side
of the board
doesn't have a whole lot
going on these
are the ferrite beads that
suppress a
little bit of high
frequency noise
coming from the Wheatstone
bridge and
then we've got your your
classic plain
old LCD here with some
buttons and just
a few transistors also this
has to be
one of the nastiest looking
solder jobs
I've ever seen in a piece
of commercial
equipment okay so if the
job here is to
sort of tap the signal and
get the
actual value of the thing
that's being
masked out of this circuit
we start to
look for ways that we can
get into sort
of tap the lines since the
analog signal
path doesn't really exist
it basically
goes straight from the
Wheatstone bridge
right into the ad converter
through
those beads there's really
no chance of
us adding another ad
converter because
this one is actually set up
with the
reference voltage going
into the
Wheatstone bridge so be
very difficult
to to tap the analog side
so I pulled up
the datasheet for this ad
converter and
as it turns out the the
data line and
the clock line go directly
into this
microcontroller and it's
the data is
read out in sort of a
synchronous way so
I I tapped the clock and
data out from
the ad chip line and looked
at it on the
scope and this is what it
looks like
okay so the bottom trace is
the clock
going from the
microcontroller to the AG
converter and the top trace
is the data
line coming from the AG
converter to the
chip and if I press on the
scale a
little bit you can see the
higher order
bits up here are changing
when I when I
pressed on the scale so
this agrees with
the datasheet I looked up
the the
datasheet for that serious
ad part and
it confirms that it's
sending data in
for byte chunks and so you
can see these
clusters of clock cycles
down here so
currently the scope is set
to 50
microseconds per division
but it's it's
unnormal trigger mode so if
i zoom out
you can see that that
cluster now it's
50 milliseconds per
division you can see
that that burst of data
happens
periodically and it turns
out it's
running at about 7.5 Hertz
so seven and
a half times per second the
microcontroller decides to
query the ad
converter and pulls that
data in in that
little burst now one
difficulty is that
the burst is actually quite
fast and so
if we zoom in a bit and
then scale over
to take a look at some of
those clock
cycles when data is being
sent the the
clock time is actually
quite fast it
turns out to be six and a
half
microseconds from rise to
rise on the
clock there so obviously we
can't pull
that with a microcontroller
because it
would just be ridiculously
fast and
another problem is that we
couldn't
really easily use an
interrupt in a lot
of microcontroller
architectures because
the rate is just so high
150 kilohertz
even though this burst only
happened
seven and a half times per
second during
this burst received period
if we try to
use an interrupt the
processor would
have to be fast enough to
handle the
interrupt before the next
clock cycle
came in so this is
definitely going to
be a problem and especially
if the the
processor has to handle other
interrupts
you might get some
interference between
different sources of
information
so I came up with a
different solution I
ended up using a parallax
propeller the
propeller is a really
interesting chip
it's a 32-bit architecture
chip but it's
built in a way that has
eight cores and
it's unlike a traditional
microcontroller and that
there's no
interrupts and so all the
cores run
synchronously and share a
common memory
space so that you can talk
from core to
core by sending information
into the
shared memory and each core
also has its
own memory to do certain
tasks so I
initially tried to program
one core in
the propellers native
programming
language called spin and it
was not fast
enough to receive the
signals and so I
put a weight instruction to
wait for a
rising edge on the clock
line and by the
time the next instruction
fired five or
ten microseconds had passed
so there's
no way to to capture the
data because
it's coming in quicker than
this thing
can runs in instructions so
the makers
of this knew that the the
real power of
this chip would be you know
realized by
programming it in assembly
so they also
allow you to do that in
fact it's
interesting and that parts
of the chip
can be programmed in
assembly and parts
can be programmed in spin
in fact even
side by side functions can
switch back
and forth between assembly
and spin
which is pretty cool so I
ended up you
know hunkering down and
writing the
assembly to capture the
data from this
line one of my requirements
for this was
that the scale itself not be
harmed by
what I you know what I
added to it
originally when I was
thinking of
getting the data out I
thought well I
could intercept the clock
line and then
basically turn off the
connection
between the microcontroller
and the ad
and then turn on the connection
from my
microcontroller to the ad
so basically
just switching the ad back
and forth
from their microcontroller
to mine but
that would cause the panel
to get weird
and I've noticed this thing
goes into
fault modes and then
doesn't recover so
that's kind of a pain in
the butt
the propeller is a 3.3 volt
device and
so I just added a couple
current
limiting resistors here
since this
circuit is five so even
though you know
this thing is pulling 0 to
5 volts these
current limiting resistors
are do a fine
enough job of preventing
too much
current from flowing into
the chip the
chip also runs very quickly
it's a 5
megahertz crystal but
there's a 16 X
phase locked loop in there
so it's
actually an 80 megahertz
clock
internally this is really
helpful in
doing assembly instructions
most
instructions are four clock
cycles per
per instruction so you can
actually get
a whole lot done when
coding it in
assembly okay so here's my
program I'm
definitely not an
experienced assembly
coder so I was basically
happy just to
get this working I'm sure
this could be
optimized a bit but there's
plenty of
time at 80 megahertz with
only four
clocks per instruction
there's actually
very easy to to make this
work and so
what I did is I have a loop
here that
just times out after one
millisecond so
what this thing does is
when it times
out it resets it's 32 bit
register and
then as the bits come in
from the ad it
just fills up that 32 bit
register and
when it times out it sends
the value
that register back to the
main program
loop and then resets and
waits for the
next one so this takes
advantage of the
fact that the data is
coming in bursts
and it uses it knows that
the start of
the data is coming because
it's just
been a long time and it's
timed out so
here's the the debug value
coming back
and if I push on the scale
a little bit
you can see the value going
up and the
units are you know
uncalibrated I
noticed that if you press
the tare
button on the front of the
scale it
doesn't actually change
this at all so
the unit conversion and tare
functions
are all done in the
microcontroller
downstream of the ad so
since I've come
this far with the propeller
I think I'll
probably just do the whole
project using
this chip it's been kind of
a while
since I've used it and it
does have some
pretty cool features that I
haven't
played with in a while
since each core
runs at 80 megahertz
possible to do video
generation with the
chip without too much work
and then your
program can just send
values to the core
that's doing video
generation and it
doesn't really add all that
much
overhead to your program
here's a shot
of the strain gauge that's
inside the
scale these devices are
actually really
simple but there can be
made very
accurately all it is is a
piece of metal
and when I press on this
the metal just
deflects a tiny amount and
the strain
gauges themselves are thin
thin film
resistors that are just
glued on to the
surface of this metal
structure so by
pressing on this the metal
structure
changes shape very very
slightly which
is what that's what strain
is and these
thin film resistors will
change
resistance very very
slightly because
they're actually being
distorted a
little bit compressed or
stretched and
the whole idea with the
Wheatstone
bridge is that some of the
resistors are
on the strain gauge for
temperature
compensation so if the
whole temperature
of the device changes a
little bit all
the resistors will change
in the same
way and so a temperature
will
essentially be compensated
out okay I
hope that was helpful see
you next time
byeinvest online and earn money, best online money making, online money income, view ads and earn money without investment, earn money online by clicking, online money income site, money earning sites, online earning sites, best website to earn money, free money earning sites, money earning websites, get money online, online earning tips, online earning without investment, earn money online without investment for students, earn money by clicking ads, earn money online without investment, online earn money website, online jobs to earn money, best online income site, top 10 online money earning sites, easy income online,
No comments:
Post a Comment