Announcement

Collapse
No announcement yet.

RFiD reader serial communication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RFiD reader serial communication

    Hi,

    have rfid reader Promag RF320R and GEN4-ULCD-32DT.
    https://www.promageurope.com/product...f310-rf320.htm
    RF320R output <frame start>tag ID<frame end> every time a rfid tag is read.

    Is there a way to simple display tag ID on ULCD-32DT?

    RF320R has output interface "RS232(UART)" or optinal "RX Line select". Baudrate 9600,N,8,1

    Have tried:

    In PostGenieInit:
    COM1_RX_pin(PA12) ; // meets GEN4-PA GPIO13
    COM1_TX_pin(PA13) ; // meets GEN4-PA GPIO14

    In MainLoop:
    gfx_MoveTo(0,0);
    if(com1_Error())
    print("COM1 ERROR") ;
    endif

    var char;
    gfx_MoveTo(0,20);
    char := serin1();
    if (char)
    print("char: ", char, " ");
    endif


    Result= char:-1

    Best Regards
    Doms

  • #2
    Hello Doms

    you will need to initalize the com port and declare a buffer

    in Globals/Data

    var combuf1[20];

    and after you set the COM1 pins

    com_SetBaud(COM1, 960);
    com_Init(combuf1,20,0);

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      Hi Pauleilo,
      thank you for your support. Have added code as you wrote but doesn´t work.

      Here my actually code:

      In PostGenieInit:
      COM1_RX_pin(PA12) ; //meets GEN4-PA GPIO13
      COM1_TX_pin(PA13) ; //meets GEN4-PA GPIO14
      com1_Count() ;
      com_SetBaud(COM1, 960);
      com_Init(combuf1,20,0);

      In Constant/Global/Data:
      var combuf1[20];

      In MainLoop:
      if(com1_Error())
      gfx_MoveTo(0,0);
      print("COM1 ERROR") ;
      endif

      var port;
      gfx_MoveTo(0,20);
      port := com_SetBaud(COM1, 960) ;
      if (port)
      print("COM1 set to 9600 Baud");
      endif

      var char;
      gfx_MoveTo(0,40);
      char := serin1();
      if (char)
      print("char: ", char, " ");
      endif

      var bufnum ;
      gfx_MoveTo(0,60) ;
      bufnum := com1_Count(); // get the number of chars available in the buffer
      if (bufnum)
      print("Im Buffer: ", bufnum, " ");
      endif



      Display output:
      COM1 set to 9600 Baud
      char:-1

      Tried it with output interface "RS232(UART)" and "RX Line select".on RF320R. Same result.
      In simple port listerner on pc i can see output is <STX>2750490458<ETX> with test rfid tag.

      Any idea how to make it work?

      Best regards
      Doms

      Comment


      • #4
        Hi Doms,

        It might be that you have the 310R instead of the 310L

        RF310R RS232
        RF310L Serial (UART)

        The information in the datsheet is not very good but I would guess that the RF310L is TTL Serial UART which is what you need to connect to the display.

        I will see if I can find some more information about the different versions.

        Best regards

        Paul

        Comment


        • #5
          Hi Paul,

          just ordered RF320L 13.56MHz Serial (UART) module.
          Should be delivered next week.

          BR
          Doms

          Comment


          • #6
            Weeks later....
            I got RF320L serial UART reader. Tried it with code above.

            Display output:
            COM1 set to 9600 Baud
            char:-1
            in Buffer : 0

            When reading RFiD Tag "char" value changes from : -1 to : -2.
            According to manual -2 is framing error?
            Need help solving this problem.

            Best Regards

            Doms
            Attached Files

            Comment


            • #7
              Hi Doms,

              Looking at the datasheet it says the baud rate is 19200. Can you try changing the Com1 baud rate.

              com_SetBaud(COM1, 1920);

              Best regards

              Paul

              Comment


              • #8
                Sorry, thats right but reader baud rate should be changed to 9600 too.

                Now reader is set to19200 Baud and added in Constant/Global/Data:
                var port ;

                In PreGenieInit:
                com_SetBaud(COM1, 1920) ;

                In MainLoop:
                gfx_MoveTo(0,20);
                port := com_SetBaud(COM1, 1920) ;
                if (port)
                print("COM1 set to: ",port, " ");
                endif


                Display output:
                COM1 set to: 146
                When reading RFiD Tag "char" value still changes from : -1 to : -2.

                Best Regards

                Axel

                Comment


                • #9
                  Hi Axel,

                  I noticed an error in the com_init line

                  it should be

                  In PostGenieInit:
                  COM1_RX_pin(PA12) ; //meets GEN4-PA GPIO13
                  COM1_TX_pin(PA13) ; //meets GEN4-PA GPIO14
                  com1_Count() ;
                  com_SetBaud(COM1, 960);
                  com1_Init(combuf1,20,0);

                  Could you post your full code here again, just so I can see how the baud rate for the device is changed.

                  Best regards

                  Paul

                  Comment


                  • #10
                    Hi Paul,

                    yes the com_init line was the Problem.
                    Now it works, Tag ID is displayed on screen.

                    Will continue with next step, sending Tag ID to unit on COM2.
                    When problems occur.......and I am sure there are problems ;-), post here.

                    Thank you

                    Code:

                    In Constant/Global/Data
                    var port ;
                    var char ;
                    var bufnum ;
                    var combuf1[20] ;
                    var cero ;

                    In PreGenieInit:
                    COM1_RX_pin(PA13) ;
                    COM1_TX_pin(PA12) ;
                    com_SetBaud(COM1, 1920) ;
                    com1_Init(combuf1,20,0) ;
                    serin1() ;
                    com1_Count() ;
                    com1_Error() ;


                    In MainLoop:
                    cero := com1_Error() ;
                    gfx_MoveTo(0,0);
                    if (cero)
                    print("COM1 ERROR:", cero, " ") ;
                    endif

                    gfx_MoveTo(0,20);
                    port := com_SetBaud(COM1, 1920) ;
                    if (port)
                    print("COM1 set to: ",port, " ");
                    endif

                    gfx_MoveTo(0,40) ;
                    bufnum := com1_Count();
                    if (bufnum >= 0)
                    print("In Buffer: ", bufnum, " ");
                    endif

                    gfx_MoveTo(0,60) ;
                    char := serin1();
                    if (char)
                    print("char: ", char, " ");
                    endif

                    repeat
                    gfx_MoveTo(0,80) ;
                    until (com1_Count () > 11) ;
                    print ("\Tag ID:\n") ;

                    gfx_MoveTo(0,120) ;
                    n := 16;
                    while (n--)
                    putch (serin1 ()) ;
                    wend

                    Display output when Tag read:
                    COM1 set to : 226
                    In Buffer : 2
                    char : 10

                    Tag ID: 8051DCAA460D04

                    Comment


                    • #11
                      Hi Paul,

                      now i want theTag ID read on COM1 -> output on COM2. Have connected GEN4-ULCD-32DT. to PC with serial sniffer program
                      and added code for output on COM2.: to (COM2); putch (serin1()) ; but no Data In serial sniffer.
                      Display output and cliearing works fine.

                      In Constant/Global/Data
                      var port1 ;
                      var port2 ;
                      var char ;
                      var bufnum ;
                      var combuf1[20] ;
                      var cero1 ;
                      var cero2 ;
                      var n ;

                      In PreGenieInit:
                      COM1_RX_pin(PA13) ;
                      COM1_TX_pin(PA12) ;
                      COM2_RX_pin(PA6) ;
                      COM2_TX_pin(PA7) ;
                      com_SetBaud(COM1, 1920) ;
                      com_SetBaud(COM2, 1920) ;
                      com1_Init(combuf1,20,0) ;
                      serin1() ;
                      com1_Count() ;
                      com1_Error() ;
                      com2_Error() ;

                      In MainLoop:
                      cero1 := com1_Error() ;
                      gfx_MoveTo(0,0);
                      if (cero1)
                      print("COM1 ERROR:", cero1, " ") ;
                      endif

                      cero2 := com1_Error() ;
                      gfx_MoveTo(0,20);
                      if (cero2)
                      print("COM1 ERROR:", cero2, " ") ;
                      endif

                      gfx_MoveTo(0,40);
                      port1 := com_SetBaud(COM1, 1920) ;
                      if (port1)
                      print("COM1 set to: ",port1, " ");
                      endif

                      gfx_MoveTo(0,60);
                      port2 := com_SetBaud(COM1, 1920) ;
                      if (port2)
                      print("COM2 set to: ",port2, " ");
                      endif

                      repeat
                      gfx_MoveTo(0,80) ;
                      bufnum := com1_Count();
                      if (bufnum >= 0)
                      print("In Buffer: ", bufnum, " ");
                      endif

                      //var char;
                      gfx_MoveTo(0,100) ;
                      char := serin1();
                      if (char)
                      print("char: ", char, " ");
                      endif

                      gfx_MoveTo(0,120) ;
                      until (com1_Count () > 8) ;
                      print ("\Tag ID:\n") ;

                      gfx_MoveTo(60,120) ;
                      n := 16;
                      while (n--)
                      putch (serin1()) ;
                      to (COM2); putch (serin1()) ;
                      wend

                      pause (3000) ;
                      gfx_Cls () ;

                      n:=sizeof(combuf1);
                      while(n--)combuf1[n]:=0;

                      Comment


                      • #12
                        Hi,

                        You could just try using the serout2 command eg

                        gfx_MoveTo(60,120) ;
                        var rec
                        n := 16;
                        while (n--)
                        rec := serin1() ;
                        putch(rec);
                        serout2(rec) ;
                        wend

                        Best regards

                        Paul

                        Comment


                        • #13
                          Hi Paul,

                          works fine, thank you.
                          Have one more problem don´t know what to do.
                          ID from my test tag is A3 F1 27 5A

                          When connecting reader direct to RS232 port on PC and sniffer -> every time the tag id is read correctly.: A3 F1 27 5A

                          When connecting reader to COM1 on GEN4-ULCD-32DT and print Tag ID to screen -> very often (but not always) the first A is lost -> 3 F1 27 5A

                          Is there anything to change at buffersize?

                          Best Regards

                          Doms

                          Comment


                          • #14
                            Hi Doms,

                            Your buffersize should be ok at 20 but increase it if you want. It seems more like that the first A is being lost because of being out of sync. Does the RFID reader send out a terminaitng character at the end of the tag that you could use to read until the terminating character is reached.

                            Best regards

                            Paul

                            Comment


                            • #15
                              Hi Paul,

                              could solve the problem witk lost A.
                              Now i've added two Winbutton and try following process:
                              Scan Tag ID on Reader connected to COM1-> works
                              Add ",1" to Tag ID and output all on COM2 when WinButton0 touched or add ",2" to Tag ID and output all on COM2 when WinButton1 touched -> doesn't work.

                              I can output Tag ID to COM2 when WinButton touched but don't know how to add values to Tag ID..

                              Best Regards

                              Doms

                              In Constant/Global/Data
                              var port1 ;
                              var port2 ;
                              var char ;
                              var bufnum ;
                              var combuf1[20] ;
                              var outbufstring[30] ;
                              var cero1 ;
                              var cero2 ;
                              var n ;

                              In PreGenieInit:
                              COM1_RX_pin(PA13) ;
                              COM1_TX_pin(PA12) ;
                              COM2_RX_pin(PA6) ;
                              COM2_TX_pin(PA7) ;
                              com_SetBaud(COM1, 1920) ;
                              com_SetBaud(COM2, 1920) ;
                              com1_Init(combuf1,20,0) ;
                              serin1() ;
                              com1_Count() ;
                              com1_Error() ;
                              com2_Error() ;

                              In MainLoop:
                              cero1 := com1_Error() ;
                              gfx_MoveTo(0,0);
                              if (cero1)
                              print("COM1 ERROR:", cero1, " ") ;
                              endif

                              cero2 := com1_Error() ;
                              gfx_MoveTo(0,20);
                              if (cero2)
                              print("COM1 ERROR:", cero2, " ") ;
                              endif

                              gfx_MoveTo(0,40);
                              port1 := com_SetBaud(COM1, 1920) ;
                              if (port1)
                              print("COM1 set to: ",port1, " ");
                              endif

                              gfx_MoveTo(0,60);
                              port2 := com_SetBaud(COM1, 1920) ;
                              if (port2)
                              print("COM2 set to: ",port2, " ");
                              endif

                              gfx_MoveTo(0,80) ;
                              bufnum := com1_Count();
                              if (bufnum >= 0)
                              print("In Buffer: ", bufnum, " ");
                              endif


                              gfx_MoveTo(0,100) ;
                              char := serin1();
                              if (char)
                              print("char: ", char, " ");
                              endif

                              In MagicTouch
                              if (ImageTouched == iWinbutton0)
                              to(outbufstring) ; putch (char);
                              to(APPEND) ; putch (",1");
                              to (COM2); print([STR] outbufstring);
                              n:=sizeof(combuf1);
                              while(n--)combuf1[n]:=0;
                              n:=sizeof(outbufstring);
                              while(n--)outbufstring [n]:=0;

                              else if (ImageTouched == iWinbutton1)
                              to(outbufstring) ; putch (char);
                              to(APPEND) ; putch (",2");
                              to (COM2); print([STR] outbufstring);
                              n:=sizeof(combuf1);
                              while(n--)combuf1[n]:=0;
                              n:=sizeof(outbufstring);
                              while(n--)outbufstring [n]:=0;

                              endif

                              Comment

                              Working...
                              X