I successfully copied/pasted snippets of Analog-to-Digital conversion code using plib on the PIC18F25K50. Initially, I thought the potentiometer I was using was non-linear, as values tended to swing very quickly. It turned out that I had set the PORTC pins to digital in order to get the USART working. Once I made sure the pin I was using with the pot was set to analog input, it worked.
I'm using fairly safe and conservative configuration values for now (nowhere near the sampling rates the A/D is capable of), so I should revisit this. However, it still means I have some placeholder code that can correctly read analog input.
The input values looked correct when printed out to putty via the UART... which seemed a very digital way of looking at analog values... which got me thinking... Can there be a more analog way to verify?
In the first video below, I use the old trick from Fortran / BASIC days of charting via a text screen by treating vertical as the X-axis and horizontal as the Y-axis. One would imagine viewing while rotating one's head 90 degrees, with forehead at 3-o'clock and chin at 9-o'clock. In this case, the X-axis is time and the Y-axis is the analog input value.
In the second video, I display a bar with length proportional to analog input value. For convenience, the value itself is printed next to the bar. There is no need for ncurses to keep the bar at the top of screen instead of scrolling away -- I just send a Ctrl-L ('\014') to clear the screen and position at upper-left corner before printing each bar.
Both these methods involve no code on the desktop -- I'm just running putty here. A useful trick though is changing putty's cursor from block to underline -- this reduces flicker.
I'm using fairly safe and conservative configuration values for now (nowhere near the sampling rates the A/D is capable of), so I should revisit this. However, it still means I have some placeholder code that can correctly read analog input.
The input values looked correct when printed out to putty via the UART... which seemed a very digital way of looking at analog values... which got me thinking... Can there be a more analog way to verify?
In the first video below, I use the old trick from Fortran / BASIC days of charting via a text screen by treating vertical as the X-axis and horizontal as the Y-axis. One would imagine viewing while rotating one's head 90 degrees, with forehead at 3-o'clock and chin at 9-o'clock. In this case, the X-axis is time and the Y-axis is the analog input value.
In the second video, I display a bar with length proportional to analog input value. For convenience, the value itself is printed next to the bar. There is no need for ncurses to keep the bar at the top of screen instead of scrolling away -- I just send a Ctrl-L ('\014') to clear the screen and position at upper-left corner before printing each bar.
Both these methods involve no code on the desktop -- I'm just running putty here. A useful trick though is changing putty's cursor from block to underline -- this reduces flicker.
RSS Feed