Modbus Help - MB2HAL
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
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 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
Please Log in or Create an account to join the conversation.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
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
Please Log in or Create an account to join the conversation.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
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
Please Log in or Create an account to join the conversation.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
Maybe I should RTFM before making an idiot of myself....OK, found I I can't load mb2hal in the named format, fails to load. That is unless I am doing something wrong.
#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.
- VNR
- Offline
- Senior Member
- Posts: 61
- Thank you received: 7
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.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
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.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
Please Log in or Create an account to join the conversation.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
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
Please Log in or Create an account to join the conversation.
- LearningLinuxCNC
- Offline
- Platinum Member
- Posts: 320
- Thank you received: 48
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
Please Log in or Create an account to join the conversation.
- racedirector
- Offline
- Elite Member
- Posts: 267
- Thank you received: 42
Off to try those settings
Please Log in or Create an account to join the conversation.