Shop OBEX P1 Docs P2 Docs Learn Events
Math routines — Parallax Forums

Math routines

4x5n4x5n Posts: 745
edited 2011-11-27 19:11 in General Discussion
I'm looking for math routines for the SX processor. I noticed a link in the sticky thread to such a lib but that link is long broken. As I think of it a lot of the links are broken to old SX threads.

Comments

  • wasswass Posts: 151
    edited 2011-11-26 22:34
    Can you be more specific? Are you coding in assembly or SX/B? 8 bit, 16-bit, 32-bit integers or floating point (I doubt it)?
    What operations do you need?

    Here's a good place to start if you're looking for assembly code: http://www.sxlist.com/techref/scenix/lib/math/basic.htm
  • 4x5n4x5n Posts: 745
    edited 2011-11-27 08:00
    wass wrote: »
    Can you be more specific? Are you coding in assembly or SX/B? 8 bit, 16-bit, 32-bit integers or floating point (I doubt it)?
    What operations do you need?

    Here's a good place to start if you're looking for assembly code: http://www.sxlist.com/techref/scenix/lib/math/basic.htm

    Sorry, My initial was made on my phone which made a lot of detail difficult. I'm considering using the SX processor with various sensors and output via lcd. The problem is that the first sensor I looked into using (of course) needs to have the output run through a formula that requires multiplication. For example the temp/humidity sensor sold by Parallax requires multiplication by a fraction and finding the square of a number. For my purposes I could get away with integer multiplication and division. I haven't ruled out some sort of a look up table but haven't worked out a way to do it that I like yet.
  • 4x5n4x5n Posts: 745
    edited 2011-11-27 08:52
    4x5n wrote: »
    Sorry, My initial was made on my phone which made a lot of detail difficult. I'm considering using the SX processor with various sensors and output via lcd. The problem is that the first sensor I looked into using (of course) needs to have the output run through a formula that requires multiplication. For example the temp/humidity sensor sold by Parallax requires multiplication by a fraction and finding the square of a number. For my purposes I could get away with integer multiplication and division. I haven't ruled out some sort of a look up table but haven't worked out a way to do it that I like yet.

    I forgot to mention that my plan is to program in assembly but I'm not adverse to using SX/B.
  • wasswass Posts: 151
    edited 2011-11-27 08:58
    If you plan to use SX/B read the section in this document about scaling sensor outputs http://www.parallax.com/Portals/0/Downloads/docs/prod/sic/3rdPrintSmartSensors-v1.0.pdf and keep in mind that SX/B can only do one math operation per assignment statement, but the logic is the same.
  • LeonLeon Posts: 7,620
    edited 2011-11-27 09:44
    Microchip has plenty of code for maths on the PIC, which could be used.
  • 4x5n4x5n Posts: 745
    edited 2011-11-27 17:24
    I found a number of routines based on code for the basic stamp that will do what I need. It would be nice if the links contained in the best of SX threads and downloads thread worked though. A lot of interesting stuff there!
  • ZootZoot Posts: 2,227
    edited 2011-11-27 19:11
    Here's my library of routines (word integers) that are mostly assembly but designed to be used in an SX/B context. You need to pre-define the variables, then include the sub/func definitions at the top of your SX/B programs and include the "guts" of the routines anywhere in the main program.
Sign In or Register to comment.