[Color Computer] [coco] Learning MW C
Joel Ewy
jcewy at swbell.net
Sun Aug 13 22:03:12 EDT 2006
George,
I'm fascinated by how many people on this list are into homebrew CNC. I
guess that's the kind of thinking the CoCo inspired in us. I have a
distinct memory of my first experience with Telewriter 64, and printing
my words out on the DMP-105. I recognized right away that the printer
was a kind of simple machine-tool, and that the fantastic liberation I
felt being able to compose my words in the memory of a computer before
having it committed to paper could be experienced with the making of any
kind of physical thing that one could construct by means of a
machine-tool controlled by a computer. So I can trace my interest in
CNC directly to my experiences with the CoCo.
I agree with Gene Heskett that Linux and EMC are a great way to go if
you're really trying to get something done quickly and easily. I plan
on replacing my old Pentium 133/DOS/DANCAM system with EMC as soon as I
find the time and collect the appropriate PC bits. On the other hand, I
completely understand your desire to run the machine with a CoCo.
There's something truly great about a system that's so simple and
comprehensible, and also about doing as much of it yourself as you can
and want to do. At this point I use my simple CNC machine just to drill
holes with a Dremel. What it does is so simple that a CoCo could be
used for the task if I had appropriate software. If it got a lot more
sophisticated than that, then maybe a faster computer would be called
for. But most of the performance requirements for running EMC is really
just overhead for the GUI, I think.
If you really want to do it with the CoCo, just to be truly intimate
with the machine, to prove it can be done, for pure hack value, or for
whatever reason, here's what I would suggest:
1. It sounds like you're using (Nitr)OS-9 already. If so, get the
source code, and find a driver for the hardware that is as similar to
the hardware you're using to drive your steppers as possible. I imagine
this would be a parallel port of some sort. The Disto printer port
might be a good place to start, or something that drives a 6821. I
don't remember if you've mentioned how you've interfaced the steppers to
the CoCo.
2. Use the existing code as a base for cooking up an assembly language
driver for your hardware. Don't try to start from scratch. That would
be an agonizing learning curve. But look at the commented NitrOS-9
disassemblies and modify them stepwise until they work with your
hardware. It's much easier to understand and modify existing assembly
code (if it's well commented) than it is to write entire device drivers
from scratch. (At least for me...)
3. Use BASIC-09 or C to write the user application that interfaces with
your driver. BASIC-09 should be fast enough to read your data files and
feed them to the driver. If you need interrupts, put all that in the
driver. Steal an interrupt service routine from an existing driver that
uses one and modify it to suit your needs. The whole question of how to
do the equivalent of a POKE in C kind of misses the point of the
C/UNIX/OS-9 philosophy. The device driver really should be the only
piece of code that accesses the hardware. The driver is there to
provide an abstracted interface to the hardware for the application
program. It sounds like you have your hardware working by POKEing
directly from BASIC-09. That's cool. You've got a quick and dirty
solution just to make the thing go, and you know it works. But now if
you separate the direct hardware manipulation off into a real assembly
language driver, you can play with the logic of the rest of the program
in isolation from the hardware component. And if you do decide to make
it a closed-loop system, or put in limit switches, or otherwise make the
hardware more complex, you can segregate that complexity from the
user-interface and data file manipulation functions by keeping the
hardware access in a proper driver.
4. If you still aren't happy with the speed after putting it in a
proper driver, start putting more of the smarts in hardware. Use your
machine to make PC boards for your next generation motor controller
interface. Instead of making sine waves in software, use a stepper
motor controller IC and just send it step and direction signals from the
CoCo.
5. Try to make your driver as generic as possible. Comment your source
well, and contribute it back to the NitrOS-9 project. Somebody else
might put it to use to run a plotter or another CNC machine, or who
knows what.
That's how I would approach it anyway. Good luck, and keep us (or at
least me) informed on your progress. It will inspire me to try more fun
projects with the CoCo, and to get back to work on my CNC machine.
JCE
George's Coco Address wrote:
> There are too many replies with too many variants to respond to them all.
> Lots of good stuff, though.
>
> Since I'm ignorant about C, and only intend to use it on a Coco, I suppose
> MW C is good enough unless I run into problems.
>
> I have been developing a system to machine some small parts for my steam
> engine projects. I'm using stepping motors on what I call my "Tiny CNC" 3 or
> 4 axis machine.It uses three or four stepping motors(depending on the
> application)
> It uses a dremel for the cutting. The machine is built, the interface is
> built and it works.
>
> A stepping motor requires a lot of steps to make one revolution, both
> positive and negative on each of the three phase coils to make it step
> properly.
> In B09, I can step ONE motor at about two hundred steps/sec using only
> positive and negative voltages (square wave). Stepping more than one motor
> takes more time and therefore, slows the process. These stepping motors step
> at 1.5 degrees/step.
> The stepping motors directly drive a screw that is 36 pitch. This requires
> 8640 steps/inch or about one inch per millennium. For the most part, when
> actually cutting, the step rate is just perfect as the dremel can only cut
> so fast and it works fine. However, at times (especially when moving to a
> new location to start a new cut), it takes a long time to move it at this
> slow
> stepping rate. Should I wish to step these motors faster, I need to also use
> a modified sine wave. I figure four bits per coil could do this. Of course,
> this takes more time for the computer to do and speed is getting more
> serious.
>
> The reason for my desire to learn "C" is so I can build a subroutine in C
> to do the stepping of the motors. This is why I want to discover a way to
> use the equivalent of Peek and Poke in C.
>
> It won't be a large subroutine by any means. My B09 subroutine is, maybe
> fifty lines of code. I figure C would be a lot faster once it's compiled.
> If it's fast enough, I intend to add some feedback from the steppers. The
> usual way is with optics. This would require some more peeks, would slow it
> down and make the process more time consuming. After that, I can begin
> learning to do the math in C and therefore, start migrating from B09 to C
> completely.
>
> If I could wrap my head around assembly, I would work with that. But I've
> tried ASM and keep failing. If I knew what I was doing wrong I could
> probably ask a question but I don't have a clue how to work it.
> I figure maybe C would be easier for me.
>
> Can a C routine be called upon from an interrupt? That would be great, as
> the optical position sensor could call on the routine. I can solder that one
> up too.
>
> It seems if it isn't B09, I'm lost
>
> I NEED ....."AN IDIOT'S GUIDE TO 6809/OS9 ASSEMBLY( HOW TO WORK THE
> THING)"
>
> Then I could begin to learn the microprocessor.
>
> George
>
>
>
> Brought to you by the 6809, the 6803 and their cousins!
> Yahoo! Groups Links
>
> <*> To visit your group on the web, go to:
> http://groups.yahoo.com/group/ColorComputer/
>
> <*> To unsubscribe from this group, send an email to:
> ColorComputer-unsubscribe at yahoogroups.com
>
> <*> Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
>
>
>
>
>
More information about the Coco
mailing list