Shop OBEX P1 Docs P2 Docs Learn Events
basic math question — Parallax Forums

basic math question

japerjaper Posts: 105
edited 2005-08-31 01:50 in Learn with BlocklyProp
trying to get some help with a math problem in stamp programing

1. if i used v = 2 * (8 / 7 ) would this be a proper format in a truth table would. stamp regognize this as =2.1428
or if i wanted this type of return would i have to use some other type of formula to figure in the remainder.

doing an agument like

if ( v < 2 * (c / b )) and (v > (w / r)) then
pulsout ,out , 5500
else
low out
endif


would this mean anything to stamp.
in typing this type stucture in , it has no effect on the result
this where lies my delima, how to use negative numbers in an argument
not looking to answers this formula just looking for the proper format

thank you

l

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-30 22:40
    You can use negative numbers in everything EXCEPT division.

    Are the arguments in your formula (c, b, w, r) actually variables?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • japerjaper Posts: 105
    edited 2005-08-30 22:54
    no these were just examples of numbers.
    let me give a a better example.

    if (v < 2 *( 8 / 6)) and ( v > (9 / 6)) then

    jasper
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-30 23:05
    If I'm not mistaken, your formula resolves to:

    · IF (v < 2.67) AND (v > 1.5) THEN
    ··· ...
    · ENDIF

    You could multiply everything by 10 (including "v") and do it like this:

    · IF (v < 27) AND (v > 15) THEN
    ··· ...
    · ENDIF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • japerjaper Posts: 105
    edited 2005-08-30 23:32
    so if "v" was a voltage return ,the example would be understood as 27 = 2.67

    hopefully ?

    jasper
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 00:28
    The BASIC Stamp doesn't do floating point values, so you can multiply them to integers as suited. If your input voltage is going to be less than 6.5535 volts then you could multiply by 100 to get 100ths resolution. Then you could use IF (volts > 267) THEN to handle the logic.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • japerjaper Posts: 105
    edited 2005-08-31 00:44
    wow i just about posted something totally different . man i am an idot.
    i just realized what you were saying. "no decimal points. " i simply should use the decimal number.
    that would give all the tolerance i could posibly need in a 8 bit system
    thanks a lot Jon for sticking with my dumb #$% until i got it.
    i can simply use the analog voltage reading as UI.
    on to the next chapter.

    jasper
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 01:02
    Your "next chapter" really should be out book, "What's A Microcontroller?" -- give it a week, and it'll give you a lifetime of solid BASIC Stamp programming skills.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • japerjaper Posts: 105
    edited 2005-08-31 01:50
    What's a MicroController?
    yea just finished it a coulpe weeks ago had to go on vacation so i couldnt get on the next course here,
    until last week.
    i espeaciallly am proud of my course project in microControler.
    it's sad that the project board did nt have a diode in it?
    buy pushing different combination of buttons, photoresitor,and Pot sensor inputs, it could:
    ramp up in steps ,a small 5 v hardrive fan. you now 25 50 75 100 yea the trick was start at 25 pwm , a quick pop to get
    the fan going, then hold fan at 10 count at 100 %
    flashing LEDS and rampup's "
    my speaker was playing tequila
    sevro was trick, photoresistor and combinaton turn pot move that made it change direction,
    with the push of a button a light reading was taken and displayed on the led.
    trying to make a autoHVAC till i found out the stamp could only do one thing at a time.
    but with a 555 timer in this new kit and the programing skills in analog _digita l could make an autoHVAC
    just an idea

    note:
    i especially like the sleep command in your code book.


    yea again
    over thinging the math "easy"
Sign In or Register to comment.