kanber Posted June 26, 2013 Share Posted June 26, 2013 Hi, I have one device that need to sent multi coil write function( 0F hex, 15 ascii code), I can sent the date with monitor to write "\x01\x0F\x01\x40\x00\x08\x01\x03\xBE\x8A" and it is working. Is there any option to do wtih channels? I tried also Device.mydevice.write("\x01\x0F\x01\x40\x00\x08\x01\x03\xBE\x8A"). but not work also, I also attached fan.jpg file which is showing Coil W/R table. I need to read also this channels Link to comment Share on other sites More sharing options...
AzeoTech Posted June 26, 2013 Share Posted June 26, 2013 You can do coil writes with channels, but they are one bit a time. To do a whole word (16 bits) you have to use the Modbus function: device.myDevice.forceCoil() I believe it is. Link to comment Share on other sites More sharing options...
kanber Posted June 27, 2013 Author Share Posted June 27, 2013 Are you saying to add this channel like force coil? and it will be work? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 27, 2013 Share Posted June 27, 2013 A force coil channel allows you to set or clear a single coil bit. It does not allow you to set more than one bit per query. If you want to set an entire word worth of bits you have to use the forceCoil() function from a sequence. DAQFactory treats coils and input status as individual bits. For 99.9% of applications, this is what customers want, and is most convenient. For cases where you really need to set multiple bits at once, there is the forceCoil() function. Note that for reading input or coil status, you can use channels and DAQFactory will automatically block the channels. It just won't block for outputs when using output channels. Link to comment Share on other sites More sharing options...
kanber Posted June 28, 2013 Author Share Posted June 28, 2013 Hello, thanks for answer. but I tried with forcecoil function like below switch case(butonno == 1) device.VRVMod.ForceCoil(1,168,{1,0,0,0,0,0,0,0}) case(butonno == 2) device.VRVMod.ForceCoil(1,168,{0,1,0,0,0,0,0,0}) case(butonno == 3) device.VRVMod.ForceCoil(1,168,{1,1,0,0,0,0,0,0}) case(butonno == 4) device.VRVMod.ForceCoil(1,168,{0,0,1,0,0,0,0,0}) case(butonno == 5) device.VRVMod.ForceCoil(1,168,{1,0,1,0,0,0,0,0}) case(butonno == 6) device.VRVMod.ForceCoil(1,168,{0,1,1,0,0,0,0,0}) case(butonno == 7) device.VRVMod.ForceCoil(1,168,{1,1,1,0,0,0,0,0}) endcase but there is check sum problem I think. I didnt try with device yet. I dont know it will work or not? Tx: \x01\x0F\x00\xA8\x00\x08\x01\x01^\x8D //ıt should be 5E8D Can it be In char? why it is not showing in hex? Tx: \x01\x0F\x00\xA8\x00\x08\x01\x02\x1E\x8C //OK Tx: \x01\x0F\x00\xA8\x00\x08\x01\x03\xDFL //ıt should be DF4C Can it be In char? why it is not showing in hex? Tx: \x01\x0F\x00\xA8\x00\x08\x01\x04\x9E\x8E //OK Tx: \x01\x0F\x00\xA8\x00\x08\x01\x05_N //ıt should be 5F4E Can it be In char? why it is not showing in hex? Tx: \x01\x0F\x00\xA8\x00\x08\x01\x06\x1FO //ıt should be 1F4F Can it be In char? why it is not showing in hex? Tx: \x01\x0F\x00\xA8\x00\x08\x01\x07\xDE\x8F //OK Link to comment Share on other sites More sharing options...
AzeoTech Posted July 1, 2013 Share Posted July 1, 2013 By default the DAQFactory monitor shows any byte between 32 and 127 as its ASCII equivilent. That's why 5E is showing up as ^, and 4C as L, etc. There is an option in the monitor that forces all characters to display in their numeric form (hex or decimal depending on a different setting). Link to comment Share on other sites More sharing options...
SteveMyres Posted July 1, 2013 Share Posted July 1, 2013 Instead of the case structure, compute the data array device.VRVMod.ForceCoil(1,168, 1 - Transpose(To.Bit(255 - buttono), 0)[0,7])[/CODE]I think you could also NOT the Transpose, but I forget the operator. Link to comment Share on other sites More sharing options...
AzeoTech Posted July 1, 2013 Share Posted July 1, 2013 Steve is right, but you don't need the transpose or the 255 - part. The 255 - part inverts, and then the 1 - inverts back. You just need: device.VRVMod.forceCoil(1, 168, (To.Bit(buttono))[0][0,7]) Link to comment Share on other sites More sharing options...
SteveMyres Posted July 3, 2013 Share Posted July 3, 2013 Achhhh -- I was looking at the array and thinking "MSB on the left, LSB on the right" like when you display a binary number. D'oh! I didn't think of subsetting the To.Bit() return column-wise on the fly instead of using Transpose(). Cool! Link to comment Share on other sites More sharing options...
SteveMyres Posted July 7, 2013 Share Posted July 7, 2013 Now, (To.Bit(buttono))[][0,7] will still return the bits as a 2D array; {{1,1,1,0,0,0,0,0}} rather than {1,1,1,0,0,0,0,0} Will that work OK in the Modbus call? If so, that will simplify some things for me. For some reason I thought the data array had to be 1D. Link to comment Share on other sites More sharing options...
AzeoTech Posted July 8, 2013 Share Posted July 8, 2013 It is still 1D, its just in a different dimension. The call should be able to take either. It ignores which dimension it is in. Link to comment Share on other sites More sharing options...
SteveMyres Posted July 8, 2013 Share Posted July 8, 2013 Interesting perspective! I would have said, since it's in the second dimension, it's by definition a 2D array, even though all the values fall in one column. Good to know about the Modbus call, though. I think there's been a number of times I demoted something to 1D to stick in a Modbus call just because I assumed I had to. This should save a step in that scenario. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.