William,
I sincerely apologize to you and to this forum.
Best regards
Chad
On 11/2/2015 10:34 AM, William Hermans wrote:
Anyway Chad, it is not my responsibility to teach basic C skills. So
hopefully your Students were taught to understand why something like
this would / could fail. And how to figure out why. Honestly though.
Any 6 year old with a browser + know how to use google could figure
this out in 2 minutes.
On Mon, Nov 2, 2015 at 9:00 AM, William Hermans <[email protected]
<mailto:[email protected]>> wrote:
#include <stdio.h>
int main(void)
{
const float max_val = 4096;
float test = ((4024 / max_val) * 1.8);
printf("%f\n", test);
return 0;
}
$ gcc test.c -Wall -o test
$ ./test
1.768359
On Mon, Nov 2, 2015 at 8:59 AM, William Hermans <[email protected]
<mailto:[email protected]>> wrote:
Anyway, since you do not seem to know why that does not work.
Math on two integer values can not give out a float value.
This is not a math problem, but a compiler behavior issue.
Intentional or no, one value in the equation brackets *has* to
be forced to a float value as such.
1) ((4024 / 4096.0) * 1.8)
*OR*
2) const float max_value = 4096; ((4024 / max_value) * 1.8)
It's also why I suggested using a const above.
On Mon, Nov 2, 2015 at 8:16 AM, William Hermans
<[email protected] <mailto:[email protected]>> wrote:
really now. Prey tell, enlighten us then with your logic.
On Mon, Nov 2, 2015 at 5:10 AM, Chad Baker
<[email protected] <mailto:[email protected]>> wrote:
No, I don't, but having taught programming for over 40
years, I know that students would take your equation
and plug it in and then be surprised that they get 0
for an answer.
On 11/1/2015 6:13 PM, William Hermans wrote:
/Or 4024 * 1.8 / 4096?/
Ok, so let us put this another way. Do you think that
is clear when written in code ? What if 1.8 were
actually assigned to a constant pointer ?
On Sat, Oct 31, 2015 at 5:01 AM, Chad Baker
<[email protected] <mailto:[email protected]>> wrote:
Or 4024 * 1.8 / 4096?
On 10/30/2015 12:18 PM, William Hermans wrote:
By the way, the ADC gives out a value of 0-4095.
So scaling voltage is really simple. Say you get
a value of 4024 for a reading. In order to get a
reading from 0-1.8v from this . . .
((4024 / 4096) * 1.8) or 1.768359375v
The max voltage on the pins still can not exceed
1.8v, this is why one needs an opamp, or similar
device to keep the input scaled down. But, in
this manner you could even track large voltages.
Hundreds or even thousands of volts, at the cost
of resolution. Which unfortunately can not be
avoided. So going by the above example . . .
((4024 / 4096) * 300) or 294.7265625v
Does this make sense ?
On Fri, Oct 30, 2015 at 9:59 AM, William Hermans
<[email protected] <mailto:[email protected]>>
wrote:
/BBB and Linux are new to me. One of
the things I would like to do is compute
a ratio between two voltages, each of
which might exceed 1.8 VDC. One
solution might be to use DACs to sent
feedback voltages to operational
amplifiers that are supplied by 1.8
VDC. The goal is to determine the ratio
as quickly as possible and without
waiting for Linux to get around to it
(waiting for the ADC to happen)./
What sample rate do you need ? If something
around only a few thousand samples a second.
This can be done from userspace without
using the PRU's. You can even use mmap()
with /dev/mem/ and directly manipulate the
ADC's registers, which can sample the ADC
faster than 200ksps. However, the sample
rate would not be as deterministic as using
the PRU's.
You can use a PRU to read the ADC's for
sure. If you search the web for Beaglebone
PRU + ADC
, you will find many ways. People have been
doing this for a long time( since the
beaglebone white ), and if you search this
google group, you'll even find full code for
something someone called "ADCcollector".
It's C, and PASM assembly, but is a very
short / easy read / understanding.
As for how to physically connect to the ADC,
I'd listen to evilwulfile. He's been an EE
for longer than many people on this group
have been alive, and he knows his stuff ( I
know him personally ). Don't risk burning up
your board, as I've seen several people on
these groups do . . .
On Fri, Oct 30, 2015 at 9:43 AM, TJF
<[email protected]
<mailto:[email protected]>> wrote:
Hi John!
As Przemek mentioned, a simple voltage
divider can scale the input voltage.
Additionaly I use a LED (orange color)
between the ADC input and ground in
order to block overvoltage. (The LED
starts to light up at 1V5 and consumes
full power at 1V8. 1 / 6 of the ADC
resolution get lost (is less accurate),
but the burning LED as indicatior is a
nice side effect.)
Regarding software you should have a
look at libpruio
<http://hackaday.com/2015/02/16/library-upgrade-to-pru-gives-fast-io-on-beaglebone/#comments>.
BR
--
For more options, visit
http://beagleboard.org/discuss
---
You received this message because you
are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop
receiving emails from it, send an email
to
[email protected]
<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout.
--
For more options, visit
http://beagleboard.org/discuss
---
You received this message because you are
subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop
receiving emails from it, send an email to
[email protected]
<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout.
--
Chad Baker Memphis, TN
--
For more options, visit
http://beagleboard.org/discuss
---
You received this message because you are
subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving
emails from it, send an email to
[email protected]
<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed
to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving
emails from it, send an email to
[email protected]
<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout.
--
Chad Baker Memphis, TN
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed
to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving
emails from it, send an email to
[email protected]
<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google
Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
Chad Baker Memphis, TN
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.