Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:59 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SM1 LCD XY Position Indicator

Author Message
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 09:51am 27 Sep 2011
Copy link to clipboard 
Print this post

Greeting's All,

I've been modifying some of the existing library
files for my own applications, one that I am having
trouble with is an X and Y Axis Position Indicator for
my Lathe, I have modified the Tacho.Bas file so that
the LCD Pins are as follows:

LCD SM1 I/Os (Pins)
12 reset counter
13 count down
14 count up
04-RS 15
06-Enable 16
11-Data Bit 4 17
12-Data Bit 5 18
13-Data Bit 6 19
14-Data Bit 7 20

This frees up I/O 11-14 for counting if required
and I know that these are allocated for the comms
ports which I am not using.

The LCD circuit is the same as LCD.bas BMP with the
10K resistors on D4 to D7 and D0 to D3 tied to ground.

Please note; I now refer to the SM1/ Maximite Pins as
I/Os, so as not to confuse with IDC Pins (I find this helps alot).

I intend to modify the Tacho.Bas file on lines 230 to 380 so
that if PIN(14)=1 (high)then LCD line 1 will display X Pos = 000.01
if PIN(14)gets another high trigger then line 1 will show 000.02
and so on, I will need to set a PIN to reset the counter to zero
and also set a PIN to count down, unless PIN(14) can count both
up and down via a rotary encoder.

I hope someone out there is listening and can assist...Regards


Muttley Snickers
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 11:46am 27 Sep 2011
Copy link to clipboard 
Print this post

I think your on the right track Muttley.

You only need two wires to detect direction and postion. The encoders used in old PC mice used a pair of LED's/phototransistors pairs slightly offset from eachother on a single slotted disk. The mouse firmware could tell direction by which pair were switched on first, and I dont see any reason why the Maximite couldn't do the same, providing the rate wasn't too high.

Other options to look into. Use a PicAxe or other micro to do the direction/step tracking and send the data to the Maximite via I2C or serial. There may be a dedicated IC that can do it. Also, an old serial mouse can be used as a dual axis tracker. The mouse chip tracks steps and direction, then periotically sends the difference data down the serial cable when requested by the PC. So even if the PC is to busy to read the serial port, the mouse will keep a tally of the encoder figures, and keep track of the mouse position, until its data is requested.

If your interested I do have some VB software I was working on years ago for tracking serial mouse data, it's possible it could be converted to MMBasic to let the Maximite communicate with a serial mouse.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
thetinkerer

Regular Member

Joined: 16/06/2011
Location: Australia
Posts: 68
Posted: 10:33pm 27 Sep 2011
Copy link to clipboard 
Print this post

Hi,
It sound like you are building a two axis DRO for your lathe. is that right?
A little while ago I trialled a quadrature encoder(as Gismo mentioned) with the maximite.
I used two inputs to detect the encoder direction/pulse. I used two inputs with a rising edge detection on each input and had the incrementing and decrementing of a counter in an interrupt routine. If the encoder went one direction the count went up and the opposite encoder direction decremented the counter.

The main routine of the program handle the display (LCD routine in your case). Sorry I don't have the code with me as I am currently over seas.
This may give some ideas: http://mcmanis.com/chuck/robotics/projects/lab-x3/quadratrak .html

regards

Marc

{Fixed the link. Gizmo}Edited by Gizmo 2011-09-29
 
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 11:00pm 27 Sep 2011
Copy link to clipboard 
Print this post

Thanks Glen for yor reply,

just to clean up that last post, the LCD side of the project
is fine, I can edit the lines eg; 330 LCD_line1$= " X Pos= 000.00"
but do not know how to generate a count or transfer the count to the
LCD.

I have set the following In regards to the I/Os:

10 PIN(14)=0
20 SETPIN 14,2
30 CLS
40 LOCATE 0,0
100 IF PIN(14)=0 THEN PRINT "Off"
110 IF PIN(140=1 THEN PRINT "On"
120 DO WHILE PIN(14)=1
130 LOOP
140 DO WHILE PIN(14)=0
150 LOOP
160 GOTO 30

This can indicate the state of I/O 14 (PIN) "On" or "Off".
I tried setting pin 14 to be a counter ie: SETPIN 14,5 but
all I get is a message saying something like "pin not configured
as an input". Does anyone know how to configure a counting input
on the SM1. Very frustrating, the only thing I have counted is the
hair thats falling out, a mate said the other day " Jez your losing
your hair" and I replied " No Im gaining more scalp".

Also i have looked at using mouse guts but I dont think that the
resolution is enough, I am happy to use Omron 1000 PPR encoders,
Which reminds me that I also have to setup a pre-scaler,
eg: 1 rotation of the encoder = 2.00 mm as the top slide on the
lathe has a 2.00mm pitch trapezoidal (Acme is Imperial, Trap is Metric)
leadscrew so it would be 2.00mm /1000=0.002 microns.

I have a Easson DRO on the milling machine with glass linear scales
which are completly covered from swarf and coolant but the lathe gets
messy and its impractical to have a linear slide on the top tool post.

Anyway time for a coffee, regards & many thanks.

PS: what about all you other blokes, surely you know how its done,
This is THE BACK SHED not the sheltered workshop, come on I need help.




Muttley Snickers
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 11:31pm 27 Sep 2011
Copy link to clipboard 
Print this post

  Muttley Snicker said  
PS: what about all you other blokes, surely you know how its done,
This is THE BACK SHED not the sheltered workshop, come on I need help.


Thats not going to encourage anyone to help you. Do you give a hungry man a fish, or teach him how to fish.

Have a look in the MMBasic manual, it covers the set pin commands. In your situation, your best approach would be to track pin state using interupts. Save what you have done, and start with a fresh new program. That way you dont get lost in the code. Experiment with the interupt feature to call routines to track the absolute X and Y position. Unfortunately its unlikely anyone has a bit of code you can use thats ready to go, you need to start from scratch and create your own, but thats the advantage of writing software, you can make it do what you want.

Once you get a bit of code that works, you can then combine it with the LCD routines to get the finished program.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
jebz

Regular Member

Joined: 13/06/2011
Location: Australia
Posts: 79
Posted: 11:52pm 27 Sep 2011
Copy link to clipboard 
Print this post

  thetinkerer said  
{Fixed the link. Gizmo}


Other link had a space hopefully this one doesn't.
http://mcmanis.com/chuck/robotics/projects/lab-x3/quadratrak .html

It's got a good code example of quadrature encoder reading.
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 12:20am 28 Sep 2011
Copy link to clipboard 
Print this post

Muttley,
For the LCD display you need to get your value and change it to a String...
So if your value is mm so
mm$=STR$(mm)
Then
330 LCD_line1$= " X Pos="+mm$+"insert the number of spaces to fill up the line"
You'll probably need to play around with leading zeros etc.
Regards
Talbit

Talbit
 
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 12:39am 28 Sep 2011
Copy link to clipboard 
Print this post

To Gizmo and all other members: I herby retract the last paragraph
of my last post and appologise to anyone that may be offended or
upset.PS If a bloke is dying of hunger you would give him the fish.

To Jebz; I had a look at the site that you linked and thank you very much,

I have Omron, Baumer and a collection of other rotary encoders, as well
as Omron and Red Lion Counter Modules that I use to test the encoders.

At the moment I am just using momenary switches to send a high or low to
the SM1 for preliminary testing an have built in the past CMOS counters
using 4511 & 4510 chips to drive a 4 x 7 segment display, the CMOS config
did not work well due to encoder interface and bounce issues with mechanical
encoders.

I have a number of linear slide scales with display modules similar to
vernier calipers but again the issue is the messy enviroment on the lathe.

I am in the process of completing a CNC machine which will use Mach3 software
to run the Parker drives and stepper motors but also want to add to the stepper
motors rotary encoders and a local LCD display to confirm the spindle position.

The SM1 could probably do this as well as monitoring the limit and EStop switches
should the PC & Mach 3 go offline (even though I have a charge pump which monitors
communication between the PC and the CNC).A runaway CNC machine is a scary thing
to behold and witness.

I liked what Gismo did with the Logitec Game Controller and intend to do a
similar thing.

As I explained to Don, I have downloaded all of the manuals, upgrades, libraries
and examples in regards to the SM1/ Maximite and have come a long way since
first power up. As previously posted I have not had experience with PIC or Basic
programming yet see the SM1 as being extremly flexible and may be applied to many
practical applications, not including Space Invaders.

I am versed in Hex & Binary and have programmed security, access control & CCTV
systems for over 20 years and am highly respected in this and other fields.

The SM1 is a new gadget to me and even though I have read all of the manuals
sometimes it just takes a basic example for the whole thing to come into focus.

Anyway, I do appreciate your replies am will persevere with this and many other
projects. Regards & Many Thanks...Peter
Muttley Snickers
 
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 01:03am 28 Sep 2011
Copy link to clipboard 
Print this post

Thanks Talbit,
This is exactly what I am after, now I can edit and apply the code
and just have to sort out the counting process and PINs.

You have saved me a lot of time and panadol. Regards..Peter
Muttley Snickers
 
Worm

Newbie

Joined: 30/06/2011
Location: New Zealand
Posts: 38
Posted: 01:06am 28 Sep 2011
Copy link to clipboard 
Print this post

Q. for Muttley. If you go down the track of using an encoder, how are you going to couple the encoder? The leadscrew will have back lash in the theads giving poor resolution. Normal postion sensors connect directly to the tool post or saddle.

Kevin
There's no such thing as a free lunch.
 
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 01:24am 28 Sep 2011
Copy link to clipboard 
Print this post

Good Day Kevin,
I have made and replaced the original leadscrew on the lathe,
and am aware of backlash issues related to rotary encoders
mounted on the leadscrew, I can adjust the play via a modified
leadscrew nut and bearing under the top slide and also keep the
gibbs firm.

On the CNC I have 16mm x 5mm pitch Ballscrews and have little
or no backlash. The intended DRO on the lathe is simply for repeatability
so that I may return to the same or near enough position after external
measurement with micrometers or verniers, PS: I am not an engineer, just
a precise hobby machinist.

Again Many Thanks...Peter

Muttley Snickers
 
Worm

Newbie

Joined: 30/06/2011
Location: New Zealand
Posts: 38
Posted: 01:38am 28 Sep 2011
Copy link to clipboard 
Print this post

Hi Peter.

All the best for your project. I will keep an eye on how you get on. Im in the proccess of looking for a lathe. Its a pain in the arse to use other peoples lathes. You do get used to your own, especialy if its an older lathe. My brothers lathe is in Sydney. A bit too far to travel.

Kevin
There's no such thing as a free lunch.
 
thetinkerer

Regular Member

Joined: 16/06/2011
Location: Australia
Posts: 68
Posted: 04:52am 28 Sep 2011
Copy link to clipboard 
Print this post

Hello Muttley,
Another option in regards to the actual measurement is something called a string encoder. This is an encoder with a spring loaded pulley(drum) which has a cable attached to it. you attach the encoder at the tailstock end and you attach the wire on the saddle. These come in incremental or absolute encoders and I have seen the incremental ones used on lathes and other machine DRO systems. The incremental encoders have a quadrature output as described in the link I posted.
 
Muttley Snicker

Newbie

Joined: 26/08/2011
Location: Australia
Posts: 18
Posted: 12:19pm 28 Sep 2011
Copy link to clipboard 
Print this post

Thanks The Tinkerer,

For my application I have not come up with anything better than
incremental rotary encoders but am open to suggestions.

As you are aware I could simply just bolt on a Mitutoyo, Sony
or Easson DRO but that would be to easy, and I would still have
the problem with swarf and coolant on the lathe.

Furthermore, I am learning ablout the SM1 and finding new applications
every day, most of which would be counting in one form or another.

And I now have a serious referance manual called GW Basic which was
all I needed to get a preview of what you others are seeing.

The main info that I found helpful was Geoffs LCD.BAS, where
he actually describes the function of the line statements.

Prior to obtaining a SM1 from Don I had always wanted to find a use
for all of the 16X2, 20X2 & 40X2 LCD modules that I had aquired over
the last 10 years or so from replaced alarm codepads, now I have a use.

Regards & Thanks Everybody...Muttley
(going to bed with my newly aquired GWBasic Manual)
Muttley Snickers
 
thetinkerer

Regular Member

Joined: 16/06/2011
Location: Australia
Posts: 68
Posted: 07:27am 30 Sep 2011
Copy link to clipboard 
Print this post

Hello Muttley,
Here is a Quadrature counter routine I rewrote.
10 XA=11'Quadrature input A on pin
15 XB=12'Quadrature input B on pin
30 SETPIN XA,6,100
35 SETPIN XB,6,200
50 LOCATE 10,10
60 PRINT count
70 GOTO 50
80 '
90 '**********************
100 'interrupt routine A
105 IF PIN(XB) THEN
110 Count = count + 1
115 ELSE
120 Count = count - 1
125 ENDIF
130 IRETURN
180 '
190 '**********************
200 'interrupt routine B
205 IF PIN(XA) THEN
210 Count = count - 1
215 ELSE
220 Count = count + 1
225 ENDIF
230 IRETURN

It only looks at the rising edge and there fore will only give you half the resolution. I guess that you could use another two inputs and trigger them on falling edge interrupts.

US digital make a range of chips that take quadrature inputs into the chip and you get pulse and direction out. This would be really good on the maximite as you would just set an interrupt on the pulse input thus capturing all pulses.

regards

Marc
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1344
Posted: 08:56am 30 Sep 2011
Copy link to clipboard 
Print this post

G'day Guy's,
A poor man's DRO on home machinery is everyone's dream and yes swarf can be a huge problem.
Now how's this for a way out idea.......

Jaycar do sell an ultrasonic chip fully sealed for a few $$$ and I have read they ain't the best but also I have read they can be a good sensor if they are fed around 90-100 volts for the 40khz pulse.

OK swarf could get in the way of a reading but with the amount of samples taken a second they can be cancelled out. The sensor could be mounted in a way it bounce a signal back to the sensor.

Now if one was to make the smarts for this why couldn't a ultrasonic sensor be used for a poormans DRO ????????
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024