Parallax Propeller your COGS ruined me!
Oldbitcollector (Jeff)
Posts: 8,091
I've been working to get that new Micromite Companion project up and running, (a combination of Propeller and PIC32 running BASIC) so naturally I've started working on programming examples in BASIC. I start by writing a simple program to read the I2C Wii Nunchuck controller. (Around 10 lines of code, so simple!), then I thought it would be cool to jump out of the loop on the press of a button and start an LED flashing at a contrable rate. Heck, in spin I'd just assign this job to another COG, set and forget it. Except... PIC32's don't have 7 more cogs to play with..
I did manage to get it working fine, but my simple 10 line program turned into ten more lines to do the job... Parallax, I've become ruined and spoiled by having so many cogs!! What have you done to me?
I have however gained a new respect for the magic that people seem to acomplish with that "other" single cog micro.
Jeff
I did manage to get it working fine, but my simple 10 line program turned into ten more lines to do the job... Parallax, I've become ruined and spoiled by having so many cogs!! What have you done to me?
I have however gained a new respect for the magic that people seem to acomplish with that "other" single cog micro.
Jeff
Comments
Propeller is for everyone, but they just don't know it yet.
Yes..... thinking leads to complex hacks to simulate multi-tasking, which leads to code that resembles a pyramid standing on it's point. Something that is miraculous in that it works all and something that tinkering with even a little can push the whole thing over.
Blinking an LED should be simple and having a cog available to do it keeps it simple.
But of course if you need to blink more than 8 LEDs at different rates, you again need to visit that hack that simulates mult-tasking.
I say get familiar with multitasking, understand it, and use it when appropriate or when you're out of cogs.
Cheers,
Peter (pjv)
NOBODY needs to blink more than 8 LEDs! NOBODY!
"Laziness is a virtue." -Linus Torvalds
-Phil
Absolutely. The microcontroller is there to make our lives easier including easier to program. I don't care if it's "lazy programming", The Propeller is there to get a job done and the less time it takes to get the job done the better.
I tried coding with Picaxe, the Basic Stamp, and the BS2, I just don't get it.. I too, have been ruined spoiled by the COG...
The unique aspect of the Propeller has always been that it kept multi-processing simple-ish, and therefore solved the most common issues you have to dance around in other micros. I need to constantly do B and C right on time while I occasionally need to do lengthy process A. Prop makes this a simple thing to deal with and I don't program like it's a brain teaser or to exercise.... I just want to get something working.
1) We have processors that are millions of times faster, have millions of times more memory and are millions of times cheaper than they were when I first ever wrote a program. And somebody is going to tell me that my program is 10 times too big or 10 times to slow. That I'm lazy. That I should spend hours optimizing every instruction sequence and reusing every possible RAM location. Really? I'm not listening. I'm already working on the next project.
2) Often being lazy involves a lot of work. For example:
You have written a program that has to do a lot of searching for stuff. The smallest simplest code to do that might just be a loop that traverses an array looking for what you want. Fine, it works. If it's a bit slow, because the array is a bit long. You can spend as much time as you like rewriting that in assembler and optimizing every instruction. It may get you a speed up of two or four times, big deal. Or you can be lazy, keep your code in a HLL, use more code and perhaps more memory, but take the time to implement a better algorithm, say a binary search or a hash table. BOOM! Your "lazy" code is now taking time proportional to log N or N (Where N is the size of the data set). That can speed things up by tens or thousands of times compared to you micro-optimization hard work. After that tweaking around with assembler instructions seems rather pointless.
As a concrete example: I wrote an FFT for the Propeller. It is hundreds of times faster than doing spectral analysis the naive way. Turns out the PASM version of it is not much faster than the C version! As a bonus the C version can be simply recompiled compiled to use 2 or 4 COGS for a bit of a boost.
I'm not saying "be lazy" really. I'm not saying dropping to assembler or tweaking around with it is never required. I'm not saying one should not keep an eye out for inefficiency and bloat. It's just that I often hear this talk of "lazy programmers" and "bloated software" from people who think that all that micro-optimizing is the only way to go.
I tend to think my code while I'm writing. I should probably sit down beforehand and create a "master plan". Then once I have the concept working, then I go back through the code to adjust, refine, and write smarter, faster code.
Lazy? Not sure. There's probably another word for it.
Jeff
I'd never write a program otherwise. I used to fail miserably in college when required to present a design up-front (which is partly why I don't code for a living). I never see the whole picture until I'm into the details. So most often I end up with something much different than I thought I would have when I started.
addictive! I can not stop programming! The multiple Cogs are a great!
I am wondering, though, abou the DEO - nano cyclone FPGA.(?) Could that be programmed to have
multiple MPUs? If so, that would open up an infinity power of programming! Have not had a chance to dive
into it yet................
-Phil
I felt so dang virtuous due to my laziness that I just had to share!
-Phil
We had a few more than eight (channels) in this dude!
It's getting some well deserved Reddit love today too..
http://www.reddit.com/r/gaming/comments/2f9w8g/not_a_huge_lol_fan_but_this_statue_from_pax_prime/
(Looks down and kicks pebbles)..... shut up.
That's impressive!