Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 46 to 60 of 99

Thread: Math problem I'm too stupid to solve

  1. #46
    Join Date
    11th January 2009 - 09:11
    Bike
    BMW R1200GS (2010)
    Location
    Hibiscus Coast, AUCKLAND
    Posts
    464
    Quote Originally Posted by McJim View Post
    Dude has a value within a range. Wants to express the equivalent value within a different range.

    Dead easy.

    Example for those not farting around with hexadecimal shit and stuff. A year has 365 days, 52 weeks and 13 lunar months.
    Lets pick day 200 out of 356
    It is also week 28.49 out of 52
    And it is also month 7.12 out of 13

    Piece of piss
    You are right, the math/maths itself is actually really simple. Where it gets slightly complicated though is that one of the ranges is -150 to +150. It's easy to think that is a range of 300, when in fact it is a range of 301. This yields the "off by one" error that has been well covered above. That's where knowing how stuff it represent by the machine can be useful.
    The chances of anything coming from Mars are a million to one, he said.

  2. #47
    Join Date
    11th January 2009 - 09:11
    Bike
    BMW R1200GS (2010)
    Location
    Hibiscus Coast, AUCKLAND
    Posts
    464
    Quote Originally Posted by Winter View Post
    Isn't anyone going to ask me what its for?
    No. Everyone got confused when you starting alluding to mV, loadcells, and the like. :-)

    Go on, what's it for.
    The chances of anything coming from Mars are a million to one, he said.

  3. #48
    Join Date
    23rd March 2007 - 10:24
    Bike
    Black something
    Location
    Auckland
    Posts
    491
    Quote Originally Posted by paddy View Post
    No. Everyone got confused when you starting alluding to mV, loadcells, and the like. :-)

    Go on, what's it for.
    teehee.

    I have LPG hot water, from two 45kg lpg bottles.

    I've built a system that continuously weighs each bottle, works out when its empty, and rings the gas company for a new one when its run out

    No more cold showers from forgetting to order more LPG for me!


    Patent pending!
    "And, look, the luscious and fecund fronds of the Silver Fern has given brilliant birth to a stupendous fruit! A red Hondaberry, desposited by a lesser known species of Plonker Gittus Maximus Idiotus."

  4. #49
    Join Date
    17th April 2009 - 14:06
    Bike
    GN250 2005
    Location
    Hamilton
    Posts
    104
    Blog Entries
    6
    very nice work.
    if you are ordering the new bottle before one is completely empty (rather than empty) your slightly off numbers are still more than close enough to make this work.

    though if I come along and put a weight on your bottle your getting a cold shower, that counts for any other foreign material getting onto the scales.
    "I know your about to do something apocalyptically evil but hey, still want to hang"

  5. #50
    Join Date
    7th April 2009 - 19:32
    Bike
    VFR400 NC30 "Silver Surfer"
    Location
    Mt Eden, Auckland
    Posts
    959
    Normally you'd have an instrumentation amplifier on the strain gauge, especially seeing as they are a differential output that can be really sensitive to input impedances... The ADAM modules look ok, I've never used them though (Always used Moxa modules instead).

    If the output from the ADC is a 16bit value from -32767 to +32768 (assuming twos complement and that you're ignoring negatives) then that will map directly to the -150 to +150mv. This means the output of the ADC will be 218.45 * input value in mv. If your input is 2mv/V at 15V then that will be 30mV in per 100kg, so 300uV per kg, or 65.53 per kg.

    Take input as integer, multiply it by 15.26 and that'll give you it in grams...

  6. #51
    Join Date
    23rd March 2007 - 10:24
    Bike
    Black something
    Location
    Auckland
    Posts
    491
    Quote Originally Posted by Zerker View Post
    very nice work.
    if you are ordering the new bottle before one is completely empty (rather than empty) your slightly off numbers are still more than close enough to make this work.

    though if I come along and put a weight on your bottle your getting a cold shower, that counts for any other foreign material getting onto the scales.
    Sort of - as the gas regulator system allows one bottle to be empty, I can wait for the first bottle to stop decreasing, IE hit its empty weight.
    if it doesn't decrease over say, three days, but the other one does, then its safe to assume its empty & order a new one.
    "And, look, the luscious and fecund fronds of the Silver Fern has given brilliant birth to a stupendous fruit! A red Hondaberry, desposited by a lesser known species of Plonker Gittus Maximus Idiotus."

  7. #52
    Join Date
    23rd March 2007 - 10:24
    Bike
    Black something
    Location
    Auckland
    Posts
    491
    Quote Originally Posted by jono035 View Post
    Normally you'd have an instrumentation amplifier on the strain gauge, especially seeing as they are a differential output that can be really sensitive to input impedances... The ADAM modules look ok, I've never used them though (Always used Moxa modules instead).

    If the output from the ADC is a 16bit value from -32767 to +32768 (assuming twos complement and that you're ignoring negatives) then that will map directly to the -150 to +150mv. This means the output of the ADC will be 218.45 * input value in mv. If your input is 2mv/V at 15V then that will be 30mV in per 100kg, so 300uV per kg, or 65.53 per kg.

    Take input as integer, multiply it by 15.26 and that'll give you it in grams...
    output from ADC = 16bit Unsigned Int.

    an amplifier would be nice, but they sound expensive, like everything else.
    "And, look, the luscious and fecund fronds of the Silver Fern has given brilliant birth to a stupendous fruit! A red Hondaberry, desposited by a lesser known species of Plonker Gittus Maximus Idiotus."

  8. #53
    Join Date
    7th April 2009 - 19:32
    Bike
    VFR400 NC30 "Silver Surfer"
    Location
    Mt Eden, Auckland
    Posts
    959
    Quote Originally Posted by Winter View Post
    output from ADC = 16bit Unsigned Int.

    an amplifier would be nice, but they sound expensive, like everything else.
    Well if it is a 16 bit unsigned int that maps directly to the range then that is a little odd... Either way, in that case just shift the zero point to 32768... so take your integer, subtract 32768, multiply by 15.26 to get grams.

  9. #54
    Join Date
    19th September 2006 - 22:02
    Bike
    02 Ducati ST4s
    Location
    Here there everywhere
    Posts
    5,458

  10. #55
    Join Date
    7th April 2009 - 19:32
    Bike
    VFR400 NC30 "Silver Surfer"
    Location
    Mt Eden, Auckland
    Posts
    959
    Quote Originally Posted by Winter View Post
    Sort of - as the gas regulator system allows one bottle to be empty, I can wait for the first bottle to stop decreasing, IE hit its empty weight.
    if it doesn't decrease over say, three days, but the other one does, then its safe to assume its empty & order a new one.
    yeah, be careful about that... Is it flagging a warning or actually sending an e-mail to make the order? You might find that if something goes wrong (load cell stops giving output, wire corrodes off, power supply dies etc.) then a rate of change detection will trigger...

    Absolute value would be the way that I would do it with it e-mailing you in such a way as to be a reminder rather than an automated system... You can do some basic low pass filtering on the results easily enough too (measure values once per second, sum them every minute and divide by 60 to give you 1 update per minute that attenuates any changes that occur faster than over a 30s or so timeframe).

    If your thing can e-mail you or raise a warning or whatever if the output drops below a certain amount too (no input at all) then that could be useful. May require some filtering as well to not trigger on a bottle change (unless you have a bottle cradle heavy enough to be measured).

    If the system is switching between bottles when the pressure drops then that would be why it waits until one is pretty much empty... The pressure should be constant with temperature until the bottle is empty (ignoring the outgoing rate of the gas etc.).

  11. #56
    Join Date
    7th April 2009 - 19:32
    Bike
    VFR400 NC30 "Silver Surfer"
    Location
    Mt Eden, Auckland
    Posts
    959
    Quote Originally Posted by paddy View Post
    You are right, the math/maths itself is actually really simple. Where it gets slightly complicated though is that one of the ranges is -150 to +150. It's easy to think that is a range of 300, when in fact it is a range of 301. This yields the "off by one" error that has been well covered above. That's where knowing how stuff it represent by the machine can be useful.
    Yeah, for most programming stuff you're dead on, but things get a little bit muddier when you're dealing with the conversion of real world analogue values to digital values. A value of zero will correspond to -150mV, a value of 65535 will correspond to 150mV, therefore it is 65536/300 for the scaling factor. When dealing with integers 150 can mean anywhere between 150.49 and 149.5 but when you're dealing with ADC inputs then you're actually talking about # of divisions between reference voltages.

  12. #57
    Join Date
    5th August 2005 - 14:30
    Bike
    Various
    Location
    Auckland
    Posts
    4,359
    Quote Originally Posted by McJim View Post
    Dude has a value within a range. Wants to express the equivalent value within a different range.

    Dead easy.

    Example for those not farting around with hexadecimal shit and stuff. A year has 365 days, 52 weeks and 13 lunar months.
    Lets pick day 200 out of 356
    It is also week 28.49 out of 52
    And it is also month 7.12 out of 13

    Piece of piss
    In keeping with the general theme of this thread, what happened to the other 13 days?
    And just for the hell of it let's run with calandar months.
    Quote Originally Posted by Tank
    You say "no one wants to fuck with some large bloke on a really angry sounding bike" but the truth of the matter is that you are a balding middle-aged ice-cream seller from Edgecume who wears a hello kitty t-shirt (in your profile pic) and your angry sounding bike is a fucken hyoshit - not some big assed harley with a human skull on the front.

  13. #58
    Join Date
    11th January 2009 - 09:11
    Bike
    BMW R1200GS (2010)
    Location
    Hibiscus Coast, AUCKLAND
    Posts
    464
    Quote Originally Posted by jono035 View Post
    Yeah, for most programming stuff you're dead on, but things get a little bit muddier when you're dealing with the conversion of real world analogue values to digital values. A value of zero will correspond to -150mV, a value of 65535 will correspond to 150mV, therefore it is 65536/300 for the scaling factor. When dealing with integers 150 can mean anywhere between 150.49 and 149.5 but when you're dealing with ADC inputs then you're actually talking about # of divisions between reference voltages.
    Okay now you got me a bit confused, and without seeming adversarial I have a few thoughts/questions. In terms of the "# of divisions" surely that is just about how many SFs you run the conversion to. In terms of you stating the scale as 300, what does a 0mV output from the loadcell represent (and before anyone jumps in with the obvious joke - it's turned off - it's a serious question).
    The chances of anything coming from Mars are a million to one, he said.

  14. #59
    Join Date
    11th January 2009 - 09:11
    Bike
    BMW R1200GS (2010)
    Location
    Hibiscus Coast, AUCKLAND
    Posts
    464
    Quote Originally Posted by NighthawkNZ View Post
    Forty two....
    It took a while. But somebody got there. :-) LoL.
    The chances of anything coming from Mars are a million to one, he said.

  15. #60
    Join Date
    7th April 2009 - 19:32
    Bike
    VFR400 NC30 "Silver Surfer"
    Location
    Mt Eden, Auckland
    Posts
    959
    Quote Originally Posted by paddy View Post
    Okay now you got me a bit confused, and without seeming adversarial I have a few thoughts/questions. In terms of the "# of divisions" surely that is just about how many SFs you run the conversion to. In terms of you stating the scale as 300, what does a 0mV output from the loadcell represent (and before anyone jumps in with the obvious joke - it's turned off - it's a serious question).
    Sure thing, ask away!

    I'm not really sure what you mean by "how many SF's you run the conversion to". In terms of the ADC itself, the number of divisions comment was meant to say that a 16 bit input ADC will spit out a number between 0 and 65535 which corresponds to what the input voltage is relative to the reference voltage.

    If the input range is 0-1V then 0V in will be 0. 1V in will be 65535. Everything else will be scaled accordingly (0.5V being 32768 for instance). To get a number in your program that refers to the actual voltage being measured then you would divide the ADC output by 65535 in this case to get the measurement. 0-1V doesn't mean there are 1001 counts or anything like that, it isn't integer mathematics.

    Don't worry about getting anything exactly right, there is no way that those modules will be good for all 16 bits of precision. Noise will eat away a pretty massive chunk of that precision, especially when your reference levels are 150mV. To change the ADC output value by 1, the input would have to be accurate to 4.6uV.

    Not entirely sure if that answers your question?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •