View Full Version : CheapAss_dro now online and working.

09-07-2005, 10:07 AM
I got the visual basic exe program posted on my website for download. (later on today) It runs in XP, 98Se windows.
It works by reading pins 10,11 as X quadrature encoder phase inputs. 12,13 as Y encoder inputs. I am using a opto22 board to isolate my port from the clarostat ($50 ea.) optical rotary encoders. I have hooked them directly to the port pins.

A onscreen status block changes color from green to red as the diameter gets below screen target setpoint. It also fires pin 2 for x, pin 3 for y when it transitions to target setpoint.

This is to mount a output light fired by the pins local to the lathe to give a heads up.

Encoders will be cable operated on wall next to lathe. Cable distance has to be less than 15' to computer/encoders or voltage drop exists and lost counts may happen.

The processor must be fast enough to run a 5ms loop to ensure no lost counts. Test computer is a 1.6 gig intel, Laptop @ 1.4 I don't have anything older here.

David Cofer, Of:
Tunnel Hill, North Georgia

09-07-2005, 11:48 AM
Well done, Ibew. You continue to amaze.

How are you mechanically connecting the encoders to the X and Y? Can you possibly post a pic of that? This is cool, I may just try it.


09-07-2005, 01:23 PM
Ibew, those Optop22 boards cost 50$ each?
Nice progress on the DRO.

09-07-2005, 01:58 PM
no, the opto boards cost me .50 each. I bought a dozen or more.

Same board I sent you. Fast modules thou. You'd be better off rigging a pic or other interface.

Or just connecting them straight in. I have done that use a biasing resistor and hook the encoder output right to the parallel port.
(old computer)

Hooking the motorcycle cables up to a cross slide? you just put two tabs on it, one to hold the cable housing, other the anchor the cable to the moving slide. Other end wraps around a disc, I used weights last time to pull on disc to keep tension on cables. You could use a spring like I did the press.

I'll take a picture, I'm still down and in the house sick.


09-07-2005, 05:45 PM
This SOB is sick and does more for this board than all of us put together.If I only understood half of what he says I could make the stuff also.

No offence meant, David

The tame Wolf !

09-07-2005, 06:30 PM
What IOWOLF said.

09-07-2005, 07:47 PM
I have to chime in also. You impress me.

09-07-2005, 08:09 PM
Ok, now I feel comfortable admiting that I ussually have no clue what David is saying.

As previously stated, can you take pictures of the hook up to the lathe so we can see how the x and the y are measured?

Damn nice work. A mind is a great thing to use!

09-07-2005, 08:36 PM
Mmmm.... getting somewhere, I see. http://bbs.homeshopmachinist.net//biggrin.gif

BTW - once relieved of it's winbloat, those machines should be capable of a sampling rate in excess of 100Khz... a low end Pentium should be able to manage the task under DOS with acceptable results...

IBEW - I believe I've mentioned this before, but I'll repeat it, just in case - check out TurboPascal 7 for DOS - for doing this kind of stuff, it's really nice, cuz' you can get complete control over the machine - and it's a free download.


09-07-2005, 09:28 PM
So where can I find your web site?

09-07-2005, 09:56 PM
<font face="Verdana, Arial" size="2">Originally posted by nt1953:
So where can I find your web site?</font>

Click on his profile, the link is in there.

I will also admit that I usually have no idea what Ibew is talking about, but it is still interesting to read.

09-07-2005, 10:22 PM
There is a free DOS DRO program.


09-07-2005, 10:31 PM
Sorry guys, I was wanting to put one more sub into it before posting it. One that you can configure the parallel port, *(blocks on the right, and pulses per inch) and it loads "your" unique setup each time. I ain't doing so well, I fell out on the couch like a lazy sick bastich..

Yeah, you can hook the encoder directly to the parallel port. No parts needed. I am trying to figure out what kind of biasing resistor you need. It works great without anything thou. Possibly since it is a optical encoder limiting the current. But for protection against stray noise it might need some resistors.

I promised to try to explain it how even IOWOlf can use this and hook it up.

You got 4 wares on pins coming from the lil blue rotating thing that looks like a speedpot, It has a turny shaft thing on it, you hook that to the cable with a lil round discy. put a spring on it to keep it pulled up tight..
Now them thar wares, one is a 5volt hot, one is a 5 volt negative, you need 5 volts on them in the right wares. Them other two? they are pulse wares that make the computer know where that there shaft is. If you turn the shaft on that lil blue thingy, it makes them wares pulsate and throb quite consistiently (*you know how your big toe throbs when you hit a bedpost barefoot? ) actually 128 times each in a full turn. Now them throbbing things on them wares happen opposite and the same time to each other. This way it's called quadrature. Now them throbs, have the following logic and what just happened a throb before tells the computer which direction it's going..

example encoder..
throbbing pulses.. (1=throb, 0=no throb)
00,01,11,10 to right=cw, left = ccw
if you follow that pulse train from that rotating blue thingy *encoder to the right and look at what jus happened the pulse change befo, it tells you cw direction on that lil shaft on that encoder thingy. Now if you follow that pattern to the
other direction it's backards to the first pattern or ccw. If your computer is really smart, meaning somebody told it (a program) how to watch that encoder and see what it did last? it'll know and remember.

*yeah I'm being sarcastic. I love you guys.. this is not hard once you get the picture on how the encoder really works....

For you "other guys" with the pocket full of pencils and slide rulers.. here.. this is the vb subroutine. Note: the lil throbbing thing is pulsed on with the "1" and off with the "0".. He he..

'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^
'00,01,11,10 to right=cw, left = ccw
'****************** Conditional statements, get the bits of encoder************
'x_anew=present status of the encoder
'x_aold= last status of the encoder..

X_Anew = Right$(PortCIn.Caption, 2)

If X_Anew = X_Aold Then Exit Sub
'ifn it ain't changed, it don't matter none.

Text1.Text = X_Anew & X_Aold
'diagnostic screen block of input

If X_Anew = "00" And X_Aold = "10" Then 'CW
X_pos = X_pos + X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "01" And X_Aold = "00" Then 'cw
X_pos = X_pos + X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "11" And X_Aold = "01" Then 'cw
X_pos = X_pos + X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "10" And X_Aold = "11" Then 'cw
X_pos = X_pos + X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "00" And X_Aold = "01" Then 'ccw
X_pos = X_pos - X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "01" And X_Aold = "11" Then 'ccw
X_pos = X_pos - X_incr
X_Aold = X_Anew
Exit Sub
End If

If X_Anew = "11" And X_Aold = "10" Then 'ccw
X_pos = X_pos - X_incr
X_Aold = X_Anew
Exit Sub
End If
If X_Anew = "10" And X_Aold = "00" Then 'ccw
X_pos = X_pos - X_incr
X_Aold = X_Anew
Exit Sub
End If

End Sub

Next? somebody buy me a palm pilot so I can program it and do away with the computer and post that program next..
(hint? the lil "runx" button is a axis feed) Not a cnc, but a feed to target.. Yeah, it'll probably get some lil motors next.. you know things that don't throb.. *(he he).. Since it is turning "on" a pin.. it must want to turn on a feed motor.. Eager computer? A lathe don't need a whole lotta program.

[This message has been edited by ibewgypsie (edited 09-07-2005).]

09-07-2005, 10:40 PM
I'll get around to porting it into turbo basic, a compiled exe dos program. On pins and all..

faster, better, quicker in dos. A cheapAss computer will be a excellent dro-feed control.
It won't be so fancy, no big blocks and buttons.


0hh yeah, most DRO linear encoders work the exact same way as this rotary, they just cost hundreds of dollars. Most are glass with lil blocks etched on them. them chinese slide ones?, well they "serial talk" to the computer but are expensive as well. I can talk to them as well.

[This message has been edited by ibewgypsie (edited 09-07-2005).]

09-07-2005, 11:57 PM

yeah, look up my cnc press project, I used a rotary encoder, Wrapped a xl toothed belt around a gear, cut the belt hooked one end of the belt to a spring, hooked the other end to the "slide" on the press and AWAY I went counting off. Used two rollers to keep it wrapped around the lil gear.


09-08-2005, 02:45 AM
I got it done, it'll run in windows at the moment.. What does it need? Other than encoders and hookup drawings? Included in the zip is a 8255.dll file used for input/output to windows, a dat file for configuration-save of your setup. Most everything is self explanatory.

Yeah, that time is right. It ain't easy being a chair bound programmer..

This lil bitty lcd-232 module has kicked my butt all day. The DRO program only took about a hour today. Mostly built of subroutines I already have done.
Well there was this lil problem with the parallel port address-file-save it'd go in in digital then come out in hex.. I was perplexed. HA.. off to roll around on the couuch some more..


[This message has been edited by ibewgypsie (edited 09-08-2005).]

[This message has been edited by ibewgypsie (edited 09-08-2005).]

09-08-2005, 05:01 AM
Hi David, can it do metric? or do you just enter a different value for pulses per inch / pulses per mm ? thanks mike

09-08-2005, 09:41 AM
It does counting.. it don't care.. Changing the ppi (pulse per "inch" to reflect PPMM) is the way you change the counting per measurement.

One note: the clarostat encoder I listed is a 128 pulse per revolution, using a belt gear example of 1" diameter x Rx2=3.14" circumfrence. or 3.14/128 pulses and that resolution is not good enough, so it need a micro gearbox to up ratio or a belt pulley multiplier or a higher resolution encoder.

My cnc press has a encoder of 2400 ppr, divided by .75" x 3.14 in distance or.. about .001 rough (*I just woke up) .00098 is actual pulse per "tick" of the encoder.

ABout the .dll...... setup and work program.

Included is the cheapass_dro.exe, a cheapass_dro.dat setup configuration file and a 8255.dll file. You must copy the 8255.dll file to "c:\WINDOWS\8255.dll", and have a copy in the directory with "cheapass_dro.exe" and also, windows must have the "c:\windows\SYSTEM\winmm.dll" timegettime function for reading in microseconds.

Both are available on the web, but the 8255.dll is included in the zip file.

[This message has been edited by ibewgypsie (edited 09-08-2005).]

09-08-2005, 09:58 AM
Which brings us back to the "other" post.. ON how to cut a cdrom with slots and build a home-made high resolution encoder for .50.

09-08-2005, 10:19 AM
Like WOW, David!!! In 1966 I took a night class on the "new math", binary stuff. That was it. I completed the class and realized that my gray matter upstairs was outclassed. I'll stick to graduated dials and maybe DRO--
if they're already set up. Somebody save me.

09-08-2005, 11:33 AM
You could cut that down a bit David. It would save time.

If (X_Anew = "01" And X_Aold = "00") Or (X_Anew = "01" And X_Aold = "00") Or (X_Anew = "11" And X_Aold = "01") Or (X_Anew = "10" And X_Aold = "11") then

X_pos = X_pos + X_incr
X_Aold = X_Anew
Exit Sub
End If

By using the port value as an index into a lookup table you could cut it down a bunch more. The lookup table could be a simple string. Do a boolean over the values in the string and return true or false.

09-08-2005, 11:37 AM

While I really don't understand all (much) of what you're doing, I do understand your discussion about the blue twirly thing and the throbbing big toe.

You should be a teacher. Students read the textbooks full of .25 words and panic because they don't understand. Someone like you comes along and explains it in the vernacular you used, and the students light up and say, you mean it's that easy? or "How come the book doesn't explain it like that?"

Your paragraph that starts with "You got 4 wares on pins..." is brilliant.

I'd be the student at the back with my hand up asking "What's a speedpot?"


09-08-2005, 12:55 PM
PDA's are about the most over priced gimmicky things I ever got a chance to play with.
Dave, have you tried an AVR butterfly demonstration board? It has a 110 segment LCD I believe with serial port, could reprogram it to read the DRO input. Hmm, actually be easier to use the ports on it, but it shares those ports with the LCD.Hmm Well, 20$ programmable DRO display if you could get it to work.

09-08-2005, 01:41 PM
I now have it ported into DOS.

Have to work on the screen format and other trivalties.

Evan: a machine code subroutine would cut that even further. Problem is, I think it should be done by a external processor that is not so tied up with keeping BillG online.

I have a pic, it is $75 for two channels of encoder/h-bridge PWM output. Working with it? I have to complete some packet transactions with it, but.. it is much better. I will do it up next in Windows.

It can take about any pulse width signal, that is the serious problem with doing this with no hardware. Your time limit window to check for movement. Real fast movement = lost position.
I got a $10 LCD that has kicked my butt fur three days. Silly thing prints garbage no matter what you throw at it. Ascii? Chr$, digital? Hex$?
I have not throwed it on the floor and danced on it .... yet.....

09-08-2005, 01:46 PM
What sort of LCD? I have some two line displays I figured out some years ago if I can remember where I put the docs.

09-08-2005, 02:03 PM
This one is a SparkFun from sparkfun.com w/piggyback Rs232 convertor.

but doing a for/next loop printing character code (chr$(loop)) it randomly prints characters. No sense or reason I have seen yet. I am wanting to stand-alone the pic board w.lcd.. or hook up the shop computer for "monitoring" cuts. Kinda like looking over your shoulder and saying.. "HEY.. you are close to the finish pass" or.. no.. past position for incut.. Or.. ??

My end result is a real good DRO, Real good gcode program machine feed, not a cnc.. but a 3d drawing to reality tool.

A year ago I had a h-bridge running off a parallel port without drives. I can't find that program or remember what I named it.

A lathe? you have a 2d profile you cut. Remember the pattern follower? A smart programmer can make a screen pattern w/machine position on screen.. CUt by computer to pattern monitoring.

With this cheapass dro? it monitors a target position and compares that to the actual "calibrated position. You would take a light cleaning cut, mic the part, enter that into the DRO as Calibrate. THEN enter the target depth Y, and distance X. Blocks on screen turn to red color to give Heads up.
I got three "fuzzy" monitors around here. Putting one over the lathe is in the plans.
(I love my Sony Flatscreen)


[This message has been edited by ibewgypsie (edited 09-08-2005).]

09-08-2005, 02:21 PM
Try chr(x) instead of chr$(x).

09-08-2005, 03:51 PM
Yeah, it's got me standing on my head.

It calls for a start and a stop bit in the com port configuration. Com1 9600,n,8,1 is how I have it set up. Mscomm don't have a start bit.


09-08-2005, 04:10 PM
Try using 1.5 or 2 stop bits. 1.5 stop should force a 1.5 start bit interval. Also try sending a zero (null) between each character.

Treven Baker
09-08-2005, 04:55 PM
Ok most of this has gone over my head but what I think I have learned here is that:

I might possibly be able to use my old computer I'm doing nothing else with and buy a couple of DRO scales ( I don't know if it matters what kind or not ) and hook them to the useless old computer and have a DRO on my old P&W jig borer.

I have no idea about the detail since I don't own any DRO stuff now.

If anyone would like to elaborate on what kinds of scales to buy that would work with my old Dell computer running windows 98 that would be very helpfull. Also what types of cables and adaptors I would need and what port to use on the computer would be helpfull.

I could down load that program but I don't know how I would get it off my new computer and onto the old one. Maybe I could burn it on a disk? - I might be able to pull that trick off. ( I'm not being sarcastic - that is just how difficult computer stuff is for me.

09-08-2005, 05:14 PM
You could buy some linear encoders from here: (scroll about halfway down the page)


for $99.00 each with 5 micron resolution and 12.59 inch travel.

09-08-2005, 06:59 PM
Nice write up Evan, but no data. I tried to view the pdf files.

Yeah, that is the "best" I have saw in a bit.
I always say industrial hardened is better than homebrew wires hanging everywhere and home wire-wrapped electronics.

(this pic chip rocks.. too bad I got it into a loop-tailspin) I can break a rock.. You can put the tiny clarostat encoder in a battery drill and spin that rascal, no lost steps or so it appears.

I just now figured out how to read the encoder registers in it. Had to hardwire reset it after I dumped a program in.
I like it.. simple once you figure out how it communicates..

With that?

John Stevenson
09-08-2005, 07:26 PM
That's been done before.
Try here for some info.


John S.

Peter Sanders
09-08-2005, 07:48 PM

<font face="Verdana, Arial" size="2">Try using 1.5 or 2 stop bits. 1.5 stop should force a 1.5 start bit interval.</font>
The start bit does not have to be set, it is always there. A 1.5 stop bit will not change the start bit.

<font face="Verdana, Arial" size="2">Also try sending a zero (null) between each character.</font>

NULL and zero are two DIFFERENT values, a NULL is nothing at all data bits are NOT set, eg 00000000 whereas zero "0" is HEX 30 or 00001100 (least significant bit first)

Kind regards


Peter Sanders
09-08-2005, 07:55 PM

<font face="Verdana, Arial" size="2">I got a $10 LCD that has kicked my butt fur three days. Silly thing prints garbage no matter what you throw at it. Ascii? Chr$, digital? Hex$?</font>
Some LCD's require information to tell it WHERE to print the data received. So you may need to send co-ordinates with your data. Similar to row=1 column = 2 print "Hello" or LCDPrint 1,2,"Hello"

Kind regards


Treven Baker
09-08-2005, 08:00 PM
Was I right about this thread realating to putting DRO onto a home computer? If not can someone explain what the thread is about?

09-08-2005, 08:14 PM

Just kinda wobbling around. I've had a bout with something nasty here. Sinus/lung infection or mean summer cold.

I posted the software above, download it and try it out. You'll have to put the 8255.dll into c:\windows so the software/windows can find it. The .dat file is the configuration file. It must be with the running program in the same directory.

How to play without a encoder? Not sure yet. I got three laying here on the bench.

The software works. I can't solve everyones hook up issue with encoders I have never saw before. So far, the software works with DMA boards, opto22 boards on the parallel port and direct hookup to optical encoders. Signals must be buffered externally to the parallel port.

I have another post started "making encoders from cdroms" perhaps you can be the first to make that work.

09-08-2005, 09:07 PM
Dave, got any part numbers on the LCD? Like the post above says, some require more setup information, can be either 4 or 8 bit, need to know which way the cursor is to go, auto or manual cursor mode, etc.

Some, unfortunately, also required external static RAM. Den

09-08-2005, 11:42 PM

That is why I said (null). CHR(0) [zero] is a null, not ascii 30.

As for start bits they can and do vary from one bit time depending on the UART type and revision. It will even vary with the baud rate selected as the internal clock that generates the data may not be evenly divided to one bit time. This is especially apparent at higher speeds on older UARTs like the 8250.

I've done plenty of work with UARTS both hardware and software including building my own from TTL.

09-09-2005, 04:52 AM

Instructions say " when you send a "R to it, it prints a R at present cursor location. It has a uart backpack 232 convertor. Not cross ttl multi-lines to write binary data to like a regular lcd .

So far it prints garbage. I think I got some bad ones. Mis programmed pics or ? Just a frustrated three days wasted of my life. I ain't mad.. nope..

On the bright side? the Moto board is a success. I got it talking, successfully sending rom packet transactions as to encoder postion and pid parameters to the visual basic subroutine. Meaning, it will work for a DRO/feed control More expensive than I wanted to do, at $75 per two axis, but still less than just a "mouse" interface board listed by John S above.

Lemme get happy with program, getting info out of chip, configuration, then I can post my hookup schematics to use quadrature encoders.

Plan is, a DRO cheap.. On same board, A feed control cheap w/two speed knobs to control speed w/endpoint monitoring, and gcode line following So if you wanted to cut Swiped of .005 off per pass you'd set it up and turn it on. THEN drink beer while it does all the work. Coupling boring is one thing I want to be able to set it up to do. Give it a starting point, tell it the ending point and turn it loose.

All this will be less than $200 total for two axis. If I play my cards right? drives are in that price.

Most people won't want the "feed" they will just want a dro. I want the chrome beauty trim rings on the wheels and the Hemi under the hood, for less than $200.

09-09-2005, 05:49 AM

The dos version rocks. Solid, no bugs. I am working on a large text screen print using a XOR function and a picture overlay of the numbers like a old style clock. Page memory swapping to reflect number needed at each location for "us" old blind guys. Otherwise the dos letter height is about 1/4" and hard to read. I have thought about doing a colored bar showing relation to target dimension.

Old dos programs are more reliable than windows ever hoped to be, newer Linux distros have as many problems as windows. Trying to juggle too many things at once. One errant bit of dust across two pins and it drops them all. I ran IBM model 25's for years on mixing machines. They ran off dos and floppy discs.

I'd like to have a half dozen of them nowadays.

Milacron of PM
09-09-2005, 11:24 AM
<font face="Verdana, Arial" size="2">Most people won't want the "feed" they will just want a dro. I want the chrome beauty trim rings on the wheels and the Hemi under the hood, for less than $200. </font>

I'm glad you want the 'feed'...good goal. In the late 70's Heidenhain developed the TNC 112, which was basically their standard DRO, but had the "active" feature of being able to input (in incr or absolute), an automatic axis move.

To activate, all you do is press the incremental or absolute button, input the travel you want to happen, press the axis button you want it to happen on, and then simply engage the regular feed lever on the machine for that axis (in appropriate direction of course). The DC drive axis motor would automatically ramp up, axis would travel to within a few thou of programmed data point, ramp down and stop..DC motor/drive shut down. Dead nuts accurate too, surprisingly enough, even at rapid travel rates and standard screws.

These were available mostly on Deckel mills, the later improved TNC 113 being more common. But they did make a TNC 114 that was available for any machine with Heidenhain scales and appropriate interface to DC drive.

I'm attempting to repair a TNC 113 now, as Heidenhain refuses to repair them anymore due to some of the DIP IC's being obsolete. They won't release schematics either. The cheapest new alternative is the TNC 124, which is overkill for the purpose and cost over $6,000...so there is some inspiration to repair the TNC 113...got some IC's on the way from Mouser that will hopefully bring the little bugger back to sanity.

09-09-2005, 12:33 PM

this board I have here is a "exact" drive. Using encoder feedback it goes to place selected. I have been running it here and really upsetting my wife watching tele.

I am in the process of ADDING in the Chinese scales to the program. They only talk at 4800 baud so they will not co-exist with a encoder. They can run with a pic/encoder with serial polling. If I get good enough with this pic chip I may read serial with it too. Same part, different jobs.


[This message has been edited by ibewgypsie (edited 09-09-2005).]

09-09-2005, 03:19 PM
Dave, On that LCD / serial interface, there is a splash screen command that you can send as sort of a self test. It's in the serial intfc manual. It's possible that their power-up reset could be a bit fussy. That LCD controller chip itself has been around forever but maybe the PIC on the serial board has a problem with reset. Some PICs have had problems recently with proper reset but I think it was around 3 volt or lower operation and then only specific parts. Den

09-09-2005, 05:06 PM
I got so much time in the Next version I am going to ebay them at a minimal cost. I have about forty hours in it now.

When I add in the chinese scale reader it should be quite a package. Using ttl/rs-level-232 convertor factory one is $75, Acroname convertor is just ten dollars or so. I have to add in a Little Machineshop.com cable into that final cost for one axis thou. NOW if I can just figure out a way to multiplex them without a pic chip. BillH's butterfly would do it I think if it has two serial lines in and one out for the com port.

So, it is going three different ways as of the moment and I am having trouble breathing again. Neighbor is mowing, Her wobbly butt is not making up for the pollen in the air. Her husband has dissapeared again, I think he's a junkie or worthless.

09-09-2005, 06:11 PM
I think he's a junkie or worthless.


The tame Wolf !

09-12-2005, 01:57 PM
ANybody seen a Parallel Pin interface that can take the input pins and stream a serial signal into them?

This will make the Chinese DRO scales work without having to have a port for each scale, the ttl/rs232 adapters are the expensive part, the parallel port should be at ttl level inputs already.

This would let you hook up 8 scales to your port.

I hate to write my own telecomm framing driver, but I probably will in the next night I can't sleep.