<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Matt<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>As usual thank you very much for your help and support.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I haven&#8217;t had a great deal of time this evening but you seem to have the Midas touch because I now seem to be up and running. &nbsp;I have a programme now successfully sending and receiving a simple on off signal between 2 boards.&nbsp; That&#8217;s progress.&nbsp; I guess I methodically stripped out everything that could be getting in the way.&nbsp; So not sure where the problem was.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I still have issues with the serial monitor though (only a minor thing).&nbsp; Even if I use the following:&nbsp; serial.setup (TX0, 9600) the monitor still reports communicating at 57600 and prints garbage when it receives data.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>This isn&#8217;t occam related I don&#8217;t think:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I get frustrated with the upload process.&nbsp; Various errors I can&#8217;t fathom out about not finding files, not in sync.&nbsp; In the end I usually end up having to restart the pc and that solves it.&nbsp; Would be nice to understand what is going on there.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Also if anyone can tell me why my pc insists on allocating COM7 and COM8 for my 2 arduino boards.&nbsp; As far as I can see I am not using any of the lower number ports.&nbsp; Not that important I suppose but would be great to understand these things better as helps troubleshooting.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Finally, yes you are right I am inquisitive I have now found those libraries.&nbsp; Thanks for that.&nbsp; I promise to keep my nose out!&nbsp; Seriously though, it is nice to see how things work.&nbsp; Again helps troubleshooting possibly.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Attached code for anyone else&#8217;s benefit of sender and receiver code.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>James<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> jadudm@gmail.com [mailto:jadudm@gmail.com] <b>On Behalf Of </b>Matt Jadud<br><b>Sent:</b> 14 January 2013 01:47<br><b>To:</b> James Brown<br><b>Cc:</b> C.CC USERS<br><b>Subject:</b> Re: [C.CC USERS] Serial questions<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>Hi James,<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>A few quick answers. I'll have to try things on an Uno to verify.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>1. &nbsp;Can I use the TX RX pins on an uno or are they effectively redundant and<br>taken up for use by USB? &nbsp;I was assuming I could simply have an occam<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>You should be able to use them.&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>Code<br>Sender<br>serial.write.byte (TX0, #AA)<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>FWIW, you can use any of the serial.write.* commands; they'll all go there. But, you know that.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal><br>Receiver<br>&nbsp; WHILE TRUE<br>&nbsp; &nbsp; SEQ<br>&nbsp; &nbsp; &nbsp; serial.read.byte (RX0, read)<br>&nbsp; &nbsp; &nbsp; IF<br>&nbsp; &nbsp; &nbsp; &nbsp; read = #AA<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detected ! SIGNAL<br>&nbsp; &nbsp; &nbsp; &nbsp; TRUE<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SKIP<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>That should poll the receiver. (I cannot, at the moment, remember if that is a blocking call. I'll look it up in a moment.) And, it should work. You might turn on an LED in your &quot;IF&quot; as a verification of receipt.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>2. &nbsp;Using occam serial.write.byte I can get it generate something (i.e. at<br>least a flash on the TX LED on board) ONLY if connected to the PC's serial<br>monitor (in which case the byte is written out as an ascii character on the<br>monitor - that's ok).<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Weird. Underneath, the code that is doing the serial send is, for all intents and purposes, identical to what the C libraries for the Arduino environment do. So, there is nothing special about the PC's serial monitor.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>3. &nbsp;I cannot get it to accept anything other than bit rate 57600. &nbsp;Anything<br>else generates garbage on the monitor.<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Hm.&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>serial.setup (TX0, 9600)<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>(or some other baud rate) should do the trick for you. That said, I'd have to check the Uno to make sure all is well. However, we don't typically make special concessions for the Uno, so again, all *should* be well here.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>4. &nbsp;Looking at the &quot;printing&quot; module code I can see calls to procs such as<br><a href="http://serial.byte.in" target="_blank">serial.byte.in</a>. &nbsp;What are these and where are they documented?<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>While this is an open source project, we'd like you to refrain from looking behind the emerald curtain. NO MORE READING THE SOURCE CODE FOR YOU!<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Humor aside, that's an internal function. serial.read.byte converts your pin number to the appropriate pin number for the hardware you're using. So, if you were using a Mega, it would translate the external pin number (on the board) to the chip pin number, so we could talk to the correct location in memory.&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Using those directly is ill advised, unless you're keenly interested in writing code that is specific to a single MCU in the AVR family, and you use the mapping PROCs as well.&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>You'd find those down in the &quot;architecture&quot; directory, BTW. That level of implementation gets specific to boards and chips.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>5. &nbsp;Finally, if I want to use serial comms, will I have to use something<br>like &quot;twi&quot; (which seems quite complicated to start out with) or am I just<br>doing something hopelessly wrong?<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>We have done exactly what you're doing in the past, with no particular, special treatment.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>That said, I've found that occam-pi is too slow to keep up with fast baud rates, and you'll probably have to run at 300 baud. (That is, you can use 9600 baud to send characters, but we can't service the receive register fast enough to keep up with a full-speed stream.)<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Push back, James, if you continue to be stuck. That's all off-the-top-of-my-head, and without hardware in hand. However, you're not doing anything overly weird, and it should work. (That is, doing sends and receives over the serial should not be difficult, and TWI is definitely not necessary. Besides, I never implemented TWI SLAVE in occam-pi, so you wouldn't be able to set it up as a receiver at the moment, anyway...)<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Cheer,<o:p></o:p></p></div><div><p class=MsoNormal>Matt<o:p></o:p></p></div></div></div></div></div></body></html>