Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

basicx · Discussion list for the BasicX family of microcontroller chips

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 2221
  • Category: Microcontrollers
  • Founded: Aug 11, 1999
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Messages 21422 - 21451 of 23507   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#21422 From: "ricinecwh" <ricinecwh@...>
Date: Sat Jul 1, 2006 8:56 am
Subject: Temperature control
ricinecwh
Send Email Send Email
 
My project is to control the temperature of a plant.
The temperature of the plant will be monitored and as an input of the
basicX controller.
If the input temperature is larger than temperature we set,
the controller will adjust it to the correct temperature by
increasing or decreasing the current to the TEC which is inside the
plant.

The problem is how can the controller automically adjust the tempature
in the basic X
Some people tell me to use the PID controller
however, i find it is difficult to fix the three variables.
Is there anypeople familiar with the PID?
or
there are any alternative way to fix it?

#21423 From: "Doug Metzler" <dougm62@...>
Date: Sat Jul 1, 2006 4:14 am
Subject: RE: [BasicX] Monitor voltage and current
lwtcdougm
Send Email Send Email
 
I’m sure there are more sophisticated ways to do this, but…



In theory you’re supposed to be able to put a very low resistance very high
wattage resistor, (say ½ ohm 5 watt) in series with your power feed and then
measure the voltage drop across that resistor – that will tell you the
current is (I = E/R) and because it’s such a low value of resistance it
won’t have an appreciable impact on the power supplied to your circuit.  In
practice I haven’t found this to be very accurate but math is math so it’s
probably a problem with my implementation.



As far as voltage you could just use a couple of resistors to create a
voltage divider to drop your voltage down to something the AD converter can
handle.  So if you are running a 12v system set it up such that your voltage
divider gives you just under 5 volts – then you can correlate that with the
actual voltage.



The rest is just a SMOP (Small Matter of Programming) :-)



DougM



   _____

From: basicx@yahoogroups.com [mailto:basicx@yahoogroups.com] On Behalf Of
nuepatrick
Sent: Friday, June 30, 2006 8:40 AM
To: basicx@yahoogroups.com
Subject: [BasicX] Monitor voltage and current



Hello all,

I am not sure if someone has addressed this issue before. I have
tried a search, but have not been able to find anything.

What I am designing is a video distribution box that is connected to
a surveillance system that is connected by a 30 conductor cable. In
the box is a set of batteries, that are used to power the cameras
and microphones that might be connected to the box. I need a way to
monitor the voltage and current that is being used by the box. This
information needs to be sent back to a LCD display that will be in
the van. I will also need a way to control some additional features
in the box. After the power has been sent to the box from the van I
will have 2 additional wires that I can use to send and receive
data. This means I will be using I2C to carry the data back to the
van. Any ideas on the best way to approach this.

The big thing now is the ability to measure voltage and current and
send it back to the surveillance system to be displayed on an LCD
display.

Any help or ideas would be greatly appericated.

Thanks

Patrick





[Non-text portions of this message have been removed]

#21424 From: "cfrancois_55116" <cfrancoi@...>
Date: Sat Jul 1, 2006 1:55 pm
Subject: Com3 overhead (again)
cfrancois_55116
Send Email Send Email
 
After reading about Com3 overhead on one of the boards, I decided to
measure it to determine if opening Com3 only when needed would be
beneficial for my application. My tests use 19200 baud and a single
task, and measure the time for a computational sequence for the
following scenerios:

                                                 Time      Speed Factor
                                                 --------  ------------
Com3 open w/input pin:                          2.042969  1.000
Com3 open w/dummy input pin:                    1.535156  1.331
Com3 not open:                                  0.921875  2.216
Com3 dynamic OpenCom/CloseCom w/dummy pin:      0.921875  2.216

It appears that closing Com3 eliminates all of the interrupt
overhead as if Com3 was never opened at all.

I measured the speed of using OpenCom+CloseCom and the average was
1.221ms with low variance.  When using the a dynamic technique, it
is important to ensure that the queues are flushed before closing
the port. Flush code is available in the files section of this group.

IMO, NetMedia should mention this overhead in their Com3
documentation. Most people are not going to expect their application
to slow down by 50% because they have Com3 open. It may even save some
defections to other platforms.

#21425 From: "Don Kirby" <psyclopedia@...>
Date: Sat Jul 1, 2006 6:12 pm
Subject: Redundant Pull-Ups?
psyclopedia
Send Email Send Email
 
After about 2 or 3 thousand hours of use, I'm finding that the BX24p
internal pull-ups are going bad.  So far, 3 of them have gone south.
The circuit is only a pushbutton switch to ground, so I don't think
that the resistors are getting destroyed from that.  I'm having this
problem with only 1 chip so far.

I'm wondering if my next batch of boards should have provisions for
external pull-ups.  Redundancy is a good thing, I suppose, and adding
one more 0603 or 0402 chip to the board really isn't a big deal.

Has anyone else experienced this kind of failure only after long term use?

-Don

#21426 From: Ken Arck <ah6le@...>
Date: Sat Jul 1, 2006 6:22 pm
Subject: Re: [BasicX] Redundant Pull-Ups?
ah6le
Send Email Send Email
 
At 06:12 PM 7/1/2006 -0000, you wrote:


After about 2 or 3 thousand hours of use, I'm finding that the BX24p
internal pull-ups are going bad.  So far, 3 of them have gone south.
The circuit is only a pushbutton switch to ground, so I don't think
that the resistors are getting destroyed from that.  I'm having this
problem with only 1 chip so far.

<----I have seen the problem of pullups dying time after time which is why
I gave up on the BX24 and went straight to Atmel parts. Cheaper, faster and
very reliable

Ken

#21427 From: Tom Becker <gtbecker@...>
Date: Sat Jul 1, 2006 7:08 pm
Subject: Re: [BasicX] Redundant Pull-Ups?
b19063
Send Email Send Email
 
My experience is the contrary.  I've never seen a bad pullup on a BX-24
pin; I've smoked a few pins, but only in careless development by my own
hand.

> ... I gave up on the BX24 and went straight to Atmel parts...

How does that help?  The BX-24 pullups _are_ Atmel pullups.


Tom

#21428 From: "Don Kirby" <psyclopedia@...>
Date: Sun Jul 2, 2006 11:36 am
Subject: Re: Redundant Pull-Ups?
psyclopedia
Send Email Send Email
 
I'll have to agree with Tom on this one, the internal pullups are
internal to the Atmel chip, not the BX24 board.

Thinking aloud:

Given that I have a few spare pins available, I could either; 1)add
the external pullup (redundant to the internal one), or 2) Tie 2 or
more pins together to make the internals redundant for themselves.
i.e. If one of the pullups goes bad, I can change the pin assignment
(via software) to use one of the other pins for the button input.

The problem really is that the whole circuit is to be potted in its'
enclosure, eliminating any possibility of replacing a bad part (BX
chip or any other).  IP67/NEMA4X creates some interesting issues with
repairability.

-Don

#21429 From: greywolf <greywof2001@...>
Date: Mon Jul 3, 2006 2:47 am
Subject: Re: Interfacing basicx with DC motor with encoder
greywof2001
Send Email Send Email
 
Hi everyone,

   thanks for the help so far. I've done the recommended reading on the web and
found a controller which I think is able to solve my problem.

   http://www.gamatronix.com/product_info.php/cPath/22/products_id/28

   Will play around with the boards and see what I can come up with. Thanks.

   Regards,
   Joseph


---------------------------------
Sneak preview the  all-new Yahoo.com. It's not radically different. Just
radically better.

[Non-text portions of this message have been removed]

#21430 From: "Craig" <craig.whitley@...>
Date: Mon Jul 3, 2006 2:14 pm
Subject: Re: Temperature control
wurlitzer28
Send Email Send Email
 
--- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@...> wrote:

>
> The problem is how can the controller automically adjust the
tempature
> in the basic X
> Some people tell me to use the PID controller
> however, i find it is difficult to fix the three variables.
> Is there anypeople familiar with the PID?
> or
> there are any alternative way to fix it?
>

Depending upon the required accuracy, you may or may not need PID
control. Will your control device be simple heat on/off, cool on/off
or do you plan on proportional control where the greater the
difference between actual temperature and desired (set point)
temperature you will increase/decrease the rate at which heat is
added or removed?

That question MUST be answered first.

If you will be using proportional control then you will want to
program a PID controller. Yes you can use PID with simple on/off
control but it is like squirrel hunting with an elephant gun.

There are many PID formulas available on the WEB and I would suggest
using the simplest expressions that maintain the desired control.

The expressions shown below are Pseudo expressions at best just to
illustrate the concepts.

PID can be thought as 3 stand alone controllers with their resulting
outputs added together to form a common control output.

The "P" in PID stands for proportional. The further your actual
temperature (or any other measurement) is from the desired (set
point) the P controller will increase/decrease output. If for example
you are only 1 degree high or low, you may not need much of a change
from your controlling device (heater, fan etc.) On the other hand if
there is a 20 degree difference you want you system to have more
output to bring the temperature back in line faster.

Error =(Set point-Actual)
P Output = (Error * P-Gain)
(you enter the P-Gain based on the system's response tea pot Vs
swimming pool)

You can run a system with just proportional gain but you will soon
find out that you will never reach the exact set point as when the
error is very small you don't have much controller output. You can
keep adding gain but eventually you will just keep overshooting then
undershooting your set point. This is usually refered to as
Proportional Droop.

INTEGRAL:
The "I" in PID is for Integral. In the most basic terms,
the integral gain is determined by the error between actual and set
point and the length of time the system has been away from the set
point. Adding Integral gain solves the problem with a Proportional
only system never reaching set point as the Integral will keep adding
to the P output positive or negative output until you reach the set
point.

For all but the most super critical temperature applications P+I will
be sufficient.

For a very, very, very simple "I" control you take the (Error * Gain)
and keep adding/subtracting that result at a given timed interval.
Care must be taken to keep the Gain as small as possible to avoid
wind up where the combined P&I values add up so fast that the system
reaches its limit way too soon and takes forever to come back under
control. Again based upon what you are trying to control (tea
pot/swimming pool) your system will require more or less time to
respond and excessive "I" gain or too short an interval will cause
overshoot/undershoot.

The "I" term will keep adding/subtracking its output every X seconds
(P-Interval)

Differential:
There are certain applications that you want to limit (or slow down)
the
response to prevent overshoot. If you have too much P or I Output it
is easy to overshoot your set point and the system will oscillate and
be unstable. The "D" in PID is Differential Gain. Again in the most
simplest of terms it looks at the "rate of change" and if that rate
is too high, the differential Output will be added/subtracted from
the P&I output sum.

Pseudo math for Differential would be: (Last Error - Current Error) *
DGain. If the difference in errors is very small the "D" output will
be very small. If the difference in Current/Last error is large then
the system is responding very fast and the DOutput will be high and
that output can be subtracted from the P+I sum.

A good cruise control in a car should have "D" gain to prevent the
car from being over, under, over, under.... speed.

I have found many people who use PIDs all the time and screw up the
concept of "I" control because there are 2 user defined values and
depending upon which one you talking about more "I"  will speed up or
slow down the response. If you increase "I GAIN" the system will
respond faster. If you increase "I Interval (time) the system will
slow down because the change in "I" output is done at a slower rate.
Don't get caught in this trap. Some otherwise intelligent engineers
will argue this point like you were attacking their religion.

PID only sounds complex unless you break it down into its 3
components and realize the math for each component is rather simple
and then you just add the 3 outputs for your final control and send
it to your D/A converter.

#21431 From: "ricinecwh" <ricinecwh@...>
Date: Mon Jul 3, 2006 1:03 pm
Subject: requirement of basicX(simple question)
ricinecwh
Send Email Send Email
 
It 's just an simple question
I would like to ask the
lowest requirment for the computer to install the basicX (and run it ,
of course)

#21432 From: "Craig" <craig.whitley@...>
Date: Mon Jul 3, 2006 2:30 pm
Subject: Re: Temperature control
wurlitzer28
Send Email Send Email
 
--- In basicx@yahoogroups.com, "Craig" <craig.whitley@...> wrote:
>
> --- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@> wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?

If you understood my previous post then setting your control values
should be done in stages.

NOTE: I would use "Single" data types for the Gains as you will
quickly find integer steps will be too inaccurate.

First: Enter "0" for I-Gain and D-Gain (if you decide to use it).

Second: Using only P-Gain increase or decrease that gain value until
the system tries to reach set point but does NOT over/undershoot.
Back off the P-Gain until the over/undershoot just stops.

Third: Start adding some I-Gain until the system starts to
over/undershoot then back off a little. NOTE: the I-Interval should
be some logical value. For example if I were controlling the
temperature of a swimming pool adding I-Gain every 10ms would not
make a lot of sense. If I were controlling a tea pot a 5 second P-
Interval might be a good starting point. You need to know the inertia
of what you are controlling.

Forth: If you decided to use "D" gain, and you might if you found
the "I-Gain" was way too sensitive, start adding "D-Gain" until
system becomes stable and not too slow. If you go overboard on "D-
GAIN" the system will not be very responsive. I doubt you will need
Differential control but it is good to know what it does.

#21433 From: "Craig" <craig.whitley@...>
Date: Mon Jul 3, 2006 2:37 pm
Subject: Re: Temperature control
wurlitzer28
Send Email Send Email
 
--- In basicx@yahoogroups.com, "Craig" <craig.whitley@...> wrote:
>
> --- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@> wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
> >
>

I had this page on my hard drive but I do not know the URL. It is
another way of explaining PID and some ACTUAL math. While the
approach is different, both work.

Proportional Integral Derivative Control
PID, although developed in the 1940s, has had staying power as a
technique for developing closed-loop process control systems. The
reason for its longevity is that PID is easily implemented in
software and performs well for linear control problems. PID works
very well when the suitable gain values are employed and the system
responds smoothly over the range of interest. A non-linear system can
usually be controlled by dividing it into multiple ranges, and
selecting optimal gain values for each range.

PID Equations
E = Setpoint - PV

CV = Kp * E + Ki * Esum + Kd * PVdelta

PV = ProcessFunction(CV)

Where
CV is the control variable. This value might be a voltage or valve
position - something that causes the control system to change.
Increasing the control variable eventually results in a measurable
increase in the PV. Similarly, decreasing the CV causes the process
to decrease the PV. A car's throttle position is the CV in a cruise-
control application.
E is the error, the difference between the desired value (Setpoint)
and the latest measured process variable (PV) value. The value of E
is positive while PV is too low, and negative when PV is too large.
Esum is the sum of errors (E). This sum is updated at a regular
interval where Esum = Esum + E. When E is positive (PV is too low)
then Esum will grow larger at each update. When E is negative (PV is
too high) then Esum will become smaller, or even grow negatively.
When E is zero (PV is at the setpoint) then Esum remains constant.
When the system is stable, both E and PVdelta are zero, and the only
component contributing to CV is the Ki * Esum term.
Kd is the derivative gain. This factor controls how strongly the
control system will react to changes in the process variable (PV)
value. The affect of the Kd * PVdelta component is to dampen the
system by reducing acceleration. Many systems run fine with Kd set to
0, resulting in what is known as a PI control loop.
Ki is the integral gain. This factor controls how strongly the
control system will react to the continuous sum (Esum) of errors (E).
Kp is the proportional gain. This factor controls how strongly the
control loop will react to the instantaneous error (E). The Kp * E
component is positive when PV is too low, negative when PV is too
high, and zero when the PV is at the set point value.
ProcessFunction represents the process. Given a control input CV, the
process will, after some delay, update some easily measured
parameter, PV. The purpose of the PID control loop is to adjust the
value of CV to obtain the desired value for PV (and thereby make
something work a little better).
PV is the process variable value. This is some aspect of the process
that can be measured - and therefore managed. The PV is what we are
trying to control. Changing the control variable (CV) tweeks the
process and eventually results in a change to the measured PV value.
A car's speed is the PV in a cruise-control application.
PVdelta is the rate of change of the process variable (PV) value.
This can be calculated by subtracting the latest PV measurement from
the previously measured PV value. The PVdelta is negative when PV is
increasing, and positive when PV is decreasing. A car's acceleration
is the PVdelta in a cruise-control application.
Setpoint is the desired value for the process variable (PV). A car's
desired cruising speed is the Setpoint in a cruise-control
application.
Application
The most flexible way to view the PID calculation is as 3 independent
terms that sum to become the control variable value. That is, CV =
P+I+D. This arrangement of the PID calculation yields flexibility in
adjusting gain values. The following sections break down how each
term is calculated.

Proportional Term (Kp * E)
The proportional term of CV can be updated as often as new
measurements of PV can be obtained. Unlike the Integral and
Derivative terms, there is no reason to wait for the process to
respond to the latest correction. The proportional correction to CV
can be applied the instant that any Error is detected. In practice,
it is usually a good idea to avoid computing Kp * E when E is lower
than some threshold in order to avoid making constant small
corrections to CV due to noise in the measurement of PV. Such a "dead-
zone" can avoid wear and tear by preventing unnecessary "hunting"
around the setpoint.

The proportional term of CV gets progressively weaker as the PV gets
closer to the Setpoint. After some time, the Kp * E will exactly
balance drag or friction in the process and reach a stable point
where PV is just below the Setpoint.

Selecting a value for Kp can be determined by experimentation. Start
with Ki and Kd at zero. Begin with estimated values and then increase
Kp until the control system oscillates, then back off to a stable
setting. The Kp may later be increased after adjusting Kd.

Integral Term (Ki * Esum)
The integral term of CV can be updated at a frequency that is limited
by the hysteresis in the system. The PID should update the CV then
wait for sufficient time to allow the process to make a significant
and measureable affect on the PV before the next calculation. At each
calculation, Esum = Esum + E. In most applications, the integral term
should not be allowed to exceed the lower and upper limits for the CV
(Esum < CVmax/Ki). As with the proportional term, it is good practice
to not update the integral term when the Error (E) is below some
threshold of tolerance. This can avoid constant small changes to CV,
causing unnecessary wear on the components of the control system.

The integral term of CV will grow (or shrink) indefinitely until the
Error (E) becomes zero. In this way, a PI or PID loop will eventually
drag PV to the setpoint.

Selecting a value for Ki can be determined by experimentation. Start
with small values and increase Ki until oscillation is first
observed. Reduce Kp to remove the oscillation.

Derivative Term (Kd * PVdelta)
The derivative term of CV is updated at a frequency that is limited
by the hysteresis in the system. The PID should update the CV then
wait for sufficient time to allow the process to make a significant
and measureable affect on the PV before the next calculation.
Normally, the derivative and integral terms of the PID equation are
calculated at the same frequency. At each calculation, PVdelta =
PVprevious - PVnow.

The derivative term of CV will become large when PV is changing
quickly, but is not a factor in systems that change very slowly. This
component tends to dampen the system and its use may allow larger
values for Kp without oscillation.

Selection of the best values for Kd requires iterative testing. First
choose a trial value for Kd, then increase Kp until oscillation is
observed. Try to remove the oscillation by increasing Kd. If that
works, then repeat - increasing Kp to oscillation, and then
increasing Kd to remove it. Use the largest gain settings that work
well at both minimum and maximum useful Setpoint values.

Example
The following psuedocode can be used as the basis for a simple PID
implementation

     // PID Example using integers

     // Constants
     // Arbitrary numbers - pick appropriate values for
     // the system of interest.
     // INTERVAL = milliseconds for PV to react to CV

#define CVmax       255     // 0 to 255
#define PVmax       100     // 0 to 100%
#define INTERVAL    500     // 500ms between "I&D" updates
#define THRESHOLD   2       // error tolerance

     // Gains
     // Make these run-time tunable in a real system.
     // The GAIN macro divides the gain values by 100
     // to allow finer granularity using integer arithmetic.

#define Kp      500         // Kp = 5.000
#define Ki      10          // Ki = 0.100
#define Kd      10000       // Kd = 100.0

#define GAIN(g,v) (((g)*(v)+50)/100)

     // Variables

int esum;                   // sum of errors
int pvprev;                 // saved previous pv value
int cvi;                    // integral component of CV
int cvd;                    // derivative component of CV

     // For timekeeping
     // time.h is standard C, defines CLOCKS_PER_SEC
     // MS() returns milliseconds elapsed since (t)

#include <time.h>
clock_t stamp;              // saved timestamp (from clock())
#define MS(t) (((clock()-(t))*1000)/CLOCKS_PER_SEC)

     // PID function - given a PV and Setpoint, returns the CV.
     // Call this function after each time the system obtains
     // a fresh value for PV.

int pid (int pv, int setpoint)
{
     int cv;                               // return value
     int error;

     error = setpoint - pv;

     if ( abs(error) < THRESHOLD )
     {
         // Error is within tolerance.

         error = 0;
     }

     // Compute proportional term

     cv = GAIN(Kp, error);   // Kp * E

     if ( MS(stamp) >= INTERVAL )
     {
         // it has been long enough since last call to
         // this function for the pv value to have been
         // affected by the previously computed cv

         stamp = clock();

         // Compute integral term by summing errors.

         esum = esum + error;

         // Limit integral term to CV range.

         if ( esum > CVmax/Ki )
             esum = CVmax/Ki;
         else
         if ( esum < 0 )
             esum = 0;

         // calculate the integral term

         cvi = GAIN(Ki, esum);         // Ki * Esum;

         // calculate the derivative term

         cvd = GAIN(Kd, pvprev - pv);  // Kd * PVdelta
         pvprev = pv;
     }

     // Add terms: P+I+D

     cv = cv + cvi + cvd;

     // Limit cv to allowed values

     if ( cv < 0 )
         cv = 0;
     else
     if ( cv > CVmax )
         cv = CVmax;

     return cv;
}

#21434 From: Tom Becker <gtbecker@...>
Date: Mon Jul 3, 2006 3:04 pm
Subject: Re: [BasicX] requirement of basicX(simple question)
b19063
Send Email Send Email
 
> ... lowest requirment for the computer...

According to Netmedia, it's "For Windows 95/98/ME/NT/2000/XP" so you
should be able to run a 386/16 with Win95 - or anything Wintel, later
and faster.


Tom

#21435 From: "njepsen@..." <njepsen@...>
Date: Fri Jun 30, 2006 9:07 pm
Subject: Re: [BasicX] Re: PID
neil_jepsen
Send Email Send Email
 
A nice treatise Craig...I enjoyed reading it. It sounds to me as though
you are a bit of a PID enthousiast, as am I.  I enjoy playing with PID,
whether it be tuning an off the shelf PID controller, or writing some
code to the job. One of the more interesting tasks I had some years ago
was controlling the sewage level & flow into a treatment plant. The
incoming sewage was pumped by three very large DC motor driven pumps,
and in addition, there was a motorised gate valve about 2m x 4m in the
intake pipe. The task was to control the level in an open channel which
was the intake into the plant, by varying the speed of the duty pump,
bringing in the two standby pumps in sequence, and as  last resort,
progressively closing the gate valve.  All three pumps were on speed
controllers.  If you got it wrong, you flooded the floor of the plant
which raised eyebrows. I remember once standing next to the channel (
which was about a meter wide and several meters deep, and I heard the
pumps suddenly start to slow...( a software bug)...Before I could move,
I was up to my ankles in %$#%$
The PID control was done in a PLC and written from scratch. It took a
while to get it right, and the main problem was the huge range of
conditions and incoming flow rates, which varied by 200-300% depending
on the weather. The non-linear pump curves did not help. In summer, one
pump would do the job at about 1/2 speed. In the winter during heavy
rain ( which caused leakage into the sewer system) all three pumps would
be flat out, and the gate valve would be modulating slowly. Its response
was quite slow obviously.
n
Craig wrote:

> --- In basicx@yahoogroups.com <mailto:basicx%40yahoogroups.com>,
> "ricinecwh" <ricinecwh@...> wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
> >
>
> Depending upon the required accuracy, you may or may not need PID
> control. Will your control device be simple heat on/off, cool on/off
> or do you plan on proportional control where the greater the
> difference between actual temperature and desired (set point)
> temperature you will increase/decrease the rate at which heat is
> added or removed?
>
> That question MUST be answered first.
>
> If you will be using proportional control then you will want to
> program a PID controller. Yes you can use PID with simple on/off
> control but it is like squirrel hunting with an elephant gun.
>
> There are many PID formulas available on the WEB and I would suggest
> using the simplest expressions that maintain the desired control.
>
> The expressions shown below are Pseudo expressions at best just to
> illustrate the concepts.
>
> PID can be thought as 3 stand alone controllers with their resulting
> outputs added together to form a common control output.
>
> The "P" in PID stands for proportional. The further your actual
> temperature (or any other measurement) is from the desired (set
> point) the P controller will increase/decrease output. If for example
> you are only 1 degree high or low, you may not need much of a change
> from your controlling device (heater, fan etc.) On the other hand if
> there is a 20 degree difference you want you system to have more
> output to bring the temperature back in line faster.
>
> Error =(Set point-Actual)
> P Output = (Error * P-Gain)
> (you enter the P-Gain based on the system's response tea pot Vs
> swimming pool)
>
> You can run a system with just proportional gain but you will soon
> find out that you will never reach the exact set point as when the
> error is very small you don't have much controller output. You can
> keep adding gain but eventually you will just keep overshooting then
> undershooting your set point. This is usually refered to as
> Proportional Droop.
>
> INTEGRAL:
> The "I" in PID is for Integral. In the most basic terms,
> the integral gain is determined by the error between actual and set
> point and the length of time the system has been away from the set
> point. Adding Integral gain solves the problem with a Proportional
> only system never reaching set point as the Integral will keep adding
> to the P output positive or negative output until you reach the set
> point.
>
> For all but the most super critical temperature applications P+I will
> be sufficient.
>
> For a very, very, very simple "I" control you take the (Error * Gain)
> and keep adding/subtracting that result at a given timed interval.
> Care must be taken to keep the Gain as small as possible to avoid
> wind up where the combined P&I values add up so fast that the system
> reaches its limit way too soon and takes forever to come back under
> control. Again based upon what you are trying to control (tea
> pot/swimming pool) your system will require more or less time to
> respond and excessive "I" gain or too short an interval will cause
> overshoot/undershoot.
>
> The "I" term will keep adding/subtracking its output every X seconds
> (P-Interval)
>
> Differential:
> There are certain applications that you want to limit (or slow down)
> the
> response to prevent overshoot. If you have too much P or I Output it
> is easy to overshoot your set point and the system will oscillate and
> be unstable. The "D" in PID is Differential Gain. Again in the most
> simplest of terms it looks at the "rate of change" and if that rate
> is too high, the differential Output will be added/subtracted from
> the P&I output sum.
>
> Pseudo math for Differential would be: (Last Error - Current Error) *
> DGain. If the difference in errors is very small the "D" output will
> be very small. If the difference in Current/Last error is large then
> the system is responding very fast and the DOutput will be high and
> that output can be subtracted from the P+I sum.
>
> A good cruise control in a car should have "D" gain to prevent the
> car from being over, under, over, under.... speed.
>
> I have found many people who use PIDs all the time and screw up the
> concept of "I" control because there are 2 user defined values and
> depending upon which one you talking about more "I" will speed up or
> slow down the response. If you increase "I GAIN" the system will
> respond faster. If you increase "I Interval (time) the system will
> slow down because the change in "I" output is done at a slower rate.
> Don't get caught in this trap. Some otherwise intelligent engineers
> will argue this point like you were attacking their religion.
>
> PID only sounds complex unless you break it down into its 3
> components and realize the math for each component is rather simple
> and then you just add the 3 outputs for your final control and send
> it to your D/A converter.
>
>
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 30/06/2006
>
>

#21436 From: "naimead" <naimead@...>
Date: Mon Jul 3, 2006 10:52 pm
Subject: Re: Can basicX keep some variables in memory?(e.g sonar distance measurements)
naimead
Send Email Send Email
 
Thanks for the help guys!Is it possible to count the number of
measurements that have been recorded into EEPROM?For example using
putEEPROM() to record for example 123 measurements within 20 sec?

naimaed

#21437 From: "ricinecwh" <ricinecwh@...>
Date: Tue Jul 4, 2006 2:40 pm
Subject: Re: Temperature control
ricinecwh
Send Email Send Email
 
Thank you for your help
I am now starting the maths of the PID

--- In basicx@yahoogroups.com, "Craig" <craig.whitley@...> wrote:
>
> --- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@> wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
> >
>
> Depending upon the required accuracy, you may or may not need PID
> control. Will your control device be simple heat on/off, cool
on/off
> or do you plan on proportional control where the greater the
> difference between actual temperature and desired (set point)
> temperature you will increase/decrease the rate at which heat is
> added or removed?
>
> That question MUST be answered first.
>
> If you will be using proportional control then you will want to
> program a PID controller. Yes you can use PID with simple on/off
> control but it is like squirrel hunting with an elephant gun.
>
> There are many PID formulas available on the WEB and I would
suggest
> using the simplest expressions that maintain the desired control.
>
> The expressions shown below are Pseudo expressions at best just to
> illustrate the concepts.
>
> PID can be thought as 3 stand alone controllers with their
resulting
> outputs added together to form a common control output.
>
> The "P" in PID stands for proportional. The further your actual
> temperature (or any other measurement) is from the desired (set
> point) the P controller will increase/decrease output. If for
example
> you are only 1 degree high or low, you may not need much of a
change
> from your controlling device (heater, fan etc.) On the other hand
if
> there is a 20 degree difference you want you system to have more
> output to bring the temperature back in line faster.
>
> Error =(Set point-Actual)
> P Output = (Error * P-Gain)
> (you enter the P-Gain based on the system's response tea pot Vs
> swimming pool)
>
> You can run a system with just proportional gain but you will soon
> find out that you will never reach the exact set point as when the
> error is very small you don't have much controller output. You can
> keep adding gain but eventually you will just keep overshooting
then
> undershooting your set point. This is usually refered to as
> Proportional Droop.
>
> INTEGRAL:
> The "I" in PID is for Integral. In the most basic terms,
> the integral gain is determined by the error between actual and
set
> point and the length of time the system has been away from the set
> point. Adding Integral gain solves the problem with a Proportional
> only system never reaching set point as the Integral will keep
adding
> to the P output positive or negative output until you reach the
set
> point.
>
> For all but the most super critical temperature applications P+I
will
> be sufficient.
>
> For a very, very, very simple "I" control you take the (Error *
Gain)
> and keep adding/subtracting that result at a given timed interval.
> Care must be taken to keep the Gain as small as possible to avoid
> wind up where the combined P&I values add up so fast that the
system
> reaches its limit way too soon and takes forever to come back
under
> control. Again based upon what you are trying to control (tea
> pot/swimming pool) your system will require more or less time to
> respond and excessive "I" gain or too short an interval will cause
> overshoot/undershoot.
>
> The "I" term will keep adding/subtracking its output every X
seconds
> (P-Interval)
>
> Differential:
> There are certain applications that you want to limit (or slow
down)
> the
> response to prevent overshoot. If you have too much P or I Output
it
> is easy to overshoot your set point and the system will oscillate
and
> be unstable. The "D" in PID is Differential Gain. Again in the
most
> simplest of terms it looks at the "rate of change" and if that
rate
> is too high, the differential Output will be added/subtracted from
> the P&I output sum.
>
> Pseudo math for Differential would be: (Last Error - Current
Error) *
> DGain. If the difference in errors is very small the "D" output
will
> be very small. If the difference in Current/Last error is large
then
> the system is responding very fast and the DOutput will be high
and
> that output can be subtracted from the P+I sum.
>
> A good cruise control in a car should have "D" gain to prevent the
> car from being over, under, over, under.... speed.
>
> I have found many people who use PIDs all the time and screw up
the
> concept of "I" control because there are 2 user defined values and
> depending upon which one you talking about more "I"  will speed up
or
> slow down the response. If you increase "I GAIN" the system will
> respond faster. If you increase "I Interval (time) the system will
> slow down because the change in "I" output is done at a slower
rate.
> Don't get caught in this trap. Some otherwise intelligent
engineers
> will argue this point like you were attacking their religion.
>
> PID only sounds complex unless you break it down into its 3
> components and realize the math for each component is rather
simple
> and then you just add the 3 outputs for your final control and
send
> it to your D/A converter.
>

#21438 From: "Alex Chaihorsky" <xyz1953@...>
Date: Tue Jul 4, 2006 4:27 pm
Subject: Re: Temperature control
biovirus1
Send Email Send Email
 
I had posted PID code for BX24 on this forum about two years ago. It
was in "Files" area but now the whole area looks different. But it
must be there somewhere.
This code worked very well for a very fast-responce job (fast heating
of a 5 grams copper plate with a 30 watt heater and temp control up to
0.1 deg C).
The output was PWM.

Alex.


--- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@...> wrote:
>
> Thank you for your help
> I am now starting the maths of the PID
>
> --- In basicx@yahoogroups.com, "Craig" <craig.whitley@> wrote:
> >
> > --- In basicx@yahoogroups.com, "ricinecwh" <ricinecwh@> wrote:
> >
> > >
> > > The problem is how can the controller automically adjust the
> > tempature
> > > in the basic X
> > > Some people tell me to use the PID controller
> > > however, i find it is difficult to fix the three variables.
> > > Is there anypeople familiar with the PID?
> > > or
> > > there are any alternative way to fix it?
> > >
> >
> > Depending upon the required accuracy, you may or may not need PID
> > control. Will your control device be simple heat on/off, cool
> on/off
> > or do you plan on proportional control where the greater the
> > difference between actual temperature and desired (set point)
> > temperature you will increase/decrease the rate at which heat is
> > added or removed?
> >
> > That question MUST be answered first.
> >
> > If you will be using proportional control then you will want to
> > program a PID controller. Yes you can use PID with simple on/off
> > control but it is like squirrel hunting with an elephant gun.
> >
> > There are many PID formulas available on the WEB and I would
> suggest
> > using the simplest expressions that maintain the desired control.
> >
> > The expressions shown below are Pseudo expressions at best just to
> > illustrate the concepts.
> >
> > PID can be thought as 3 stand alone controllers with their
> resulting
> > outputs added together to form a common control output.
> >
> > The "P" in PID stands for proportional. The further your actual
> > temperature (or any other measurement) is from the desired (set
> > point) the P controller will increase/decrease output. If for
> example
> > you are only 1 degree high or low, you may not need much of a
> change
> > from your controlling device (heater, fan etc.) On the other hand
> if
> > there is a 20 degree difference you want you system to have more
> > output to bring the temperature back in line faster.
> >
> > Error =(Set point-Actual)
> > P Output = (Error * P-Gain)
> > (you enter the P-Gain based on the system's response tea pot Vs
> > swimming pool)
> >
> > You can run a system with just proportional gain but you will soon
> > find out that you will never reach the exact set point as when the
> > error is very small you don't have much controller output. You can
> > keep adding gain but eventually you will just keep overshooting
> then
> > undershooting your set point. This is usually refered to as
> > Proportional Droop.
> >
> > INTEGRAL:
> > The "I" in PID is for Integral. In the most basic terms,
> > the integral gain is determined by the error between actual and
> set
> > point and the length of time the system has been away from the set
> > point. Adding Integral gain solves the problem with a Proportional
> > only system never reaching set point as the Integral will keep
> adding
> > to the P output positive or negative output until you reach the
> set
> > point.
> >
> > For all but the most super critical temperature applications P+I
> will
> > be sufficient.
> >
> > For a very, very, very simple "I" control you take the (Error *
> Gain)
> > and keep adding/subtracting that result at a given timed interval.
> > Care must be taken to keep the Gain as small as possible to avoid
> > wind up where the combined P&I values add up so fast that the
> system
> > reaches its limit way too soon and takes forever to come back
> under
> > control. Again based upon what you are trying to control (tea
> > pot/swimming pool) your system will require more or less time to
> > respond and excessive "I" gain or too short an interval will cause
> > overshoot/undershoot.
> >
> > The "I" term will keep adding/subtracking its output every X
> seconds
> > (P-Interval)
> >
> > Differential:
> > There are certain applications that you want to limit (or slow
> down)
> > the
> > response to prevent overshoot. If you have too much P or I Output
> it
> > is easy to overshoot your set point and the system will oscillate
> and
> > be unstable. The "D" in PID is Differential Gain. Again in the
> most
> > simplest of terms it looks at the "rate of change" and if that
> rate
> > is too high, the differential Output will be added/subtracted from
> > the P&I output sum.
> >
> > Pseudo math for Differential would be: (Last Error - Current
> Error) *
> > DGain. If the difference in errors is very small the "D" output
> will
> > be very small. If the difference in Current/Last error is large
> then
> > the system is responding very fast and the DOutput will be high
> and
> > that output can be subtracted from the P+I sum.
> >
> > A good cruise control in a car should have "D" gain to prevent the
> > car from being over, under, over, under.... speed.
> >
> > I have found many people who use PIDs all the time and screw up
> the
> > concept of "I" control because there are 2 user defined values and
> > depending upon which one you talking about more "I"  will speed up
> or
> > slow down the response. If you increase "I GAIN" the system will
> > respond faster. If you increase "I Interval (time) the system will
> > slow down because the change in "I" output is done at a slower
> rate.
> > Don't get caught in this trap. Some otherwise intelligent
> engineers
> > will argue this point like you were attacking their religion.
> >
> > PID only sounds complex unless you break it down into its 3
> > components and realize the math for each component is rather
> simple
> > and then you just add the 3 outputs for your final control and
> send
> > it to your D/A converter.
> >
>

#21439 From: Tom Becker <gtbecker@...>
Date: Tue Jul 4, 2006 5:31 pm
Subject: Re: [BasicX] Re: Temperature control
b19063
Send Email Send Email
 
> It was in "Files" area but now the whole area looks different.

Two clicks finds that it's still there; look in
Files/Datasheets-Appnotes-Examples-Drawings/Code Techniques.  You
uploaded it as "biovirus1".


Tom

#21440 From: "Craig" <craig.whitley@...>
Date: Wed Jul 5, 2006 12:39 am
Subject: Re: PID
wurlitzer28
Send Email Send Email
 
--- In basicx@yahoogroups.com, "njepsen@..." <njepsen@...> wrote:
>
> A nice treatise Craig...I enjoyed reading it. It sounds to me as
though
> you are a bit of a PID enthousiast, as am I.

Thanks, I know what you mean about the $#@% ankle deep if the pumps
don't work right.

I do like working with PIDs as once you get past 3 things happening at
once they work slick. Once properly tuned they are neat to watch
operate (only engineers would get a kick out of this).

#21441 From: "tc_lawabider" <jesdilbert@...>
Date: Wed Jul 5, 2006 7:17 pm
Subject: HM55B compass code help needed
tc_lawabider
Send Email Send Email
 
Hi everyone,
I've been trying to learn the differences between PStamp code and
BasicX code with this project. I'm converting the provided code from
Parallax for use with this new board.
It seems someone already did this (Tom Handley?), but his site is down.
The original file is:

***********************
' -----[ Pins/Constants/Variables
]-------------------------------------------
DinDout        PIN      6                    ' P6 transceives to/from
Din/Dout
Clk            PIN      5                    ' P5 sends pulses to
HM55B's Clk
En             PIN      4                    ' P4 controls HM55B's
/EN(ABLE)

Reset          CON      %0000                ' Reset command for HM55B
Measure        CON      %1000                ' Start measurement command
Report         CON      %1100                ' Get status/axis values
command
Ready          CON      %1100                ' 11 -> Done, 00 -> no errors
NegMask        CON      %1111100000000000    ' For 11-bit negative to
16-bits

x              VAR      Word                 ' x-axis data
y              VAR      Word                 ' y-axis data
status         VAR      Nib                  ' Status flags
angle          VAR      Word                 ' Store angle measurement

' -----[ Main Routine
]-------------------------------------------------------

DO                                           ' Main loop

   GOSUB Get_Compass_Axes                     ' Get x, and y values

   angle = x ATN -y                           ' Convert x and y to brads
   angle = angle */ 360                       ' Convert brads to degrees

'  DEBUG HOME, "x-axis N(-S) = ",SDEC x,      ' Display axes and degrees
'        CLREOL, CR, "y-axis W(-E) = ",
'        SDEC y, CLREOL, CR, CR, "angle = ",
'        DEC angle, " degrees", CLREOL
DEBUG HOME, DEC3 angle
   PAUSE 150                                  ' Debug delay for slower PCs

LOOP                                         ' Repeat main loop


' -----[ Subroutines
]--------------------------------------------------------

Get_Compass_Axes:                            ' Compass module subroutine

   HIGH En: LOW En                            ' Send reset command to HM55B
   SHIFTOUT DinDout,clk,MSBFIRST,[Reset\4]

   HIGH En: LOW En                            ' HM55B start measurement
command
   SHIFTOUT DinDout,clk,MSBFIRST,[Measure\4]
   status = 0                                 ' Clear previous status flags

   DO                                         ' Status flag checking loop
     HIGH En: LOW En                          ' Measurement status command
     SHIFTOUT DinDout,clk,MSBFIRST,[Report\4]
     SHIFTIN  DinDout,clk,MSBPOST,[Status\4]  ' Get Status
   LOOP UNTIL status = Ready                  ' Exit loop when status
is ready

   SHIFTIN  DinDout,clk,MSBPOST,[x\11,y\11]   ' Get x & y axis values
   HIGH En                                    ' Disable module

   IF (y.BIT10 = 1) THEN y = y | NegMask      ' Store 11-bits as signed
word
   IF (x.BIT10 = 1) THEN x = x | NegMask      ' Repeat for other axis

   RETURN
*************************

Shiftin and out are different on the basicX, and some of the syntax is
off.

The follow is what I have - it gets stuck in an infinite loop, and I
didn't even try to parse the data yet because I have a feeling my
shiftin/shiftouts are incorrect.

********************************
'------start of hm55 compass reader for basicx24p
Option Explicit

Public Const SerialLine As Byte = 12 'P7/Pin 12 is our in/out serial line
Public Const ENLine As Byte = 9 'P4/Pin 9 is our /EN line
Public Const CLK As Byte = 10 'P5/Pin 10 is our CLK line
Public Const High As Byte = 1 'Simple definition of booleans
Public Const Low As Byte = 0 'Define low boolean
Public Const Reset As Byte = 0000
'Public Const Measure As Byte = 1000
'Public Const ReportReady As Byte = 1100
'------main sub
Public Sub Main()
'Do simple in/out with compass... no parsing (yet)
Dim status As Byte, x As Byte, y As Byte
Debug.Print "Starting compass interface module"
DO
'-------------------------------------------------------------------------------\
----------------------------------------------
Debug.Print "At the beginning of the loop"
Call PutPin (EnLine, High) 'Set the enable line high
Call PutPin (EnLine, Low) 'Set the enable line high
Call ShiftOut (SerialLine, CLK, 4, Reset)'Shiftout with MSB first to
Serial Line and Clock, 4 bits, specifically reset
Debug.Print "Compass has been reset by enable high, enable low, reset
serial"
'-------------------------------------------------------------------------------\
----------------------------------------------
Debug.Print "Telling the compass to measure"
Call PutPin (EnLine, High) 'Set the enable line high
Call PutPin (EnLine, Low) 'Set the enable line high
Call ShiftOut (SerialLine, CLK, 4, 1000)'Shiftout with MSB first to
Serial Line and Clock, 4 bits, specifically measure (bits for 1000)
Debug.Print "Compass set to measure by enable high, enable low,
measure command"
'-------------------------------------------------------------------------------\
----------------------------------------------
status = 0'Set the status flag to something that will make it loop
until we know that the information has been gathered

'-------------------------------------------------------------------------------\
----------------------------------------------
DO 'Run only while the compass is not "ready"
Debug.Print "In the waiting loop"
Call PutPin (EnLine, High) 'Set the enable line high
Call PutPin (EnLine, Low) 'Set the enable line high
Call ShiftOut (SerialLine, CLK, 4, 1000)'Shiftout with MSB first to
Serial Line and Clock, 4 bits, specifically measure (bits for 1000)
status = ShiftIn (SerialLine, CLK, 0011)'Set status to the shiftin.
This is MSB last, so instead of looking for ReportReady (1100), it
finds the reverse (0011).
LOOP UNTIL status = 1100
Debug.Print "No longer waiting - data ready."
'-------------------------------------------------------------------------------\
----------------------------------------------
'REDO THIS CODE
'My attempt - only uses one variable...
'----------------
'status = ShiftIn (SerialLine, CLK, FlipBits(x))'Get the value sent
out on the serial line and break it up into X and Y.
'Call PutPin (EnLine, High) 'Set the enable line high to stop the sending.
'Debug.Print "Value returned is"
'Debug.Print CStr(x)

'The old code
'  SHIFTIN  DinDout,clk,MSBPOST,[x\11,y\11]   ' Get x & y axis values
'  HIGH En                                    ' Disable module

'  IF (y.BIT10 = 1) THEN y = y | NegMask      ' Store 11-bits as
signed word
'  IF (x.BIT10 = 1) THEN x = x | NegMask      ' Repeat for other axis
'------------
'-------------------------------------------------------------------------------\
----------------------------------------------
LOOP
'-------------------------------------------------------------------------------\
----------------------------------------------
End Sub
'------end main sub
*********************************

Has anyone worked with this sensor before? Any help, sample code, etc.
would be greatly appreciated. I'm really lost when it comes to MSB/LSB
and all that good stuff.
Thanks!

#21442 From: "deltapparo" <DelTapparo@...>
Date: Thu Jul 6, 2006 5:23 pm
Subject: Piezo Transducers
deltapparo
Send Email Send Email
 
I am confused as to what to buy and how these things work. I want a
cheap audio tranducer that I can use the SOUND command to produce
various audio sounds. Many of these devices don't specify a frequency
response range. Are the only good at the resonant freq?

What devices do you folks use? I am looking for cheap parts ( <$2 ). I
can drive it directly from a discrete output, or a Darlington pair
powered from 14.4V.

#21443 From: Tom Becker <gtbecker@...>
Date: Thu Jul 6, 2006 9:43 pm
Subject: Re: [BasicX] Piezo Transducers
b19063
Send Email Send Email
 
> ... I want a cheap audio tranducer...

Most piezo sounders have a narrow useful frequency spectrum; those I've
handled seem to like 2KHz, or so.  If you intend to produce musical
sounds or speech, I suspect you'll need a wider response than a piezo
will provide.

You might look at small dynamic speakers like you'd find in a small
radio or desk speakerphone.  For instance:
https://www.goldmine-elec-products.com/prodinfo.asp?number=G14397
http://www.panasonic.com/industrial/components/pdf/004_eas_generalspeaker.PDF

Since dynamic transducers are low-impedance devices, you'll need to
drive them differently (current) than you might drive a piezo (voltage).


Tom

#21444 From: "Tom Becker" <gtbecker@...>
Date: Thu Jul 6, 2006 10:21 pm
Subject: Re: Piezo Transducers
b19063
Send Email Send Email
 
#21445 From: "tc_lawabider" <jesdilbert@...>
Date: Fri Jul 7, 2006 3:51 am
Subject: Re: HM55B compass code help needed
tc_lawabider
Send Email Send Email
 
Anyone?
I've got some newer code... Now I think it might be variable types,
since it doesnt enjoy using bytes for some of them.


********************
'------start of hm55 compass reader for basicx24p
Option Explicit

Public Const SerialLine As Byte = 12 'P7/Pin 12 is our in/out serial line
Public Const ENLine As Byte = 9 'P4/Pin 9 is our /EN line
Public Const CLK As Byte = 10 'P5/Pin 10 is our CLK line
Public Const High As Byte = 1 'Define 1 as High
Public Const Low As Byte = 0 'Define 0 as Low
Public Const Reset As Long = 0000
Public Const Measure As Long = 1000
Public Const ReadyReport As Long = 1100
'------main sub starts here
Public Sub Main()
	 Dim status As Long, x As Byte, y As Byte
	 Dim totnum As Byte
	 DO
		 Call PutPin (EnLine, High)
		 Call PutPin (EnLine, Low) 'Set the enable line high, then set it low
			 Call ShiftOut (SerialLine, CLK, 4, Reset)'Shiftout with MSB first
to Serial Line and Clock, 4 bits
		 Call PutPin (EnLine, High)
		 Call PutPin (EnLine, Low) 'Set the enable line high, then set it low
			 Call ShiftOut (SerialLine, CLK, 4, Measure)'Shiftout with MSB first
to Serial Line and Clock, 4 bits
				 status = 10'Set the status flag to something that will make it
loop until we know that the information has been gathered
					 DO 'Run only while the compass is not "ready"
						 Call PutPin (EnLine, High)
						 Call PutPin (EnLine, Low) 'Set the enable line high, then set it low
							 Call ShiftOut (SerialLine, CLK, 4, ReadyReport)'Shiftout with
MSB first to Serial Line and Clock, 4 bits, specifically measure (bits
for 1000)
							 status = FlipBits(ShiftIn(SerialLine,CLK,4))'Set status to the
shiftin. This is MSB last, so instead of looking for ReportReady
(1100), it finds the reverse (0011).
						 Debug.Print CStr(status)
					 LOOP UNTIL status = 1100
Debug.Print "No longer waiting - data ready."
'-------------------------------------------------------------------------------\
----------------------------------------------
totnum = FlipBits(ShiftIn(SerialLine,CLK,11))'get 11 bits to break up
into x and y
Call PutPin (EnLine, High) 'Set the enable line 1 to stop the sending.
'-------------------------------------------------------------------------------\
----------------------------------------------
Debug.Print "Value returned is"
Debug.Print CStr(totnum)
'Now break this up into x and y, then  apply the mask?
'  IF (y.BIT10 = 1) THEN y = y | NegMask      ' Store 11-bits as
signed word
'  IF (x.BIT10 = 1) THEN x = x | NegMask      ' Repeat for other axis
'-------------------------------------------------------------------------------\
----------------------------------------------
LOOP
'-------------------------------------------------------------------------------\
----------------------------------------------
End Sub
'------end main sub
**********************************

#21446 From: "nuepatrick" <nuepatrick@...>
Date: Fri Jul 7, 2006 9:01 pm
Subject: Please help
nuepatrick
Send Email Send Email
 
I am trying to measure 10 - 15 volts. I have the following program

'--------------------------------------------------------------------
' This program will measure the battery voltage using a voltage
divider
' Vin------R1------R2------Gnd
'               |
'               |
'               |
'              P13
' R1 is 10.01K 1% and R2 is 4.99K 1%
'The maximum voltage will be (5V(max input voltage allowed to the
chip) * (R2 + R1)) / R2 which will yield a value of ~15.03 this is
my maximum input voltage


Sub Main()
	 Dim VoltCount As Integer
	 Dim BatteryVoltage As Single
     Const ADCpin As Byte = 13

     Do

      VoltCount = GetAdc(ADCpin)
	 Debug.Print "The ADC Value is: ";CStr(VoltCount)
	 BatteryVoltage = CSng(Getadc(ADCpin) \ 1024) * 15.03
	 Debug.Print "The Battery Voltage is: "; CStr(BatteryVoltage)
	 Loop

End Sub
'--------------------------------------------------------------------

When I run the program I get ADC values starting at 304 for 0 Volts
this is wrong it should start out at 0 I think, and the value climbs
to 1023 which makes sense. Also I don't read any voltage its always 0

I am confused what am I doing wrong? I'm sure I've got this all
messed up.

Thanks

Patrick

#21447 From: "nuepatrick" <nuepatrick@...>
Date: Fri Jul 7, 2006 10:00 pm
Subject: Measure Battery Voltage
nuepatrick
Send Email Send Email
 
Please disreguard the previous post

Here is a better version of what I need to do. The only problem I am
having now is that the displayed value is not tracking the measured
value. What am I doing wrong here.


'--------------------------------------------------------------------
' This program will measure the battery voltage using a voltage
divider
' Vin------R1------R2------Gnd
'               |
'               |
'               |
'              P13
' R1 is 10.01K 1% and R2 is 4.99K 1%
'The maximum voltage will be (5V * (R2 + R1)) / R2 which will yield
a value of ~15.03


Sub Main()
	 Dim Pin As Single
	 Dim BatteryVoltage as Single
     Const ADCpin As Byte = 13

     Do

      Call GetAdc(ADCpin,Pin)
	 Debug.print " ADC Voltage: "; CStr(Pin)
	 BatteryVoltage = (CSng(Getadc(ADCpin)) / 1023.0) * 15.03
	 Debug.Print "Battery Voltage is: "; CStr(BatteryVoltage)
	 Call Delay(0.5)
	 Loop

End Sub

Again thanks for the help.

Patrick

#21448 From: "aviv_marom" <aviv_marom@...>
Date: Fri Jul 7, 2006 9:19 pm
Subject: SRF08 -Ultrasonic Range Finder.
aviv_marom
Send Email Send Email
 
Hello,
My name is Aviv and I'm studying Electronic Engineering In Israel
(www.hit.ac.il)
As part of my degree I'm doing a project on the following
issue :"Measuring Distance Between two Cars".
This project will be offered to the police as a way to enforce the
Law of "Keeping Distance between cars".

During my Project I have built\designed a system that works in the
following method:
  - Transmitting \intercepting an Alta-Sonic pulse via the SRF08 -
Ultrasonic Ranger .
  - Analysis of the Time Duration in the gap between the two cars via
the OOPIC-R controller.

However,
During my measurements in the street (external envirarment) I have
encountered in the following phenomenon ,
- I'm picking an object at a distance of ~3 meters, where there is no
object at all.

I have read the SRF08 Technical data.
Please see bellow my program .
I have copied only the relevant part of my program (where I
configures the SRF08 and doing the Transmitting \reading) .

*********My Program ****************************************

SRF08.Node = 112;  //Srf08 Address 0XE0
   	 SRF08.Mode = cv10bit;
   	 SRF08.NoInc = 1;
	 SRF08.Width = cv8bit;

	 //SRF08.Location = 2;
	 //SRF08=116; // Limit first Sonar Range to ~5 meters
[(43mm*116)+43mm]


	 SRF08.Location = 1;
	 SRF08=25; // Limit Maximum analogue gain to 94 (Min of gain)


       Counter.Input.Link(In);
       Counter.Output.Link(Out);
       Counter.Clockin1.Link(OOPic.HZ60);
       Counter.Direction = 0;
       Counter.Mode = 0;


       do
       {
          SRF08.Location = 0;
          SRF08.Width = cv8bit;
          SRF08 = 81; //Start Range in [cm]


          do
          {
            Ver = SRF08;
          } While (Ver==255); // wait untill range is completed

          SRF08.Width = cv16bit;
          SRF08.Location = 2;
          Range1 = SRF08; // Range read in [cm]

	    SRF08.Location = 4;
          Range2 = SRF08; // Range read in [cm]

	    SRF08.Location = 6;
          Range3 = SRF08; // Range read in [cm]

	    SRF08.Location = 8;
          Range4 = SRF08; // Range read in [cm]

	    SRF08.Location = 18;
          Range5 = SRF08; // Range read in [cm]

	    SRF08.Location = 20;
          Range6 = SRF08; // Range read in [cm]

************ END Of Program ******************************

As You can see I have tried to Limit the 'Maximum analogue gain' to
94 (and tried other values as well).
In addition I have placed the SRF08 Ranger in various poisons and
tried to measure in various streets.
Please advise if I can supply to the SRF08 more than 5 volt.

Waiting for your answer,
Thanks,
Aviv Marom.

#21449 From: Tom Becker <gtbecker@...>
Date: Fri Jul 7, 2006 10:10 pm
Subject: Re: [BasicX] Please help
b19063
Send Email Send Email
 
> ... When I run the program I get ADC values starting at 304..

Is the pin's pullup on?  If you haven't, set the pin to InputTristate.


Tom

#21450 From: Thad Larson <highwayman_33402@...>
Date: Fri Jul 7, 2006 10:48 pm
Subject: Re: [BasicX] Measure Battery Voltage
highwayman_3...
Send Email Send Email
 
ASCII graphics can be a pain, but I have to ask : Shouldn't P13 be connected
between R1 and R2 ?

   Thad

nuepatrick <nuepatrick@...> wrote:
           ' This program will measure the battery voltage using a voltage
divider
' Vin------R1------R2------Gnd
' |
' |
' |
' P13
' R1 is 10.01K 1% and R2 is 4.99K 1%



         New Message Search
   Find the message you want faster. Visit your group to try out the improved
message search.




   Share feedback on the new changes to Groups


     Recent Activity

       8
   New Members

Visit Your Group
   SPONSORED LINKS

    Microcontrollers
    Microprocessor
    Intel microprocessors
    Pic microcontrollers
    Violator


   .





---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs.Try it free.

[Non-text portions of this message have been removed]

#21451 From: "nuepatrick" <nuepatrick@...>
Date: Fri Jul 7, 2006 11:01 pm
Subject: Re: Measure Battery Voltage
nuepatrick
Send Email Send Email
 
It is connected between R1 and R2

As a note when I start at 0 volts I have an ADC value of ~300 I can
increase the voltage until I get to 11.7 volts which is an ADC value
of 1023 Something is amiss

Thanks

Patrick
--- In basicx@yahoogroups.com, Thad Larson <highwayman_33402@...>
wrote:
>
> ASCII graphics can be a pain, but I have to ask : Shouldn't P13 be
connected between R1 and R2 ?
>
>   Thad
>
> nuepatrick <nuepatrick@...> wrote:
>           ' This program will measure the battery voltage using a
voltage
> divider
> ' Vin------R1------R2------Gnd
> ' |
> ' |
> ' |
> ' P13
> ' R1 is 10.01K 1% and R2 is 4.99K 1%
>
>
>
>         New Message Search
>   Find the message you want faster. Visit your group to try out
the improved message search.
>
>
>
>
>   Share feedback on the new changes to Groups
>
>
>     Recent Activity
>
>       8
>   New Members
>
> Visit Your Group
>   SPONSORED LINKS
>
>    Microcontrollers
>    Microprocessor
>    Intel microprocessors
>    Pic microcontrollers
>    Violator
>
>
>   .
>
>
>
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs.Try it free.
>
> [Non-text portions of this message have been removed]
>

Messages 21422 - 21451 of 23507   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help