Beginning programming question

Mar 03, 2011 100 Replies

At least with C you don't crash a CNC machine. I had my first crash in quite some time with this one yesterday:

M3 G00 Z0 GO1 Z-.5 F2.0 X16.5

I didn't catch it with the high speed run through while cutting air.

P.S. If you don't see it, caps lock was on and I hit the O insted of the 0, right beside each other on the keyboard. So, the control stayed in G00 mode. Try to find that in a long program.

Karl

See

formatting link
utiliity to count all characters in a CNC ascii text file. Can be useful to detect non-printing characters, lower case "L" in place of one, etc. Count generated for ascii characters 0 through 255. Includes PowerBasic and exe file that will run under Windows -- no dos box needed. Includes some test cnc input files and sample output. Also outputs .csv file for Excel analysis.

-- Unka George (George McDuffee) .............................. The past is a foreign country; they do things differently there. L. P. Hartley (1895-1972), British author. The Go-Between, Prologue (1953).

There are still a couple more layers below assembly language. An easy step down is machine language. The next step down is understanding instruction decode. But only worthwhile if you are going to design computers or work on an antique that you can single step through an instruction.

I am a little surprised no one has mentioned Forth.

I think that Knuth's books are great for understanding computer programming at close to the lowest level. But " Software Engineering Economics" by Barry Boehm would probably be far more worthwhile to read if he is going to be involved with creating systems that use computers.

Dan

The Okuma OSP2000 control has to have the bootstrap loader programed through the front panel. The control itself was very good for its time and still run with almost no problems.

John

That is a very common mistake when writing programs by hand. The one easy way to check is with notepad and the 'find' feature searching for O's or any other undesirable letter. Most controls that I've run will not accept programming errors and will indicate what line the error occurs.

John

Yup. Assembly would have been a 'step down' in complexity after that!

I must have been on the 'bleeding edge' then. My first computer roared along at 2.5 MHz.

formatting link
I thought Visicalc was the cat's pajamas!

'Course I paid $5K for the setup. Over $11K in today's funny money.

Yikes!

--Winston

gcc will spit out a warning: "do you mean a==b".

If you want to talk about hard to find bugs, try this one in Fortran:

subroutine x(j) if( j .ne. 0 ) j = 3 end

call x(1)

You now have 1 == 3. This makes even more fun, when you don't have access to subroutine X.

One time at a Usenix conference, we were talking about C, I made the comment, "C is just a portable assembly language". Denis Richie said, "I've never thought of it in that context, but yeh".

C comes from BCPL, which comes from SYMPLE, which is a portable assembly language.

Wuss!

We programmed the bootloader by soldering diodes in a matrix on a circuit board. Diode present meant a one, diode absent meant a zero. This was the PROM of the day (SEL 32 computer, early 1970s)

Joe Gwinn

On Sat, 05 Mar 2011 23:47:21 -0600, Jon Elson wrote: ...

Problems like that take mere seconds to find if one uses reasonable compiler options. For example, command "gcc iftest.c -Wall -o iftest" produces the following message for the program shown below.

iftest.c: In function ?main?: iftest.c:5: warning: suggest parentheses around assignment used as truth value

#include int main (void) { int a=0, b=1; if (a=b) printf("if %d = %d\n", a, b); return 0; }

Program output is the same ("if 1 = 1") with or without the -Wall ("All Warnings") option. In my experience it is reasonable to always compile with -Wall, and work on the program until all warnings go away. Note, -Wall doesn't actually produce all possible warnings; for that you need switches like -ansi and -pedantic; see eg notes at

Any modern BASIC compiler is a good place to start.

You worked for SEL ? I worked for Interdata.

While not freeware, PowerBasic is the lineal descendent of Borland's TurboBASIC, and is very robust and fast, both to compile and run, with good developer environment. The console compiler is ideal for data intensive operations that dont require much operator input. This runs on Windows and does not require a DOS box. A 32 bit application/

see

formatting link
for general info and
formatting link
for console [text mode] compiler info [49.00$US for v4.0,169.00$ for v5.0 printed manual available at 49$US]

formatting link

-- Unka George (George McDuffee) .............................. The past is a foreign country; they do things differently there. L. P. Hartley (1895-1972), British author. The Go-Between, Prologue (1953).

No, a SEL customer. I was later an Interdata (in the form of Perkin Elmer) customer as well.

And when I started, we programmed in assembly code (~ 70,000 lines), only later sliding over to the new thing, Fortran (~ 60,000 lines, if I recall). There were lots of debates about the practicality of fortran in such applications, given the inefficiency of fortran-generated code, but the combination of the 3:1 or 4:1 reduction in coding effort of high-order languages compared to assembly coupled with the Moores-Law increase in computer power soon pushed assembly code to the margins. It was cheaper to simply overpower the inefficiency.

Joe Gwinn

I worked for EAI, another customer of SEL, and the company Bruno and Sinnott left to form Interdata. I was present at the beginning of the end for superminis. EAI had a rack with six 8086 processor cards and some memory hooked into a SEL 32/97, running as a multiprocessor. We determined that the (very cheap) rack had about one quarter of the processing power of the big power sucking (ECL) supermini. Analog/Hybrid computer sales didn't last long enough to take advantage of a cheaper digital controller. Sic Transit Gloria.

Kevin Gallimore

Visicalc WAS!

Still is, although there are considerably more polished spreadsheets now.

But yeah. Suddenly there was a new way to play computer!

and it really really worked!

Yeah... I paid $3G for Autocad (10). Turned out I hated Autocad. It was about as handy as a rock for drawing.

Been working with Design CAD ever since. For $69

Interdata 7/32 machines we used for flight sims (way back mumble years ago).

But bias power had to be supplied - in correct sequence.

Seems others thought it a viable plan as well...

(...)

Yup. That was the first time I uttered the phrase "User Vicious". :)

Generic CADD at $99.00 was 'way more intuitive and useful for me.

I went from Generic CADD to VisualCAD to Rhino3D. I love Rhino3D.

--Winston

Hey! I just finished writing a file called "startup.s" for a custom board -- I'll give you _one guess_ what it's written in!

Assembly language is still alive and well, even if it lives in the dark corners of the development efforts.

And SINCE . IT . IS .. FREEWARE...

I played with FreeBasic a while back and was impressed. It wasn't hard to get old QB45 code running. Nor was it hard to adapt to FreeBasic default styles.

I did a little Alien Invaders hack that was kinda fun.

Lots of examples and toys available for it (FB) as well.

This, by all means, should be deemed to be the basic BASIC.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required