<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?</title>
		<link>http://forums.leaflabs.com/topic.php?id=256</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:24:41 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=256" rel="self" type="application/rss+xml" />

		<item>
			<title>josheeg on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1943</link>
			<pubDate>Sat, 23 Oct 2010 14:57:59 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1943@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well I am wireing up the ft2232h board called the usb1232h by dlp to be the higher speed usb link.&#60;br /&#62;
their will be 9 bits and power and ground. &#60;/p&#62;
&#60;p&#62;1-8 for eatch analog to digital converter biopotential measurement system. &#60;/p&#62;
&#60;p&#62;and a pin for telling the module to write that 8 bit byte to the USB virtual com port.&#60;/p&#62;
&#60;p&#62;I found when lowering the speed of the ads1298 biopotential mesurement chip to 250 samples per second the output made sence and their was supposed to be 1100 the register 00 status register word 24 bits in this case then 0000000 00000000 the lead off detection for the 16 sensor pins it takes 8 differential mesurements simultaniously and with more of these mesurement boards they can be synced to work all at the same time with the start pin.&#60;br /&#62;
then the GPIO bits output 1111 because the input to the gpio pins were vcc.&#60;/p&#62;
&#60;p&#62;What was happening is I had it print out only the status word before the 8 samples. then repeat.&#60;br /&#62;
But what I got back after a screen worth of 1100 00000000 00000000 1111 ignore the spaces that was just to help me count.&#60;/p&#62;
&#60;p&#62;There would be 1's and 0's in places... 110 00000001 00000010 1101&#60;br /&#62;
Now the status of lead off detection I turned off so it should alwase be 0's.&#60;/p&#62;
&#60;p&#62;So when I setup the high speed link and the maple acts as the register loader then clocks the bits out the high speed link. &#60;/p&#62;
&#60;p&#62;Here is a robot magazine article that shows someone else did this their is a youtube link in the back of the article showing him play with this.&#60;/p&#62;
&#60;p&#62;ACTIVATION OF A MOBILE ROBOT THROUGH A BRAIN COMPUTER INTERFACE&#60;/p&#62;
&#60;p&#62;When to replace the keyboard&#60;br /&#62;
—by Kevin M. Berry&#60;/p&#62;
&#60;p&#62;Thank you everyone for your interest it is great inspiration.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1909</link>
			<pubDate>Thu, 21 Oct 2010 19:04:48 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1909@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josheeg, you might try buffering your samples and then printing them all at once. There actually are some helper functions that give you direct access to the USB send buffer for faster access. See here:    &#60;a href=&#34;http://github.com/leaflabs/libmaple/blob/master/libmaple/usb/usb.c&#34; rel=&#34;nofollow&#34;&#62;http://github.com/leaflabs/libmaple/blob/master/libmaple/usb/usb.c&#60;/a&#62; - the function you want is &#34;usbSendBytes(uint8 buf, uint16 len)&#34; which is a NON-blocking USB send function (i think I saw an error in the comments about this)&#60;/p&#62;
&#60;p&#62;For the record, this whole codebloc (the entire USB stack) is going to be replaced soon...&#60;/p&#62;
&#60;p&#62;Anyway, the max send buffer is 64 bytes, so you might be able to get away with something like (assuming you have 8 bit data):&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;uint8 dataBuf[64];

while(1) {
  for (int i=0;i&#38;lt;64;i++) {
      dataBuf[i] = readSensor();
  }

  int bytesSent = 0;
  while(bytesSent != 64) {
    bytesSent += usbSendBytes(dataBuf,64);
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This is hardly the &#34;best&#34; thing to do, but its simple and should be substantially faster than looping over SerialUSB.send(). The reason is that there is no high level USB tx buffer besides the 64 byte hardware packet memory. So if you send 1 byte, or if you send 64 bytes, it takes roughly the same amount of time. You might as well send 64 bytes.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1902</link>
			<pubDate>Thu, 21 Oct 2010 17:35:46 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1902@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Stephen - that's very kind and generous of you to say. Sadly, I am no angel, not even close.&#60;/p&#62;
&#60;p&#62;When folks are able to move along well under their own steam, like Josheeg, I am more than willing to help try to keep them moving. &#60;/p&#62;
&#60;p&#62;I have another side. I am not prepared to do most of the work for someone's project. They dream it up, they do the heavy lifting. Pretty basic really :-(&#60;/p&#62;
&#60;p&#62;On the other hand, I am fascinated by Josheeg's project, so self-interest keeps my attention. After all, what school kid wouldn't want to play with an eeg on their friends :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1884</link>
			<pubDate>Thu, 21 Oct 2010 14:19:42 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">1884@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;gbulmer, your posts show how much patience you have.  You look at writing from the  perspective (and bias) of the writer.  A very useful skill.  Your students are lucky to have a teacher with such clear communication skills!  You are a great role model for them!&#60;/p&#62;
&#60;p&#62;I think I often err on the side of writing too much (my default verbosity setting is on).  I write my longer posts using a text editor, which allows me to edit the messages for errors in spelling, grammar, punctuation, clarity, correctness, etc.&#60;/p&#62;
&#60;p&#62;Josheeg, I am very interested in your project.  I would also benefit if you took sightly more time to write more.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;Stephen from NYC
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1878</link>
			<pubDate>Thu, 21 Oct 2010 13:43:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1878@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josheeg - I'm sorry I am confused.&#60;br /&#62;
You are very familiar with what you are doing, so it probably all seems very obvious to you, but I am not familiar with it, so I need some clearer explanation.&#60;/p&#62;
&#60;p&#62;Are the characters that are being printed the right characters, but in the wrong order,&#60;br /&#62;
OR&#60;br /&#62;
are the characters themselves not the right ones?&#60;/p&#62;
&#60;p&#62;So, for example, if you are expecting the digits '0' to '9' and space, are you seeing '0' to '9', but the digits are in the wrong order?&#60;br /&#62;
OR&#60;br /&#62;
are some characters being lost, or printed more than once?&#60;br /&#62;
OR&#60;br /&#62;
are you seeing other characters, and not only the right ones (in this example, the equivlanet would be seeing letters and punction instead of only '0' to '9')?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1867</link>
			<pubDate>Thu, 21 Oct 2010 06:41:46 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1867@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was printing one 24 bit binary number per line.&#60;br /&#62;
and kept printing every time the sensor was ready.&#60;br /&#62;
500 times per sec 500 samples per second 24 characters long.&#60;br /&#62;
then it did not apear to have 1s being replaced with 0's and 0's replaved with 1s 1-3 times in a random line.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1866</link>
			<pubDate>Thu, 21 Oct 2010 04:27:55 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1866@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;when you say&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;every once in a wile apears random the output comes out different from what the sensor is set to output&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;is it completly random characters (not didigits, or anything you recognise), or does it look like some characters were lost or overwritten?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=256#post-1863</link>
			<pubDate>Wed, 20 Oct 2010 21:42:06 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1863@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;loop(){  SerialUSB.println(sensor);} would this be a bad way to code things?&#60;br /&#62;
I think my code I was trying to print sensor values that came out faster than the print statement could handle so every once in a wile apears random the output comes out different from what the sensor is set to output I tested this by setting the sensor to output the same thing over and over.&#60;/p&#62;
&#60;p&#62;my implementation prints out 24 characters so I can see the sensors registers as it updates but I think the sensor returning 500SPS &#60;/p&#62;
&#60;p&#62;humm 250 sps on low power mode instead of 500 sps high resolution mode apears to work well I don't see the glitches.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
