Here is my second program using one of the Pic 16F684's Analog to Digital Converters. I needed a voltage window detector for the simple lamp circuit in the crickets. More or less it is neccesary to send a Digital high if a voltage is greater than voltage 1, but less than voltage 2. Here using Vcc and Ground as reference, I've read a value from the PickIt1's on board potentionmeter, and sent a digital signal based on its position in relation to the window. Once again, not sure this is the best way to go about the process.
#include
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
& UNPROTECT & BORDIS & IESODIS & FCMDIS);
int Reading, r1, r2, r3, D1;
int ADCState;
main()
{
/////////// INIT ////////////
PORTA = 0;
PORTC = 0;
TRISA = 0b000001; // All Bits of PORTA are Outputs except RA0
TRISC = 0; // All Bits of PORTC are Outputs
CMCON0 = 7; // Turn off Comparators
ANSEL = 1 << 0; // RA0 is ADC input
ADCON0 = 0b00000001; // Left justify, Use Vdd, Do not start, Turn on
ADCON1 = 0b00010000; // run oscillatr as 8 x prescalar>
ADCState = 0;
//// MAIN LOOP ////
while(1)
{
/////////// DISPLAY READOUT ///////////
if(Reading > 100 && Reading < 150){
RA1 = 1; // Value from pot.
RA2 = 0; // Grounded for charlieplex.
}else{
RA1 = 0;
RA2 = 0;
}
switch(ADCState)
{
case 0: //Start ADC operation
GODONE = 1;
ADCState = 1;
for(D1=0;D1<400;D1++);
break;
case 1:
ADCState = 0;
r1 = ADRESH;
r2 = ADRESH >> 4;
r3 = ADRESH & 0x0F;
Reading = r1+r2+r3;
for(D1=0;D1<400;D1++);
break;
}
}
}
Due to some issues in the Digital Crickets for DGL, I've been doing some PIC programming using a borrowed PickIt1, Pic 16F684 and High-Tech C compiler. This has been an interesting journey. In the future I'm thinking I might go the AVR direction because there seems to be more documentation out there. Though PIC does have a good, internationally attended forum that reponds quickly. As always the community is where to go for trouble shooting. I thought I'd post my very first sucessful program. It's a short program to cycle through a the PickIt1's Tri-state Charlieplex. There is some question whether or not the timing oscillator is set correctly, though I've tested around and the timing seems ok. I provide this program and the following with the extreme caveate that I'm very new to Pic and C. Here we go:
/*
File: main.c
Target: pic16f684
Compiler: PICC Lite V9.60PL2
*/
#include <htc.h>
__CONFIG(UNPROTECT & FCMDIS & IESODIS & WDTDIS & PWRTDIS & BORDIS & MCLREN & INTIO);
// Using Internal Clock of 8 Mhz
#define FOSC 8000000L
#define OSCCON = 0x70;
// Delay Function
//
// This inline delay function is very non-portable.
// It assumes that the compiler will generate
// a 3-cycle loop and that only an 8-bit
// counter is needed.
//
// Using these assumptions the maximum
// delay supported is 382 microseconds
// with an 8MHZ FOSC. YMMV
//
#define _delay_us(x) { unsigned char us; \
us = (unsigned long)FOSC*(x)/12000000L|1L; \
while(--us != 0) continue; }
void _delay_ms(unsigned int ms)
{
unsigned char i;
do
{
i = 4;
do
{
_delay_us(250);
} while(--i);
} while(--ms);
}
void main(void){
// Cycle through Tri-State Charlieplex
TRISA = 0b00000;
ANSEL = 0;
while(1){
TRISA = 0b00110;
RA4 = 1;
RA5 = 0;
_delay_ms(500);
TRISA = 0b00110;
RA4 = 0;
RA5 = 1;
_delay_ms(500);
TRISA = 0b100010;
RA4 = 1;
RA2 = 0;
_delay_ms(500);
TRISA = 0b100010;
RA4 = 0;
RA2 = 1;
_delay_ms(500);
TRISA = 0b010010;
RA5 = 1;
RA2 = 0;
_delay_ms(500);
TRISA = 0b010010;
RA5 = 0;
RA2 = 1;
_delay_ms(500);
TRISA = 0b110000;
RA1 = 0;
RA2 = 1;
_delay_ms(500);
TRISA = 0b110000;
RA1 = 1;
RA2 = 0;
_delay_ms(500);
}
}
I finally finished my long awaited podcast for Trace Reddell's Digital Sound Cultures class. Here is a brief blurb:
The podcast, Remixing Collective Memory: Low End Theory Sound will explore collective memory, remix, and genre melding from the epicenter of the Airliner’s Low End Theory Night. For the last few years L.A.’s the Airliner club has sponsored Low End Theory Night, which has exposed some of the most innovative and contemporary artists in hip-hop. One common thread amongst Low End Theory artists is a collective exploration of eighties and nineties youth culture, through their subject matter, aesthetic, and sample base. Other strong influences include science fiction, glam, crumping/pop and lock, metal.
Remixing Collective Memory explores the Low End Theory scene and its artists through the lens of technonostalgia, collective memory/shared experience, and remix culture. Paul D. Miller writes that the phonograph, recording technology, produced, “a non-sequential form of text, one including associative trails, dynamic annotations, and cross references”. (Miller, 349) Exploring the musical aesthetics and artists of the Low End Theory scene will reveal that remix, recombinant music acts as a transmitter or instigator of collective memory because the samples involved create an external network of meaning and association that exists between the artists/club goers. For instance much of the aesthetics and samples of Future Blap are heavily reminiscent of eighties and nineties youth culture, early video games, hip hop, punk, metal, cartoons, Sci-Fi, and Horror movies. While these elements are often embedded in the music, they act as a three dimensional mosaic for the listener familiar with that culture, connecting the DJ/Artists’ memory to that of the listeners’ via shared experience.
The File is available here as in uncompressed .wav format:
podcast-final.wav (439MB)
A compressed streamable version will be available at archive.org soon.
Works Cited
Miller, Paul D. “Algorithms: Erasures and the Art of Memory.” Audio Culture
Readings In Modern Music. Ed. Cox, Christolph and Daniel Warner. New
York: Continuum International Publishing Group, 2008.