Matthew Belanger's PCOMP Journal
(Or How To Make The World's Most Expensive Radio Controlled Car)

 

Week 1:
This journal is intended to document my efforts in Physical Computing. Over time I will update it and try to include usefull information to others who may be interested.

Week 2:
Not much to say about this first assignment except that I had fun. This is all new to me and I wasn't really sure if I would be into it or not. I look forward to using the chip.

Week 3:
Going into this week's assignment I had already heard other peoples chip communication horror stories so I was prepared for the worst. I had no problems communicating with the chip. Guess I should consider myself a lucky one. The only real problems I encountered were specific to the BasicX application itself. It must have been designed by cheese eating blue ass monkeys is all I can figure. Surely people who actually use this software didn't write it.

Week 4:
I had alot of fun with this week's assignment. I don't really have a programing background and I have been struggling with ICM so I really wanted to spend some time trying to figure this stuff out on the programming end. After completing the walk through part of the assignment I had enough confidence to make something a little more elaborate so I decided, based on Tom's suggestion to make a practical joke, to make a game with LEDs and switches. The game, I decided, had to be no fun at all. In addition, I felt like it should be frustrating and appear to have no logic. However, if the player was persistant, eventually he/she would figure out the way to solve it. Buttons and switches had to be activated in the right relationship to each other and at precise times in order to solve the game. The player simply had to turn on all 4 LEDs with a series of 3 switches. I would compair my game to a Rubicks Cube. Sure, it's a game, but is is any fun? No...

Week 5:
Turning on a motor for the first time was cool. It was truely the first physical action made this semester by me through this chip. Until this week it was just a matter of turning on pretty lights with switches. Now that I have the power to turn on motors all kinds of doorways are opening up.

Week 6:
Analog input is cool because it alows more refined control of our chips. Things don't just have to be simply on or off, hot or cold. Potentiometers can be used to create a state somewhere between on and off for our chips.

Week 7:
After the completion of this weeks assignment I really feel that we are capable of doing almost anything.Being able to control a servo motor through analog output is really the last key at least as far as the basics are concerned. Everything from here will just build off of these ideas and skills.

Week 8:
I struggled with what to make for my midterm until I finally decided to make a radio controlled car. I felt like this would take advantage of nearly everything I had learrned so far within one project that would actually be fun to produce, and more importantly, fun to use. I don't know enough about how to controll the car remotly yet so I will just work on the steering, driving, and housing elements for the mid term. If I can get that to work then I can worry about gaining controll of the car by remote down the road. I went out and got a K'nex set that looked like a good starting point for my car. I was about $40 and included more than enough parts. It came with a motor that I hacked into so I could control it from the BX24. I had been planning on making my own motor but when I came across this it just made sense to use the K'nex motor. I attached a servo motor to the front. Then I attached that to an axel I made from K'nex parts.

Programming the chip was pretty easy once all the parts were in place. I just incorporated what I had learned in previous assignments into this project. Everything worked pretty much as planned until I had the bright idea of making it more presentable. I had a problem in that the wires would often come out when making the car go forward or turn. I wanted to secure the wires a little better and also tidy things up a bit. Of course the damn thing didn't work when I got it all back together. Eventually I got it going again. I had foolishly replaced some wires in the wrong places.

Week 9:
This weeks assignment, serial communication, went off without a hitch. I will have to incorporate this into my car if and when I find an RF module that works with the BX-24.

Week 10:
I spent most of this week shoping for an RF Transmitter/Reciever system to use with my remote control car. After struggling with some RF parts that I ordered from Radio Shack I concluded that there was simply not enough documentation for me to make them work with my limited knowledge. I hope I can get them to work at some point because the Radio Shack solution is a whole hell of a lot cheaper than the Parallax RF Transceiver I eventually went with. I found this website about a wireless closed-loop system by Adam Fulford to be extremely helpful. Adam is using a BX-24 and the Parallax Trannceivers I mentioned above.

Week 11:
Eventually I would love to have a Director controller for this car with live video feedback. My Lingo skills are so bad I guess I will have to work toward that over the next year or so. I got my camera and portable TV for use with my car this week. The camera worked for a little while but quickly fell apart. I will be sending it in for repairs. I doubt it will make it back in time for Finals.

Week 12:
I am really strugling with this serial RF communication. If I don't have some progress soon I may have to scrap this remote control car idea and work on something else for my Final.

Week 13:
Joey was able to get my 2 chips communicating via RF this week. For some reason I was unable to get them talking on my own. After 2 weeks at a stand still I am now able to make some progress. Eventually I will post some diagrams for both circuits. Until then I leave you with a fun movie of me trying to drive my car and some code as a guide.




Here is the code for the reciever/car chip:

' setting up all the variables.
dim inputBuffer(1 To 255) as byte
dim outputBuffer(1 To 20) as byte
dim thisByte as byte
dim myData as string
dim inByte1 as byte
dim inByte2 as byte
dim outByte as byte
dim outPin as byte
dim inPin as byte
dim minPulse as single
dim maxPulse as single
dim pulseWidth as single
dim refreshPeriod as single

' the main subroutine.
sub main ()

' defines the variables inPin and outPin.
outPin = 12
inPin = 11

' defines which pins COM3 will be and defines protocol.
call defineCom3(inPin,outPin,bx1000_1000)

' sets aside memory for input and output.
call openQueue(inputBuffer, 20)
call openQueue(outputBuffer, 20)

' opens COM3.
call openCom(3, 9600, inputBuffer, outputBuffer)

' this do loop checks to see if there is any data waiting in the inputBuffer.
' if there is data the prgram jumps to the subroutine myCar.
' if there is no data the chip sends out a byte to the controller chip
' reporting that it is ready.

do
if statusQueue(inputBuffer) = false then
debug.print "No inByte"
outByte = 1
debug.print" outByte = "; cStr(outByte)
call putQueue(outputBuffer, outByte, 1)
else
if statusQueue(inputBuffer) = true then
debug.print "Gotta inByte"
call myCar()
end if
end if
loop

end sub

' this the subroutine myCar. it does most of the real work.
sub myCar()

' this part sets up the servo.
minPulse = 0.0012
maxPulse = 0.0020
pulseWidth = minPulse
refreshPeriod = 0.02
dim pulseRange as single
pulseRange = maxPulse - minPulse

' the do loop for this subroutine starts here.
do

' this part gets data from the inputBuffer and decides what to do with it.
call getQueue(inputBuffer, inByte1, 1)
debug.print" inByte1 = "; cStr(inByte1)
call getQueue(inputBuffer, inByte2, 1)
debug.print" inByte2 = "; cStr(inByte2)

' this is the code that controls the servo.
call pulseOut(15, pulseWidth,1)
'inByte1 = inByte1 * 4
pulseWidth = minPulse + ((pulseRange * cSng(inByte1)) / 255.0)
'call sleep(refreshPeriod)


' this is the code that controls the motor.
if inByte2 = 48 then
call putPin(13,0)
end if
if inByte2 = 49 then
call putPin(13,1)
end if
l
oop

end sub


Here is the code for the transmitter/controller chip:

' setting up all the variables.
d
im inputBuffer(1 To 20) As Byte
dim outputBuffer(1 To 20) As Byte
dim myData1 as string
dim myData2 as integer
dim outByte1 as byte
dim outByte2 as byte
dim inByte as byte
dim outPin as byte
dim inPin as byte


' the main subroutine.

sub main ()

' defines the variables inPin and outPin.
outPin = 12
inPin = 11

' define which pins COM3 will be and defines protocol.
call defineCom3(inPin,outPin,bx1000_1000)
' set aside memory for input and output:
call openQueue(inputBuffer, 20)
call openQueue(outputBuffer, 20)

' opens COM3.
call openCom(3, 9600, inputBuffer, outputBuffer) do

' at this point the controller is waiting for a byte from the car so
' it knows to begin sending data.
this checks for an inByte.
' if an inByte is present then the program jumps to the subroutine getByte.
if statusQueue(inputBuffer) = true then
debug.print "Gotta inByte"
call getByte()
end if
if statusQueue(inputBuffer) = false then
debug.print "No inByte"
end if loop
end sub

' this subroutine checks to see if the inByte is a 1 or not.
' if the inByte is a 1 that signals that the car is ready for data.
' the program jumps to the myCar subroutine.
s
ub getByte()

do
call getQueue(inputBuffer, inByte, 1)
debug.print "inByte = " ; cstr (inByte)
if inByte = 1 then
call myCar()
else
debug.print "No dice"
end if
loop
end sub

' this subroutine does most of the work.
sub myCar()

do

' read the push button on pin 13 and convert it to a readable ASCII value.
myData1 = cStr(getPin(13))
outByte1 = asc(myData1)
debug.print "pin 13 = " ; cstr (getPin(13))
debug.print "outByte1 = " ; cstr (outByte1)

' send outByte1 out the serial port.
call putQueue(OutputBuffer, outByte1, 1)

' read the pot on 16 and convert.
myData2 = getADC(16)
myData2 = myData2 \ 4
debug.print "pin 16 = " ; cstr (getPin(16))
debug.print "outByte2 = " ; cstr (outByte2)

' send outByte2 out the serial port:
call putQueue(OutputBuffer, myData2, 1)

loop

end sub