happysmile Posted August 6, 2013 Share Posted August 6, 2013 please help ! Using ARDUINO UNO to generate serial Comm signal "1111111111111111 \ 13 \ 10" which is a array in my Arduino application. This array is status ON / OFF of 16 relays. ON = logic 0 and OFF = logic 1. mydevice = Serial Ascii / 9600 N81 canal_0 in to see the data "1111111111111111" is going well, except for the first location. When it is "0" disappears. Q. how to get state 1 to 16 in separate channels, canal_1 to canal_16 Link to comment Share on other sites More sharing options...
AzeoTech Posted August 6, 2013 Share Posted August 6, 2013 I'm not sure how you are getting the data now, so I'll just explain how to do it all. I'm going to assume you have mydevice setup with a NULL protocol. I'm also going to assume that your device sends the data on its own. In a sequence put: device.mydevice.purge() private string datain private data while(1) try datain = device.mydevice.readuntil(10) if (getlength(datain) != 17) // 16 channels plus the carriage return continue endif data = asca(datain) for (private i = 0, i < 16, i++) execute("canal_" + doubleToStr(i+1) + ".addValue(" + doubleToStr(data[i] - 48) + ")") endfor catch() ? strLastError endcatch delay(0.05) endwhile That should do it, though of course I didn't test it. I used an ascii trick. ASCA() converts the string into an array of numbers. In your case, its either 48 for "0" or 49 for "1". But I want 0 or 1 in the channel, so I subtract 48. Link to comment Share on other sites More sharing options...
lorelei Posted June 1, 2014 Share Posted June 1, 2014 Hello Guru. did you create a channel like "test type"? I can´t show the values. I have trying to use the same code, but for read 16 ascii value. thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 2, 2014 Share Posted June 2, 2014 Yes, you would create 16 channels canal_0 through canal_15, all Device Type "Test", I/O type "A to D", Timing = 0. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.