How to use a servo with in built 23bit Absolute encoder with kflop

Moderators: TomKerekes, dynomotion

User avatar
TomKerekes
Posts: 2559
Joined: Mon Dec 04, 2017 1:49 am

Re: How to use a servo with in built 23bit Absolute encoder with kflop

Post by TomKerekes » Tue Feb 09, 2021 1:53 pm

Hi Amit,
What kind of converter do you have?

I have below converter, and manual.

https://www.hexin-technology.com/shared ... Manual.pdf
https://www.hexin-technology.com/RS-232 ... t-257.html
It seems that converter uses a trick to get its power from the RTS and DTR signals which Kanalog does not have. The manual says to apply 5V or 12V to pin 6 if you don't have those. Did you do this?


Also because RS-485 is half duplex (it can't transmit and receive at the same time) it somehow needs to know which it should be doing. Its not clear how your converter does this. You might use a converter that states flow control signals are not required as Kanalog doesn't support RS232 flow control signals. It only supports Transmit and Receive signals.

How is it wired?

This connector has rs232 at one end and RS485 to the other end. Rs232 is wired with KANALOG JP10 with RJ12 connector, and RS485 is connected to LEADSHINE servo drive CN4 connector.
That's not telling us how it is wired. Specify what pins are connected to what.

What baud rate did you use on the PC?

I used 57600 baud rate, and i have changed the same in Modbusmasterver1.c also.
Please post the modified program.
Do you have an oscilloscope to check activity on the Kanalog Tx and Rx lines?

No.
Please get one
Regards,

Tom Kerekes
Dynomotion, Inc.

User avatar
cnc_freak
Posts: 55
Joined: Fri Apr 20, 2018 5:36 am

Re: How to use a servo with in built 23bit Absolute encoder with kflop

Post by cnc_freak » Tue Feb 09, 2021 10:12 pm

I have already show you where to but the address you want, with this picture.The highlighted area is the transmited address. In high byte you have to write 06 and in low the 02.
Attachments
Modbus1.JPG

AmitKumar171
Posts: 134
Joined: Tue Feb 20, 2018 7:35 am
Location: India

Re: How to use a servo with in built 23bit Absolute encoder with kflop

Post by AmitKumar171 » Wed Feb 17, 2021 9:50 am

Hi tom and cnc_freak

Thanks for your replies.

I got one rs485 to rs232 converter without flow control and i have done wiring according to the description mentions in kflop and leadshine manual and after running modbus master init v1, i am getting attached console response.
Screenshot (119).png
Please tell me how to send the 0x602c, this address. this register holds the current absolute positions of motor in leadshine.

I have modified some code in modbus master init v1 and attached same.
ModbusMasterVer1.c
(16.34 KiB) Downloaded 47 times
Please help on getting absolute position from leadshine drive.

Waiting for your kind reply.
Thank You

AMIT KUMAR

User avatar
TomKerekes
Posts: 2559
Joined: Mon Dec 04, 2017 1:49 am

Re: How to use a servo with in built 23bit Absolute encoder with kflop

Post by TomKerekes » Wed Feb 17, 2021 4:04 pm

Hi Amit,

It now seems to be communicating without errors.

You told us it worked with the PC but never told us anything about what you did or what kind of data you received.

Right now your code:

Code: Select all

	{"\x01\x04\x60\x2C\x00\x01", 6, 0},	// Read inputs to MBRegisters[0]
Reads one 16 bit register. To get 23 bits of data you will need to read more than one 16-bit register. So you probably need to change to read 2 registers:

Code: Select all

	{"\x01\x04\x60\x2C\x00\x02", 6, 0},	// Read encoder data to MBRegisters[0] and MBRegister[1]


Then change the RegUnload function to put the data somewhere for you to view. Such as:

Code: Select all

// marshal and move values read from PLC/Slave into MBRegisters to KFlop memory
void ModbusMaster_RegUnload()
{
    persist.UserData[150]= MBRegisters[0];  // put read encoder registers into global memory
    persist.UserData[151]= MBRegisters[1];
}
Then display the global registers in the Console to see if they make sense with:
GetPersistDec150;GetPersistDec151

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply