Jump to content

mkomar

EstablishedMember
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About mkomar

  • Rank
    Newbrie
  1. Yes you can change a single bit on a port from in to out and back by changing the bit of that ports TRISx register. As for all the other stuff you will need to know to complete your project you may need to just try and learn it as best you can. If you do not have the time you may want to hire someone to help. <{POST_SNAPBACK}> I hear ya. Not expecting to have someone write it for me. Was hoping I was making a common error that would be easily spotted by someone with some experience. I guess that isn't the case. I'll get it figured out. With regard to the tris questi
  2. Alrighty, here is what I would really love to see this do. Beginning from an unpowered state: 1) Users pushes button 1. 2) Led lights up and a 90 second timer begins. 3) If during this process, an abort button is pressed (Which could be the same button), then the sequence stops here and the device powers down. 4) If the 90 seconds is reached, then a relay is activated for 1 second and then the device powers down. If the powering up/down features are not possible, that is fine. It'd be neat, but that's fine. If I can't have that feature easily, then I would want to add
  3. My bad. Here is the skinny. Here is the perfect world. 1) Device begins in a powered down state. 2) User presses activate button. 3) LED Lights up, and 90 second timer starts. 4) If abort button is pressed during the 90 seconds, the device powers down. 5) If the 90 seconds elapses without being aborted, a relay is activated for 1 second. 6) Device powers down. I guess I'd actually be OK with there only being one button, and if the button is pushed for a second time (after being pushed one to begin the process) then it aborts and powers itself down. Is this something realis
  4. It just struck me that I may need to be switching the port in question back and forth between input and output as I try to poll it. I'll be trying that as soon as I get a chance. What I am not sure about at this point is how do I change a single pin between I/O? I know how to use the 'tris' function to set them all, but I've only ever assigned them all. ie: tris=0b00110110 or so. If I want to alter the state of pin3 and ONLY pin3, what do I do?
  5. You raise some good points. I have been changed the code to use only 'portX,1' references instead of a mix. I have still not gotten much further. #include <system.h> void main() { trisb=0b00000011; portb=0; unsigned int counter=0; char activate=0; char abort=0; while ( 1 ) { if ( test_bit(portb,0) ) { activate=1; counter=0; set_bit(portb,3); // light the 'activated' LED. while (counter<6000) { counter++; delay_ms(10); if (test_bit(portb,1)) // The Abort button was pressed. { clear_bit(portb,3); // Clear the Active LED counter=6000; // This to get ou
  6. #include <system.h> volatile bit ra0@0x6.0; volatile bit ra1@0x6.1; unsigned int counter=0; void main() { trisa=00000000b; trisb=11111111b; while ( 1 ) { set_bit(porta,0); // Light the power LED. if (ra0 == 1 ) { set_bit(porta,1); // light the 'activated' LED. for (counter=0;counter<5000;counter++) // 5000x1ms gives me about 5 seconds. Will want 60-120 when it's live. { if (ra1 == 1) // The Abort button was pressed. { clear_bit(porta,1); // Light the Aborted LED (only for debugging purposes). delay_ms(5); counter=5500; // This to
  7. I am more than willing to admit that it may not be working as I expect due to me not understanding how it is supposed to work. I am new to all of this (PICs and C). #include <system.h> volatile bit ra0@0x6.0; volatile bit ra1@0x6.1; unsigned int counter=0; int aborted=0; void main() { trisa=00000000b; trisb=11111111b; while ( 1 ) { set_bit(porta,0); // Light the power LED. if (ra0 == 1 ) { set_bit(porta,1); // light the 'activated' LED. for (counter=0;counter<5000;counter++) // 5000x1ms gives me about 5 seconds. Will want 60-120 when it's live. {
×
×
  • Create New...