Shop OBEX P1 Docs P2 Docs Learn Events
CORDIC BUGZ - A Demo of P2's Cordic Engine — Parallax Forums

CORDIC BUGZ - A Demo of P2's Cordic Engine

ozpropdevozpropdev Posts: 2,793
edited 2014-03-22 06:24 in Propeller 2
Hi All,

Sorry to alarm you guys with my use of the B word....
Edit: Modified Title to minimize panic!

This program is a demo of the P2's Cordic engine.
A collection of bugs follow a simple rule:
"If something gets in your way, TURN" .

The code uses the QARCTAN and QSINCOS instructions to calculate
bug trajectory and special awareness of screen edges and other bugs.
The FRAC instruction is also used as a handy way of converting angles to
the 32 bit format required by the Cordic engine.

Their a 3 versions, 1 for Nano boards and 2 for the DE2 boards.
The DE2 versions have more bugs and increased screen resolutions.

Output is VGA 800x600 16 Color and runs in 1 Cog.
FPGA core is current 29th Jan 2014 build.

The bug graphics are quite simplistic (Graphics is not my strong point), but
the characters also use the cordic to rotate and plot outlines.

Just a bit of fun :lol: and Happy New Year everyone! :)
Brian

Latest version here
1024 x 613 - 41K

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2013-12-30 22:26
    <recovering from heart failure..>

    Thanks - I will take a look later when heart rate lowers ;)
  • jmgjmg Posts: 15,175
    edited 2013-12-30 22:38
    ozpropdev wrote: »
    ...
    A collection of bugs follow a simple rule:

    hehe - clever .... but shouldn't bugs have 6 legs ?
  • ozpropdevozpropdev Posts: 2,793
    edited 2013-12-30 23:31
    jmg wrote: »
    hehe - clever .... but shouldn't bugs have 6 legs ?

    These are custom low power bugs, only 4 legs are required! :lol:
  • cgraceycgracey Posts: 14,206
    edited 2013-12-31 01:35
    You about gave me a heart attack, too. I had just been on the RadioShack site digging past all the Arduino's to see how Parallax's products were being represented. A lot of them had one or two stars (out of five), with reviews stating, "didn't work", "no manual", "Trust me. Don't buy this." I think, in a lot of cases, they just didn't understand the product. Maybe the Arduino will afford them success.

    Anyway, I downloaded your files and modified the DE2-115 version to work with my latest Prop2/PNut combo, but I can't get it to work. I haven't spent a lot of time on it, but I did make a lot of necessary changes to instruction names and branch syntax (@ instead of # for DJNZ, etc). I want to see this work, so I'll look more into it soon. Right now, I'm trying to get my head around the cache lines after having taken what turned out to be a whole week's break from working. I'm fatter and duller than I was before, so it's yet difficult.
  • ozpropdevozpropdev Posts: 2,793
    edited 2013-12-31 02:04
    cgracey wrote: »
    You about gave me a heart attack, too.

    Sorry Chip, Maybe I should have called them BUGZ or CRICKETS! :)
    Anyway, I downloaded your files and modified the DE2-115 version to work with my latest Prop2/PNut combo, but I can't get it to work. I haven't spent a lot of time on it, but I did make a lot of necessary changes to instruction names and branch syntax (@ instead of # for DJNZ, etc). I want to see this work, so I'll look more into it soon.

    Hopefully it's not too much work to get it going :)
  • BaggersBaggers Posts: 3,019
    edited 2013-12-31 02:35
    I really need to get my kit up and running soon :) I'm missing out on all the P2 fun, especially with having some spare time over the holidays!

    Looks good ozpropdev :) keep up the great work!
  • SeairthSeairth Posts: 2,474
    edited 2013-12-31 08:10
    While I wait for the DE0-Nano breakout board, I'll have to be content with just reading over the code. To that end, I like the snippet loader. I'm guessing this this will become obsolete, however, due to the hub-execution mode.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-12-31 08:18
    I'm waiting for the big update I assume will come from Chip soon including the "execute from hub" feature as well as all of the instruction set changes that go with it.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-12-31 17:19
    cgracey wrote: »
    You about gave me a heart attack, too. I had just been on the RadioShack site digging past all the Arduino's to see how Parallax's products were being represented. A lot of them had one or two stars (out of five), with reviews stating, "didn't work", "no manual", "Trust me. Don't buy this." I think, in a lot of cases, they just didn't understand the product. Maybe the Arduino will afford them success.

    Anyway, I downloaded your files and modified the DE2-115 version to work with my latest Prop2/PNut combo, but I can't get it to work. I haven't spent a lot of time on it, but I did make a lot of necessary changes to instruction names and branch syntax (@ instead of # for DJNZ, etc). I want to see this work, so I'll look more into it soon. Right now, I'm trying to get my head around the cache lines after having taken what turned out to be a whole week's break from working. I'm fatter and duller than I was before, so it's yet difficult.
    Chip, the break has been well-earned. You will come back much fresher, and with new perspectives on the whole thing, who knows what you will come up with! ;)
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-01-26 20:59
    Hi All

    Here is an updated version of CORDIC Bugz for the DE2-115 FPGA (Build 26 Jan 2014).
    Code is no longer supported on DE0-Nano, as it needs math and 240k hub for video (sorry guys :( )
    This version has more bugz and double screen width.

    Cheers
    Brian
  • nutsonnutson Posts: 242
    edited 2014-01-26 22:50
    Works fine for me, althuogh I see some irregular flickering (1-2 Hz) on the left and right vertical field delimiter lines

    Edit: just tried on another monitor, rock steady picture! Some of the demo's work fine on monitor 1 (balls) and some on monitor 2 (bugz).
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-01-26 23:08
    nutson wrote: »
    Works fine for me, althuogh I see some irregular flickering (1-2 Hz) on the left and right vertical field delimiter lines

    Try changing the "SCHEDULE" register to %%100 from %%10 and in the VGA driver add a NOP or two after the RDWIDE instruction.
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-01-26 23:21
    Brian,
    Would you be able to post a short video clip of your demo please (for those of us without the DE2)?
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-01-27 00:10
    Hi Ray
    Here's a short video of the "BUGZ" in action.
    Apologies for my shaky hand and quality of production. (No Oscar nomination here) :lol:
    Cheers
    Brian
  • ctwardellctwardell Posts: 1,716
    edited 2014-01-27 00:41
    That is very cool.

    P2 Fish Tank! is next...

    C.W.
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-01-27 01:25
    Thanks Brian - nice job!
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-01-28 19:12
    Hi All

    Here is the latest version of CORDIC Bugz.
    It has been converted to HUB Execution mode and the latest FPGA Build (28th Jan 2014)

    The conversion from code snippet loading to hub exec mode was a lot easier than I expected. Well done Chip! :)

    Code uses 2 cogs now and has more bugz..

    Cheers
    Brian
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-28 19:32
    It worked for me. Looks good!
  • SapiehaSapieha Posts: 2,964
    edited 2014-01-28 20:10
    Hi ozpropdev.

    Very clean and nice code.
    Shows HUBEXEC's possibilitys and power.

    Only thing I changed.
                 orgh    $E00/4    'Use F11 in PNut to run
    
    

    That shows me more logicaly what place that code Starts


    ozpropdev wrote: »
    Hi All

    Here is the latest version of CORDIC Bugz.
    It has been converted to HUB Execution mode and the latest FPGA Build (28th Jan 2014)

    The conversion from code snippet loading to hub exec mode was a lot easier than I expected. Well done Chip! :)

    Code uses 2 cogs now and has more bugz..

    Cheers
    Brian
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-01-29 01:01
    Sapieha wrote: »
    Hi ozpropdev.

    Very clean and nice code.
    Shows HUBEXEC's possibilitys and power.

    Only thing I changed.
                 orgh    $E00/4    'Use F11 in PNut to run
    
    

    That shows me more logicaly what place that code Starts

    Thanks Sapieha
    I agree it is a bit confusing, maybe we need a simple directive like ORGR or ORGB (Hub ram base address $380 ($E00/4))

    Cheers
    Brian
  • SapiehaSapieha Posts: 2,964
    edited 2014-01-29 01:36
    Hi ozpropdev.

    One of thet You propose
    > directive like ORGR or ORGB (Hub ram base address $380 ($E00/4))
    ---> BUT that onit first filing of 0000000 in BIN file (BIN file starts with first address thta are present in ORGB-ase



    ozpropdev wrote: »
    Thanks Sapieha
    I agree it is a bit confusing, maybe we need a simple directive like ORGR or ORGB (Hub ram base address $380 ($E00/4))

    Cheers
    Brian
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-02-05 20:19
    Hi All

    I tweaked CORDIC Bugz a bit to get more bugz(64), screen colors, resolution(800x600) and speed.
    Run under 28th Jan DE2-115 FPGA build.

    KEY3 restarts bugz
    SW0 pauses bugz.

    Try increasing number of bugz to say 120 and watch them squeeze into every space! :lol:

    Cheers
    Brian
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-03-22 06:24
    Here's the latest CORDIC BUGZ for the F{GA release (20th March 2014)
    A few more tweaks for better performance. :)
Sign In or Register to comment.