tag:blogger.com,1999:blog-28432783632631093222024-03-05T20:37:25.676-08:00IOBLOCKSDave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.comBlogger22125tag:blogger.com,1999:blog-2843278363263109322.post-14369105485263630232016-10-24T23:53:00.000-07:002016-10-24T23:53:31.391-07:00VS Code for GO - get a function listI have been using VS Code to design my GO code ever since my last MacBook died of caffeine poisoning (don't ask).<br /><br />I had been using UltraEdit since 1998 and had found nothing that really changed my mind but I had been exploring VS Code for Ethereum work.<br />
<br />
The new MacBook was supposed to be a temporary fix but four months on and no sign of the old MacBook back, it is looking quite permanent now.<br />
<br />
So -what do I like about it? A lot. And I am learning more every day.<br />
<br />
<u>Today's tip</u><br />
<br />
UltraEdit used to have the option of showing a list of functions in a separate pane. I could not find this in VS Code. Here is how to do it.<br /><br />Cmd+P pops up the action entry box<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFy1lakdpcseCs6UhPsNx5gBi20iR9bFBwG9kDfJ99KHX149zF6NHJi3k2OYwIjn7hym3zawWQgk2XcTemb3ZR8-sRIx2bNKawVNv74qeF0woV86LZi_PxYLbqefrim3hAMv2Lr8pR27I/s1600/Screen+Shot+2016-10-25+at+2.42.24+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="35" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFy1lakdpcseCs6UhPsNx5gBi20iR9bFBwG9kDfJ99KHX149zF6NHJi3k2OYwIjn7hym3zawWQgk2XcTemb3ZR8-sRIx2bNKawVNv74qeF0woV86LZi_PxYLbqefrim3hAMv2Lr8pR27I/s320/Screen+Shot+2016-10-25+at+2.42.24+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Type a '@' in this box and you get a list of the imports, variables, functions etc. in your current file.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCzBncm8kVFRGq7AqkZG_LX-SFKDeRgv7OMpW262P_gjweYyjKXz6NkWvr6GQQje2fSqAUcdpgfeREiCET0ph4ybM3WCmz_F5VRaObiMH3kD2u40sR1NNXR4E1Qv8k41bez9eCr_Eg6z0/s1600/Screen+Shot+2016-10-25+at+2.50.14+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="121" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCzBncm8kVFRGq7AqkZG_LX-SFKDeRgv7OMpW262P_gjweYyjKXz6NkWvr6GQQje2fSqAUcdpgfeREiCET0ph4ybM3WCmz_F5VRaObiMH3kD2u40sR1NNXR4E1Qv8k41bez9eCr_Eg6z0/s320/Screen+Shot+2016-10-25+at+2.50.14+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Selecting one of these takes you to the correct place in the file.</div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-75904009965767847972016-09-04T09:36:00.000-07:002016-09-04T09:36:34.738-07:00POSTGRES - Change money field to Integer....So, we had a table with a money field when all of a sudden we realised that it would make a lot more sense for the amount to be expressed in cents instead of in dollars.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ 1234.56 would now become 123456</span><br />
<br />
I am sure that there is a far better way to do this but - I am an occasional DB admin and so I figured that I needed to<br />
<br />
<ol>
<li>Convert dollars to cents</li>
<li>Convert Money to Integer</li>
</ol>
<div>
#1 was easy : <span style="font-family: "courier new" , "courier" , monospace;">update bills set amount=amount*10;</span></div>
<br />
<br />
#2 was a bit more tricky. Very hard to convert Money to Int.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">amount::varchar </span><span style="font-family: "arial" , "helvetica" , sans-serif;">does, however, yield a string so</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">Create a new int column:</span><br /><br /><span style="font-family: Courier New, Courier, monospace;">Alter table bills add column iamount int;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Then copy the correct amount into it:</span><br />
<br />
<div class="p1">
<span class="s1"><span style="font-family: "courier new" , "courier" , monospace;">update bills set iamount =<br /> replace(substr(amount::varchar,2,length(amount::varchar)-4),</span></span><br />
<span class="s1"><span style="font-family: "courier new" , "courier" , monospace;"> ',','')::int;</span></span><br />
<span class="s1"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Then drop the old column and rename the new....</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">alter table bills drop column amount;</span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">
</span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">alter table bills rename column iamount to amount;</span></span></div>
<br /></div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-63960200445594711092016-06-30T08:18:00.002-07:002016-06-30T08:35:41.908-07:00Compiling GO code for the BeagleBone Black<span style="font-family: "arial" , "helvetica" , sans-serif;">One thing I love about GO is that you can cross compile code for different platforms. </span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br />The Ethereum Foundation use this feature to create developer releases of GETH (the ethereum node written in GO) to many platforms relatively quickly.<br /><br />It also means that I do not need to wait ages for a slow processor like the Raspberry Pi 1 or the BeagleBone Black to make the build, I can do it from my MacBook.</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I first learned how effortless it was from <a href="https://github.com/audreylim/go-snap" target="_blank">Audrey Lim's go-snap project</a><br /><br />There are more details about cross compiling for ARM in the <a href="https://github.com/golang/go/wiki/GoArm" target="_blank">GoArm Wiki</a></span></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So finally - to compile on Linux or a MacBook for the BBB*</span><br />
<b><span style="color: #38761d;"><br /><span style="font-family: "courier new" , "courier" , monospace;"># GOARCH=arm GOOS=linux GOARM=7 go build myBBBprogram.go</span></span></b></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Once it has finished you should have a cross compiled executable. All you have to do is to transfer it to the BBB with scp or an sftp utility and you are in business!</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">*or on a PC if you really have to...</span></div>
<div>
</div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-45435072721534951812016-06-30T08:00:00.005-07:002016-06-30T08:38:12.591-07:00Set Fixed IP Address on BeagleBone Black (Debian)<span style="font-family: arial, helvetica, sans-serif;">After a couple of years of serious distractions, I dragged my BeagleBone Blacks out of the cupboard and am putting them to use hosting test software in the office so that people can access them while I am away.</span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br />I downloaded the latest Debian because it seems that Arch had not been updated recently</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Many things have changed, in particular the connection manager but it is a very simple process.<br /><br />These commands may require running as root (via Sudo or su)</span></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">First find your service name (I have truncated the names of mine for brevity)</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="color: #38761d; font-family: "courier new" , "courier" , monospace; font-size: x-small;"># <strong style="background-color: white; border: 0px; line-height: 21px; margin: 0px; padding: 0px; vertical-align: baseline;">connmanctl services</strong></span></div>
<div>
<span style="color: #38761d;"><span style="background-color: white; font-family: "courier new" , "courier" , monospace; font-size: x-small; font-weight: bold; line-height: 21px;">your_network_id </span><span style="background-color: white; font-family: "courier new" , "courier" , monospace; font-size: x-small; font-weight: bold; line-height: 21px;">wifi_000c</span></span></div>
<div>
<span style="background-color: white; border: 0px; line-height: 21px; margin: 0px; padding: 0px; vertical-align: baseline;"></span><br />
<div class="p1" style="font-family: intel-clear, arial, helvetica, "helvetica neue", verdana, sans-serif; font-size: 14px; font-weight: bold;">
<span style="background-color: white; border: 0px; line-height: 21px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="s1"><br /></span></span></div>
<span style="background-color: white; border: 0px; line-height: 21px; margin: 0px; padding: 0px; vertical-align: baseline;">
<div class="p1" style="color: #3d3d3d; font-family: intel-clear, arial, helvetica, "helvetica neue", verdana, sans-serif;">
<span class="s1">Then set the IP address, netmask and gateway address</span></div>
<div class="p1" style="color: #3d3d3d; font-family: intel-clear, arial, helvetica, "helvetica neue", verdana, sans-serif;">
<span class="s1"><br /></span></div>
<div class="p1" style="font-weight: bold;">
<span class="s1"><span style="color: #38761d; font-family: "courier new" , "courier" , monospace; font-size: x-small;">#connmanctl config wifi_000c --ipv4 manual 192.168.0.200 255.255.255.0 192.168.0.1</span></span></div>
<div class="p1" style="color: #3d3d3d; font-family: intel-clear, arial, helvetica, "helvetica neue", verdana, sans-serif; font-size: 14px; font-weight: bold;">
<span class="s1"><br /></span></div>
<div class="p1" style="color: #3d3d3d;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you have logged in via SSH and are entering the commands remotely, the BBB will now freeze because you have already changed the IP address and so your connection is frozen.</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br />Reboot and your connection is up on the new address.</span><br />
</span></div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-36139114410690792422016-04-05T14:49:00.000-07:002016-04-05T14:50:19.776-07:00Getting Started with EthereumIt has become clear that Cryptocurrencies are not so much about using the currency as a means of saving or speculation, more about using their key features on which to build a platform that has value and doing so in a more secure, flexible and inexpensive way than were possible without the technology.<br />
<br />
The result of this is that, while you still see many people mining Bitcoin, stashing it and praying for the value to increase back to the glory days, there are many more services that buy and re-sell bitcoin almost instantaneously in different markets, using the technology as a way of transferring value around the world at the speed of light.<br />
<br />
But still, Bitcoin was a currency. Ripple, Stellar and their spinoffs moved this forward by being an asset trading platform. The ripple and stellar currencies were merely the oil for the machine, the value being the incentive for miners to keep the wheels of the processing nodes turning.<br />
<br />
Stellar has some excellent features. Automatic exchanges can be set up - and peer exchanges - anybody who deals in two assets may propose exchange rates - and the best will win. But at the end of the day, they are still rigid systems and you need to build a system to take advantage of them.<br />
<br />
A couple of years ago there were (if you will pardon me for saying it) ripples in the ether. A paper had been written proposing what were called "smart contracts". <br />
<br />
Smart contracts are small programs inserted into a blockchain which get run every time somebody wants to interact with them. People who want to use a smart contract have to pay for the privilege because thousands of people worldwide are expected to offer computing power to run these programs. The programs themselves are ultimately very flexible - written in languages similar to Javascript or Python.<br />
<br />
At the time of writing Ethereum, the result of all this work, is starting to take the crypto world by storm. While still officially in Beta, people are using it to manage all kinds of things - from auctions and trading systems to online gambling.<br />
<br />
OK, I hear comments. That is a huge amount of verbosity. What's the point?<br />
<br />
The main point is that I am exploring Ethereum and have been doing a bit of coding. Some of it digs quite deep into the Ethereum source Code. <br />
<br />
In the process, I am building some useful libraries which I will be sharing in a way that allows us to explore the power of Ethereum.<br />
<br />
Expect to hear from me soon.Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com2tag:blogger.com,1999:blog-2843278363263109322.post-47608893884615394562015-10-04T04:13:00.000-07:002015-10-04T04:13:03.515-07:00Processing 3 is out - but to get it to work with Android on the Mac takes a bit of troubleProcessing - one of my favourite tools for PC side development has just had new release. Unfortunately is does seem a bit raw at the moment.<br /><br />You can download Processing3 from the usual site <a href="http://www.processing.org/">http://www.processing.org</a> and you can find the recommended setup information at <a href="https://github.com/processing/processing-android/wiki">https://github.com/processing/processing-android/wiki</a> but a number of people, myself included, seemed to be having trouble getting it to work.<br /><br />After some digging on the forums I did manage to get it working so I thought I would summarise what had to be done.<br /><br />1) If you have Android Studio or Eclipse installed, locate the Android SDK folder otherwise you will need to download it (SDK only) as described in the wiki above.<br /><br />2) Not sure if this is 100% correct but from the wiki you will need to load API 10. You can use preferences from Android Studio or run the android app in the tools folder to do so.<br />
<br />
3) I did add the variables in the .bash_profile but that did not work for me. Further digging led me to this post : <a href="http://forum.processing.org/two/discussion/12665/android-sdk-could-not-be-loaded">http://forum.processing.org/two/discussion/12665/android-sdk-could-not-be-loaded</a><br /><br />summarizing: <br /><br />
<ol>
<li>open processing preferences, note the path of preferences.txt, probably<br />/Users/<your name>/Library/Processing/preferences.txt<br />obviously <your name> needs to be replaced by your user name.</li>
<li>Close Processing</li>
<li>Edit preferences.txt and add the following two lines at the beginning<br />android.sdk.path=/Users/<your name>/Library/Android/sdk<br />android.sdk.version=10</li>
</ol>
<div>
That seemed to do it for me. Haven't tried using an SDK > 10 even though somebody has claimed that it may work and haven't run a full test - but not getting the error must be a good start.</div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com1tag:blogger.com,1999:blog-2843278363263109322.post-2858661993545662042014-09-07T09:30:00.000-07:002014-09-07T09:32:38.096-07:00Loading an array/slice of objects from a JSON file in GolangAs usual, with a new project arriving my first question is "what can we learn on this one?"<br />
<br />
So, having found that Go (aka Golang) is a decendant of Modula-2 and has some pretty nifty features, I decided that Golang was the way to Go (if you will pardon the expression).<br />
<br />
The next thing that I do is head straight for the target, reading just enough to get me there. If the journey is a happy one I may flesh things out later, but when you are relying on the internet and googling, the search results are a bit like flicking through a book - but not as good because sometimes a book yields a gem that you weren't looking for.<br />
<br />
The project is made of multiple servers (raspberry pi) doing crazy stuff all talking to each other as well as hardware and Arduinos. The first server was a sound player controlled by other remote servers. It loaded a name->filename map from a JSON file. Not too tricky.<br />
<br />
The second one needed some routing tables loaded. I wanted pure object arrays loaded from JSON.<br />
<br />
Note : You can't use an Array, you need a SLICE. Arrays are fixed size.<br />
<br />
I Googled and came across lots of people on StackOverflow asking the same question.<br />
<br />
A lot of the answers and questions revolved around <span style="color: red;">interface{} </span>which I tried and<span style="color: red;"> </span>got working but it seemed a bit tricky because there are multiple type conversions involved - silly when all records are the same type. And there seemed to be NOBODY telling how to do it.<br />
<br />
So, if you are trying to load an <strike>array</strike> slice of objects from a JSON file - bearing in mind I have been doing this for a couple of weeks with a lot of that time goofing off, here it is....<br />
<br />
The data record I want to load<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">type command_record struct {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Source string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>What string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Condition string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Value string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Host string</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Action string</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Which we will represent in JSON as</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">[</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Source": "sensor",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"What": "temp",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Condition": "GT",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Value": "35",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Host": "sensor",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Action": "REDON"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> },</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Source": "host",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"What": "sensoralarm",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Condition": "NIL",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Value": "0",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Host": "sensor",</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Action": "BLUOFF"</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"></span><br />
<span style="font-family: Courier New, Courier, monospace;"> ]</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">So the slice is represented as </span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">var sensor_script *[]command_record</span><br />
<br />
Note the * which means we are only declaring a pointer.<br />
<br />
And we read the file into a slice of bytes<br />
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>file, e := ioutil.ReadFile("./sensor.json")</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if e != nil {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Printf("File error %v\n", e)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>os.Exit(1)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Then we convert it objects using json.Unmarshal and print it just to show it works</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>json.Unmarshal(file, &sensor_script)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for _, v := range *sensor_script {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.Source)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.What)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.Condition)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.Value)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.Host)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println(v.Action)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>fmt.Println("=========")</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
</div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">And, after all that time - it is that simple. And I am sure that many many people have figured it out within ten minutes, but others have too google it and waste a lot of time. This is for them.</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;"> The code and a sample JSON file can be found on Github at </span><a href="https://github.com/DaveAppleton/LoadObjectSliceFromJson">https://github.com/DaveAppleton/LoadObjectSliceFromJson</a></div>
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com1tag:blogger.com,1999:blog-2843278363263109322.post-10387940209982790292014-05-05T03:12:00.001-07:002014-05-05T04:42:43.335-07:00Build a simple Transistor Curve Tracer using an Arduino and Processing<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">You always get to that point, when
teaching something easy, that you start to cross over into the realm
of the slightly more complicated. That was what happened when I
started showing how to use a transistor to buffer an Arduino output
to switch a 12V load. So we started going into current amplifiers,
Vbe and Vce, Saturation and configurations.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<br />
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The next day, on my way to a meeting I
was struck with the idea that an Arduino could make it really easy to
show how a transistor works – and it would be more understandable
because the students would build it themselves.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<h3 style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The theory</span></h3>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">A transistor is a current controlled
device. It will control the current through the collector to be a
multiple of the base current <i>as long as that current is
available.</i><span style="font-style: normal;">The last part
is important. If you have a supply that can only provide 10 mA, there
is no way that the transistor can manufacture more. It can only allow
the current available to pass or restrict it.</span></span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3qYmfhmsdRJUMn5xbQ8RHGrIBdu9wESoOzrvdVa8V0nO0W5U-X0Kdls4WDZrOZV5T0T7zxlWIPjYuiwStSHdGttl-tuibm2HdgbIkCIEG7mWkYM51fvafQU_nTLL1QhUOcAEVdNBWQj8/s1600/transistor.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3qYmfhmsdRJUMn5xbQ8RHGrIBdu9wESoOzrvdVa8V0nO0W5U-X0Kdls4WDZrOZV5T0T7zxlWIPjYuiwStSHdGttl-tuibm2HdgbIkCIEG7mWkYM51fvafQU_nTLL1QhUOcAEVdNBWQj8/s1600/transistor.tiff" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div align="CENTER" style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">I<sub>c</sub> = max (β
x I<sub>b ,</sub>,available)
</span></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div align="CENTER" style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">where
I<sub>c</sub>
is the collector current, β
is the gain and I<sub>b </sub>is
the current into the base.</span></div>
<div style="margin-bottom: 0in; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">In
common emitter mode, the load and the supply voltage determine the
maximum available current. So, for example, a 100 ohm load to a 5V
supply cannot possibly supply more than 10 mA to ground by virtue of
ohms law.</span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<h3 style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The
Implementation</span></h3>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The idea was to start off with
something incredibly simple that the students could understand – so
I settled on manual control of the input voltage using a
potentiometer.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The transistor and the two resistors form part of the test circuit.</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnv4M5y2sv_3WrYxAPvS3L23hDTqNE-B653avwBne2St7MQuDbW7nTGR0dnWM3Z0qgsKfE3Bn-kDa4UrrpvFSyVL-62vo3Cd4xs4KmVJWhii50DS8iCtXmBTOfVeqm9T18Ks7E5z4MhLo/s1600/CurveTracer_schem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnv4M5y2sv_3WrYxAPvS3L23hDTqNE-B653avwBne2St7MQuDbW7nTGR0dnWM3Z0qgsKfE3Bn-kDa4UrrpvFSyVL-62vo3Cd4xs4KmVJWhii50DS8iCtXmBTOfVeqm9T18Ks7E5z4MhLo/s1600/CurveTracer_schem.png" height="204" width="320" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Test Circuit Diagram</span></div>
<br />
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Thus the Arduino is able to measure the source
voltage, the base voltage and the collector voltage as you change the potentiometer position.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />Thus I<sub>b
</sub>can be determined by ( Vs – Vb ) / R<sub>b</sub></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"> and I<sub>c
</sub>can be determined by (5V - Vc) / R<sub>c
</sub><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">This was easily wired up on a
breadboard as follows</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLWPWvm4IQfghv4Fg1p0EkdAIwRCJQpAjs3rwQD05zhCs5z14w2OoMre9GQJGZ8I3-RGI2AQg_fiQKzPlPJd0P4ei7-WFBDkmPcN8Gt-itgdErnQq4yjhPskmoSiV1w65uSTUWu8jdq14/s1600/CurveTracer_bb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLWPWvm4IQfghv4Fg1p0EkdAIwRCJQpAjs3rwQD05zhCs5z14w2OoMre9GQJGZ8I3-RGI2AQg_fiQKzPlPJd0P4ei7-WFBDkmPcN8Gt-itgdErnQq4yjhPskmoSiV1w65uSTUWu8jdq14/s1600/CurveTracer_bb.png" height="310" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h3 style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The Arduino code</span></h3>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Since we want to graph the output, we
will send it to a host computer via the USB Serial link. This reduces
the requirements of the Arduino code to reading the analog inputs,
converting them to voltages and transmitting them.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Since the Arduino has 12 bit analog
inputs (0-1023) where 0 represents 0V and 1023 represents 5V we need
to scale the analog readings.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"> V = analogRead( port ) * 5 / 1023</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">We then combine the three readings into
a single text line and transmit them in text mode to the computer.
Using plain text makes it far easier to debug the program on both
sides. As a result, the Arduino code is really simple.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;">void setup() { </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.begin(9600); </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;">} </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;">void loop() {</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float bvc = analogRead(A0); </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float bvb = analogRead(A2);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float bvs = analogRead(A3);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> // convert to volts </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float vc = 5.0*bvc/1024.0;</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float vb = 5.0*bvb/1024.0;</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> float vs = 5.0*bvs/1024.0;</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> // transfer in one single line</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.print(vc);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.print(",");</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.print(vb);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.print(",");</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> Serial.println(vs);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;"> delay(500);</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: Courier New, Courier, monospace;">}</span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span><span style="background-color: #ffe599; font-family: 'Courier New', Courier, monospace;"> </span></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">And that's it! The program simply reads
the voltages and sends them to your computer which has the job of
interpreting and displaying the data!</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">We use the computer to receive and
display the data so we write a small program in processing that will
read the data from the serial port and store it into a list
structure. A serial event is generated every time a new line of text
arrives. The data is extracted and put into an object which is
stored in an ArrayList. The ArrayList is sorted based on Ib as each
item is added because data can come in out of order as you twiddle
the potentiometer knob. If you turn too fast you will start with a
very rough graph. You can refine it by turning it backwards and
forwards – or turning it slowly.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The program then draws a graph
background and plots the required graph as selected by the user.</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The program then draws a graph
background and plots the required graph as selected by the user.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Options available:</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Ib / Ic - press C</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Ib / Vc - press V</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Vs / Vc - press B</span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Additionally P clears the graph and Q
will close the connection to the Arduino</span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Since the Processing code is somewhat more involved, you can download it from GitHub from the link at the end of this article. The raw data gives us the following curve:</span><br />
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP4PozOdNwtYDoPhXm-Xo3yVo4nFuvG-5CArSlbSDivV7cJYsG_Y16RiwQ49aBb7UyJIVzAbPCF2u1yI0GDQs_cUJPHuAMvj5zGucw-d52TFkKDmjpjNY6DniZIcmepzd6kS_Gx46Rz5s/s1600/vvcurve.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP4PozOdNwtYDoPhXm-Xo3yVo4nFuvG-5CArSlbSDivV7cJYsG_Y16RiwQ49aBb7UyJIVzAbPCF2u1yI0GDQs_cUJPHuAMvj5zGucw-d52TFkKDmjpjNY6DniZIcmepzd6kS_Gx46Rz5s/s1600/vvcurve.tiff" height="320" width="292" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Collector Voltage vs Input Voltage</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">This is a plot of the raw data from the Arduino - but is really only useful for understanding exactly this configuration (with these exact resistors). However it does show you that you have an inverting amplifier.<br /><br /> Calculating using the values of the two resistors allows us to determine the current and get Ib / Vc and Ib / Ic plots</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiwFbtL9vTePLtjXPR4k3F8MgQNrFc1sgCpHMe4KYigwFR6A_9j5nL0ACI8DNOQCKqcpDuZ_az2PmNxClRmTuOmjlkVQcw_2WhKC1vib1apnUG1NWfiFke3K5YTKn96TlUa9Oq6a6UGmI/s1600/curveTracerVoltage.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiwFbtL9vTePLtjXPR4k3F8MgQNrFc1sgCpHMe4KYigwFR6A_9j5nL0ACI8DNOQCKqcpDuZ_az2PmNxClRmTuOmjlkVQcw_2WhKC1vib1apnUG1NWfiFke3K5YTKn96TlUa9Oq6a6UGmI/s1600/curveTracerVoltage.tiff" height="320" width="307" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Variation of Vc with Ib</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNzgcQ0E7tX2B6NdEwkeOvQIunIwcST6szJiCIKPPK6Bz6pVo8fJc1jAkpsogr7yn34N0YwiGzhz6HiNhqEmwf5XzNdyejohDe6WS_C39qUnkinXhkSGFqAjDBsCHQvh8MJo-r5H8UV6k/s1600/curveTracerCurrent.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNzgcQ0E7tX2B6NdEwkeOvQIunIwcST6szJiCIKPPK6Bz6pVo8fJc1jAkpsogr7yn34N0YwiGzhz6HiNhqEmwf5XzNdyejohDe6WS_C39qUnkinXhkSGFqAjDBsCHQvh8MJo-r5H8UV6k/s1600/curveTracerCurrent.tiff" height="320" width="307" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Variation of Ic with Ib</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Results</span></h3>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The Ib/Ic curve shows the tail off of the
gain when the transistor reaches saturation. The saturation occurs
not because of the transistor but because the resistor cannot allow a current of more 5v/Rc to pass given the 5V supply.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">As you play with the potentiometer, you will notice that more points make the curve smoother.
Depending on the consistency of your connections you may experience a
few glitches but you get enough data to see the pattern.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">One reason you may get some glitches is that you may be moving the potentiometer too fast, thereby causing some inconsistency in the potentiometer value between the three readings.</span></div>
<h3 style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Improvements</span></h3>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The circuit seems to work pretty well –
and the curves are OK except that they are a bit jagged.
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">On refelection, we are assuming that
all three readings are under simultaneous conditions when in fact,
moving the potentiometer means that the readings are not at the same
point. Just as important, we cannot cover a smooth range of input
voltages (Vs) because we are manually turning a knob on the
potentiometer.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The obvious first improvement would be
to replace the potentiometer with something similar but controllable
by the Arduino. Two contenders would be either a Digital to Analog
convertor or a Digital Potentiometer. In this design I settled for a
Digital Potentiometer for the scientifically precise reason that
Element14 had some in stock so they arrived before the DAC chips.
Hence I settled on the MCP4131 Single Channel 7 bit Digital
Potentiometer.</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpG-1hflBnc1Ne_GD58O_4KNZgPNLrebjN9UPIBwU-MuQVgSy-45SMgXgZBWaCdQdpFYQfBkfP3RwoU6s4FGbpkAZC-AX0LPCLL3OAmdRtfSGT6TAOe8C8IAG7ttB9t6F2UyMsa4WSbMQ/s1600/MCP4131.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpG-1hflBnc1Ne_GD58O_4KNZgPNLrebjN9UPIBwU-MuQVgSy-45SMgXgZBWaCdQdpFYQfBkfP3RwoU6s4FGbpkAZC-AX0LPCLL3OAmdRtfSGT6TAOe8C8IAG7ttB9t6F2UyMsa4WSbMQ/s1600/MCP4131.tiff" /></a></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The MCP4131 is an SPI device with a
small difference. I will be covering the nuts and bolts of SPI in another post. This device shares SDI and SDO so you need to add a small change from the usual circuit - which is a single resistor as shown by this note in the data sheet.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi66KSr0btP2AGup-OwlEu9Jjs_Ve1FWWAFEol6tkurYFD6ViDaLTV2PQf7hDOMXgYUQg8RgnlnKzpsciasuUMkNT8boLuS6YfyruS9fFyMLm6moKhvAc8C9vFHEz_RCD_SK4MFX-GUcF8/s1600/resistor.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi66KSr0btP2AGup-OwlEu9Jjs_Ve1FWWAFEol6tkurYFD6ViDaLTV2PQf7hDOMXgYUQg8RgnlnKzpsciasuUMkNT8boLuS6YfyruS9fFyMLm6moKhvAc8C9vFHEz_RCD_SK4MFX-GUcF8/s1600/resistor.tiff" height="93" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLg8sk3__bmSR4Hd3qOhe6WYcWlENzJG92DW_-DQqWhdb0yncgz8UFqaJuqV1ricg_ltZnlEIt09WSTsGhutB-2uqPPf2dvpM4u2ccIgBZUZH5d406mLxnOjlahsTiRmZbH9jzxflopqc/s1600/note2.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLg8sk3__bmSR4Hd3qOhe6WYcWlENzJG92DW_-DQqWhdb0yncgz8UFqaJuqV1ricg_ltZnlEIt09WSTsGhutB-2uqPPf2dvpM4u2ccIgBZUZH5d406mLxnOjlahsTiRmZbH9jzxflopqc/s1600/note2.tiff" height="24" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The calculations required by Note 2 are
that
</span></div>
<ol>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">When the first edge is asserted,
the resistor must be low enough to allow the CPU to drive the
device's pins both high and low</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">When the second edge is asserted,
the resistor must be high enough to allow the device to override the
CPU's outputs.<br /><br />
</span></div>
</li>
</ol>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The calculations require reading both the CPU and device's data sheets but show that i</span><span style="font-family: Arial, Helvetica, sans-serif;">n practice there are quite a wide
range of values possible. I selected a 4.7K resistance out of sheer
instinct. </span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">This is really simple to implement as shown below.</span></div>
<br />
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3RJwmnu7EaERYVt7It6OGkVz5i8NSP1ZvcIX2CwvFM-jwhUHNno3ZB2WJnP18rxLhJyKk8RRh9Pn4gzSd5wIwNYpLXBpFHhDxkru02sy33pzUbjeIhY4cQPme0s_YAVvuYN7efG7G88A/s1600/CurveTracer+-+2_schem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3RJwmnu7EaERYVt7It6OGkVz5i8NSP1ZvcIX2CwvFM-jwhUHNno3ZB2WJnP18rxLhJyKk8RRh9Pn4gzSd5wIwNYpLXBpFHhDxkru02sy33pzUbjeIhY4cQPme0s_YAVvuYN7efG7G88A/s1600/CurveTracer+-+2_schem.png" height="186" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">And the wiring is just as easy</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYBZrjj7LjIdyCyEAvyvnrSkNQMJIidYLYsn9OzUZbLjpsLo7j0CXnfcTlerosIy2uw0pVPOzRRM-9lZfEQpGaDl9oTF5b3-egGfAxgWTTnn2q5lcJvS95-6YeEkDEx6JvVYkfzeHPERI/s1600/CurveTracer+-+2_bb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYBZrjj7LjIdyCyEAvyvnrSkNQMJIidYLYsn9OzUZbLjpsLo7j0CXnfcTlerosIy2uw0pVPOzRRM-9lZfEQpGaDl9oTF5b3-egGfAxgWTTnn2q5lcJvS95-6YeEkDEx6JvVYkfzeHPERI/s1600/CurveTracer+-+2_bb.png" height="315" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Revised wiring using MCP4131 digital Potentiometer</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">To use the MCP4131 you can download and
install the MCP4131 library. I thought I was going to have
to write it - but it is quite a simple library.<br /><br /><a href="https://github.com/johnnyonthespot/MapleLibraries/tree/master/MCP4131">https://github.com/johnnyonthespot/MapleLibraries/tree/master/MCP4131</a></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">One important thing to note is that
although it is a seven bit device, the vales range from 0 to 128, not
127 as you would normally imagine.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<h3 style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"> Use of the MCP4131</span></h3>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<div style="margin-bottom: 0in;">
<span style="font-size: x-small;"><br /><span style="font-family: Courier New, Courier, monospace;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;">#include <SPI.h>
</span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">#include
<MCP4131.h></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace;"><br />
</span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">//setup
an instance of MCP4131</span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">MCP4131
MCP4131(10); // with a CS pin of 10</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in; page-break-before: always;">
<span style="font-family: Arial, Helvetica, sans-serif;">In the setup
code</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">MCP4131.setTap(MCP4131_MIN);
//Sets the pot to 0.</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
</div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">if
(MCP4131.initTCON()) //init the pot, connect wiper0, and turn ON pot</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">{</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;"> Serial.println("Init
Error!");</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">}</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">And in the loop (with a variable
“tapValue” which is suitably declared and controlled somewhere)</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">if
(MCP4131.setTap(tapValue))</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">{</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;"> Serial.println("setTap
Error!");</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: x-small;">}</span></span></div>
<div style="background: #e6ff00; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">And that's it. </span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">Since I had to write changes to the
Arduino code to use the MCP4131, I also modified it to do a single
sweep of the Potentiometer (with tapValue from 0 to 128) and then
stop until it received a “G” on the serial port.<br /><br />Then I
modified the Processing code to send the G when the user requested
for a new graph to be drawn.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">The result was far smoother graphs.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1T7BgX_mmULSONSKx0GrhrXW0R-PKhyA7EjN4RdtxrK2oCoS-ZYa5adnkQyUHss8wPiYPO4n8p3KWL17u4xxTeqAAIPTQamw47RrUHDtb95ko7VN85j7EHP78npTHeXYmagMo4hNAgnc/s1600/AdvancedCurve.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1T7BgX_mmULSONSKx0GrhrXW0R-PKhyA7EjN4RdtxrK2oCoS-ZYa5adnkQyUHss8wPiYPO4n8p3KWL17u4xxTeqAAIPTQamw47RrUHDtb95ko7VN85j7EHP78npTHeXYmagMo4hNAgnc/s1600/AdvancedCurve.tiff" height="320" width="307" /></a></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">That's is about it. There is a ton of future work to be done - starting with different transistor configurations.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">See the GitHub repositories below for code:</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://github.com/DaveAppleton/ArduinoCurveTracer">https://github.com/DaveAppleton/ArduinoCurveTracer</a></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://github.com/DaveAppleton/ArduinoCurveTracerWithSPI">https://github.com/DaveAppleton/ArduinoCurveTracerWithSPI</a></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://github.com/DaveAppleton/ProcessingCurveTracer">https://github.com/DaveAppleton/ProcessingCurveTracer</a></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
</div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com4tag:blogger.com,1999:blog-2843278363263109322.post-1147596845647039852013-04-29T08:59:00.000-07:002013-04-30T10:11:09.040-07:00Geekcamp SG<div class="separator" style="clear: both; text-align: center;">
<a href="http://geekcamp.sg/static/images/geekcampsg-logo-hori.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="99" src="http://geekcamp.sg/static/images/geekcampsg-logo-hori.png" width="320" /></a></div>
<br />
<br />
<br />
Last year, in a fit of wild enthusiasm I offered to talk at <a href="http://geekcamp.sg/" target="_blank">Geekcamp SG</a>. The talk was to be called "Hardware is NOT boring" and would show racing cars being controlled by a mobile phone and an Arduino. Sometimes this is the only way that I can kick myself into doing something for fun.<br />
<br />
The thing is, you only get to talk if enough masochists vote for you. They did.<br />
<br />
With the deadline looming, I stayed up late in my favorite JB coffee shops working on the code, built hardware by day - and worked out a backup plan (trains) in case the cars didn't want to run properly.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/gFk9SP-d-U4?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
I had to be in North Johor the day before the event till late - when all was done I jumped on the Harley and rode like the devil down Highway 1 to Singapore. Gotta love night rides on un-illuminated Malaysian roads. Reached Singapore at 4, stayed up till about 6.30, grabbed a couple of hours sleep and made it to GeekCamp just in time.<br />
<br />
Being a bit dazed, I was not really awake enough to pay attention to Subh's talk so I started hacking a mouse controlled by a 3D accelerometer and an Arduino Leonardo - which also made it into the talk. Went home, out like a light - but up early next day for Hari Raya.<br />
<br />
So seriously, am I stupid enough to do it again? Not a chance. This year I have a partner in crime : Adnan Jalaludin, the designer, maker and seller of the <a href="http://www.2wattelements.com/products/raspy-juice-rev-1-beta-kit" target="_blank">Raspy Juice</a> - an add on board for the PI which features a buck regulator, real time clock and an AtMEGA processor for servo control.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://cdn.shopify.com/s/files/1/0175/2574/products/Raspy_3303_close_up_1024x1024.jpg?232" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="210" src="http://cdn.shopify.com/s/files/1/0175/2574/products/Raspy_3303_close_up_1024x1024.jpg?232" width="320" /></a></div>
<br />
<br />
So, this year it is all about Raspberry Pi, Servos, DC motors, webcams and anything else we can get our hands on. We will be drawing on Adnan's encyclopedic knowledge of Linux, Hardware and other stuff and seeing what we come up with.<br />
<br />
I, for one, am quite looking forward to seeing it.<br />
<br />
And there will be circuits you can build.<br />
There will be software to download and try.<br />
There may be flying things if I can bend enough ARMs....<br />
<br />
Oh yeah. When things don't work, there will also be some really bad jokes.<br />
<br />
Geekcamp SG.<br />
7th September 2013,<br />
Microsoft Singapore.Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com1tag:blogger.com,1999:blog-2843278363263109322.post-18664461572861740962013-01-21T20:25:00.001-08:002013-01-21T20:25:28.527-08:00Thursday 31st Arduino Intermediate class - coming?Since Curica seems to be down - and I am not keen to use any of the sites that want you to pre-pay - may discourage you from committing (in case you need o drop out) / coming at the last minute, and I don't want to side step their payment mechanisms - I am resorting to asking you to simply drop a comment here to indicate if you are coming.<br />
<br />
<span style="background-color: white;"><span style="color: #444444;">Details: </span></span><br />
<br />
<span style="background-color: white;"><span style="color: #444444;">This session we will cover</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"><br /></span></span>
<span style="background-color: white;"><span style="color: #444444;">1. Use of Serial port for </span></span><br />
<span style="background-color: white;"><span style="color: #444444;"> Output</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"> Debugging</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"> Input (interaction)</span></span><br />
<span style="background-color: white;"><span style="color: #444444;">2. Interrupts</span></span><br />
<span style="background-color: white;"><span style="color: #444444;">3. Timers</span></span><br />
<span style="background-color: white;"><span style="color: #444444;">4. Seven Segment LED</span></span><br />
<span style="background-color: white;"><span style="color: #444444;">5. Servo Motors</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"><br /></span></span>
<span style="background-color: white;"><span style="color: #444444;">Venue: Hackerspace SG, 70 A Bussorah St, Singapore 199483</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"><br /></span></span>
<span style="background-color: white;"><span style="color: #444444;">Date / Time: Thursday 31st Jan, 7.00 p.m. - 9.00 p.m.</span></span><br />
<span style="background-color: white;"><span style="color: #444444;"><br /></span></span>
<span style="background-color: white;"><span style="color: #444444;">Cost: $45.00 if you have change - otherwise $50.00</span></span><br />
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com3tag:blogger.com,1999:blog-2843278363263109322.post-3322978974973306642013-01-21T20:13:00.001-08:002013-01-21T20:13:35.516-08:00Basic class - Friday 25th Jan - Coming?Since Curica seems to be down, I am not terribly keen to use any of the online booking systems that make you pay in advance because I understand that things come up at the last minute and so you may not be able to make it - and likewise you may want to come along at the last minute....<br />
<br />
So - if you are coming - please leave a comment here<br />
<br />
Details:<br />
<br />
<span style="background-color: white; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">By popular demand we are yet again offering yet another reprise of our introductory hands on course that will teach you how to build cool things with the Arduino - the open source micro controller platform that has changed the world by making micro controllers accessible to hobbyists at a really affordable price. You will learn how to use the Arduino in your hobby projects. Control LEDs, Buzzers etc, detect the state of buttons & sensors. Some simple programming and electronics will be taught (emphasis on simple) but you will get results very quickly. Hackerspace are making their Arduino kits available for the class so all you need to do is to bring along your notebook. Beginners class. (repeated by popular demand) </span><span style="background-color: white; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">You will need to bring your own laptop.</span><br />
<span style="background-color: white; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;"><br /></span>
<span style="background-color: white; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">Venue: </span><span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">Hackerspace SG, 70A Bussorah St, singapore 199483</span><br />
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;"><br /></span>
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">Date / Time: Friday 25th Jan, 7.00 p.m. - 10.00 p.m.</span><br />
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;"><br /></span>
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;">Cost: S$ 45 if you have change, otherwise $50 ;-)</span><br />
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;"><br /></span>
<span style="background-color: gainsboro; color: #404040; font-family: 'PT Sans', sans-serif; font-size: 14px; line-height: 18px;"><br /></span>Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com3tag:blogger.com,1999:blog-2843278363263109322.post-71570078286233997012013-01-15T20:47:00.000-08:002013-01-15T20:47:03.251-08:002013 - Happy New Year -<br />
(Taking "arang batu" to Istana Bahru)<br />
<br />
IOBLOCKS is starting 2013 from Istana Bahru - a new home in Johor Bahru right next to one of the Sultan's palaces. The place is quite a mess having combined the old office with heaps of personal possessions.<br />
<br />
We have been here since October 2012 but the insanity of teaching schedules of my Image Processing classes at DigiPen meant that those few remaining free minutes were used looking after clients rather than creating some kind of order.<br />
<br />
Our Android Apps for Cytech Technologies' Comfort home control system are now available on Google Play. They have been pretty well received. Now it is time for the iPad version.<br />
<br />
January 2013 will see two Arduino classes at Hackerspace SG - a basic class on the 25th (Friday) and an intermediate on the 31st (Thursday).<br />
<br />
The Intermediate session will feature Serial ports, debugging, 7 segment LED, Servos, interrupts and timers.<br />
<br />
Finally - received an excellent testimonial from a client even though we didn't get the job...<br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 12.727272033691406px; line-height: 15.454545021057129px;">"In the short time that I spent with you, it impressed upon me that you had machine vision knowledge that was far better than the other vendors. I'm lining-up a few more Vision Inspection projects and will be contacting you soon."</span><br />
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-62643939494295564362012-12-24T20:47:00.001-08:002012-12-24T20:47:37.197-08:00Keypad code available on BitBucketYou can now download the code for the Keypad/LCD code from <a href="https://bitbucket.org/dappleton/arduino-keypad-and-lcd" target="_blank">BitBucket</a><br />
<br />
This is my first attempt using BitBucket so please let me know if there are any problemsDave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-53702815660035139972012-08-25T04:33:00.002-07:002012-08-25T04:34:57.714-07:00New coursesWe will be offering a range of classes in the next few weeks depending on demand....<br />
<div>
<br /></div>
<div>
<u><a href="http://www.curica.com/class_events/control-things-with-the-arduino-yet-again-aug-31--2" target="_blank">Control Things with the Arduino </a></u></div>
<div>
- our basic class</div>
<div>
<br /></div>
<div>
<u>More Fun with Arduinos </u></div>
<div>
- introduces interrupts, timers, servos, seven segment LED as a programming example.....</div>
<div>
<br /></div>
<div>
<u>Communicating with the Arduino</u></div>
<div>
- shows how to interface LCD and Keypad to the Arduino</div>
<div>
<br /></div>
<div>
And we intend to have our first class showing the Arduino with Ethernet shield </div>
<div>
(i.e. Ethernet and SD card)</div>
<div>
<br /></div>
<div>
Check <a href="http://www.curica.com/" target="_blank">CURICA</a> for details.</div>
Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-68211019451652671582012-08-25T02:50:00.001-07:002012-08-25T02:50:18.000-07:00GeekCampSG 2012 has come and gone. Not fantastic timing - on the last day of Ramadan - leaving me to prepare notes in the middle of the night - while travelling etc. But for some reason, people seemed to like the talk entitled Hardware is not Boring where I used an Arduino to control the speed of toy racing cars in response to commands sent from mobile phones.<br />
<br />
You can find the slides on <a href="https://speakerdeck.com/u/daveappleton/p/hardware-is-not-boring" target="_blank">SpeakerDeck</a><br />
<br />
The video is missing - as is one other slide which did not get included for some reason.... but the essence is there.<br />
<br />
The demo did not go as smoothly as hoped - they never do. I should not have used the Scalextric Micro - the cars have magnets that make them hard to move. <br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/gFk9SP-d-U4" width="560"></iframe>
When I tried it on the full sized Scalextric later it went like a dream. It also managed to power little Ali's Thomas the Tank Engine as well.<br />
<br />
For once I finished in record time - so I finished up showing something I had hacked together half an hour before - using an Arduino Leonardo and a 3D Accelerometer to work as a mouse.<br />
<br />
We are looking at having Arduino classes again soon at Hackerspace SG. Please check either at Hackerspace, on Curica or back here for details<br />
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-65354792435027488882012-07-22T07:40:00.000-07:002012-07-22T07:40:38.671-07:00Anybody who has succeeded in using MKNetworkKit?<br />
<br />
I am having a bit of trouble following this. I am using XCode 4.2 on Snow Leopard<br />
<br />
I am trying to evaluate using MKNetworkKit to replace some hairy network code I wrote a year or so ago....<br />
<br />
So I am testing out the <a href="http://feistygoat.com/blog/2012/05/upload-a-photo-using-objective-c-ios/" style="background-color: #eeeeee;" target="_blank">Upload Photo project at FiestyGoat</a><br />
<br />
I used GitHub to download MKNetworkKit to my documents folder.<br />
<br />
I built MKNetworkKit-IOS<br />
<br />
Then....<br />
I started by creating a new workspace (Uploader) and then a new project (Upload) as a single view application using storyboards. The project is in Desktop/Xcode Projects/Upload.<br />
<br />
I then dragged the MKNetworkKit subfolder (i.e. the one that contains Reachability & Categories) to the project<br />
copying the files across<br />
<br />
I then dropped into Finder and removed the two unwanted files (NSAlert+.....h/m) and cleaned the project.<br />
<br />
Then I modified Upload-Prefix.pch<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">#ifdef __OBJC__</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> #import <UIKit/UIKit.h></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> #import <Foundation/Foundation.h></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> #import "MKNetworkKit.h"</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">#endif</span><br />
<br />
Then I tried to build it and I get an error <span style="background-color: red;"><span style="color: yellow;">"'MKNetworkKit.h' file not found"</span></span><br />
<br />
Now I am pretty sure that I am missing something pretty simple but cannot figure out what. I am pretty sure that if I was supposed to change project settings somebody would have mentioned it.....<br />
<br />
Any idea what my stupid error is?<br />
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com1tag:blogger.com,1999:blog-2843278363263109322.post-54070430191582467462012-07-18T17:57:00.000-07:002012-07-18T17:57:00.194-07:00Using an LED as a light sensorWe are working on Power Control Systems now. So we were sitting in the library and we started talking about solar panels and how they worked.<br />
<div>
<br /></div>
<div>
It was around this point that I remembered Jolyon's habit of using things backwards - like using a loud speaker as a microphone and using a 12v transformer to create 240V from a chopped 12V supply...</div>
<div>
<br /></div>
<div>
And I remembered reading about using an LED back to front to act as a light sensor. So I rigged up this little circuit as a quick demo right there in the library....</div>
<div>
<table><caption><span style="color: orange; font-family: Arial, Helvetica, sans-serif;">LED as a sensor</span></caption>
<tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0O8C07nsvWmB_OGRR95lUpDBWQCxud5KSu6ElzuGLYSKn63pbtQL8InCEtQkpVaqUJpTpWuqcPDYEp-Yx8ED33l5D9JEfRYhR5NztrBPpQ4phVp22-lOSt73_EwY1dTgow9760solS68/s1600/diag1.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0O8C07nsvWmB_OGRR95lUpDBWQCxud5KSu6ElzuGLYSKn63pbtQL8InCEtQkpVaqUJpTpWuqcPDYEp-Yx8ED33l5D9JEfRYhR5NztrBPpQ4phVp22-lOSt73_EwY1dTgow9760solS68/s1600/diag1.tiff" /></a></td><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgreVKtmo3OzIOaD1vDfuoiXsOb7kZFShSDeMUMk0k8oYHZbQWr5T3zeSKe8mmivF8iciUerYd8JLKNNuAIHqsmjMOjFU5ox9vN7mrA-r4Z_W7xsvtwvfA2wjYEKX-BDsasu5Is4azUdHM/s1600/fritz1.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgreVKtmo3OzIOaD1vDfuoiXsOb7kZFShSDeMUMk0k8oYHZbQWr5T3zeSKe8mmivF8iciUerYd8JLKNNuAIHqsmjMOjFU5ox9vN7mrA-r4Z_W7xsvtwvfA2wjYEKX-BDsasu5Is4azUdHM/s320/fritz1.tiff" width="315" /></a></td></tr>
</tbody></table>
<br /></div>
A few lines of code and it was up and running........<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4yU9hKkB75h_TG5tuKU9TlvLKVeVy9xHjC7HzSUoWqE30oHtyWwXd7IvfvSDp44v3Bnkw0Q_gtfBETcBqSC8JV9YFa0B5z24jJ_QuclIxNBhlK9DgEfAzjZ9_leZVKRaaj9BcT_dzXkM/s1600/code.tiff" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4yU9hKkB75h_TG5tuKU9TlvLKVeVy9xHjC7HzSUoWqE30oHtyWwXd7IvfvSDp44v3Bnkw0Q_gtfBETcBqSC8JV9YFa0B5z24jJ_QuclIxNBhlK9DgEfAzjZ9_leZVKRaaj9BcT_dzXkM/s1600/code.tiff" /></a></div>
<br />
Pretty simple eh?<br />
<br />
I just used my iPhone as a light source using Torchlight - one of the many free apps that use the phone's LED... and the results were pretty astounding.....<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK_7TW6akIDROz_-KtN7EF1jTcd9JacJjvp494eD1EBrgQo9pXpqNPoiuw5uzd7DDS6OM8reUS9Lr3SdI02cvUtw5b5mAFpe4PxNa00NQb07qd9fqQ2f_UsgpAGh6ZaUNBjDhafIoOCe0/s1600/serial.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK_7TW6akIDROz_-KtN7EF1jTcd9JacJjvp494eD1EBrgQo9pXpqNPoiuw5uzd7DDS6OM8reUS9Lr3SdI02cvUtw5b5mAFpe4PxNa00NQb07qd9fqQ2f_UsgpAGh6ZaUNBjDhafIoOCe0/s320/serial.png" width="292" /></a></div>
<br />
This must be one of the most simple Arduino circuits and it works because when light hits the PN junction of the LED it generates a SMALL voltage that you can read on the analog input pin.<br />
<br />
Because the voltage is so small, we need to add upp a large number of cycles to ensure that our reading is not from random noise.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<br /></div>Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com1tag:blogger.com,1999:blog-2843278363263109322.post-79995750401419804242012-07-11T09:52:00.002-07:002012-07-11T09:52:30.905-07:00Ethernet, LCD's, Keyboards and moreWe've been kinda busy.....<br />
<br />
Alvin at Hackerspace arranged with <a href="http://www.sgbotic.com/" target="_blank">SGBotic</a> to promote the courses on their website and the response was kind of fantastic.... and agreeing to it blew my idea of starting an Arduino store right out of the water but to be honest it is quite a relief.<br />
<br />
We will still be putting some Arduino stuff together (special kits maybe) - and I am seriously thinking of doing something to jump start the Malaysian Arduino scene but I will not bite the hand that feeds me especially when they are getting me some robot toys to play with....<br />
<br />
Since the last post we have had a couple more intro courses which were really well attended and the long awaited <a href="http://www.curica.com/class_events/communicating-with-the-arduino" target="_blank">"Communicating with the Arduino"</a>.<br />
<br />
In "Communicating with the Arduino", the second of our intermediate classes, we left our students to make some of the decisions - e.g. pin assignments. As expected, some guys, made the same mistakes that I did (and others) which was an excellent opportunity to teach more debugging techniques as well as some underlying principles.<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/URcl5rLuowQ" width="560"></iframe>
<br />
<br />
And then - really cool - I was asked to give a talk to IOS Dev Scout about using the Arduino with the iPhone. This meant it was time to start preparing our new intermediate class which I had been thinking about for sometime about "Arduinos on the net"<br />
<br />
<br />
I presented an Arduino acting as an HTTP server, a TELNET server and a custom protocol server. In the last case I made the Arduino emulate a <a href="http://www.cytech.biz/" target="_blank">Cytech Comfort Home Automation System</a> and control it with the <a href="http://www.cytech.biz/iphone_app_1.html?category_id=98" target="_blank">IOS App</a> that I wrote for Cytech last year.<br />
<br />
Finally we logged into the Cytech demonstration system (a Dolls House in their office in UBI with loads of lights) and arbitrarily turned lights on and off while watching it on a live webcam feed.<br />
<br />
So keep tuned - we will try to present this course on a Saturday afternoon in the next month.<br />
<br />
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-59158262834732083382012-04-01T20:41:00.001-07:002012-04-01T20:41:59.105-07:00I couldn't help it…..The processing class was great.<div>
<br /></div>
<div>
It all started with a piece of paper….</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6h6X8aqsp23H7ob0k1OaAJVnzo6r-dYmTIgRvI8rdwi-ADTGR8BgfkPnbz9D9KN_vMdh6zjyz4ier2fLWptRUy9gX8_VJRgnE06pWuqCZT7bXGf4z-mUGDtuSzPWpA7Coqs_jP3iw8I/s1600/IMG_2090.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="287" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6h6X8aqsp23H7ob0k1OaAJVnzo6r-dYmTIgRvI8rdwi-ADTGR8BgfkPnbz9D9KN_vMdh6zjyz4ier2fLWptRUy9gX8_VJRgnE06pWuqCZT7bXGf4z-mUGDtuSzPWpA7Coqs_jP3iw8I/s320/IMG_2090.jpg" width="320" /></a></div>
<div>
<br /><div>
<br /></div>
<div>
We had three people signed up - one couldn't make it - but in a way that made it even more fun.</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiitRfukFcCqqkeKlAgunuY_cnsazfTBauPxdyNNrt1K2jBNTCVJFKozIhdGoNm3XCoKjrT_SL2gBoIDG1AetblWT8QELRjhxcHYWc0vvpb6XR3lEBJfEx9JT-3qCz8s-nNioLhG-voIbw/s1600/IMG_2089.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiitRfukFcCqqkeKlAgunuY_cnsazfTBauPxdyNNrt1K2jBNTCVJFKozIhdGoNm3XCoKjrT_SL2gBoIDG1AetblWT8QELRjhxcHYWc0vvpb6XR3lEBJfEx9JT-3qCz8s-nNioLhG-voIbw/s320/IMG_2089.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Hackerspace SG processing class<br />left -> right : Zul (far left), Kit Sunde and Bjorn Andersson</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
<br /></div>
<div>
Kit & Bjorn were great - they got all the demos working and we got through all the material in record time which gave us time to go into "workshop mode"….</div>
<div>
<br /></div>
<div>
We took the last tutorial and started turning it into a game……</div>
<div>
<br /></div>
<div>
Then over the weekend I was stuck with a really lousy internet connection so I started adding music and a final image to it. You can see the results on <a href="http://www.ioblocks.com/keen" target="_blank">the ioblocks site</a></div>
<div>
<br /></div>
<div>
It may never win the world gaming awards but it was fun…. </div>
<div>
<br /></div>
<div>
Thanks to Kit and Bjorn - and for Zul for both being a better lecturer than me and for turning my crazy ideas into a decent lesson plan and notes :-)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
</div>
</div>Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-54410360545174854692012-04-01T20:17:00.000-07:002012-04-01T20:17:25.358-07:00Dazzle your friends with Processing!A couple of years ago I came across Processing in a <a href="http://dawson-station.blogspot.com/2010/04/virtual-scale.html" target="_blank">Ken Olsen's blog</a> where he was using an Arduino to control a model railway layout which implemented a shunting puzzle. He used Processing to create a simulation of it.<br />
<br />
Later when we built a 3D visual inspection system I decided to use Processing to visualise the data we were getting back from the system. It was never very pretty (i didn't spend enough time on it) but it served its purpose...<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu__ikNwVgkgJTk-2vqefccO5cSAm_x2W0WmnGcbz-zBAA7KCpBWoLNhySO4MXfBbYfFvKzq3qjPezS17ITf3EALJ9v1vzaUY7yoUf-InmxMH7dyz-0UKFsh0mqeBzu0suL9XCnRR8V64/s1600/3dimage.tiff" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu__ikNwVgkgJTk-2vqefccO5cSAm_x2W0WmnGcbz-zBAA7KCpBWoLNhySO4MXfBbYfFvKzq3qjPezS17ITf3EALJ9v1vzaUY7yoUf-InmxMH7dyz-0UKFsh0mqeBzu0suL9XCnRR8V64/s320/3dimage.tiff" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">3D Visualisation of semiconductor leadframe</td><td class="tr-caption" style="text-align: center;"><br /></td><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
But the main thing was that Processing was pretty easy to use. The next time I used it was when I was mentoring some students who built a data logger for a 3D accelerometer - I helped them playback the position and orientation of the sensor.<br />
<br />
Each time, the code required was really minimal compared to traditional programming languages.<br />
<br />
To sum up processing - you can start getting results in two or three lines of code - and you don't need to be a programmer to write them.<br />
<br />
Come along and start dazzling your friends!<br />
<br />
30th March<br />
HackerSpace SG<br />
70A Bussorah St @ 7.00 p.m.<br />
<br />
<br />
<br />
<br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0tag:blogger.com,1999:blog-2843278363263109322.post-68246147945007126642012-03-15T19:34:00.000-07:002012-03-15T19:34:03.346-07:00Control things with the Arduino! (repeat)The guys at Hackerspace were so happy with our last two sessions that we have been invited back!<br />
<br />
We are holding another introductory class on Friday 23rd. We have also been asked to do an advanced class on a weekend.....<br />
<br />
Come along on the 23rd to discover how you, at very little cost, can build some really cool stuff.<br />
<br />
We introduce a bit of programming and some simple electronics and at the end of the session you will have it singing and dancing. Well - not really dancing but flashing lights, playing tunes and reacting to its environment.....<br />
<br />
Last time we conducted the course, quite a few guys were already starting their own projects and one guy had almost finished his before we finished....<br />
<br />
See you there!<br />
<br />
70A Bussorah Street<br />
7 p.m. to 10 p.m.<br />
(longer if we have enough fun)Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com2tag:blogger.com,1999:blog-2843278363263109322.post-79418639832847446772012-02-26T05:42:00.000-08:002012-02-26T05:42:15.013-08:00More Fun with the Arduino<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"></span></span><span style="font-family: Arial,Helvetica,sans-serif;">We have been planning a second class in our "Control Things with the Arduino"</span> <span style="font-family: Arial,Helvetica,sans-serif;">series since the positive feedback made a repeat session of the basic class necessary.</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">We knew what we would cover - Keypads and LCD's - but the ones we found locally were so expensive that we started sourcing them ourselves... and got stuck with horrible lead times... and we are still waiting for the stuff to be in. You can see <a href="http://www.youtube.com/watch?v=URcl5rLuowQ&context=C347e5deADOEgsToPDskLmYmW_0zsKA_lMg7dMm_FA" target="_blank">a video of one of the demos that we made</a> on Youtube </span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">So finally we decided to do a different session first. We thought for a bit and worked out some useful things to cover - a mix of hardware and software which we hope will come in handy.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">This session we will cover</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">1. Use of Serial port for </span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"> Output</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"> Debugging</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"> Input (interaction)</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">2. Interrupts</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">3. Timers</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">4. Seven Segment LED</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">5. Servo Motors</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">This time we will be building things up as we go along so combine what we learn into a small project.</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">Class date - 1st March 2012 at 7.00 p.m.</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">HackerspaceSG</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">70B Bussorah Street</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">Singapore</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">Cost: S$ 45 per head, a portion of which goes to HackerspaceSG</span><br />Dave Appletonhttp://www.blogger.com/profile/03056312169503843223noreply@blogger.com0