|
|
View previous topic :: View next topic |
Author |
Message |
pekka1234
Joined: 28 May 2017 Posts: 83
|
Mitutoyo problem |
Posted: Tue Nov 26, 2024 7:27 am |
|
|
Hey, I have tried to read Mititutoyo micrometer with PIC18F2550, with 20MHz crystal with USB connection.
I know that it is not an easy case, although I did it 1988 to Finnish paper factory. I need only 8555 card and a normal PC. It was an easy cake.
I have tried four different devices, but nothing happens.
Only in Request pin rises to 1.5V. When RD pin should go to low I should Request also low and in Data and clock should give 13 data.
I have tried to rise data, clock and RD pins with 22kohm to 5V.
Trey rise to 5V, but nothing happens.
Maybe some of you have heard this device and maybe help me.
Here are the pictures of my Mitutoyo devices
https://probyte.fi/Picture.jpg
and here is the schematic
http://probyte.fi/MITsch.jpg
Here is how the signal should work
http://probyte.fi/Mitu.jpg
And here my code
Code: | /* Mitsutoyo micrometer reading to PC:lla by USB
Pekka Ritamäki
date: 19.11.2024
file Mitu1.c
it has PIC18F255 USB device with 20MHz Crystal
It has 5 wires to mirodata device.
USB signals work, but data from Mitutoyo does't
These are Mitotoyo wires
Pin 1 = gnd
Pin 2 = RD
Pin 3 = Clock
Pin 4 = Data
Pin 5 = Request this is only output pin, but only low
it is normally 1.5V, but when you saw PIN 2(RD) to go 0V,
you give 100-200 us Low pulse to REQUEST and then 13 bits data to come out with the clock
*/
#include <18F2550.h>
#fuses HSPLL, PLL5, CPUDIV1, USBDIV, NOWDT, NOLVP, NODEBUG, NOCPB
#use delay(clock=48000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <string.h>
#include <ex_usb_common.h>// this iss CCS given USB converter
#include <usb_cdc.h>
#define CLOCK_PIN PIN_B2
#define DATA_PIN PIN_B3
// Data length 13 bits Mitutoyo-mikrometer)
#define DATA_BITS 13
//===
#define RD1 PIN_B1
#define REQ1 PIN_B0
#define Data1 PIN_B3
#define CLOCK1 PIN_B2
#define LED1 PIN_A4
#define MAXDATA 5
#define RD3 PIN_A2
#define REQ3 PIN_A3
#define Data3 PIN_A0
#define CLOCK3 PIN_A1
#define LED3 PIN_C0
#define NEGATIVE 0b1000
int8 xdata1[5]={"-23456"};
int8 neg1;
// this function is got from outside, but it doesn't work '
int16 read_micrometer_data() {
int16 data = 0;
output_toggle(LED1 );
delay_ms(199);
output_toggle(LED1 );
//wait (CLOCK -> 0 and ->1 )
while (input(CLOCK_PIN) == 1); //CLOCK -> 0
output_low(REQ1) ;
delay_us(150);
output_float(REQ1);
while (input(CLOCK_PIN) == 0); //Wait CLCOK -> 1
// read 13 bits with CLOCK sync
for (int i = 0; i < DATA_BITS; i++) {
while (input(CLOCK_PIN) == 1); // //CLOCK ->
data <<= 1; // move lower bits left
if (input(DATA_PIN)) {
data |= 1; // add a 1 bit, if the DATA is HIGH
}
output_toggle(LED1 );
while (input(CLOCK_PIN) == 0); //Wait CLCOK -> 1
}
printf(usb_cdc_putc, "OK %ld\r",data);
return data;
}
// read1 data, clock, first wait RD-> 0 and give low ->request puls and read
void read1 ()
{
int8 i,j;
output_high (LED1); // put led1 off
While ( RD1); // wait ->0V
output_low(LED1); //put led1 on
output_low (REQ1) ; // keep REQ1 bit low
delay_us(400); // 100us puls ito Mitutoyo
output_float(pin_B0); //set REQ pin floating
for (i=0; i<4; i++) // read four bitsä fot - marking
{
While (!input(CLOCK1)) ; // wait -> 1
neg1 += input(DATA1)<<i ; // raad data
While (input(CLOCK1)) ; // wait -> 0
printf(usb_cdc_putc,"1 neg %x\r", neg1);
for (i=0; i<MAXDATA; i++) // Reaf 5 *4 bIts
{
for(j=0;i<4;j++) { // read 4 bits
While (!input(CLOCK1)) ; // wait till goes -> 1)
xdata1[i] += input(DATA1)<<j ; // read 0. bit to lower
ouTput_toggle(LED1);
While (input(CLOCK1) ); // wait ->0
}
printf(usb_cdc_putc,"%d neg %x\r", i ,xdata1[i]);
output_low (LED1); // led1 off
}
}
}
//#include <usb_cdc.h>
void usb_debug_task(void)
{
static int8 last_connected;
static int8 last_enumerated;
int8 new_connected;
int8 new_enumerated;
new_connected=usb_attached();
new_enumerated=usb_enumerated();
if (new_connected && !last_connected)
{
uart_printf(uart_putc, "\r\n\nUSB connected, waiting for enumaration...");
}
if (!new_connected && last_connected)
{
uart_printf(uart_putc, "\r\n\nUSB disconnected, waiting for connection...");
}
if (new_enumerated && !last_enumerated)
{
uart_printf(uart_putc, "\r\n\nUSB enumerated by PC/HOST");
}
if (!new_enumerated && last_enumerated)
{
uart_printf(uart_putc, "\r\n\nUSB un-enumerated by PC/HOST, waiting for enumeration...");
}
last_connected=new_connected;
last_enumerated=new_enumerated;
}
//
void main ()
{
int8 i;
usb_init () ;
for(i=0;I< 10;i++)
{
printf(usb_cdc_putc, "Mitutoyo %d \r" ,i ); // some testing
delay_ms(1000);
output_toggle(PIN_A4) ;
}
set_tris_B(0xFF-1 ); // All high, but no PIN B0
set_tris_C(0xFF-9); // Put C4 to LED
while(1 )
{
usb_task();
usb_debug_task();
printf(usb_cdc_putc, "Now start Req ->low \r" );
while(1)
read1();
}
} |
Can you show any code for Mitutouo?
Pekka |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9232 Location: Greensville,Ontario
|
|
Posted: Tue Nov 26, 2024 9:11 am |
|
|
1st important question
Which 'micrometer' model ?? !!
Decades ago,' prePIC', I had to use 'logic level interface' as Mitty unit was battery powered. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Tue Nov 26, 2024 9:52 am |
|
|
Yes. I too have used them. Most are 1.5v devices. You need logic level
translation between 5v and 1.5v logic. The signal going to 1.5v, says
your device is the same. |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
Mitutoyo |
Posted: Tue Nov 26, 2024 10:20 am |
|
|
I have four different micrometer
One is round 543-601B original Mitutoyo. It 5mm length
One is about 40 years old Mitutoyo Absolute Digimatic the model has already removed, Oy is normal 150mm length.
Then I have quite new Powerfix (it is a similar to Mitutoyo) model 2285F . It is 150 mm length.
Then I have 1 meter Mitutoyo, but I it now out of my house
All they have 6 mm width , 5 pin connection.
The right pin is in all GND and the left pin is Request, 1.5V , it should go to ground. when RD (pin 2) goes low. Then there are CLK 3 and Data 4. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Thu Nov 28, 2024 8:45 am |
|
|
Yes, but these output signals need level translation. The REQ pin should
be pulled down by a FET.
Your connections should be:
N channel FET. One with a gate volt of only perhaps 3v.
PIC to gate of FET. FET source to GND. FET drain to REQ.
Then CLK and DATA each with a pull-up resistor to 1.55v, connected
to inputs of CMOS buffer gates.
Mitotoyo used to do a page in one of their data sheets, showing this
wiring.
You pulse REQ (turn your PIC output high to turn the FET on). The
unit should reply with data and the clock. The data bit should appear
within about 95uSec (memory here).
You can sample the data on either clock edge. The sequence is data
appears, then the clock drops/rises, then another data bit. The data
is sent just over 2000bps.
The data packet is 13 nibbles. 4 are just 1111, then 0000 or 0001 for +/-,
followed by 6 BCD digits, then a binary code 0100, 1100, 0010, or 1010
for 2,3,4 or 5 decimal places. finally 0000 or 0001 for mm/inch
The circuit you show is the wrong way round. REQ is an input to the
micrometer and needs to be pulled down. The outputs need the CMOS
gates you show. You really need to be using a FET, not a bipolar transistor
for the pull-down. This has to go below 0.4v and the diode drop in a
transistor won't give this. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|