Shop OBEX P1 Docs P2 Docs Learn Events
Micromega uM-FPU Coprocessor output question — Parallax Forums

Micromega uM-FPU Coprocessor output question

LeeWLeeW Posts: 14
edited 2009-12-22 18:27 in BASIC Stamp
Hello All,

I have a question about the way my Micromega uM-FPU Coprocessor is outputting / calculating values. I am trying to do the Log (base 10) of a number, but the issue is only numbers under 100 are calculated correctly. Anything above 100 is output as **.*****· (my format is 85) with the exception of the number 300. When 300 is calculated it outputs the same value as the Log of 44 which is·1.64345. I've been reading through the manual over and over and I'm sort of stumped as to what to do to correct this problem. I'll post the code·that I wrote to use with the sample umfpu-spi.bs2 program that is provided.

" DO
· DEBUG CR, "Enter a number: "
· SERIN 16,84,[noparse][[/noparse]DEC CalcLog]
· SHIFTOUT FpuOut, FpuClk, MSBFIRST, [noparse][[/noparse]LogNum, LONGBYTE, CalcLog, LOG10]
· SHIFTOUT FpuOut, FpuClk, MSBFIRST, [noparse][[/noparse]LogNum]
· format = 85·············································· ' Determines how many values are shown; Tens digit stands for the total #
······························································· ' of variables to display, ones digit stands for the amount of decimal
······························································· ' places that are to be displayed. As an example, 51 stands for (5) total
· GOSUB Print_FloatFormat·····························' characters displayed, with (1) decimal place
· LOOP
· END "

If anyone has any ideas I'd be appreciative of a response..

·

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-12-22 16:36
    You don't have your variables defined. That program probably would not even compile. Could you attach the real code you are running on the stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-12-22 17:42
    "84" is not the correct baud-rate selector -- so it looks like you're sending the FpuOut gibberish.
    Try adding a line SEROUT 16, 16864, [noparse][[/noparse]"Your number is: ", DEC CalcLog, CR]
    and see what the number the program is trying to use actually is.
  • LeeWLeeW Posts: 14
    edited 2009-12-22 18:27
    Hey Allan, I assume the number you meant was 16468... I tried it and it does the same exact thing as if I was using 84 as the baud rate selector. I still have the issue with the calculation not working correctly for anything over 100.

    I'm wondering if it has anything to do with the way the number is converted into a float?
Sign In or Register to comment.