Shop OBEX P1 Docs P2 Docs Learn Events
quick question about propforth — Parallax Forums

quick question about propforth

RforbesRforbes Posts: 281
edited 2014-01-27 19:09 in General Discussion
Hey all,
Does propforth incorporate floating point math functionality? Something like the f32 object? I have a project that is math and trig intensive and might like to give it a try with p ropforth.
If it supports it.

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2014-01-23 19:22
    I believe that it does via some add on libraries. Look in the extension directory which has various modules you can load.

    Over in my scara robot arm project I developed fixed point trig and inverse trig functions which is another way to solve the problem

    http://forums.parallax.com/showthread.php/151826-Scara-robot-using-servos-and-hardware-store-components-(Video)
  • RforbesRforbes Posts: 281
    edited 2014-01-24 05:23
    @Martin- Ok, thanks! I haven't even attempted to mess with propforth (or any other forth) yet. I'm trying to get a feel for whether or not it would be a good way to go with regards to faster execution time.


    By the way, I've watched your scara video several times. I love that thing! :)
  • Martin_HMartin_H Posts: 4,051
    edited 2014-01-24 06:51
    Rforbes wrote: »
    By the way, I've watched your scara video several times. I love that thing! :)

    Thanks!

    I really haven't noticed if Propforth is faster than Spin because the gating item for most of my projects is the inertia of the robot. I tend to keep movements slow and controlled to avoid vibrations creeping in. If I added trapezoidal ramping I could speed things up a scooch, but I would still be well below the execution of even the slowest interpreter. The thing I liked about it was it being interpreted which has made certain kinds of projects easier.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-24 10:33
    There is a software float package someplace, I think its on the downloads pages. BUT while the software handles the parts, you still have to write the bits to display the values and or get them in and out of your application.

    AS I understand it, the forth software float is not a whole lot different in execution speed from any other implementation of software float on the prop, but you have to check with the other guys for actual numbers.

    We found that any advantage to using float is negated by the extra support code and execution time.

    Nick Lordi posted code to support a floating point coporcessor, alos on the down loads page or a wiki page. Here again it seems that the advantage of using the coprocessor is negated by the support code and the time it takes to transfer to and from the prop and the coprocessor. It was fine for Nick applications, and might be OK for yours. But Sal finds it quicker and easier to just do the math in scaled integer (or dump it to the PC or RPi and do the crunchy stuff on the workstation).
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-25 06:00
    ANS Forth supports floating point in Forth, and pfth is ANS Forth.

    But the reality is that really fast floating point is always going to be in assembler code. Desktop PC's can run circles around a Propeller if you need a lot of number crunching and feeding the raw data into a spreadsheet may save time. In some cases, an XBee can wirelessly transmit data in real-time to a PC to be processed and handed back to the Propeller to take any action required.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-25 07:00
    ANS Forth supports floating point in Forth, and pfth is ANS Forth.

    But the reality is that really fast floating point is always going to be in assembler code.

    ... running on floating point hardware.

    The propforth floating point package is optimized in assembler. The prop is integer. The float package is only going to be so fast, and not as fast as on float hardware.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-25 07:10
    ANS Forth supports floating point in Forth, and pfth is ANS Forth.
    The floating point words in ANS Forth are optional, and they aren't implemented in pfth. I would suggest using C for a project that requires a lot of floating point math.
  • RforbesRforbes Posts: 281
    edited 2014-01-25 16:55
    Thanks much fellas. I will keep reading about the various forths and try to figure out the best way to speed up the execution times. I'd like to not rely on a pc to do the calcs because I wanna keep it as a stand-alone app. I still haven't tackled any pasm yet so its all written in spin and uses 4 cogs running f32 (which is awesome!) But I will keep at it!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-26 00:05
    Maybe one Propeller as a floating point co-process and another as your Forth machine.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-01-26 08:40
    I thought there was older Propforth code for talking to on of the FP coprocessors...maybe even the one Parallax sels(sold). I'll look when I'm back to my PC!
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-27 19:09
    Rforbes wrote: »
    Thanks much fellas. I will keep reading about the various forths and try to figure out the best way to speed up the execution times. I'd like to not rely on a pc to do the calcs because I wanna keep it as a stand-alone app. I still haven't tackled any pasm yet so its all written in spin and uses 4 cogs running f32 (which is awesome!) But I will keep at it!

    What is it you are calculating? If you can state it as scaled integer, it will be faster and more accurate than float, and you will be smarter for figuring it out. Avoid float unless you have float hardware, unless you just want to prove that you can do it.
Sign In or Register to comment.