Modbus Help - MB2HAL

More
26 Jun 2015 21:58 - 26 Jun 2015 21:59 #60163 by racedirector
Replied by racedirector on topic Modbus Help - ClassicLadder
Thats excellent to hear Victor, finally getting something right in LCNC! :) Thanks for your input, appreciated.

One more question if I can. I need to connect the hal spindle pins to the mb2hal component before testing them don't I? I tried doing mb2hal.spindlerun.0 = 1 and halrun didn't know what I was talking about. For example
net spindle-speed motion,spindle,speed-out => mb2hal.spindlefreq
I'm still trying to find the hal pins to connect to.....

I am also seeing if I can connect a few more coils to mb2hal: #13 to tell if the spindle is stopped or running, #14 to see if it is going CW or CCW, #23 I think indicates the spindle is at the set frequency/speed and then #19 to tell me if the VFD is in alarm or not. Whether that works or not is an unknown qty :)

Cheers
Bruce
Last edit: 26 Jun 2015 21:59 by racedirector.

Please Log in or Create an account to join the conversation.

More
27 Jun 2015 17:50 - 27 Jun 2015 17:51 #60181 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
Just wanted to check a couple of things...

Loading mb2hal.... am I correct in using this to name it x200-vfd? loadusr -Wn x200-vfd mb2hal -n x200-vfd My ini file is called x200-vfd and I have named mb2hal internally to x200-vfd.

I also figured out how to set the pins in hal run using setp and actually got the spindle to run. Real pleased with that!!!

Implementing all this in my hal file, can someone confirm I need to use the motion.spindle pins? I see there is also halui.spindle pins but I assume they are for the user interface side of things.

Almost there...

Cheers
Bruce
Last edit: 27 Jun 2015 17:51 by racedirector.

Please Log in or Create an account to join the conversation.

More
27 Jun 2015 21:14 - 27 Jun 2015 21:15 #60185 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
OK, found I I can't load mb2hal in the named format, fails to load. That is unless I am doing something wrong.

I have another problem. I am trying to read a bunch of coils to give me information on the status of the drive. I am using fnct_15_write_multiple_coils as none of the others seem to fit. In the coil list a few posts above I am looking at:

0003h External Trip
0004h Trip Reset
000Eh Run/Stop Status
000Fh FW/RV status
0010h Inverter Ready
0014h Alarm Signal
0018h Frequency Arrival Signal

Based on my previous success at numbering the elements I am assuming the following:

0003h -s element 2, 0004h = 3, 00Eh = 12, 00Fh = 13, 0010h = 14, 0014h = 18, 0018h = 22

which I set up in my ini file (attached). However I am getting errors coming back from mb2hal for those settings. I am also attaching a screenshot of a couple of the errors. Oh, and al the pins are there because I was trying something different but the errors remained the same.

Does anyone know what is possibly going wrong?

Cheers
Bruce
Attachments:
Last edit: 27 Jun 2015 21:15 by racedirector.

Please Log in or Create an account to join the conversation.

More
28 Jun 2015 07:31 #60206 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL

OK, found I I can't load mb2hal in the named format, fails to load. That is unless I am doing something wrong.

Maybe I should RTFM before making an idiot of myself....

#Using HAL_MODULE_NAME=mymodule: loadusr -Wn mymodule mb2hal config=config_file.ini


Lesson learned...

Please Log in or Create an account to join the conversation.

More
29 Jun 2015 22:07 #60253 by VNR
Replied by VNR on topic Modbus Help - MB2HAL

I have another problem. I am trying to read a bunch of coils to give me information on the status of the drive. I am using fnct_15_write_multiple_coils as none of the others seem to fit. In the coil list a few posts above I am looking at:

0003h External Trip
0004h Trip Reset
000Eh Run/Stop Status
000Fh FW/RV status
0010h Inverter Ready
0014h Alarm Signal
0018h Frequency Arrival Signal


You cannot "read" using "write" functions
use fnct_02_read_discrete_inputs for single (true/false) status
or use fnct_03_read_holding_registers for registers containing values

Please Log in or Create an account to join the conversation.

More
30 Jun 2015 19:18 #60286 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
Thanks Victor

Something weird is going on right now, suddenly the VFD has started not responding to my run command. It will start after about 5 minutes then I can't stop it unless I exit halrun and reload the mb2hal. Trying to figure that one out.

Please Log in or Create an account to join the conversation.

More
01 Jul 2015 15:37 #60306 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
Think I may have the answer, the PC is playing silly buggers. Currently formatting another machine so I can set that one up and test.

Please Log in or Create an account to join the conversation.

More
03 Sep 2015 15:55 - 03 Sep 2015 15:56 #62077 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
So after a couple of months away from my machine I finally have the VFD talking to LinuxCNC, well actually the other way around. I had to write another function into mb2hal to read coils so I could read the status of at-speed and will now plug in a few other checks like I had planned.

A couple of things have me stumped however and I am hoping someone can help.

I am connecting mb2hal to LinuxCNC via the motion.spindle hal pins. This is what I have in my blacksheep.hal file:
loadusr -Wn x200 mb2hal config=x200vfd.ini

net x200-run x200.run.00 <= motion.spindle-on
net x200-dir x200.direction.00 <= motion.spindle-forward 
net x200-RPM x200.frequency.00 <= motion.spindle-speed-out
net x200-at-speed x200.at-speed.00 <= motion.spindle-at-speed

setp x200.direction.00 0

A couple of problems exist.

1. The direction coil in the X200 is either 1 (REV) or 0 (FWD). As you can see I am trying to fix that in place with the setp command. However, the motion.spindle-forward command is actually making the spindle turn in REVerse. DO I have this connected wrong? M3 turns it on but the direction is wrong, M4 also turns it on but the direction is CORRECT. I thought M3 with CW and M4 was CCW?

2. The speed/frequency is incorrect for the speed setting command. During my tests I found that setting the speed to, say, 2400 the spindle would be at 400Hz or 24,000rpm. So at the moment a speed command of S12000 is causing the VFD to run the spindle at 24,000 or 400Hz as 12,000 is more than 2400... if you catch my drift. So do I need to plus a scale object in there somewhere? The docs for scale a real lean so I have no idea how to use it, would appreciate some pointers to its use.

Any help would be appreciated

Cheers
Last edit: 03 Sep 2015 15:56 by racedirector.

Please Log in or Create an account to join the conversation.

  • LearningLinuxCNC
  • LearningLinuxCNC's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
More
03 Sep 2015 19:34 #62079 by LearningLinuxCNC
Replied by LearningLinuxCNC on topic Modbus Help - MB2HAL
you have spindle speed directly tied to frequency. So if you have a spindle speed of greater than 400 it is going to the max freq of the drive which would be 400. That is why you are getting the same results for 24000 and 12000. You need to scale spindle speed to the frequency so if 24000 = 400 hz then your scale would be 0.016666667 so you would do the following.
loadusr -Wn x200 mb2hal config=x200vfd.ini

loadrt scale.1
addf scale.1 servo-thread

scale.1.gain = 0.0166667

net spindle-speed scale.1.in <= motion.spindle-speed-out
net x200-freq x200.frequency.00 <= scale.1.out

net x200-run x200.run.00 <= motion.spindle-on
net x200-dir x200.direction.00 <= motion.spindle-forward 

net x200-at-speed x200.at-speed.00 <= motion.spindle-at-speed

setp x200.direction.00 0
 
The following user(s) said Thank You: racedirector

Please Log in or Create an account to join the conversation.

More
03 Sep 2015 19:57 #62081 by racedirector
Replied by racedirector on topic Modbus Help - MB2HAL
Thank you sir, brilliant. I could kiss you if a) you weren't in another country and b) a man! :)

Off to try those settings

Please Log in or Create an account to join the conversation.

Time to create page: 0.098 seconds
Powered by Kunena Forum