Arduino sending garbage over com port


Author
Message
ewashi12
ewashi12
New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)
Group: Forum Members
Posts: 4, Visits: 7
I'm using two Arduino to control external stimuli. I have an issue where if I upload code to the Arduino, then the Arduino will not be able to receive or send communication to Inquisit. If I send anything to Inquisit it is interpreted as '?' (63) and anything sent from Inquisit is not registered by the Arduino. I've tried to flush the serial buffer through my Arduino code, to no successful. The only remedy I have found is opening the serial monitor, in the Arduino IDE, and sending input from the Arduino. If anyone can offer assistance, I would appreciate it.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 82K
ewashi12 - 4/20/2022
I'm using two Arduino to control external stimuli. I have an issue where if I upload code to the Arduino, then the Arduino will not be able to receive or send communication to Inquisit. If I send anything to Inquisit it is interpreted as '?' (63) and anything sent from Inquisit is not registered by the Arduino. I've tried to flush the serial buffer through my Arduino code, to no successful. The only remedy I have found is opening the serial monitor, in the Arduino IDE, and sending input from the Arduino. If anyone can offer assistance, I would appreciate it.

Generally, this sounds like an issue with your Arduino moreson than Inquisit. As an initial matter, though, you should at least specify
(1) what exactly your Arduino sends, and
(2) what your Arduino expects to receive.

Note that Inquisit does not send strings or chars over the serial port, it sends integers (8 bits, expressed either in binary "00000000" to "11111111" or decimal 0 to 255). If you need to send mult-byte chars, you may have be able to get things to work by sending numerical ascii codes á la

<block example>
/ trials = [1=init; 2-10=test_lines; 11=reset]
</block>

// initialize the module by sending the two init bytes ("RR" or 82 and 82 as decimal ASCII codes)
<trial init>
/ stimulusframes = [1=init_byte1; 2=init_byte2]
/ validresponse = (0)
/ trialduration = 50
</trial>

<trial test_lines>
/ stimulusframes = [1=on_byte1; 2=on_byte2; 21=off_byte1; 22=off_byte2]
/ validresponse = (0)
/ trialduration = 500
</trial>

<trial reset>
/ stimulusframes = [1=init_byte1; 2=init_byte2]
/ validresponse = (0)
/ trialduration = 50
</trial>

// send "01", "02", "03", "04", "05", "06", "07", "08", and "FF"
// to turn on lines 1 to 8 successively and finally all eight lines at once ("FF")
<port on_byte1>
/ items = (48, 48, 48, 48, 48, 48, 48, 48, 70) // ASCII codes for digit "0" (48) and character "F" (70)
/ select = sequence
/ erase = false
/ port = com3
</port>

<port on_byte2>
/ items = (49, 50, 51, 52, 53, 54, 55, 56, 70) // ASCII codes for digits "1" (49) to "8" (56) and character "F" (70)
/ select = port.on_byte1.currentindex
/ erase = false
/ port = com3
</port>

<port init_byte1>
/ items = (82) // ASCII code for character "R"
/ erase = false
/ port = com3
</port>

<port init_byte2>
/ items = (82) // ASCII code for character "R"
/ erase = false
/ port = com3
</port>

// send "00" to turn off lines
<port off_byte1>
/ items = (48) // ASCII code for digit "0"
/ erase = false
/ port = com3
</port>

<port off_byte2>
/ items = (48) // ASCII code for digit "0"
/ erase = false
/ port = com3
</port>



ewashi12
ewashi12
New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)
Group: Forum Members
Posts: 4, Visits: 7
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 82K
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?


Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.

EDIT: Eh, math is hard, 111011 would be 59, ASCII code for the semicolon ";". So, okay, something appears to be not working.

ADDING: Note that in RS232 the "1" bit is actually indicated by low voltage (< 0), whereas the "0" bit is signalled by high voltage (> 0). I would suspect that your Arduino inverts that, hence the One's Complement issue.


Edited Last Month by Dave
ewashi12
ewashi12
New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)
Group: Forum Members
Posts: 4, Visits: 7
Dave - 4/21/2022
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?

Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.


For the first question there is a bit inversion happening. From investigation I found that (000010 -> 111101) when it was received by Inquisit. This may be the fault of the Arduino, but I've written a python program that received input from the Arduino and it read the byte the same way it was sent from the Arduino. For the second part, I know the Arduino will send data over the com port but anything sent will be interpreted as 63 (111111). 
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 82K
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?

Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.


For the first question there is a bit inversion happening. From investigation I found that (000010 -> 111101) when it was received by Inquisit. This may be the fault of the Arduino, but I've written a python program that received input from the Arduino and it read the byte the same way it was sent from the Arduino. For the second part, I know the Arduino will send data over the com port but anything sent will be interpreted as 63 (111111). 

No idea offhand re. the 63 (00111111 or 11000000 taking into account the bit inversion). What's the exact Inquisit version you have installed (Tools -> System Information or Help -> About)? Also, please post the Inquisit code. You can attach it per +Insert -> Add File.

ewashi12
ewashi12
New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)New Member (10 reputation)
Group: Forum Members
Posts: 4, Visits: 7
Dave - 4/21/2022
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?

Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.


For the first question there is a bit inversion happening. From investigation I found that (000010 -> 111101) when it was received by Inquisit. This may be the fault of the Arduino, but I've written a python program that received input from the Arduino and it read the byte the same way it was sent from the Arduino. For the second part, I know the Arduino will send data over the com port but anything sent will be interpreted as 63 (111111). 

No idea offhand re. the 63 (00111111 or 11000000 taking into account the bit inversion). What's the exact Inquisit version you have installed (Tools -> System Information or Help -> About)? Also, please post the Inquisit code. You can attach it per +Insert -> Add File.

Version: 6.5.1 64bit (build 6436)
Thank you for the help. I'm also currently looking into any issues that could be on the Arduino's side. 
Attachments
controller_vibration_test.iqx (12 views, 1.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 82K
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?

Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.


For the first question there is a bit inversion happening. From investigation I found that (000010 -> 111101) when it was received by Inquisit. This may be the fault of the Arduino, but I've written a python program that received input from the Arduino and it read the byte the same way it was sent from the Arduino. For the second part, I know the Arduino will send data over the com port but anything sent will be interpreted as 63 (111111). 

No idea offhand re. the 63 (00111111 or 11000000 taking into account the bit inversion). What's the exact Inquisit version you have installed (Tools -> System Information or Help -> About)? Also, please post the Inquisit code. You can attach it per +Insert -> Add File.

Version: 6.5.1 64bit (build 6436)
Thank you for the help. I'm also currently looking into any issues that could be on the Arduino's side. 

6.5.1 is not quite up to date. Please install 6.5.2, just to make sure we're on the same page.

https://www.millisecond.com/download/
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 82K
Dave - 4/21/2022
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
Dave - 4/21/2022
ewashi12 - 4/21/2022
The Arduino sends the numbers 2 (111101) and 4 (111011) to Inquisit, we found that Inquisit was taking the 1's complement of anything we sent over. If I've recently uploaded code to the Arduino or booted the computer running Inquisit it only recognizes those inputs as '?' (63). Inquisit sends to the Arduino 57,67 to initiate and stop a rumble stimulus respectively. If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit. Please let me know if I should post the code of the Arduino or Inquisit. Thanks!


I'm confused.

111101 is 61 in decimal, 61 being the ASCII code for the character "=".
111011 is 63 in decimal, 63 being the ASCII code for the character "?".

So, if I read you correctly -- "[...] it only recognizes those inputs as '?' (63)" -- at least part of that seems to work as expected. What am I missing?

Then, "If the computer has just been booted or code has been uploaded to the board, the Arduino will not respond to anything sent by Inquisit" to me sounds like some kind of intialization issue with the Arduino.

Feel free to post the Inquisit code. As for the Arduino code, I'm not an Arduino person, so I won't be able to help with that.


For the first question there is a bit inversion happening. From investigation I found that (000010 -> 111101) when it was received by Inquisit. This may be the fault of the Arduino, but I've written a python program that received input from the Arduino and it read the byte the same way it was sent from the Arduino. For the second part, I know the Arduino will send data over the com port but anything sent will be interpreted as 63 (111111). 

No idea offhand re. the 63 (00111111 or 11000000 taking into account the bit inversion). What's the exact Inquisit version you have installed (Tools -> System Information or Help -> About)? Also, please post the Inquisit code. You can attach it per +Insert -> Add File.

Version: 6.5.1 64bit (build 6436)
Thank you for the help. I'm also currently looking into any issues that could be on the Arduino's side. 

6.5.1 is not quite up to date. Please install 6.5.2, just to make sure we're on the same page.

https://www.millisecond.com/download/

Alright, as for the bit inversion on input, according to some quick tests on my end, that's Inquisit's fault. I.e. if you have

<trial mytrial>
/ inputdevice = com2
/ validresponse = (4,2)
</trial>

and send 00000010 (2 in decimal, 02 in hex), the trial will not accept that due to the screwy bit inversion (and possibly another issue I don't fully understand yet). Not pretty, but the immediate workaround would be to send the inverted value (FD for 2 if you're sending hex, otherwise 253 if you're sending decimal byte values; FB for 4, or 251 in decimal).

This works on my setup (though note that I'm not using an Arduino and am sending hex bytes to the COM interface).

<trial mytrial>
/ inputdevice = com1
/ validresponse = (4,2)
</trial>

<block myblock>
/ trials = [1-2 = mytrial]
</block>




As for the sending issue you described, I appear to be unable to reprodcuce this on my setup. I.e. if I send out over the COM

<port c1>
/ items = (82)
/ port = com1
</port>


that is read as the character "R" as expected.





Similarly, if I send the values you are using -- 57 and 67 --

<port c1>
/ items = (57, 67)
/ port = com1
/ select = sequence
</port>


those are read as characters 9 and C on the serial line.



which aligns with expectations:




Edited Last Month by Dave
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search