« Week 3 Activity: Wooster Group | Main | Steven Johnson »

September 27, 2005

Week 3 Lab: Serial Ouptut

It took a while to solder the serial port together. Eventually I realized that the serial port that came with the store kit was a piece of crap and everyone else had bought an individual serial port with coupling 'half pins'. I broke off all of my pins and then it was easier to solder on some angle pins. My first serial port program:

SEROUT2 portc.6, 16468, ["Hello World!", 13,10]

I then attached a variable resistor to the PIC and ran the following code for output to the serial. Basic stuff. I did burn my finger on the voltage regulator when I misalligned the PIC. Always check twice.

DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCvar VAR WORD ' Create variable to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' Wait .5 second
main:
ADCIN 0, ADCvar ' Read channel 0 to adval
serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out,
' with linefeed and carriage return (10, 13)
GoTo main ' Do it forever

I then added a motor to my circuit. Instead of just getting a numeric read from my pot, I wanted a physical actuator to convey the POT value in the physical world. In hindsight, my problem is that I put the motor on the same circuit as the pot which diminished what was going to serial out. As my motor revved up, the numbers stopped appearing in hyperterminal. Tomorrow I will try to put the motor on different output pins and see if hyperterminal and the motor can run at once.

Posted by mb2811 at September 27, 2005 12:14 AM