[Csnd] Get bad values with serialRead/ Arduino
Date | 2012-01-31 17:39 |
From | obaudouin |
Subject | [Csnd] Get bad values with serialRead/ Arduino |
(csd below) Hello! I am trying an Arduino Uno. I get correct values with the arduino software (~ from 330 to 340) In Csound, I get correct values with serialPrint (~ from 330 to 340) but not with serialRead: i1 -1.00000 i1 13.00000 i1 56.00000 i1 13.00000 i1 10.00000 i1 51.00000 i1 50.00000 i1 56.00000 i1 13.00000 i1 10.00000 i1 51.00000 i1 50.00000 i1 56.00000 i1 13.00000 i1 10.00000 i1 51.00000 i1 50.00000 i1 56.00000 i1 13.00000 i1 10.00000 i1 51.00000 i1 50.00000 i1 56.00000 ... An idea? -------------- |
Date | 2012-01-31 18:19 |
From | jpff@cs.bath.ac.uk |
Subject | Re: [Csnd] Get bad values with serialRead/ Arduino |
I assume this is Linux? What values were you expecting? All it is doing is unsigned byte b; bytes = read((int)*p->port, &b, 1); if (bytes > 0) *p->rChar = b; else *p->rChar = -1; return OK; > (csd below) > > Hello! > > I am trying an Arduino Uno. I get correct values with the arduino software > (~ from 330 to 340) > In Csound, I get correct values with serialPrint (~ from 330 to 340) but > not > with serialRead: > > i1 -1.00000 > i1 13.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > ... > > An idea? > > > -------------- > > |
Date | 2012-01-31 19:03 |
From | obaudouin |
Subject | [Csnd] Re: Get bad values with serialRead/ Arduino |
Yes, it is on Linux. Expected values: from 330 to 340 (OK with serialPrint, but not with serialRead). ----- Olivier Baudouin, PhD http://olivierbaudouin.com MINT-OMF Paris-Sorbonne -- View this message in context: http://csound.1045644.n5.nabble.com/Get-bad-values-with-serialRead-Arduino-tp5445222p5445466.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2012-01-31 19:33 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Get bad values with serialRead/ Arduino |
hello, I have very small experience with arduino and I don't havew now one, but from my knowledge: doesn't it depend, what kind of info is the arduino sending? Do you know what sketch is uploaded to arduino? The difference is that if arduino is sending the information wit Serial.print it is sent to serial port as string (or text), so you can do cat /dev/ttyUSB0 in terminal and see readable output if it is sent with Serial.write , inf is sent as binary bytes. I assume, similarly csound's serialPrint assumes that string is coming in and serialRead reads the stream as binary bytes. If Arduino sends '300' with print, bytes '3','0','0' etc are read with serialRead. That's why the porridge. In short: if you get expected result with serialPrint, stick to it! (although Serial.write in arduino and serialRead in csd should be faster), hope it helps. tarmo On Tuesday 31 January 2012 19:39:23 obaudouin wrote: > (csd below) > > Hello! > > I am trying an Arduino Uno. I get correct values with the arduino software > (~ from 330 to 340) > In Csound, I get correct values with serialPrint (~ from 330 to 340) but not > with serialRead: > > i1 -1.00000 > i1 13.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > i1 13.00000 > i1 10.00000 > i1 51.00000 > i1 50.00000 > i1 56.00000 > ... > > An idea? > > > -------------- > > |
Date | 2012-01-31 20:31 |
From | jpff@cs.bath.ac.uk |
Subject | Re: [Csnd] Re: Get bad values with serialRead/ Arduino |
I remain confused, as 300 > 255 which is the largest value readable > Yes, it is on Linux. > Expected values: from 330 to 340 (OK with serialPrint, but not with > serialRead). > > ----- > > Olivier Baudouin, PhD > http://olivierbaudouin.com > MINT-OMF > Paris-Sorbonne > > -- > View this message in context: > http://csound.1045644.n5.nabble.com/Get-bad-values-with-serialRead-Arduino-tp5445222p5445466.html > Sent from the Csound - General mailing list archive at Nabble.com. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe > csound" > > > > |
Date | 2012-02-01 09:02 |
From | obaudouin |
Subject | [Csnd] Re: Get bad values with serialRead/ Arduino |
jpff wrote > > I remain confused, as 300 > 255 which is the largest value readable > But Arduino analog outputs send values from 0 to 1023... ----- Olivier Baudouin, PhD http://olivierbaudouin.com MINT-OMF Paris-Sorbonne -- View this message in context: http://csound.1045644.n5.nabble.com/Get-bad-values-with-serialRead-Arduino-tp5445222p5446899.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2012-02-01 09:34 |
From | jpff@cs.bath.ac.uk |
Subject | Re: [Csnd] Re: Get bad values with serialRead/ Arduino |
but the csound opcode reads 1 byte at a time, so yu need to reconstruct a 10bit number > > jpff wrote >> >> I remain confused, as 300 > 255 which is the largest value readable >> > > But Arduino analog outputs send values from 0 to 1023... > > > ----- > |
Date | 2012-02-01 09:42 |
From | obaudouin |
Subject | [Csnd] Re: Get bad values with serialRead/ Arduino |
How would you do that? ----- Olivier Baudouin, PhD http://olivierbaudouin.com MINT-OMF Paris-Sorbonne -- View this message in context: http://csound.1045644.n5.nabble.com/Get-bad-values-with-serialRead-Arduino-tp5445222p5446985.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2012-02-01 14:11 |
From | obaudouin |
Subject | [Csnd] Re: Get bad values with serialRead/ Arduino (SOLVED) |
I have mapped the analog Arduino output to send values from 0 to 255. Thats OK now. Thanks! ----- Olivier Baudouin, PhD http://olivierbaudouin.com MINT-OMF Paris-Sorbonne -- View this message in context: http://csound.1045644.n5.nabble.com/Get-bad-values-with-serialRead-Arduino-tp5445222p5447608.html Sent from the Csound - General mailing list archive at Nabble.com. |