mbed Datalogger for KOHZU SC-410 4Axis Controller and Micrometer which has RS232C output p30 TRG IN: TRG OUT(Linked to pulse motor Axis CW/CCW PULSE) of SC-410 *needs change opendrain mode, and pull up to +3.3 or +5V* p13 TRG OUT: 50Hz output of TRIGGER to Micrometer p10 Serial RX:Micrometer RS232C output, *CMOS LEVEL,Converter needed* mbed HDK Serial :Coupling Pulse count and RS232C data output

Dependencies:   mbed

mbed Datalogger Helper for KOHZU SC-410 4Axis Controller and Micrometer which has RS232C output.

Pin Assignment

  • p30 TRG IN: TRG OUT(Linked to pulse motor Axis CW/CCW PULSE) of SC-410 *needs change opendrain mode, and pull up to +3.3 or +5V*
  • p13 TRG OUT: 50Hz output of TRIGGER to Micrometer
  • p10 Serial RX:Micrometer RS232C output, *CMOS LEVEL,Converter needed*
  • mbed HDK Serial :Coupling Pulse count and RS232C data output

[SC-410 side]

                              +---vvvv------- VU (mbed +5V)
                              |
----|>o---------SC410TRG------+-------------- p13
                              |
----------------SC410GND------+-------------- GND (mbed GND)

[Micrometer Side]

        OC Driver(or PhotoCoupler)
p30 ----- |>o----- TRGIN (Micrometer)

GND -------------- GND (if needed)

p10 ------o<|----- RS232C TX
        LEVEL
      CONV(232C->CMOS)

Revision:
1:2ee96e43619f
Parent:
0:bfb59ebe2f4a
Child:
2:b3703b128b14
--- a/main.cpp	Mon Feb 10 07:47:19 2014 +0000
+++ b/main.cpp	Mon Feb 10 07:51:06 2014 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 
 Serial pc(USBTX,USBRX) ;
+Serial zw(p9,p10) ;
 InterruptIn TRG(p30) ;
 DigitalOut TRG_OUT(p13) ;
 DigitalOut led1(LED1),led2(LED2),led3(LED3),led4(LED4);
@@ -26,8 +27,14 @@
     }
 }
 
+char zwrxbuf[1024] = "---------------------------" ;
+int zwrxctr = 0;
+
+char sendbuf[] = "************" ;
+
 int main() {
     pc.baud(115200) ;
+    zw.baud(115200) ;
     TRG.mode(PullUp) ; 
   TRG.fall(trgon);
     timer.attach(timer1ms,0.001) ; // 1ms
@@ -37,7 +44,7 @@
             if (onctr >= 20) {
                 onctr = 0 ;
                 led4 = !led4 ;
-                pc.printf(":%d\r\n",edgectr) ;
+                pc.printf("%d,%s\r\n",edgectr,sendbuf) ;
             } else if (onctr >= 10) {
                 TRG_OUT = 0 ;   
             }   else {
@@ -48,7 +55,28 @@
         if (pc.readable()) {
             if (pc.getc() == '*') {
                 edgectr = 0 ;
-                pc.printf("+%d\r\n",edgectr) ;
+                for(int i=0;i<sizeof(sendbuf)-1;i++) {
+                    sendbuf[i] = '*' ;
+                }
+                pc.printf("%d,%s\r\n",edgectr,sendbuf) ;
+            }
+        }
+        
+        // read zw
+        if (zw.readable()) {
+            int c = zw.getc() ;
+            if (c != 0x0D) {
+                zwrxbuf[zwrxctr] = c ;
+                zwrxctr = (zwrxctr + 1) & 0xFF ;
+                led3 = !led3 ;
+            } else {
+                // copy
+                for(int i=0;i<sizeof(sendbuf)-1;i++) {
+                    sendbuf[i] = zwrxbuf[i] ;
+                }
+                // reset
+                zwrxctr = 0 ;
+                led2 = !led2 ;
             }
         }
     }