tag:blogger.com,1999:blog-82564532009-02-21T04:38:32.209-08:00Physical Computing @ ITPJohn Schimmelnoreply@blogger.comBlogger17125tag:blogger.com,1999:blog-8256453.post-1103461157381251932004-12-14T04:57:00.000-08:002004-12-19T04:59:17.380-08:00Coffeetable ProjectFor my final PComp project I worked on a coffeetable built from printers that I found on the streets of New York. Check it out.
<br />
<br /><a href="http://www.base2john.com/itp/coffeetable/">http://www.base2john.com/itp/coffeetable/</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-110346115738125193?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1103119267546830292004-12-11T05:56:00.000-08:002004-12-19T05:00:07.016-08:00Radio projectChia H and I took an old radio and attempted to make it a history machine full of campaign commericals from Presidental elections.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-110311926754683029?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1098393310499528842004-10-21T14:09:00.000-07:002004-10-21T14:19:30.820-07:00Shoe Pictures<img src="http://www.base2john.com/itp/pcomp/shoe1.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/shoe2.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/shoe4.jpg" /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109839331049952884?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1098317854708537222004-10-20T17:17:00.000-07:002004-10-20T17:17:34.706-07:00PIC Shoe Codeinput portc.7
<br />INPUT portb.7
<br />output portc.6
<br />inputVar VAR byte
<br />pot1 VAR WORD ' Create variable to store result
<br />pot2 VAR WORD
<br />buttonVar VAR WORD
<br />
<br />
<br />' POTENTIOMETER SETUP
<br />' Define ADCIN parameters
<br />DEFINE ADC_BITS 10 ' Set number of bits in result
<br />DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
<br />DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
<br />
<br />
<br />TRISA = %11111111 ' Set PORTA to all input
<br />ADCON1 = %10000010 ' Set PORTA analog and right justify result
<br />PAUSE 500 ' Wait .5 second
<br />
<br />
<br />'-------------------------------------------------------
<br />
<br />
<br />main:
<br />ADCIN 0, pot1 'potentiometer variable
<br />ADCIN 1, pot2 'potentiometer variable
<br />pot1 = pot1/4 'divide the value because it's too big
<br />pot2 = pot2/4
<br />
<br />
<br />'----------------------
<br />' THE LISTENING CODE - puts message into inputVar
<br />serin2 portc.7, 16468, [inputVar] 'listening for potentiometer value
<br />if portb.7 = 1 then
<br /> buttonVar = 1
<br />else
<br /> buttonVar = 0
<br />endif
<br />
<br />
<br />if inputVar=65 then ' if received message is 65, then respond to processing
<br />
<br />
<br />'usage: serout2 dataPin, mode, [data]
<br />serout2 portc.6, 16468, [pot1,pot2,buttonVar] 'talk to processing
<br />ENDif
<br />
<br />
<br />goto main
<br />
<br />
<br />nodata:
<br />return<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109831785470853722?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1098317785019797302004-10-20T17:15:00.000-07:002004-10-20T17:16:25.020-07:00Processing Shoe Codefloat[] data = new float[3]; // create 2 space data array. 1) Potentiometer and 2) photocell
<br />int index=0;
<br />float xpos,ypos;
<br />int bck;
<br />
<br />int[] dotsXpos = new int[30];
<br />int[] dotsYpos = new int[30];
<br />int dots;
<br />
<br />void setup() {
<br /> background(0);
<br /> size(305,305);
<br /> beginSerial(); //begin serial communication thing
<br /> serialWrite(65); //talk to PIC . like saying hello
<br />}
<br />
<br />void loop() {
<br />
<br /> fill(0,140,140);
<br /> noStroke();
<br /> ellipse(xpos,ypos,3,3);
<br />
<br /> for (int i=0;i<dotsXpos.length;i++) {
<br /> if ((dotsXpos[i] != 0) && (dotsYpos[i] != 0)) {
<br /> fill(255,255,0);
<br /> noStroke();
<br /> ellipse(dotsXpos[i],dotsYpos[i],10,10);
<br /> }
<br /> }
<br />
<br /> if (bck==1) {
<br /> dotsXpos[dots] = int(xpos);
<br /> dotsYpos[dots] = int(ypos);
<br />
<br /> if (dots>30) {
<br />
<br /> dots= 0;
<br /> }
<br /> else {
<br /> dots = dots++;
<br /> }
<br /> }
<br />}
<br />
<br />void serialEvent() { //automatic serial listener
<br /> data[index] = serial; // save messages to data array
<br /> index=index+1; // increment serial counter
<br />
<br /> if (index==3) { // both messages received
<br /> ypos = 255 - float(data[0]); // rename the first message to xpos
<br /> xpos = float(data[1]);
<br /> bck = int(data[2]); //save photocell value
<br /> serialWrite(65); // responsd back to PIC
<br /> index = 0; // reset serial counter to zero
<br /> }
<br />
<br />}
<br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109831778501979730?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1098056776685991852004-10-17T16:45:00.000-07:002004-10-17T16:46:16.686-07:00serial and processing codePROCESSING CODE
<br />
<br />float[] data = new float[2]; // create 2 space data array. 1) Potentiometer and 2) photocell
<br />int index=0;
<br />float xpos;
<br />int bck;
<br />
<br />void setup() {
<br /> size(255,255);
<br /> beginSerial(); //begin serial communication thing
<br /> serialWrite(65); //talk to PIC . like saying hello
<br />}
<br />
<br />void loop() {
<br /> background(bck);
<br /> fill(0,0,244);
<br /> ellipse(xpos, 100, 50,50); //movable circle
<br />
<br />}
<br />
<br />void serialEvent() { //automatic serial listener
<br /> data[index] = serial; // save messages to data array
<br /> index=index+1; // increment serial counter
<br />
<br /> if (index==2) { // both messages received
<br />
<br /> xpos = float(data[0]); // rename the first message to xpos
<br /> bck = int(data[1]); //save photocell value
<br /> serialWrite(65); // responsd back to PIC
<br /> index = 0; // reset serial counter to zero
<br /> }
<br />
<br />}
<br />
<br />
<br />
<br />'----------------------------------------
<br />PIC CODE
<br />
<br />
<br />input portc.7
<br />output portc.6
<br />inputVar VAR byte
<br />sensorValue VAR WORD ' Create variable to store result
<br />photoValue VAR WORD
<br />
<br />' POTENTIOMETER SETUP
<br />' Define ADCIN parameters
<br />DEFINE ADC_BITS 10 ' Set number of bits in result
<br />DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
<br />DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
<br />
<br />TRISA = %11111111 ' Set PORTA to all input
<br />ADCON1 = %10000010 ' Set PORTA analog and right justify result
<br />PAUSE 500 ' Wait .5 second
<br />
<br />'-------------------------------------------------------
<br />
<br />main:
<br /> ADCIN 0, sensorValue 'potentiometer variable
<br /> ADCIN 1, photoValue 'photocell
<br /> sensorValue = sensorValue/4 'divide the value because it's too big
<br />
<br />'----------------------
<br />' THE LISTENING CODE - puts message into inputVar
<br />serin2 portc.7, 16468, [inputVar] 'listening for potentiometer value
<br />
<br /> if inputVar=65 then ' if received message is 65, then respond to processing
<br /> gosub blink 'blink LED
<br /> 'usage: serout2 dataPin, mode, [data]
<br /> serout2 portc.6, 16468, [sensorValue,photoValue] 'talk to processing
<br /> ENDif
<br />
<br /> goto main
<br />
<br />
<br />blink:
<br /> high portd.2
<br /> pause 250
<br /> low portd.2
<br /> pause 250
<br /> return
<br />
<br />nodata:
<br /> return<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109805677668599185?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1097698519867416342004-10-13T13:36:00.000-07:002004-10-13T13:15:19.866-07:00Servo control not sooo bad but...Ok, so on Friday night I began testing out the servo motor more. I got the motor to move both from a program and from a potentiometer.
<br />
<br />After taking the code from the website to make the servo move to the left then to the right I wanted to add in some buttons to control the direction. This took some figuring out but eventually I understood that the pulsewidth that the PIC is sending out must stay between two constants: minPulse and maxPulse. While I'm not totally sure if this is correct but pretending the pulseWidth is a degree element 0 degrees to 200 degrees (more like 180) it was easier to see how the variable referred to position.
<br />
<br />here's the code for the button servo action.
<br />
<br />===========================================
<br />
<br />INPUT portd.1
<br />INPUT portd.0
<br />OUTPUT portc.3
<br />
<br />start:
<br />
<br /> pulseWidth VAR BYTE
<br /> ' set up constants with the minimum and maximum pulsewidths
<br /> minPulse CON 50
<br /> maxPulse CON 250
<br /> ' set up a constant with the time between pulses:
<br /> refreshPeriod CON 20
<br />
<br /> ' set an initial pulsewidth:
<br /> pulseWidth = minPulse
<br />
<br />main:
<br /> ' change the angle for the next time around:
<br /> IF (pulseWidth <= maxPulse) AND (portd.1=1) THEN
<br /> pulseWidth = pulseWidth+1
<br /> GOSUB move
<br /> HIGH portd.2
<br /> ELSE
<br /> pulseWidth = pulseWidth
<br /> LOW portd.2
<br /> ENDIF
<br />
<br /> ' change the angle for the next time around:
<br /> IF (pulseWidth >= minPulse) AND (portd.0=1) THEN
<br /> pulseWidth = pulseWidth-1
<br /> GOSUB move
<br /> HIGH portd.3
<br /> ELSE
<br /> pulseWidth = pulseWidth
<br /> LOW portd.3
<br /> ENDIF
<br />GOTO main
<br />
<br />move:
<br />'take the output pin low so we can pulse it high
<br /> LOW PORTC.3
<br /> ' pulse the pin
<br /> PULSOUT PORTC.3, pulseWidth
<br /> ' pause for as long as needed:
<br /> PAUSE refreshPeriod
<br /> RETURN
<br />
<br />
<br />===========================================
<br />and a button servo picture.
<br /><img src="http://www.base2john.com/itp/pcomp/servo1/buttonservo.jpg" />
<br />
<br />
<br />I got the code for the servo to be controlled by a potentiometer and tried it out.
<br />===========================================
<br />
<br />
<br /> ' Define ADCIN parameters
<br /> DEFINE ADC_BITS 10 ' Set number of bits in result
<br /> DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
<br /> DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
<br />
<br /> sensorValue VAR WORD ' Create variable to store result
<br />
<br /> TRISA = %11111111 ' Set PORTA to all input
<br /> ADCON1 = %10000010 ' Set PORTA analog and right justify result
<br /> PAUSE 500 ' Wait .5 second
<br />
<br /> pulseRange VAR WORD
<br /> pulseWidth VAR BYTE
<br /> ' set up constants with the minimum and maximum pulsewidths
<br /> minPulse CON 50
<br /> maxPulse CON 250
<br /> ' set up a constant with the time between pulses:
<br /> refreshPeriod CON 20
<br />
<br /> ' set an initial pulsewidth:
<br /> pulseWidth = minPulse
<br /> pulseRange = maxPulse - minPulse
<br />
<br />main:
<br /> ADCIN 0, sensorValue
<br /> 'take the output pin low so we can pulse it high
<br /> LOW PORTC.3
<br /> ' pulse the pin
<br /> PULSOUT PORTC.3, pulseWidth
<br /> ' pause for as long as needed:
<br /> PAUSE refreshPeriod
<br />
<br />
<br /> pulseWidth = minPulse + (pulseRange * (sensorValue/10)) / 100
<br />
<br /> ' change the angle for the next time around:
<br /> 'IF pulseWidth > maxPulse Then
<br /> ' pulseWidth = minPulse
<br /> 'Else
<br /> ' pulseWidth = pulseWidth + 1
<br /> 'Endif
<br />
<br />GOTO main
<br />
<br />==========================================
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/servo1/potservo.jpg" />
<br />
<br />
<br />I have another project from sustainable energy that I am working on that involves solar panels. I will post some information about that later on but think about charging a capacitor from a solar panel and then releasing it when it reaches a desired voltage. It makes a project very organic in the sense that it totally depends on the sun for life. I think these will make incredibly interesting opportunities for advocating alternative energies.
<br />
<br />See you all in class.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109769851986741634?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1097554895303387522004-10-11T20:52:00.000-07:002004-10-11T21:40:41.926-07:00The completed broccoli botSo my first Physical computing project is finished. Last Wednesday we presented it to the class. As a review , the project proposed was suppose to enhance or change a space. We picked a supermarket and eventually made it to the idea that a talking piece of broccoli would be a nice enhancement for a shopping experience.
<br />
<br />Purchased items include
<br />
<br />Teenage Mutant Ninja turtle - Toys'R Us - $8
<br />Felt - Canal Street - ~$10
<br />Balloons - Party City - $5
<br />
<br />5V Relay - Radio Shack - $3
<br />Candy Corn (container) - CVS - $.99 (switch)
<br />
<br />The project was a good experience for the first one, I really appreciated getting feedback from others and their ideas for it. While time constraints made it impossible to adjust this project I will be sure to talk up my ideas earlier on to get to use some people's ideas.
<br />
<br />Lamar and I had both pleasant and stressful moments getting this to work. It's good to take breaks, walk away and just not think about certain pieces of the puzzle. And when all else fails ask Todd!
<br />
<br />Here's a picture of the completed switch
<br /><img src="http://www.base2john.com/itp/pcomp/broc/finalswitch.jpg" />
<br />
<br />On the top left is the homemade switch from a candy corn container, two metal threaded rods and a metal ball. The ball uses the two rods as contacts and becomes a rocker bumpin switch. The PIC is able to determine if the switch is open or closed and control the tape recorder from that contact. Here's a closer look.
<br /><img src="http://www.base2john.com/itp/pcomp/broc/ballswitch.jpg" />
<br />
<br />A closer view of the breadboard is easier to follow so look at this.
<br /><img src="http://www.base2john.com/itp/pcomp/broc/closer.jpg" />
<br />On the bottom right of the board you'll see the typical 5V regulator we have been using in class since the beginning. The bottom bus has 5V in it and powers the switch (currently out of the picture) and the PIC. On the top bus is the power for the tape player - at the top left of the board we made an adjustable voltage regulator and this was described earlier - basically the adjusted voltage on the top bus is 3.7 V and this was enough to power the cassette recorder.
<br />
<br />Using two 9V batteries we tested the voltages again and then we went to construct the broccoli. First blow up the bop bag. Next cover it in green felt and then balloons. Place board and tape player in the head region.
<br />Enjoy these.
<br /><img src="http://www.base2john.com/itp/pcomp/broc/outside1.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/broc/closeuphead.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/broc/touchin.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/broc/icecream.jpg" />
<br />
<br />We didn't get permission to test the broccoli in the grocery store and I still think we should have just ran in and took the photos and left but something was in the air those last nights telling me to behave. So we took it out on the streets and had some people touch it.
<br />
<br />The basic problems:
<br />Interface - no one has really been standing next to a 33" tall vegetable before and they certainly don't want to break it and or knock it over. People need to know what they can and can't interact with, the broco gave mixed emotions and some people were just avoiding it. certainly no interaction from avoidance....or is there?
<br />
<br />Listening - so if a piece of broccoli was going to talk to you would you listen? how is it going to be relevant? do you think you would respond back? Then what? If the broccoli had a large knowledge about a supermarket like where to get certain foods or products then the broco bot might help people shop - but that's what clerks are for too.
<br />
<br />Having to do it again I think I would make the broccoli bigger and more durable. It's current size would be slayed by a normal shopping cart. I think there needs to be more affordance for people to know how to use it and probably not a sign like Andrew said. Could it constantly sway or bop back and forth to get people's attention and then use a proximity meter to know when to start talking?
<br />
<br />I'm happy with the work, but I'm happier now because I know more technology and code to do more interesting things. but yea, baby steps.
<br />
<br />Lata,<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109755489530338752?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1096748586824063942004-10-02T13:19:00.000-07:002004-10-02T13:23:06.826-07:00code for PICmain:
<br />
<br />if portc.3 = 0 then
<br /> high porta.0
<br /> pause 10000
<br /> low porta.0
<br />endif
<br />goto main
<br />
<br />this looks for an open switch and then turns pin A0 HIGH for 10,000 milliseconds. While the pin is HIGH the relay is closed and current flows for 10 seconds.
<br />
<br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109674858682406394?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1096740320356202202004-10-02T10:15:00.000-07:002004-10-02T13:18:38.916-07:00Candy Corn SwitchYesterday we made a switch out of a candy corn cylinder from CVS pharmacy. Placing two parallel metal screws through the container the metal ball would close the switch when both contacts (screws) were touched. If bumped the ball rolls forward off the contacts and the switch is closed. This is where we will program in some logic to use the open switch to play the tape player for a few seconds.
<br />
<br />All in all the switch isn't pretty but it works - no real need for asthetics because it will be hidden inside the head of the broccoli.
<br />
<br />
<br />Will post pictures later.
<br />
<br />----------------------------------------------------
<br />Building the circuit.
<br />
<br />We built a circuit with 2 different voltages on 2 separate buses. 1 with 3.7volts from the adjustable voltage regulator and the other bus with regular 5V. We discussed the situation and knew that we must keep the buses separate all the time and the closest they can get is at the reed relay. We programmed the PIC and then set up the relay and after some simple debugging we had the switch controlling the power of the tape recorder.
<br />
<br />Today, saturday, we will clean up the board's wiring and test it out with 2 9V batteries.
<br />
<br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109674032035620220?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1096475075227112692004-09-29T08:18:00.000-07:002004-09-29T12:17:17.143-07:00Babysteps to the Broccoli botHello.
<br />
<br />On Saturday Lamar and I got to work on one of essential parts of our project. The project involves enhancing or changing the space at the supermarket. After observing the location we found that the most evident activity was the cart's role in shopping. Carts always tend to avoid each other and the people pushing them also avoid crashing into shelves, end displays and shoppers. Would it be possible to use the cart to enhance the environment ?
<br />
<br />Jumping ahead, after a few ideas we decided that a giant inflatable piece of broccoli in the vegetable aisle would be a nice addition to a sometimes quiet environment. The broccoli would be a dressed up inflatable clown and when bumped by a cart would tell shoppers fun broccoli facts and cooking tips.
<br />
<br />Now to talk about parts and construction needs.
<br />1) inflatable clown was found on froogle at a kids store for $6.55 (plus $5 shipping, ugh) http://www.kidsurplus.com. Fedex delivered the clown yesterday but to whom I don't know. Kid Surplus's customer service is on the case now. Hopefully I'll have it by Monday night.
<br />
<br />2) Felt - purchased down on one of the many fabric stores near canal and broadway. $6/yard^2.
<br />3) Relay switch - 5V reed switch from radio shack - be persistent with the staff there they may try to tell you that they're out of parts.
<br />
<br />other parts: breadboard, PIC 18F452, microcassette recorder and adjustable voltage regulator.
<br />
<br />The adjustable voltage regulator was a new combination of components we learned about from Todd and was used to power the microcassette recorder. The way the the action will project will work is :
<br />
<br />1) cart bumps broccoli
<br />2) a switch is activated - tells PIC to turn on the microcassette recorder
<br />3) PIC keeps the tape playing for about 15 to 20 seconds.
<br />
<br />The microcassette recorder will be run off a relay switch, controlled by the PIC because a normal switch will won't be able to hold for a set amount of time. No big deal.
<br />
<br />Next the idea came to me that the cassette recorder only needed 3 volts to run. it only had 2 AA batteries. would it possible to run the cassette player off the PIC's power from a pin that is turned on - it's output is 5V! Just to keep you all from wasting your own time, no you can't run a 3V cassette player off a 5V output pin from a PIC...simply because of the amps involved in starting and moving the player's tiny motor.
<br />
<br />Here's a picture of the voltage regulator that we built. parts include a L3M17 voltage regualtor, trim pot, and 330 ohm resistor.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/project1/adjustableVReg.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/project1/relay.jpg" />
<br />
<br />
<br />The main purpose of this setup was to give the cassette player the right voltage and amps that it needed. I'm still not entirely sure of the physics but the trim pot was adjusted with a screwdriver and measured with a multimeter. The voltage we were looking for was 3 - 3.5V. We set it to 3.5. After testing the new current on the player it worked. horrah!
<br />
<br />Next step was to connect the player to the relay, and connect the relay to the PIC. This was a troubled spot because the relay we had was a piece of crap. the legs were too small and didn't sit in the breadboard. We went to radioshack and got a good reed relay the same as we saw in class. In a matter of 5 minutes after getting back to ITP we had that relay working with the PIC controlling the relay, the relay switching the player.
<br />
<br />After the pleasure of our little hack subsided we called it a day. Some things still needed are the clown switch that activates when bumped by the cart or person. I am thinking that we need a small metal BB and some wires. As the clown sits still, the BB will have the switch closed, sitting on top of 2 wires. When the clown is bumped the BB rolls off the wires and now the switch is OPEN. The PIC will quickly see that the switch is open and turn the player on for a set amount of time. The BB will return to the dimple it nests in and the switch will close again, this happens as the clowns slowly settles down. The player is not controlled by the BB switch but is working from the PIC.
<br />
<br />more later, hopefully when the clown comes in.
<br /><img src="http://www.base2john.com/itp/pcomp/project1/vreg2.jpg" /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109647507522711269?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1095987998862379552004-09-23T16:04:00.000-07:002004-09-23T22:27:39.716-07:00Analog input with the PICI'm working on the analog input with the PIC controller right now. This is interesting - thinking of all the applications that use this type of control, potentiometers are in stero volume and tuning knobs, in flex sensors and in measuring temperature.
<br />
<br />I hooked up a potentiometer to my PIC at RA0 which is the second pin on the top left of the chip - just under the 10K resistor. There is also a serial cable connected to the computer to display the value of the potentiometer or any variable resistor. Displaying from 0 to 1023 you can use this variable to control other elements on the board.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/lab3pics/analogIn1.JPG" />
<br />
<br />
<br />Later on I replaced the potentiometer with a photocell and had to add a 10k resistor with it to keep the current smooth. still not sure what that means. The resistor and a leg of the photocell was plugged into RA0 and the second leg of the photocell was plugged into ground.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/lab3pics/analogIn2.JPG" />
<br />
<br />The code I was working on was a distance location system. If nothing obstructed the light then the green LED stayed on. If a shadow or hand came into view of the photocell the yellow light would turn on (green off). If the shadow/hand got to close the red light turns on, and if impact occurs the red LED blinks.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/lab3pics/greenlight.JPG" />
<br /><img src="http://www.base2john.com/itp/pcomp/lab3pics/redlight.JPG" />
<br />
<br />here is the code.
<br />
<br />'------------------------------------------------------------
<br />' PicBasic Pro program to display result of
<br />' 10-bit A/D conversion through serial at 9600 baud
<br />'
<br />' Connect analog input to channel-0 (RA0)
<br />
<br />' Define ADCIN parameters
<br />DEFINE ADC_BITS 10 ' Set number of bits in result
<br />DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
<br />DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
<br />
<br />ADCvar VAR WORD ' Create variable to store result
<br />
<br />TRISA = %11111111 ' Set PORTA to all input
<br />ADCON1 = %10000010 ' Set PORTA analog and right justify result
<br />Pause 500 ' Wait .5 second
<br />
<br />main:
<br /> ADCIN 0, ADCvar ' Read channel 0 to adval
<br /> serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out,
<br />
<br /> 'determine the analog input and control the LEDs
<br /> SELECT CASE ADCvar
<br /> CASE IS > 820 'blink red led
<br /> high portd.6
<br /> pause 250
<br /> low portd.6
<br /> pause 250
<br /> low portd.5
<br /> low portd.4
<br /> CASE IS > 680 'turn on red led
<br /> high portd.6
<br /> low portd.5
<br /> low portd.4
<br /> CASE IS > 575 'turn on yellow led
<br /> low portd.6
<br /> high portd.5
<br /> low portd.4
<br /> CASE else ' keep green led on
<br /> low portd.6
<br /> low portd.5
<br /> high portd.4
<br />
<br /> END SELECT
<br />
<br /> 'Button Code here
<br /> if portb.0 = 1 then ' if the switch is closed on pin RB0
<br /> low portd.0 ' set pin RD1 low
<br /> else
<br /> high portd.0 ' set RD1 high
<br /> SEROUT2 portc.6, 16468, ["Hello World!", 13, 10]
<br /> endif
<br />GoTo main
<br />'-------------------------------------------------------------------
<br />
<br />The difficulties today came from the BASIC programming language. I ended up finding the error. After using IF THEN statements I decided to test out the SELECT CASE statement and use it instead. I forgot to remove the THEN statement and the compiler caught it. After referencing the manual I found my error. Compile then Programmer then test and hoorah!
<br />
<br />It's simple enough. I'm going to look for a simple device to attach but will keep the board as is until class. Also bought some more jameco products so I'll have more to play with, the flex sensor should come next week.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109598799886237955?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1095895217460007602004-09-22T16:17:00.000-07:002004-09-22T16:21:38.943-07:00Updated code.In class right now and just learned that the code for the serial communications was a bit jumbled. I have the new code now and will change it tonight.
<br />
<br />if you can't wait to see the code here you go:
<br />SEROUT2 portc.6, 16468, ["Hello World!", 13,10]
<br />
<br />the 13, 10 was switched previously. here is the website for serial communication with the PIC - http://stage.itp.tsoa.nyu.edu/%7Etigoe/pcomp/code/archives/000568.shtml<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109589521746000760?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1095885085363642802004-09-22T13:25:00.000-07:002004-09-23T22:46:55.556-07:00mr. board meet mr. computeroutput from my serial communication test is a success. soldered the headers to the serial piece. check this out...
<br />
<br />Hello Wo2ld!
<br />Hell/ World!
<br />HòHello WoòHello World!
<br />Hello World!
<br />€‹ëºHª±±½World!
<br />Hello World!
<br />Hell World!
<br />HelloÿWorld!
<br />ello WoRld!
<br />HÉllo World!
<br />Hello World!
<br />HËllo ׽ɱ‘…
<br />Hello World!
<br />ý
<br />
<br />here's the code.
<br />
<br />'---------------------------------------------------------
<br />input portb.0
<br />output portd.0
<br />OUTPUT portc.6
<br />
<br />main:
<br />if portb.0 = 1 then ' if the switch is closed on pin RB0
<br /> low portd.0 ' set pin RD1 low
<br />else
<br /> high portd.0 ' set RD1 high
<br /> SEROUT2 portc.6, 16468, ["Hello World!", 10, 13]
<br />endif
<br />
<br />goto main
<br />'---------------------------------------------------------
<br />
<br />Hello world indeed. not sure why the characters are goofy but it works. next i'm going to wire my pants to talk to my shoes and my shoes to talk to the floor. it's gonna be great.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/lab3pics/serialcom.JPG" /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109588508536364280?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1095525695670963952004-09-18T12:41:00.000-07:002004-09-18T09:41:35.670-07:00Blinkie and the Pic18F452, sort of rolls off your tongue however it's bit intimidating at first. it's just a black little piece of plastic and metal, perhaps there's more inside the electronic insect. I have programmed Basic stamps before and I was just as anxious about the first success as getting the PIC to work.
<br />
<br />Here's a quick run through of the events that occurred:
<br />Thursday, September 16th
<br />- 9:45AM Fedex arrives with free sample chips from MicroChip(.com)
<br />- 2:30PM Get PIC programmer and set up in Lab
<br />- 3:05PM First LED is blinking from the simple program on the chip.
<br />
<br />Now that the first program is working and I understand the process of getting the code onto the chip I am much more comfortable with the needed technical knowledge.
<br />
<br />The first program was to make an LED blink. Here's the code
<br />
<br />'---------------------------------------------------------
<br />main:
<br /> high portd.0 'turn LED on
<br /> pause 500 'wait half second
<br /> low portd.0 'turn LED off
<br /> pause 500 'wait another half second
<br />goto main 'loop
<br />'---------------------------------------------------------
<br />
<br />The code wasn't new to me but the process of using a programming environment, compiling and then writing the program to the chip was. After writing to the chip, removing it from the cradle and placing it correctly onto the breadboard was an extra step that the Basic stamp avoided.
<br />
<br />here are some pictures of the final products.
<br />
<br /><img src="http://www.base2john.com/itp/pcomp/lab2pics/topdown.jpg" />
<br /><img src="http://www.base2john.com/itp/pcomp/lab2pics/blinkie.jpg" />
<br />
<br />After getting the LED to blink I added a switch to the circuit. If the button was pressed, pin B.0, the LED, pin D.0 would turn on. If released the LED would turn off. here is the code...
<br />
<br />'---------------------------------------------------------
<br />input portb.0
<br />output portd.0
<br />
<br />main:
<br /> if portb.0 = 1 then ' if the switch is closed on pin RB0
<br /> low portd.0 ' set pin RD1 low
<br /> else
<br /> high portd.0 ' set RD1 high
<br /> endif
<br />goto main
<br />'---------------------------------------------------------
<br /><img src="http://www.base2john.com/itp/pcomp/lab2pics/blinkbut.jpg" />
<br />
<br />After the switch worked I decided to stop there. I will probably do more this weekend, play with some sensors and variable resistors.
<br />
<br />Oh, yea, ArtBot is this weekend. get there. <div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109552569567096395?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1095132195682626022004-09-13T19:41:00.000-07:002006-08-12T14:47:04.240-07:00First lab - getting the breadboard to workOK, so the first lab went really well. It was all very satisfying even if some experiments did not work out completely. I was in the lab, playing, for about 3 hours on Monday afternoon. My first job was to get the power adaptor plug soldered and working. Todd was giving a quick demonstration and I watched his soldering techniques carefully... shouldn't be too difficult. So the iron is hot and ready, I tin the tip of the iron with solder and quickly sponge it. ok, all's good so far. Now i'm trying to get the solder onto the wires of the adaptor and this turned out to several attempts and about a half hour till I was satisfied. <br /><br />The best tip I discovered when heating and applying solder is to get the components hot then touch the solder with the heat. When a drip connects the pieces together, slowly pet the droplet with the tip and edge of the iron, it really smoothed out the last spots I was fixing. Here is a picture of the adaptor with wire soldered.<br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/first_soldering.jpg" /><br /><br />Next was time to test the power. I put a 5V voltage regulator on the board, with some jumpers going to the bus runs. I had a LED and resistor to verify power. And tada!<br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/testing_power.jpg" /><br /><br />I decided to make the breadboard look nice and neat the entire time. So I started to trim the jumpers down and place the power test LED at the bottom of the board. <br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/cleanboard.jpg" /> <img src="http://www.base2john.com/itp/pcomp/lab1pics/2leds.jpg" /><br /><br />The rest of the time in the lab I spent playing around rearranging and finding misc. electronics to plug into the board. The first test was the LED chaingang. 2 LED's worked in serial, 3 didn't. <br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/2series.jpg" /> <img src="http://www.base2john.com/itp/pcomp/lab1pics/3series.jpg" /><br /><br />I soldered my Potentiometer with the Red (power), Green (data), black (ground) and plugged it into the board to vary the resistance of my LED. Once I got the correct RGB wiring and not RBG the poteniometer was easy to use. <br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/potentiometer.jpg" /><br /><br />Next I replaced the Potentiometer with a photoresistor. I like the photoresistors, I think I will explore them more later - perhaps to detect shadows and shapes of shadows.<br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/Photoresistor.jpg" /><br /><br />After some searching the junk shelf I found a little speaker, a noisemaker. Similar to the annoying sound of a smoke detector, the potentiometer made it a little fun -like a poorly made guitar.<br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/NoisePotentiometer.jpg" /><br /><br />Found a momentary switch/button on the shelf and replaced the potentiometer. I made a little horn.<br /><img src="http://www.base2john.com/itp/pcomp/lab1pics/horn.jpg" /><br /><br />Towards the end of the experimenting I found an old Microsoft mouse which I quickly chopped the end off of to see what wires lay inside. There were 5 - red, black, white, blue and orange. I hooked up the red and black to the power and ground then took all the wires from the blue, white and orange and twisted them together to make them share their juice. My multimeter found 5V at the red and black connection but nothing happened elsewhere. It would have been neat to use the mouse to vary the resistance and make the noisemaker play. I'll google microsoft mouse wiring right now and see if I can find anything.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109513219568262602?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0tag:blogger.com,1999:blog-8256453.post-1094701763978838142004-09-08T20:49:00.000-07:002004-09-08T20:49:23.976-07:00Test Postmm, electrons!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8256453-109470176397883814?l=www.base2john.com%2Fitp%2Fpcomp%2Findex.html'/></div>John Schimmelnoreply@blogger.com0