From: sandeep patil
Subject: voltage & current program
Date: 
Message-ID: <1176180991.071069.104220@q75g2000hsh.googlegroups.com>
can you tell me any function in ohms law & it related program.
who i will right program on it.

sandeep patil

From: Pascal Bourguignon
Subject: Re: voltage & current program
Date: 
Message-ID: <877iskocoi.fsf@voyager.informatimago.com>
"sandeep patil" <·········@gmail.com> writes:
> can you tell me any function in ohms law & it related program.
> who i will right program on it.

Ohm's Law, for a resistor, is:

   U = R * I  (voltage = resistance * intensity)

You can write a function in Common Lisp to solve this equation, known
at least two of its variables:

(defun resistor-ohm-law (&key u r i)
  (cond
     (u  (cond (r (list :i (/ u r)))
               (i (list :r (/ u i)))
               (t (list :|R(I)| (lambda (i) (/ u i))
                        :|I(R)| (lambda (r) (/ u r)))))
   
         



-- 
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
From: Rob Warnock
Subject: Re: voltage & current program
Date: 
Message-ID: <NO-dnaPWQ6bJzobbnZ2dnUVZ_uSgnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| "sandeep patil" <·········@gmail.com> writes:
| > can you tell me any function in ohms law & it related program.
| > who i will right program on it.
| 
| Ohm's Law, for a resistor, is:
|    U = R * I  (voltage = resistance * intensity)
+---------------

FYI, in standard English engineering notation/language,
the symbol for voltage is "V", not "U". And the symbol "I"
refers to "current", not "intensity". And although this
doesn't matter at all to correctness, the rule is usually
given with "R" last [for unknown-to-me historical reasons,
I suppose]:

     V = I * R  (voltage = current * resistance)

+---------------
| You can write a function in Common Lisp to solve this equation,
| known at least two of its variables:
| 
| (defun resistor-ohm-law (&key u r i)
|   (cond
|      (u  (cond (r (list :i (/ u r)))
|                (i (list :r (/ u i)))
|                (t (list :|R(I)| (lambda (i) (/ u i))
|                         :|I(R)| (lambda (r) (/ u r)))))
+---------------

Yes, this is one place where I really, really like CL's keywords!!
But I generally write this kind of thing as follows, which feels to
me to be more perspicuous [though admittedly slightly more redundant
and thus *slightly* less efficient -- a tradeoff I'm usually willing
to make]:

  (defun resistor-ohm-law (&key v r i)
    (cond
      ((and v i r)
       (error "May not specify all three parameters!"))
      ((and v r) (list :i (/ v r)))
      ((and v i) (list :r (/ v i)))
      ((and i r) (list :v (* i r)))
      (t
       (error "Must specify at least two parameters!"))))


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pascal Bourguignon
Subject: Re: voltage & current program
Date: 
Message-ID: <87r6qsmb8v.fsf@voyager.informatimago.com>
····@rpw3.org (Rob Warnock) writes:

> Pascal Bourguignon  <···@informatimago.com> wrote:
> +---------------
> | "sandeep patil" <·········@gmail.com> writes:
> | > can you tell me any function in ohms law & it related program.
> | > who i will right program on it.
> | 
> | Ohm's Law, for a resistor, is:
> |    U = R * I  (voltage = resistance * intensity)
> +---------------
>
> FYI, in standard English engineering notation/language,
> the symbol for voltage is "V", not "U". And the symbol "I"
> refers to "current", not "intensity". And although this
> doesn't matter at all to correctness, the rule is usually
> given with "R" last [for unknown-to-me historical reasons,
> I suppose]:
>
>      V = I * R  (voltage = current * resistance)

Thank you.

In French, U and V are used about interchangeably for voltage, with
perhaps a slight preference for U by physicists (vs. electricians)
because V is usually the speed (velocity).

And I guess we put R before I, because R is usually the constant,
while voltage and current may change. 


> +---------------
> | You can write a function in Common Lisp to solve this equation,
> | known at least two of its variables:
> | 
> | (defun resistor-ohm-law (&key u r i)
> |   (cond
> |      (u  (cond (r (list :i (/ u r)))
> |                (i (list :r (/ u i)))
> |                (t (list :|R(I)| (lambda (i) (/ u i))
> |                         :|I(R)| (lambda (r) (/ u r)))))
> +---------------
>
> Yes, this is one place where I really, really like CL's keywords!!
> But I generally write this kind of thing as follows, which feels to
> me to be more perspicuous [though admittedly slightly more redundant
> and thus *slightly* less efficient -- a tradeoff I'm usually willing
> to make]:
>
>   (defun resistor-ohm-law (&key v r i)
>     (cond
>       ((and v i r)
>        (error "May not specify all three parameters!"))
>       ((and v r) (list :i (/ v r)))
>       ((and v i) (list :r (/ v i)))
>       ((and i r) (list :v (* i r)))
>       (t
>        (error "Must specify at least two parameters!"))))

Agreed.  We can always count on a sufficiently smart compiler (or
write a macro to give more smarts to one's compiler).

-- 
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
From: sandeep patil
Subject: Re: voltage & current program
Date: 
Message-ID: <1176274096.741268.110710@y80g2000hsf.googlegroups.com>
On Apr 10, 2:05 pm, ····@rpw3.org (Rob Warnock) wrote:
> Pascal Bourguignon  <····@informatimago.com> wrote:
> +---------------
> | "sandeep patil" <·········@gmail.com> writes:
> | > can you tell me any function in ohms law & it related program.
> | > who i will right program on it.
> |
> | Ohm's Law, for a resistor, is:
> |    U = R * I  (voltage = resistance * intensity)
> +---------------
>
> FYI, in standard English engineering notation/language,
> the symbol for voltage is "V", not "U". And the symbol "I"
> refers to "current", not "intensity". And although this
> doesn't matter at all to correctness, the rule is usually
> given with "R" last [for unknown-to-me historical reasons,
> I suppose]:
>
>      V = I * R  (voltage = current * resistance)
>
> +---------------
> | You can write a function in Common Lisp to solve this equation,
> | known at least two of its variables:
> |
> | (defun resistor-ohm-law (&key u r i)
> |   (cond
> |      (u  (cond (r (list :i (/ u r)))
> |                (i (list :r (/ u i)))
> |                (t (list :|R(I)| (lambda (i) (/ u i))
> |                         :|I(R)| (lambda (r) (/ u r)))))
> +---------------
>
> Yes, this is one place where I really, really like CL's keywords!!
> But I generally write this kind of thing as follows, which feels to
> me to be more perspicuous [though admittedly slightly more redundant
> and thus *slightly* less efficient -- a tradeoff I'm usually willing
> to make]:
>
>   (defun resistor-ohm-law (&key v r i)
>     (cond
>       ((and v i r)
>        (error "May not specify all three parameters!"))
>       ((and v r) (list :i (/ v r)))
>       ((and v i) (list :r (/ v i)))
>       ((and i r) (list :v (* i r)))
>       (t
>        (error "Must specify at least two parameters!"))))
>
> -Rob
>
> -----
> Rob Warnock                     <····@rpw3.org>
> 627 26th Avenue                 <URL:http://rpw3.org/>
> San Mateo, CA 94403             (650)572-2607

dear sir

i want to get real current & voltage value  from my divece power
supply how i will get it value
is it possible in lisp ,your solution is usable but mey i know how i
measure current & voltage follow in my device

regard
sandeep patil
pune
From: Rob Warnock
Subject: Re: voltage & current program
Date: 
Message-ID: <GJOdnbxvE6N_EYHbnZ2dnUVZ_t3inZ2d@speakeasy.net>
sandeep patil <·········@gmail.com> wrote:
+---------------
| i want to get real current & voltage value  from my divece power
| supply how i will get it value
| is it possible in lisp ,your solution is usable but mey i know how i
| measure current & voltage follow in my device
+---------------

Well, how would you measure it *without* Lisp?!?
First tell us that, and then we might have a chance
of telling you how Lisp could do the same thing.

[Note: Performing physical measurements on the internals
of one's system is typically a *very* platform-specific
issue having very little to do with programming languages
per se and much more to do with what drivers (I2C, ACPI, etc.)
your platform provides...]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: sandeep patil
Subject: Re: voltage & current program
Date: 
Message-ID: <1176370015.871628.309200@d57g2000hsg.googlegroups.com>
On Apr 11, 12:23 pm, ····@rpw3.org (Rob Warnock) wrote:
> sandeep patil <·········@gmail.com> wrote:
>
> +---------------
> | i want to get real current & voltage value  from my divece power
> | supply how i will get it value
> | is it possible in lisp ,your solution is usable but mey i know how i
> | measure current & voltage follow in my device
> +---------------
>
> Well, how would you measure it *without* Lisp?!?
> First tell us that, and then we might have a chance
> of telling you how Lisp could do the same thing.
>
> [Note: Performing physical measurements on the internals
> of one's system is typically a *very* platform-specific
> issue having very little to do with programming languages
> per se and much more to do with what drivers (I2C, ACPI, etc.)
> your platform provides...]
>
> -Rob
>
> -----
> Rob Warnock                     <····@rpw3.org>
> 627 26th Avenue                 <URL:http://rpw3.org/>
> San Mateo, CA 94403             (650)572-2607

Dear sir

i want to access voltage & current value in my Lisp Program.
if you have any idea about it then tell me.
to access value perform operaton on it.
i have plan to ight program for laptop battery.

sandeep
From: John Thingstad
Subject: Re: voltage & current program
Date: 
Message-ID: <op.tqn3ibuspqzri1@pandora.upc.no>
On Thu, 12 Apr 2007 11:26:55 +0200, sandeep patil <·········@gmail.com>  
wrote:

> i have plan to ight program for laptop battery.
(I assume you mean: I have plans to write a program to monitor laptop  
battery status.)

Why? That is already buildt into XP.
You can get a icon that presents battery left.
For other features see the power management interface.
(I assume you are using Xp since almost all linux/unix users seem to  
mention this..)
IE. It is better to use the OS support.

Or just use one of these. Their free
http://www.vicman.net/downloads/dir/Battery-Monitoring-For-Laptop/35744.html

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Rob Warnock
Subject: Re: voltage & current program
Date: 
Message-ID: <u8CdncBkLMNpbYPbnZ2dnUVZ_jydnZ2d@speakeasy.net>
sandeep patil <·········@gmail.com> wrote:
+---------------
| On Apr 11, 12:23 pm, ····@rpw3.org (Rob Warnock) wrote:
| > Well, how would you measure it *without* Lisp?!?
| > First tell us that, and then we might have a chance
| > of telling you how Lisp could do the same thing.
| >
| > [Note: Performing physical measurements on the internals
| > of one's system is typically a *very* platform-specific
| > issue having very little to do with programming languages
| > per se and much more to do with what drivers (I2C, ACPI, etc.)
| > your platform provides...]
| >
| > -Rob
| >
| > -----
| > Rob Warnock                     <····@rpw3.org>
| > 627 26th Avenue                 <URL:http://rpw3.org/>
| > San Mateo, CA 94403             (650)572-2607
| 
| Dear sir
| 
| i want to access voltage & current value in my Lisp Program.
| if you have any idea about it then tell me.
| to access value perform operaton on it.
| i have plan to ight program for laptop battery.
+---------------

You *STILL* haven't answered my question!!! How would you do
it in *any* other programming language of your choice on the
particular operating system and platform you're running on???!?
(...which you haven't told us.) The answer depends *COMPLETELY*
on your operating system and platform!!

For example, once upon a time, I ran CMUCL on a laptop that was
running FreeBSD 2.2.6, and *that* laptop had only APM, not ACPI,
so on *that particular* laptop with *that particular* operating
system, one opened "/dev/apm" and did an "APMIO_GETINFO" ioctl(),
which one could do from within CMUCL as follows [roughly, not tested]:

    (use-package :alien)
    (use-package :c-call)

    (def-alien-type nil
      (struct apm_info
	(ai_infoversion  unsigned-int)
	(ai_major        unsigned-int)
	(ai_minor        unsigned-int)
	(ai_acline       unsigned-int)
	(ai_batt_stat    unsigned-int)
	(ai_batt_life    unsigned-int)
	(ai_batt_time    int)
	(ai_status       unsigned-int)
	(ai_batteries    unsigned-int)
	(ai_capabilities unsigned-int)
	(ai_spare0       unsigned-int)
	(ai_spare1       unsigned-int)
	(ai_spare2       unsigned-int)
	(ai_spare3       unsigned-int)
	(ai_spare4       unsigned-int)
	(ai_spare5       unsigned-int)))

    (defvar *ai* (make-alien '(struct apm_info)))

    (defconstant +APMIO_GETINFO+ #x4040500b)

    (let ((fd (unix:unix-open "/dev/apm" 0 0)))
      (unless fd
	(error ...some useful error message...))
      (multiple-value-bind (result err)
	  (unix:unix-ioctl fd +APMIO_GETINFO+ (alien-sap *ai*))
        (when err
	  (error ...some useful error message...))
        (list (slot *ai* 'ai_acline)
	      (slot *ai* 'ai_batt_life))))

    ==> (0 73)	; If you're running on the battery & it's 73% charged.

But *none* of that would work on the laptop I use today, since
it supports *only* ACPI and not APM at all.

As I said before [twice], how you do this is *VERY* operating
system and platform dependent [and Lisp-implementation-dependent].
Without those details, no-one can help you!!


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Thomas A. Russ
Subject: Re: voltage & current program
Date: 
Message-ID: <ymiabx70xrr.fsf@sevak.isi.edu>
····@rpw3.org (Rob Warnock) writes:

> Pascal Bourguignon  <···@informatimago.com> wrote:
> 
>      V = I * R  (voltage = current * resistance)
> 
> +---------------
> | You can write a function in Common Lisp to solve this equation,
> | known at least two of its variables:
> | 
> | (defun resistor-ohm-law (&key u r i)
> |   (cond
> |      (u  (cond (r (list :i (/ u r)))
> |                (i (list :r (/ u i)))
> |                (t (list :|R(I)| (lambda (i) (/ u i))
> |                         :|I(R)| (lambda (r) (/ u r)))))
> +---------------

I like the idea of returning curried versions of Ohm's law if only one
of the three parameters is specified.

> Yes, this is one place where I really, really like CL's keywords!!
> But I generally write this kind of thing as follows, which feels to
> me to be more perspicuous [though admittedly slightly more redundant
> and thus *slightly* less efficient -- a tradeoff I'm usually willing
> to make]:
> 
>   (defun resistor-ohm-law (&key v r i)
>     (cond
>       ((and v i r)
>        (error "May not specify all three parameters!"))

Actually, at this point, I would evaluate Ohm's law and only signal an
error if it wasn't valid.  As a return value in the valid case, I
suppose that one could use T, although that may make interpreting the
answer a bit trickier.  (One could also return NIL instead of signaling
an error, which would make this useful as a predicate as well)

>       ((and v r) (list :i (/ v r)))
>       ((and v i) (list :r (/ v i)))
>       ((and i r) (list :v (* i r)))
>       (t
>        (error "Must specify at least two parameters!"))))



-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Rob Warnock
Subject: Re: voltage & current program
Date: 
Message-ID: <x6mdnV_upoxmSrjbnZ2dnUVZ_hmtnZ2d@speakeasy.net>
Thomas A. Russ <···@sevak.isi.edu> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) writes:
| >   (defun resistor-ohm-law (&key v r i)
| >     (cond
| >       ((and v i r)
| >        (error "May not specify all three parameters!"))
| 
| Actually, at this point, I would evaluate Ohm's law and only signal
| an error if it wasn't valid.
+---------------

An iteresting idea, except that it violates one of the prime tenets
of dealing with floating-pont numbers, which is *never* to compare
them for exact equality!!  [And if you're not going to use "=", then
you would need an additional :EPSILON keyword to specify the acceptable
error in the comparison, and that's just getting ugly...]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: ············@gmail.com
Subject: Re: voltage & current program
Date: 
Message-ID: <1177012088.508820.194180@l77g2000hsb.googlegroups.com>
On Apr 18, 1:34 am, ····@rpw3.org (Rob Warnock) wrote:
> An iteresting idea, except that it violates one of the prime tenets
> of dealing with floating-pont numbers, which is *never* to compare
> them for exact equality!!

Well... that's not _quite_ true.  IEEE 754 arithmetic is
deterministic; you know the direction of rounding errors and you know
that fl(a) + fl(b) == fl(fl(a) + fl(b)), in which fl(a) is the
floating-point representation of a, and + is a stand-in for +, -, *
or /.  But it _is_ rare that one actually tests for exact equality.

> [And if you're not going to use "=", then
> you would need an additional :EPSILON keyword to specify the acceptable
> error in the comparison, and that's just getting ugly...]

Well, you only need to fix "EPSILON" once and then you compute
relative error for everything.  There's no need to specify a different
EPSILON for each operation.

mfh
From: Rob Warnock
Subject: Re: voltage & current program
Date: 
Message-ID: <IZidnW7eHviy1bXbnZ2dnUVZ_rjinZ2d@speakeasy.net>
············@gmail.com <············@gmail.com> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) wrote:
| > [And if you're not going to use "=", then
| > you would need an additional :EPSILON keyword to specify the acceptable
| > error in the comparison, and that's just getting ugly...]
| 
| Well, you only need to fix "EPSILON" once and then you compute
| relative error for everything.  There's no need to specify a different
| EPSILON for each operation.
+---------------

That statement would have gotten an "F" in my college's
Numerical Methods class. Acceptable relative error *does*
depend on context...


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: ············@gmail.com
Subject: Re: voltage & current program
Date: 
Message-ID: <1177098274.246680.282120@l77g2000hsb.googlegroups.com>
On Apr 19, 9:57 pm, ····@rpw3.org (Rob Warnock) wrote:
> ············@gmail.com <············@gmail.com> wrote:
> | Well, you only need to fix "EPSILON" once and then you compute
> | relative error for everything.  There's no need to specify a different
> | EPSILON for each operation.
> +---------------
>
> That statement would have gotten an "F" in my college's
> Numerical Methods class. Acceptable relative error *does*
> depend on context...

Haha, good point! ;-P  I should have said that the UI would be
improved by making EPSILON a package-scope-global parameter, rather
than specifying it for each operation, as the relative error context
probably changes much less frequently than the number of times that
the Ohm's Law function is invoked.  (EPSILON is a function of e.g. the
number of digits of accuracy in the input data, and the OP probably
wants to do a lot of Ohm's Law calculations over a set of measurements
taken with the same device.)

mfh
From: sandeep patil
Subject: Re: voltage & current program
Date: 
Message-ID: <1176274049.865630.281430@p77g2000hsh.googlegroups.com>
On Apr 10, 1:29 pm, Pascal Bourguignon <····@informatimago.com> wrote:
> "sandeep patil" <·········@gmail.com> writes:
> > can you tell me any function in ohms law & it related program.
> > who i will right program on it.
>
> Ohm's Law, for a resistor, is:
>
>    U = R * I  (voltage = resistance * intensity)
>
> You can write a function in Common Lisp to solve this equation, known
> at least two of its variables:
>
> (defun resistor-ohm-law (&key u r i)
>   (cond
>      (u  (cond (r (list :i (/ u r)))
>                (i (list :r (/ u i)))
>                (t (list :|R(I)| (lambda (i) (/ u i))
>                         :|I(R)| (lambda (r) (/ u r)))))
>
> --
> __Pascal Bourguignon__http://www.informatimago.comhttp://pjb.ogamita.org

dear sir

i want to get real current & voltage value  from my divece power
supply how i will get it value
is it possible in lisp ,your solution is usable but mey i know how i
measure current & voltage follow in my device

regard
sandeep patil
pune