OK, I have to admit I had some very bad weeks at work. Besides doing my usual chores I am hunting a elusive bug. No correlation of OS/Browser/Computer of affected users. Sometimes it works, sometimes it does not. It is not a major thing, just one Text field not showing up with the correct value. It stays empty. Sometimes, for some user (less than 5%).
But it drains on me. I wrote all the code. There is no one to blame and sadly no one to ask, since I am the one and only programmer there. I was stuck
. After weeks of staring and testing I gave up. I came to the conclusion that I am unworthy and not able to call myself a programmer anymore.
Before starting to drink and give up my beloved profession, I decided to "Something completely different" to ease my head off the problem.
If you loose the fun of programming, what can you do to rescue yourself? - Get the Propeller out and have some FUN programming!
And so I did. Inspired by @Idbruce
I started to look at that multi-axis-thing. Just as challenge, I do not really need a stepper driver, I even do not own any stepper-motors to test it with.
So I build myself some spin test-bed to check out my idea of using a HUB-long as common tick-counter, driven by one controller-cog, read by the axis-cogs. First I planned to use CNT, but decided against because ramping is hopefully more easy when I can vary my step-speed.
As usual things got out of hand quite fast. To test my multi-axis-controller I had to feed it with data, so I needed a Gcode parser. After testing in Spin with - hmm - slow but promising results, I decided to do this in PASM. And the funny thing is, it was quite easy to port the spin to PASM, sometimes the PASM was even smaller!
And now all of it is PASM, even the starting SPIN cog gets used. No need for it anymore.
COG0 - runs SPIN first, then the Gcode Parser pasmgcode
COG1 - runs JDcogSerial
a fullduplex serial driver with buffers in the COG. I really love that one, easy to use from other spin or PASM COGs
COG2 - runs the Multi-Axis-Controller pasmaxisctl
, getting movements from the Gcode COG and dispatching them to the Axis-COGs.
COG3-COG7 (aka 5 of them) are available as Axis-COGS.
Since I wanted to test more then 5 axis, and the 1-axis COG is below 90 longs, I also build 2-axis, 3-axis and 4-axis COGs using jmpret. Once you get the schema done, that jmpret-multitasking is quite easy to use.
The current Demo uses 1-axis and 2-axis per COG driver. The 5 COGs are running 9 axis together, U,V,W,X,Y,Z,A,B,C.
To run this Demo you just need any propeller board you have with 5Mhz and a serial connection to P30/P31 at 115200 baud.
By now the drivers do not toggle any pins, you need to add that if you want to. For now this are just templates reporting that the step is done.
So ANY board you have will do, it does not use any pins except serial. Just run in RAM for testing.
After loading and opening your Terminal program (115200 baud), you have to press 'THE ANY KEY' on your keyboard. Any of the Any-Keys will do.
switch off local echo for nicer displays.
After pressing the Any-Key you will get a short status message from Spin, then Spin dies and the gcode parser takes over the serial line.
From now on you just can throw Gcode at it.
a simple 'X10' will do as example
The Parser starts up as command G00 (fast movement) and G90 (absolute positioning)
Currently supported commands are
G0 or G00 - linear interpolation - set speed to fast, 4 times normal speed
G1 or G01 - linear interpolation - set speed to normal
G90 - set absolute positioning for axis values
G91 - set relative position for axis values
Currently supported axis are
I am miss-using command "D" for output control, or debug level. It starts as "D1"
Debug level are
D0 - no output on serial
D1 - output positions and status after each completed movement. (standard at startup)
D2 - as above but gives you also used delay values and some timing information
D3 - as above but gives you positions for each step taken
I am also miss-using command "F"
At startup the step counter for movements is more or less free running. With the "F" command you can set a frequency in Hz for the fastest step.
a "F10" will try to do 10 steps per second on the fastest axis. Nice for debugging and watching steps.
a "F1000" will try to run the fastest axis at 1kHz.
a "F" or "F0" will switch off the choke and go back to free running again.